Counterbox Epics Module
A Stream and Asyn based driver for configuring the Counterboxes at SINQ.
This supports the older 4 and 8 channel EL737 models and the new 10CH 2nd generation systems.
How to Use
Unless a custom database is needed, a device can be configure simply by setting the required environment variables when calling the correct counterbox script.
Required Variables
Environment Variable | Purpose |
---|---|
PREFIX | Prefix of all device specific PVs |
NAME | First field in all PVs after Prefix |
CNTBOX_IP | Network IP of device |
CNTBOX_PORT | Network Port of device |
All PVs take the form
$(PREFIX):$(NAME):*
Available device startup scripts
- scripts/counterbox_4ch.cmd
- scripts/counterbox_8ch.cmd
- scripts/counterbox_v2.cmd
A device can be configured using one of the startup scripts as follows
epicsEnvSet("PREFIX", "SQ:INSTRUMENT") # can also be set in runScript call
runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, CNTBOX_IP=TestInst-DAQ1, CNTBOX_PORT=2000"
PVs of Interest
PV | Description |
---|---|
$(PREFIX):$(NAME):MsgTxt | Contains unexpected response to executed command |
$(PREFIX):$(NAME):STATUS | 0: Idle, 1: Counting, 2: Low rate, 3: Paused, 4: Error |
$(PREFIX):$(NAME):MONITOR-CHANNEL | Channel that PRESET-COUNT monitors (has RBV, only v2 can be changed) |
$(PREFIX):$(NAME):PRESET-COUNT | Run count until specified pv value reached |
$(PREFIX):$(NAME):PRESET-TIME | Run count until specified pv value in seconds reached |
$(PREFIX):$(NAME):THRESHOLD | Minimum rate for counting to preceed. (has RBV) |
$(PREFIX):$(NAME):THRESHOLD-MONITOR | Channel monitored for minimum rate (has RBV) |
$(PREFIX):$(NAME):ELAPSED-TIME | Time Counterbox has been measuring for |
$(PREFIX):$(NAME):M_ | Current count on channel. (1-10 depending on box) |
$(PREFIX):$(NAME):CHANNELS | Number of available channels (4, 8 or 10) |
Generating Test Signals
The 2nd generation systems have two test channels that can be used to output signals at a variable rate. These can be used to ensure the other channels are working and to check the IOC - Nicos integration. These can be loaded at runtime via the following
epicsEnvSet("LOAD_TEST_PVS","")
runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, CNTBOX_IP=TestInst-DAQ1, CNTBOX_PORT=2000"
See the file counterbox_v2_test.db
Simulation
Simulation of the Hardware can be toggled on as follows:
epicsEnvSet("SET_SIM_MODE","") # run counterbox simulation instead of connecting to actual box
runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=CB_TEST, CNTBOX_IP=localhost, CNTBOX_PORT=2000"
In such a case, the provided CNTBOX_IP
is ignored, and a python program
simulating the hardware is started in the background, listening at the
specified CNTBOX_PORT
. So, if you have multiple devices listening on the same
port, you might have to change this port value of one of the devices when
simulating hardware. You can then interact with the PVs as with the normal
hardware. Keep in mind, however, that not all functionality has been
implemented.
Testing
An IOC with the counterbox_v2 started in simulation mode can be started via the test/ioc.sh script.
There is also a simple automated test that can be run for a simple check of functionality and that the PVs load test/test.py.
Both require that the module has been built and installed as is normal in the require based module system.
You might have to change the specified version in the test/st.cmd file to the version you compiled and want to test.