diff --git a/Makefile b/Makefile index f2d3b36..e0e4c88 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # This build the sinq extensions for the PSI EPICS setup include /ioc/tools/driver.makefile -MODULE=counterbox +MODULE=sinqDAQ BUILDCLASSES=Linux EPICS_VERSIONS=7.0.7 ARCH_FILTER=RHEL% @@ -13,26 +13,26 @@ REQUIRED+=stream # DB files to include in the release TEMPLATES += db/channels.db -TEMPLATES += db/counterbox_4ch.db -TEMPLATES += db/counterbox_8ch.db -TEMPLATES += db/counterbox_common.db -TEMPLATES += db/counterbox_v2.db -TEMPLATES += db/counterbox_v2_test.db -TEMPLATES += db/counterbox.proto +TEMPLATES += db/daq_4ch.db +TEMPLATES += db/daq_8ch.db +TEMPLATES += db/daq_common.db +TEMPLATES += db/daq_2nd_gen.db +TEMPLATES += db/daq_2nd_gen_test.db +TEMPLATES += db/daq.proto # Just for simulation -TEMPLATES += db/counterbox_simcontrol.db +TEMPLATES += db/daq_simcontrol.db # DBD files to include in the release -DBDS += src/counterbox.dbd +DBDS += src/daq.dbd # Source files to build -SOURCES += src/counterbox.cpp +SOURCES += src/daq.cpp -SCRIPTS += scripts/counterbox_4ch.cmd -SCRIPTS += scripts/counterbox_8ch.cmd -SCRIPTS += scripts/counterbox_v2.cmd -SCRIPTS += sim/counterbox_sim.py +SCRIPTS += scripts/daq_4ch.cmd +SCRIPTS += scripts/daq_8ch.cmd +SCRIPTS += scripts/daq_2nd_gen.cmd +SCRIPTS += sim/daq_sim.py CXXFLAGS += -std=c++17 USR_CFLAGS += -Wall -Wextra #-Werror diff --git a/README.md b/README.md index 2e1be67..c22f0aa 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ 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. +the required environment variables when calling the correct DAQ interface +script. Required Variables @@ -18,8 +19,8 @@ Required Variables |----------------------|-----------------------------------------| | INSTR | 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 | +| DAQ\_IP | Network IP of device | +| DAQ\_PORT | Network Port of device | All PVs take the form @@ -29,16 +30,16 @@ $(INSTR)$(NAME):* Available device startup scripts -* scripts/counterbox\_4ch.cmd -* scripts/counterbox\_8ch.cmd -* scripts/counterbox\_v2.cmd +* scripts/daq\_4ch.cmd +* scripts/daq\_8ch.cmd +* scripts/daq\_2nd\_gen.cmd A device can be configured using one of the startup scripts as follows ``` epicsEnvSet("INSTR", "SQ:INSTRUMENT:") # can also be set in runScript call -runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, CNTBOX_IP=TestInst-DAQ1, CNTBOX_PORT=2000" +runScript "$(sinqDAQ_DIR)daq_2nd_gen.cmd" "NAME=DAQ, DAQ_IP=TestInst-DAQ1, DAQ_PORT=2000" ``` ## PVs of Interest @@ -52,8 +53,8 @@ runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, CNTBOX_IP=TestI | \$(INSTR)\$(NAME):PRESET-TIME | Run count until specified pv value in seconds reached | | \$(INSTR)\$(NAME):THRESHOLD | Minimum rate for counting to preceed. (has RBV) | | \$(INSTR)\$(NAME):THRESHOLD-MONITOR | Channel monitored for minimum rate (has RBV) | -| \$(INSTR)\$(NAME):ELAPSED-TIME | Time Counterbox has been measuring for | -| \$(INSTR)\$(NAME):M_ | Current count on channel. (1-10 depending on box) | +| \$(INSTR)\$(NAME):ELAPSED-TIME | Time DAQ has been measuring for | +| \$(INSTR)\$(NAME):M_ | Current count on channel. (1-10 depending on DAQ system) | | \$(INSTR)\$(NAME):CHANNELS | Number of available channels (4, 8 or 10) | ## Generating Test Signals @@ -65,34 +66,34 @@ runtime via the following ``` epicsEnvSet("LOAD_TEST_PVS","") -runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, CNTBOX_IP=TestInst-DAQ1, CNTBOX_PORT=2000" +runScript "$(sinqDAQ_DIR)daq_2nd_gen.cmd" "NAME=DAQ, DAQ_IP=TestInst-DAQ1, DAQ_PORT=2000" ``` -See the file [counterbox\_v2\_test.db](./db/counterbox_v2_test.db) +See the file [daq\_2nd\_gen\_test.db](./db/daq_2nd_gen_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" +epicsEnvSet("SET_SIM_MODE","") # run DAQ simulation instead of connecting to actual system +runScript "$(sinqDAQ_DIR)daq_2nd_gen.cmd" "NAME=CB_TEST, DAQ_IP=localhost, DAQ_PORT=2000" ``` -In such a case, the provided `CNTBOX_IP` is ignored, and a python program +In such a case, the provided `DAQ_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 +specified `DAQ_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). +See [sim/daq\_sim.py](sim/daq_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. +An IOC with the 2nd generation DAQ 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). diff --git a/db/channels.db b/db/channels.db index 4f0fb54..11753b5 100644 --- a/db/channels.db +++ b/db/channels.db @@ -4,7 +4,7 @@ # INSTR - Prefix # NAME - the device name, e.g. EL737 # PROTO - Stream device protocol file -# ASYN_PORT - Low level Asyn IP Port to Counterbox +# ASYN_PORT - Low level Asyn IP Port to DAQ # CHANNEL - the number associated with the measurment channel ################################################################################ @@ -25,12 +25,12 @@ record(bo, "$(INSTR)$(NAME):C$(CHANNEL)") record(longin, "$(INSTR)$(NAME):M$(CHANNEL)") { - field(DESC, "Counterbox CH$(CHANNEL)") + field(DESC, "DAQ CH$(CHANNEL)") } record(ai, "$(INSTR)$(NAME):R$(CHANNEL)") { - field(DESC, "Counterbox Rate CH$(CHANNEL)") + field(DESC, "Rate of DAQ CH$(CHANNEL)") field(INP, "@$(PROTO) readRate($(INSTR)$(NAME):, $(CHANNEL)) $(ASYN_PORT)") field(DTYP, "stream") field(SCAN, "1 second") diff --git a/db/counterbox.proto b/db/daq.proto similarity index 94% rename from db/counterbox.proto rename to db/daq.proto index 29d78a8..6a0ba2f 100644 --- a/db/counterbox.proto +++ b/db/daq.proto @@ -1,5 +1,5 @@ # -# Counterbox Protocol File +# SinqDAQ Protocol File # OutTerminator = CR; InTerminator = CR; @@ -14,7 +14,7 @@ initialise { out "ECHO 2"; # Ask for reponses in "%(\$1MsgTxt)s"; # Clear MsgTxt on Init @mismatch{ - exec 'echo "Failed to configure counterbox" && exit(1)'; + exec 'echo "Failed to configure DAQ" && exit(1)'; } } @@ -65,9 +65,8 @@ stopCount { } clearTimer{ - # We first stop the count, as otherwise on the newest counterboxes - # it starts counting again if a time preset was set. - # Not a problem with the older boxes + # We first stop the count, as otherwise the 2nd Gen Data Acquisition starts + # counting again if a time preset was set. Not a problem with the older boxes stopCount; out "CT"; in; diff --git a/db/counterbox_v2.db b/db/daq_2nd_gen.db similarity index 98% rename from db/counterbox_v2.db rename to db/daq_2nd_gen.db index ea81465..f3cb0f8 100644 --- a/db/counterbox_v2.db +++ b/db/daq_2nd_gen.db @@ -5,7 +5,7 @@ # INSTR - Prefix # NAME - the device name, e.g. DAQV2 # PROTO - Stream device protocol file -# ASYN_PORT - Low level Asyn IP Port to Counterbox +# ASYN_PORT - Low level Asyn IP Port to DAQ ################################################################################ # Status Variables diff --git a/db/counterbox_v2_test.db b/db/daq_2nd_gen_test.db similarity index 95% rename from db/counterbox_v2_test.db rename to db/daq_2nd_gen_test.db index 3a9ace7..68d3a7c 100644 --- a/db/counterbox_v2_test.db +++ b/db/daq_2nd_gen_test.db @@ -5,7 +5,7 @@ # INSTR - Prefix # NAME - the device name, e.g. DAQV2 # PROTO - Stream device protocol file -# ASYN_PORT - Low level Asyn IP Port to Counterbox +# ASYN_PORT - Low level Asyn IP Port to DAQ ################################################################################ # Testing Commands diff --git a/db/counterbox_4ch.db b/db/daq_4ch.db similarity index 94% rename from db/counterbox_4ch.db rename to db/daq_4ch.db index 4cb7dd3..1e2c1ac 100644 --- a/db/counterbox_4ch.db +++ b/db/daq_4ch.db @@ -4,7 +4,7 @@ # INSTR - Prefix # NAME - the device name, e.g. EL737 # PROTO - Stream device protocol file -# ASYN_PORT - Low level Asyn IP Port to Counterbox +# ASYN_PORT - Low level Asyn IP Port to DAQ ################################################################################ # Status Variables diff --git a/db/counterbox_8ch.db b/db/daq_8ch.db similarity index 94% rename from db/counterbox_8ch.db rename to db/daq_8ch.db index 3fd8a33..d1893b0 100644 --- a/db/counterbox_8ch.db +++ b/db/daq_8ch.db @@ -4,7 +4,7 @@ # INSTR - Prefix # NAME - the device name, e.g. EL737 # PROTO - Stream device protocol file -# ASYN_PORT - Low level Asyn IP Port to Counterbox +# ASYN_PORT - Low level Asyn IP Port to DAQ ################################################################################ # Status Variables diff --git a/db/counterbox_common.db b/db/daq_common.db similarity index 94% rename from db/counterbox_common.db rename to db/daq_common.db index 201fecf..7cfc1f3 100644 --- a/db/counterbox_common.db +++ b/db/daq_common.db @@ -9,7 +9,7 @@ # Send initial initialisation commands record(bo, "$(INSTR)$(NAME):INIT-CONF") { - field(DESC, "Initialises the Counterbox") + field(DESC, "Initialises the DAQ") field(OUT, "@$(PROTO) initialise($(INSTR)$(NAME):) $(ASYN_PORT)") field(PINI, "YES") # Run at init field(DTYP, "stream") @@ -17,7 +17,7 @@ record(bo, "$(INSTR)$(NAME):INIT-CONF") record(longout, "$(INSTR)$(NAME):FULL-RESET") { - field(DESC, "Reset the Counterbox") + field(DESC, "Reset the DAQ") field(OUT, "@$(PROTO) fullReset($(INSTR)$(NAME):) $(ASYN_PORT)") field(DTYP, "stream") } @@ -28,16 +28,16 @@ record(longout, "$(INSTR)$(NAME):FULL-RESET") record(stringin, "$(INSTR)$(NAME):MsgTxt") { field(DESC, "Unexpected received response") - field(DTYP, "devCounterBoxStringError") + field(DTYP, "devDAQStringError") field(FLNK, "$(INSTR)$(NAME):INVALID-CONFIG") } # We want to recognise the invalid config error message, so that we can rerun -# the init if it occurs. This should only happen after turning the box off and +# the init if it occurs. This should only happen after turning the DAQ off and # on again or running a full reset record(scalcout, "$(INSTR)$(NAME):INVALID-CONFIG") { - field(DESC, "Has the counterbox been configured?") + field(DESC, "Has the DAQ been configured?") field(CALC, "AA[0,2] == '?OF'") field(INAA, "$(INSTR)$(NAME):MsgTxt") field(FLNK, "$(INSTR)$(NAME):REINIT-CONF") @@ -76,7 +76,7 @@ record(calc, "$(INSTR)$(NAME):MAP-STATUS") record(mbbi, "$(INSTR)$(NAME):STATUS") { - field(DESC, "Counterbox Status") + field(DESC, "DAQ Status") field(INP, "$(INSTR)$(NAME):MAP-STATUS NPP") field(ZRVL, "0") field(ZRST, "Idle") @@ -86,7 +86,7 @@ record(mbbi, "$(INSTR)$(NAME):STATUS") field(TWST, "Low rate") field(THVL, "3") field(THST, "Paused") - # 4 should never happen, if it does it means the counter box reports undocumented statusbits + # 4 should never happen, if it does it means the DAQ reports undocumented statusbits field(FRVL, "4") field(FRST, "INVALID") } @@ -207,6 +207,6 @@ record(ai, "$(INSTR)$(NAME):READALL") record(ai,"$(INSTR)$(NAME):ELAPSED-TIME") { - field(DESC, "Counterbox Measured Time") + field(DESC, "DAQ Measured Time") field(EGU, "seconds") } diff --git a/db/counterbox_simcontrol.db b/db/daq_simcontrol.db similarity index 88% rename from db/counterbox_simcontrol.db rename to db/daq_simcontrol.db index 36e5128..53e5ca0 100644 --- a/db/counterbox_simcontrol.db +++ b/db/daq_simcontrol.db @@ -1,4 +1,4 @@ -# Sinq Counterbox EPICS Database for StreamDevice Communication with Simulation +# Sinq DAQ EPICS Database for StreamDevice Communication with Simulation # Macros # # INSTR - Prefix diff --git a/scripts/counterbox_4ch.cmd b/scripts/counterbox_4ch.cmd deleted file mode 100644 index 28fb81c..0000000 --- a/scripts/counterbox_4ch.cmd +++ /dev/null @@ -1,22 +0,0 @@ -require asyn -require stream - -epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") - -$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc -$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT)") -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 4 &" -# starting the python socket seems to take a while -# and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 - -epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") -drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) -dbLoadRecords("$(counterbox_DB)counterbox_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=4") -dbLoadRecords("$(counterbox_DB)counterbox_4ch.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") - -# Could also use substitions instead. -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") diff --git a/scripts/counterbox_8ch.cmd b/scripts/counterbox_8ch.cmd deleted file mode 100644 index c82c9a2..0000000 --- a/scripts/counterbox_8ch.cmd +++ /dev/null @@ -1,26 +0,0 @@ -require asyn -require stream - -epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT)") - -$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc -$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT)") -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT) 8 &" -# starting the python socket seems to take a while -# and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 - -epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") -drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) -dbLoadRecords("$(counterbox_DB)counterbox_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=8") -dbLoadRecords("$(counterbox_DB)counterbox_8ch.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") - -# Could also use substitions instead. -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=5") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=6") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=7") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=8") diff --git a/scripts/counterbox_v2.cmd b/scripts/counterbox_v2.cmd deleted file mode 100644 index 8d2a2d2..0000000 --- a/scripts/counterbox_v2.cmd +++ /dev/null @@ -1,32 +0,0 @@ -require asyn -require stream - -epicsEnvSet("$(NAME)_CNTBOX_HOST", "$(CNTBOX_IP):$(CNTBOX_PORT=2000)") - -$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc -$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_CNTBOX_HOST", "127.0.0.1:$(CNTBOX_PORT=2000)") -$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(counterbox_DIR)counterbox_sim.py $(CNTBOX_PORT=2000) 10 &" -# starting the python socket seems to take a while -# and need misc to use built in sleep command -$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 - -epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") -drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_CNTBOX_HOST)", 0, 0, 0) -dbLoadRecords("$(counterbox_DB)counterbox_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=10") -dbLoadRecords("$(counterbox_DB)counterbox_v2.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=10") - -# Could also use substitions instead. -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=5") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=6") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=7") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=8") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=9") -dbLoadRecords("$(counterbox_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=10") - -$(LOAD_TEST_PVS=#) $(LOAD_TEST_PVS) dbLoadRecords("$(counterbox_DB)counterbox_v2_test.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") - -$(SET_SIM_MODE=#) $(SET_SIM_MODE) dbLoadRecords("$(counterbox_DB)counterbox_simcontrol.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") diff --git a/scripts/daq_2nd_gen.cmd b/scripts/daq_2nd_gen.cmd new file mode 100644 index 0000000..cdcf852 --- /dev/null +++ b/scripts/daq_2nd_gen.cmd @@ -0,0 +1,32 @@ +require asyn +require stream + +epicsEnvSet("$(NAME)_DAQ_HOST", "$(DAQ_IP):$(DAQ_PORT=2000)") + +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc +$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_DAQ_HOST", "127.0.0.1:$(DAQ_PORT=2000)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(sinqDAQ_DIR)daq_sim.py $(DAQ_PORT=2000) 10 &" +# starting the python socket seems to take a while +# and need misc to use built in sleep command +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 + +epicsEnvSet("PROTO", "$(sinqDAQ_DB)daq.proto") +drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_DAQ_HOST)", 0, 0, 0) +dbLoadRecords("$(sinqDAQ_DB)daq_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=10") +dbLoadRecords("$(sinqDAQ_DB)daq_2nd_gen.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=10") + +# Could also use substitions instead. +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=5") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=6") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=7") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=8") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=9") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=10") + +$(LOAD_TEST_PVS=#) $(LOAD_TEST_PVS) dbLoadRecords("$(sinqDAQ_DB)daq_2nd_gen_test.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") + +$(SET_SIM_MODE=#) $(SET_SIM_MODE) dbLoadRecords("$(sinqDAQ_DB)daq_simcontrol.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") diff --git a/scripts/daq_4ch.cmd b/scripts/daq_4ch.cmd new file mode 100644 index 0000000..6c43c94 --- /dev/null +++ b/scripts/daq_4ch.cmd @@ -0,0 +1,22 @@ +require asyn +require stream + +epicsEnvSet("$(NAME)_DAQ_HOST", "$(DAQ_IP):$(DAQ_PORT)") + +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc +$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_DAQ_HOST", "127.0.0.1:$(DAQ_PORT)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(sinqDAQ_DIR)daq_sim.py $(DAQ_PORT) 4 &" +# starting the python socket seems to take a while +# and need misc to use built in sleep command +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 + +epicsEnvSet("PROTO", "$(sinqDAQ_DB)daq.proto") +drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_DAQ_HOST)", 0, 0, 0) +dbLoadRecords("$(sinqDAQ_DB)daq_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=4") +dbLoadRecords("$(sinqDAQ_DB)daq_4ch.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") + +# Could also use substitions instead. +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") diff --git a/scripts/daq_8ch.cmd b/scripts/daq_8ch.cmd new file mode 100644 index 0000000..1ac5187 --- /dev/null +++ b/scripts/daq_8ch.cmd @@ -0,0 +1,26 @@ +require asyn +require stream + +epicsEnvSet("$(NAME)_DAQ_HOST", "$(DAQ_IP):$(DAQ_PORT)") + +$(SET_SIM_MODE=#) $(SET_SIM_MODE) require misc +$(SET_SIM_MODE=#) $(SET_SIM_MODE) epicsEnvSet("$(NAME)_DAQ_HOST", "127.0.0.1:$(DAQ_PORT)") +$(SET_SIM_MODE=#) $(SET_SIM_MODE) system "$(sinqDAQ_DIR)daq_sim.py $(DAQ_PORT) 8 &" +# starting the python socket seems to take a while +# and need misc to use built in sleep command +$(SET_SIM_MODE=#) $(SET_SIM_MODE) sleep 3 + +epicsEnvSet("PROTO", "$(sinqDAQ_DB)daq.proto") +drvAsynIPPortConfigure("ASYN_$(NAME)", "$($(NAME)_DAQ_HOST)", 0, 0, 0) +dbLoadRecords("$(sinqDAQ_DB)daq_common.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=8") +dbLoadRecords("$(sinqDAQ_DB)daq_8ch.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME)") + +# Could also use substitions instead. +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=1") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=2") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=3") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=4") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=5") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=6") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=7") +dbLoadRecords("$(sinqDAQ_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNEL=8") diff --git a/sim/counterbox_sim.py b/sim/daq_sim.py similarity index 87% rename from sim/counterbox_sim.py rename to sim/daq_sim.py index 578925a..627a1c6 100644 --- a/sim/counterbox_sim.py +++ b/sim/daq_sim.py @@ -14,13 +14,13 @@ TOTAL_CH = int(sys.argv[2]) # Number of Channels LOG2FILE = False if len(sys.argv) < 4 else bool(int(sys.argv[3])) import logging -logger = logging.getLogger('counterbox') +logger = logging.getLogger('daq') if LOG2FILE: - logging.basicConfig(filename=os.path.join(os.getcwd(), 'counterbox_sim.log'), level=logging.INFO) + logging.basicConfig(filename=os.path.join(os.getcwd(), 'daq_sim.log'), level=logging.INFO) -class CounterBox: +class DAQ: def __init__(self, total_channels): self.total_channels = total_channels self.counts = [0] * self.total_channels @@ -66,7 +66,7 @@ class CounterBox: return self.counts[channel - 1] def getCounts(self): - # The sinqtest box returns a maximum of 8 + # The sinqtest daq returns a maximum of 8 return self.counts[0:min(len(self.counts), 8)] def getMonitorCount(self): @@ -217,7 +217,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: logger.info(f'RECEIVED: "{received}"') return received - counterbox = CounterBox(TOTAL_CH) + daq = DAQ(TOTAL_CH) while True: @@ -232,85 +232,85 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: send('') elif data == 'ECHO 2': - send('Counterbox') # Sends some sort of info command + send('DAQ System Version Simulation') # Sends some sort of info command elif data == 'RA': send( ' '.join(map(str, - [counterbox.getRunTime()] + \ - counterbox.getCounts() + [daq.getRunTime()] + \ + daq.getCounts() )) ) elif re.fullmatch(r'RC (\d+)', data): channel = int(re.fullmatch(r'RC (\d+)', data).group(1)) - count = counterbox.getCount(channel) + count = daq.getCount(channel) send(f'{count}') elif data == 'RS': - send(str(counterbox.getStatus())) + send(str(daq.getStatus())) elif data == 'S': - counterbox.stop() + daq.stop() send('') elif data == 'CT': - counterbox.clearTime() + daq.clearTime() send('') elif re.fullmatch(r'CC (\d+)', data): counter = int(re.fullmatch(r'CC (\d+)', data).group(1)) - counterbox.clearCount(counter) + daq.clearCount(counter) send('') elif re.fullmatch(r'TP (\d+(\.\d+)?)', data): presettime = float(re.fullmatch(r'TP (\d+(\.\d+)?)', data).group(1)) - counterbox.startTimePreset(presettime) + daq.startTimePreset(presettime) send('') elif re.fullmatch(r'MP (\d+)', data): counts = int(re.fullmatch(r'MP (\d+)', data).group(1)) - counterbox.startCountPreset(counts) + daq.startCountPreset(counts) send('') elif data == 'PC': - send(str(counterbox.getMonitorChannel())) + send(str(daq.getMonitorChannel())) elif re.fullmatch(r'PC (\d+)', data): channel = int(re.fullmatch(r'PC (\d+)', data).group(1)) - counterbox.setMonitorChannel(channel) + daq.setMonitorChannel(channel) send('') elif data == 'DR': - send(str(counterbox.getMinRateChannel())) + send(str(daq.getMinRateChannel())) elif re.fullmatch(r'DR (\d+)', data): channel = int(re.fullmatch(r'DR (\d+)', data).group(1)) - counterbox.setMinRateChannel(channel) + daq.setMinRateChannel(channel) send('') elif re.fullmatch(r'DL (\d+)', data): channel = int(re.fullmatch(r'DL (\d+)', data).group(1)) - send('{:.3f}'.format(counterbox.getMinRate(channel))) + send('{:.3f}'.format(daq.getMinRate(channel))) elif re.fullmatch(r'DL (\d+) (\d+(?:.\d+)?)', data): channel, rate = re.fullmatch(r'DL (\d+) (\d+(?:.\d+)?)', data).groups() - counterbox.setMinRate(int(channel), float(rate)) + daq.setMinRate(int(channel), float(rate)) send('') elif re.fullmatch(r'RR (\d+)', data): channel = int(re.fullmatch(r'RR (\d+)', data).group(1)) - send(counterbox.getRate(channel)) + send(daq.getRate(channel)) elif re.fullmatch(r'GT (\d+)', data): channel = int(re.fullmatch(r'GT (\d+)', data).group(1)) - enabled, highlow = counterbox.getGateStatus(channel) + enabled, highlow = daq.getGateStatus(channel) send(f'{int(enabled)} {int(highlow)}') elif re.fullmatch(r'GT (\d+) (\d+) (\d+)', data): channel, enable, highlow = re.fullmatch(r'GT (\d+) (\d+) (\d+)', data).groups() channel, enable, highlow = int(channel), bool(int(enable)), bool(int(highlow)) - counterbox.setGateStatus(channel, enable, highlow) + daq.setGateStatus(channel, enable, highlow) if enable: send(f'Gate {channel} enabled, counting when input = {"high" if highlow else "low"}') else: @@ -320,7 +320,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: elif re.fullmatch(r'GATE (\d+) (\d+)', data): channel, highlow = re.fullmatch(r'GATE (\d+) (\d+)', data).groups() channel, highlow = int(channel), bool(int(highlow)) - counterbox.setGate(channel, highlow) + daq.setGate(channel, highlow) send('') else: diff --git a/src/counterbox.dbd b/src/counterbox.dbd deleted file mode 100644 index 4ef690d..0000000 --- a/src/counterbox.dbd +++ /dev/null @@ -1,5 +0,0 @@ -#--------------------------------------------- -# Counterbox specific DB definitions -#--------------------------------------------- - -device(stringin,INST_IO,devCounterBoxStringError,"devCounterBoxStringError") diff --git a/src/counterbox.cpp b/src/daq.cpp similarity index 96% rename from src/counterbox.cpp rename to src/daq.cpp index 591fea3..02d2bf0 100644 --- a/src/counterbox.cpp +++ b/src/daq.cpp @@ -54,7 +54,7 @@ struct { DEVSUPFUN get_ioint_info; DEVSUPFUN read_ai; DEVSUPFUN special_linconv; -} devCounterBoxStringError = { +} devDAQStringError = { 6, NULL, NULL, NULL, NULL, (DEVSUPFUN)map_raw_failure_message, NULL}; -epicsExportAddress(dset, devCounterBoxStringError); +epicsExportAddress(dset, devDAQStringError); diff --git a/src/daq.dbd b/src/daq.dbd new file mode 100644 index 0000000..3bfdf32 --- /dev/null +++ b/src/daq.dbd @@ -0,0 +1,5 @@ +#--------------------------------------------- +# DAQ specific DB definitions +#--------------------------------------------- + +device(stringin, INST_IO, devDAQStringError, "devDAQStringError") diff --git a/test/st.cmd b/test/st.cmd index 73fe2fb..7f55320 100755 --- a/test/st.cmd +++ b/test/st.cmd @@ -2,13 +2,13 @@ on error break -require counterbox +require sinqDAQ epicsEnvSet("STREAM_PROTOCOL_PATH","./db") epicsEnvSet("INSTR","SQ:TEST:") epicsEnvSet("NAME","CB_TEST") -epicsEnvSet("SET_SIM_MODE","") # Run Counterbox Simulation Instead of Actual Box -runScript "$(counterbox_DIR)counterbox_v2.cmd" "CNTBOX_IP=127.0.0.1, CNTBOX_PORT=2000" +epicsEnvSet("SET_SIM_MODE","") # Run Simulation Instead of Actual Interface +runScript "$(sinqDAQ_DIR)daq_2nd_gen.cmd" "DAQ_IP=127.0.0.1, DAQ_PORT=2000" iocInit()