ISIS Logo
UTILITIES
EPICS Utilities
Functions | Variables
iocshCmdFuncs.cpp File Reference

Enhanced EPICS iocshCmd functions. More...

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <exception>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <map>
#include <list>
#include <string>
#include <time.h>
#include <sstream>
#include <fstream>
#include <unistd.h>
#include "epicsStdlib.h"
#include "epicsString.h"
#include "epicsStdio.h"
#include "dbDefs.h"
#include "epicsMutex.h"
#include "dbBase.h"
#include "dbStaticLib.h"
#include "dbFldTypes.h"
#include "dbCommon.h"
#include "dbAccessDefs.h"
#include <epicsTypes.h>
#include <epicsTime.h>
#include <epicsThread.h>
#include <epicsTimer.h>
#include <iocsh.h>
#include "envDefs.h"
#include "macLib.h"
#include "errlog.h"
#include <registryFunction.h>
#include <epicsExport.h>
#include "utilities.h"

Go to the source code of this file.

Functions

static char * ioc_getenv (const char *var)
 
static void loadMacEnviron (MAC_HANDLE *pmh)
 
static void subMacros (std::string &new_macros, const char *macros, const char *loopVar)
 look for e.g. $(I) and replace with so we can substitute later with macEnvExpand() More...
 
epicsShareFunc void iocshCmdLoop (const char *command, const char *macros, const char *loopVar, int start, int stop, int step)
 Execute command multiple times substituting a specified macro according to a number range. More...
 
epicsShareFunc void iocshCmdList (const char *command, const char *macros, const char *loopVar, const char *list, const char *sep)
 Execute a command multiple times according to a list of items separated by known separator(s). More...
 
static void iocshCmdLoopInitCallFunc (const iocshArgBuf *args)
 
static void iocshCmdListInitCallFunc (const iocshArgBuf *args)
 
static void iocshCmdFuncsRegister (void)
 
 epicsExportRegistrar (iocshCmdFuncsRegister)
 

Variables

static const iocshArg iocshCmdLoopInitArg0 = { "command", iocshArgString }
 command string More...
 
static const iocshArg iocshCmdLoopInitArg1 = { "macros", iocshArgString }
 macros to pass to command More...
 
static const iocshArg iocshCmdLoopInitArg2 = { "loopVar", iocshArgString }
 loop macro variable name More...
 
static const iocshArg iocshCmdLoopInitArg3 = { "start", iocshArgInt }
 Loop start value. More...
 
static const iocshArg iocshCmdLoopInitArg4 = { "stop", iocshArgInt }
 Loop end value. More...
 
static const iocshArg iocshCmdLoopInitArg5 = { "step", iocshArgInt }
 Loop step (default: 1) More...
 
static const iocshArg *const iocshCmdLoopInitArgs []
 
static const iocshArg iocshCmdListInitArg0 = { "command", iocshArgString }
 command string More...
 
static const iocshArg iocshCmdListInitArg1 = { "macros", iocshArgString }
 macros to pass to command More...
 
static const iocshArg iocshCmdListInitArg2 = { "loopVar", iocshArgString }
 list macro variable name More...
 
static const iocshArg iocshCmdListInitArg3 = { "list", iocshArgString }
 list of values to substitute More...
 
static const iocshArg iocshCmdListInitArg4 = { "sep", iocshArgString }
 list value separator character More...
 
static const iocshArg *const iocshCmdListInitArgs []
 
static const iocshFuncDef iocshCmdLoopDef = {"iocshCmdLoop", sizeof(iocshCmdLoopInitArgs) / sizeof(iocshArg*), iocshCmdLoopInitArgs}
 
static const iocshFuncDef iocshCmdListDef = {"iocshCmdList", sizeof(iocshCmdListInitArgs) / sizeof(iocshArg*), iocshCmdListInitArgs}
 

Detailed Description

Enhanced EPICS iocshCmd functions.

Author
Freddie Akeroyd, STFC ISIS Facility fredd.nosp@m.ie.a.nosp@m.keroy.nosp@m.d@st.nosp@m.fc.ac.nosp@m..uk

Definition in file iocshCmdFuncs.cpp.

Function Documentation

epicsExportRegistrar ( iocshCmdFuncsRegister  )
static char* ioc_getenv ( const char *  var)
static

Definition at line 52 of file iocshCmdFuncs.cpp.

Referenced by iocshCmdList(), and iocshCmdLoop().

static void iocshCmdFuncsRegister ( void  )
static

Definition at line 283 of file iocshCmdFuncs.cpp.

References iocshCmdListInitCallFunc(), and iocshCmdLoopInitCallFunc().

epicsShareFunc void iocshCmdList ( const char *  command,
const char *  macros,
const char *  loopVar,
const char *  list,
const char *  sep 
)

Execute a command multiple times according to a list of items separated by known separator(s).

The command argument is executed, as per the usual EPICS iocshCmd(), but with additional environment variables set according to the macros arguments; however at the end of execution these macros are reset back to their original values. It is possible to embed a changing macro loopVar within this list whose value follows items in list.

The name of the macro to be used for substitution is contained in loopVar and needs to be referenced in an \ escaped way to make sure EPICS does not try to substitute it too soon. As well as the macros the command is also passed the loopVar macro value

* iocshCmdList("< st\$(S).cmd", "P=1,Q=Hello\$(S)", "S", "A;B;C", ";")
*
Parameters
[in]commandcommand string
[in]macrosmacros to pass to command
[in]loopVarlist macro variable name
[in]listlist of values to substitute
[in]seplist value separator character
Examples:
st.cmd.

Definition at line 194 of file iocshCmdFuncs.cpp.

References ioc_getenv(), loadMacEnviron(), and subMacros().

Referenced by iocshCmdListInitCallFunc().

static void iocshCmdListInitCallFunc ( const iocshArgBuf *  args)
static

Definition at line 278 of file iocshCmdFuncs.cpp.

References iocshCmdList().

Referenced by iocshCmdFuncsRegister().

epicsShareFunc void iocshCmdLoop ( const char *  command,
const char *  macros,
const char *  loopVar,
int  start,
int  stop,
int  step 
)

Execute command multiple times substituting a specified macro according to a number range.

The command argument is executed, as per the usual EPICS iocshCmd(), but with additional environment variables set according to the macros arguments; however at the end of execution these macros are reset back to their original values. It is possible to embed a changing macro loopVar within this list whose value follows the range start to stop.

The name of the macro to be used for substitution is contained in loopVar and needs to be referenced in an \ escaped way to make sure EPICS does not try to substitute it too soon. As well as the macros the command is also passed the loopVar macro value

* iocshCmdLoop("< st\$(I).cmd", "P=1,Q=Hello\$(I)", "I", 1, 4)
*
Parameters
[in]commandcommand string
[in]macrosmacros to pass to command
[in]loopVarloop macro variable name
[in]startLoop start value.
[in]stopLoop end value.
[in]stepLoop step (default: 1)
Examples:
st.cmd.

Definition at line 123 of file iocshCmdFuncs.cpp.

References ioc_getenv(), loadMacEnviron(), and subMacros().

Referenced by iocshCmdLoopInitCallFunc().

static void iocshCmdLoopInitCallFunc ( const iocshArgBuf *  args)
static

Definition at line 273 of file iocshCmdFuncs.cpp.

References iocshCmdLoop().

Referenced by iocshCmdFuncsRegister().

static void loadMacEnviron ( MAC_HANDLE *  pmh)
static

Definition at line 65 of file iocshCmdFuncs.cpp.

Referenced by iocshCmdList(), and iocshCmdLoop().

static void subMacros ( std::string &  new_macros,
const char *  macros,
const char *  loopVar 
)
static

look for e.g. $(I) and replace with so we can substitute later with macEnvExpand()

Definition at line 81 of file iocshCmdFuncs.cpp.

Referenced by iocshCmdList(), and iocshCmdLoop().

Variable Documentation

const iocshFuncDef iocshCmdListDef = {"iocshCmdList", sizeof(iocshCmdListInitArgs) / sizeof(iocshArg*), iocshCmdListInitArgs}
static

Definition at line 271 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdListInitArg0 = { "command", iocshArgString }
static

command string

Definition at line 261 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdListInitArg1 = { "macros", iocshArgString }
static

macros to pass to command

Definition at line 262 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdListInitArg2 = { "loopVar", iocshArgString }
static

list macro variable name

Definition at line 263 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdListInitArg3 = { "list", iocshArgString }
static

list of values to substitute

Definition at line 264 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdListInitArg4 = { "sep", iocshArgString }
static

list value separator character

Definition at line 265 of file iocshCmdFuncs.cpp.

const iocshArg* const iocshCmdListInitArgs[]
static
Initial value:
static const iocshArg iocshCmdListInitArg2
list macro variable name
static const iocshArg iocshCmdListInitArg4
list value separator character
static const iocshArg iocshCmdListInitArg0
command string
static const iocshArg iocshCmdListInitArg1
macros to pass to command
static const iocshArg iocshCmdListInitArg3
list of values to substitute

Definition at line 266 of file iocshCmdFuncs.cpp.

const iocshFuncDef iocshCmdLoopDef = {"iocshCmdLoop", sizeof(iocshCmdLoopInitArgs) / sizeof(iocshArg*), iocshCmdLoopInitArgs}
static

Definition at line 269 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg0 = { "command", iocshArgString }
static

command string

Definition at line 252 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg1 = { "macros", iocshArgString }
static

macros to pass to command

Definition at line 253 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg2 = { "loopVar", iocshArgString }
static

loop macro variable name

Definition at line 254 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg3 = { "start", iocshArgInt }
static

Loop start value.

Definition at line 255 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg4 = { "stop", iocshArgInt }
static

Loop end value.

Definition at line 256 of file iocshCmdFuncs.cpp.

const iocshArg iocshCmdLoopInitArg5 = { "step", iocshArgInt }
static

Loop step (default: 1)

Definition at line 257 of file iocshCmdFuncs.cpp.

const iocshArg* const iocshCmdLoopInitArgs[]
static
Initial value:
static const iocshArg iocshCmdLoopInitArg0
command string
static const iocshArg iocshCmdLoopInitArg1
macros to pass to command
static const iocshArg iocshCmdLoopInitArg2
loop macro variable name
static const iocshArg iocshCmdLoopInitArg4
Loop end value.
static const iocshArg iocshCmdLoopInitArg3
Loop start value.
static const iocshArg iocshCmdLoopInitArg5
Loop step (default: 1)

Definition at line 258 of file iocshCmdFuncs.cpp.

Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5