Skip to content
John Holt edited this page Nov 30, 2017 · 29 revisions

Wiki > The Backend System > IOCs > IOC utilities

The utilities comprise of useful IOC db templates and IOC shell utilities.

DB Templates

Unit Setter

This copies units from a pv and sets them on a different pv. E.g.

file $(UTILITIES)/db/unit_setter.template { 
  pattern 
    {P,    FROM, TO}

    {"\$(P)", "UNITS", "READING"}
    {"\$(P)", "UNITS", "SP"}

}

This will copy units from the value of the pv $(P)UNITS to $(P)READING and $(P)SP.

Error Setting

Creates a raw pv that can be written to by a stream protocol and then transfer the stream protocols pv error and value to the real pv.

For example:

file $(UTILITIES)/db/error_setter.template {
    pattern {P, STREAM_PV, PV_NAME}

    {"\$(P)", "FREQ:REF", "FREQ:SP:RBV"}
    {"\$(P)", "FREQ:REF", "FREQ"}

}

In this example the PV FREQ:REF reads the values from a status and then set the values, via the protocol file, in the FREQ:SP:RBV:RAW.A pv. This value and any error that occurs in the FREQ:REF is the nset on the FREQ:SP:RBV pv. This allows you to easily show a disconnected error in PVs that are set from the protocol file.

Shell Utilities

There are a number of IOC shell utilities defined in C:\Instrument\Apps\EPICS\support\utilities which can be used in an IOC shell to help startup IOCs. The doxygen docs are here http://epics.isis.rl.ac.uk/doxygen/main/support/utilities/.

calc

Performs an arithmetic operation on an expression and return the integer value to a specific environment variable:

calc("ENV1","1+1",1,2)

The arguments are as follows:

  1. The output environment variable
  2. The expression to be evaluated
  3. Options
  4. The output length

My best guess is that the expression is evaluated using the calcPerform method from the EPICS standard library so the expression should match the syntax as used in a calc record.

The options are detailed in ioccalc.cpp in the utilities directory.

Examples can be seen in the Galil and McLennan motor records.

dcalc

As calc, but returns a double value. The 4th argument is for the number of decimal places, not the value length.

dcalc("ENV1","0.1*0.2",1,2)

An example can be seen in the Eurotherm IOC, file st-timing.cmd.

stringtest

TODO

stringiftest(resultvar, lhs, operation, rhs)

Defines an environment variables as empty or a comment depending on if lhs is empty. The variables defined are:

  • IF<resultsvar> '#' if empty; otherwise ' '
  • IFNOT<resultsvar> ' ' if empty; otherwise '#'

parameters

  1. resultvar - the basename of the environment variable to set
  2. lhs - the string to test
  3. operation - set the first bit for verbose mode
  4. rhs - does nothing

setIOCName

TODO

getIOCName

TODO

getIOCGroup

TODO

mkdir

TODO

Clone this wiki locally