J. Lewis Muir, 2010-07-02

EPICS Base Blueprint: iocsh-if-flow-control

This feature would enable conditionally executing parts of an iocsh script. To keep it simple, the conditional test could just be whether a command returns zero. A command could be added to test whether an environment variable is set (e.g. epicsIsEnvSet) or is equal to some string (e.g. epicsIsEnvEqualTo).

A case where this would be useful is when some hardware might be present or not and one wants to easily include or exclude parts of an iocsh script. Another case would be when one wants to easily include or exclude certain behavior. Instead of having to comment in or out parts of an iocsh script, one can simply set a "flag" environment variable that indicates whether to include certain parts of an iocsh script.

Example:

if epicsIsEnvSet USE_PILATUS_6M; then
  dbpf("x7PIL1:det1:TriggerMode","Ext. Trigger")
  dbpf("x7PIL1:det1:ArrayCallbacks","Disable")
  dbpf("x7PIL1:det1:ThresholdEnergy","12.398419")
  dbpf("x7PIL1:det1:FilterTransm","0.0")
  dbpf("x7PIL1:det1:OscillAxis","X, CW")
fi