Adding sim and test

This commit is contained in:
2024-11-05 09:29:38 +01:00
parent 29e8aa9e85
commit 897e54901f
17 changed files with 465 additions and 161 deletions

View File

@ -1,7 +1,7 @@
Counterbox Epics Module
-----------------------
A Stream and Asyn based driver for Counterboxes as SINQ.
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.
@ -17,8 +17,9 @@ Required Variables
|----------------------|-----------------------------------------|
| PREFIX | Prefix of all device specific PVs |
| NAME | First field in all PVs after Prefix |
| ASYN_PORT | Unique name for referencing Asyn device |
| CNTBOX_HOST | Network IP and Port of device |
| ASYN\_PORT | Unique name for referencing Asyn device |
| CNTBOX\_IP | Network IP of device |
| CNTBOX\_PORT | Network Port of device |
All PVs take the form
@ -28,16 +29,16 @@ $(PREFIX):$(NAME):*
Available device startup scripts
* scripts/counterbox_4ch.cmd
* scripts/counterbox_8ch.cmd
* scripts/counterbox_v2.cmd
* 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, ASYN_PORT=CBOXV2, CNTBOX_HOST=TestInst-DAQ1:2000"
runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, ASYN_PORT=CBOXV2, CNTBOX_IP=TestInst-DAQ1, CNTBOX_PORT=2000"
```
## PVs of Interest
@ -55,7 +56,7 @@ runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, ASYN_PORT=CBOXV
| \$(PREFIX):\$(NAME):M_ | Current count on channel. (1-10 depending on box) |
| \$(PREFIX):\$(NAME):CHANNELS | Number of available channels (4, 8 or 10) |
## Testing
## 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
@ -68,3 +69,36 @@ runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, ASYN_PORT=CBOXV
```
See the file [counterbox\_v2\_test.db](./db/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" "ASYN_PORT=CBOXV2, 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.
See [sim/counterbox\_sim.py](sim/counterbox_sim.py).
## Testing
An IOC with the counterbox\_v2 started in simulation mode can be started via
the [test/ioc.sh](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](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](test/st.cmd) file to the version you compiled and want to test.