6 Commits
0.0.1 ... 0.0.3

11 changed files with 195 additions and 51 deletions

View File

@ -7,17 +7,16 @@ EPICS_VERSIONS=7.0.7
ARCH_FILTER=RHEL%
# additional module dependencies
REQUIRED+=stream
REQUIRED+=asyn
REQUIRED+=calc
# Release version
LIBVERSION=ed-dev
REQUIRED+=stream
# DB files to include in the release
TEMPLATES += db/counterbox.db
TEMPLATES += db/counterbox.proto
TEMPLATES += db/counterbox_common.db
TEMPLATES += db/counterbox_4ch.db
TEMPLATES += db/counterbox_8ch.db
TEMPLATES += db/counterbox_v2.db
TEMPLATES += db/counterbox_common.db
TEMPLATES += db/counterbox.proto
# DBD files to include in the release
DBDS += src/counterbox.dbd
@ -25,7 +24,8 @@ DBDS += src/counterbox.dbd
# Source files to build
SOURCES += src/counterbox.cpp
SCRIPTS += scripts/counterbox.cmd
SCRIPTS += scripts/counterbox_4ch.cmd
SCRIPTS += scripts/counterbox_8ch.cmd
SCRIPTS += scripts/counterbox_v2.cmd
CXXFLAGS += -std=c++17

56
README.md Normal file
View File

@ -0,0 +1,56 @@
Counterbox Epics Module
-----------------------
A Stream and Asyn based driver for Counterboxes as 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 |
| ASYN_PORT | Unique name for referencing Asyn device |
| CNTBOX_HOST | Network IP and 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 "$(sinq_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, ASYN_PORT=CBOXV2, CNTBOX_HOST=TestInst-DAQ1: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) |

View File

@ -95,6 +95,12 @@ readMinRate{
################################################################################
# Read Values From Monitors
readAll4 {
out "RA";
in "%(\$1ELAPSED-TIME)f %(\$1M1)d %(\$1M2)d %(\$1M3)d %(\$1M4)d";
@mismatch{in "%(\$1MsgTxt)s";}
}
readAll8 {
out "RA";
in "%(\$1ELAPSED-TIME)f %(\$1M1)d %(\$1M2)d %(\$1M3)d %(\$1M4)d %(\$1M5)d %(\$1M6)d %(\$1M7)d %(\$1M8)d";

View File

@ -1,4 +1,4 @@
# EL737 EPICS Database for streamdevice support
# Counterbox EPICS Database
# Macros
# P - Prefix
# NAME - just a name, e.g. EL737
@ -22,6 +22,13 @@ record(longin, "$(P):$(NAME):MONITOR-CHANNEL_RBV")
field(DISP, 1)
}
record(longin, "$(P):$(NAME):CHANNELS")
{
field(DESC, "Total Supported Channels")
field(VAL, 4)
field(DISP, 1)
}
################################################################################
# Count Commands
@ -30,7 +37,7 @@ record(longout,"$(P):$(NAME):THRESHOLD-MONITOR")
field(DESC, "Channel monitored for minimum rate")
field(VAL, "1") # Monitor
field(DRVL, "1") # Smallest Threshold Channel
field(DRVL, "8") # Largest Threshold Channel
field(DRVL, "4") # Largest Threshold Channel
}
################################################################################
@ -39,7 +46,7 @@ record(longout,"$(P):$(NAME):THRESHOLD-MONITOR")
record(ai, "$(P):$(NAME):READALL")
{
field(DESC, "Reads monitors and elapsed time")
field(INP, "@$(PROTO) readAll8($(P):$(NAME):) $(ASYN_PORT)")
field(INP, "@$(PROTO) readAll4($(P):$(NAME):) $(ASYN_PORT)")
field(SCAN, ".2 second")
field(DTYP, "stream")
field(FLNK, "$(P):$(NAME):UNSET-COUNTING")

73
db/counterbox_8ch.db Normal file
View File

@ -0,0 +1,73 @@
# EL737 EPICS Database for streamdevice support
# Macros
# P - Prefix
# NAME - just a name, e.g. EL737
# PROTO - Stream device protocol file
# ASYN_PORT - Low level Asyn IP Port to EL737
################################################################################
# Status Variables
record(longin, "$(P):$(NAME):MONITOR-CHANNEL")
{
field(DESC, "PRESET-COUNT Monitors this channel")
field(VAL, 1)
field(DISP, 1)
}
record(longin, "$(P):$(NAME):MONITOR-CHANNEL_RBV")
{
field(DESC, "PRESET-COUNT Monitors this channel")
field(VAL, 1)
field(DISP, 1)
}
record(longin, "$(P):$(NAME):CHANNELS")
{
field(DESC, "Total Supported Channels")
field(VAL, 8)
field(DISP, 1)
}
################################################################################
# Count Commands
record(longout,"$(P):$(NAME):THRESHOLD-MONITOR")
{
field(DESC, "Channel monitored for minimum rate")
field(VAL, "1") # Monitor
field(DRVL, "1") # Smallest Threshold Channel
field(DRVL, "8") # Largest Threshold Channel
}
################################################################################
# Read all monitors values
record(ai, "$(P):$(NAME):READALL")
{
field(DESC, "Reads monitors and elapsed time")
field(INP, "@$(PROTO) readAll8($(P):$(NAME):) $(ASYN_PORT)")
field(SCAN, ".2 second")
field(DTYP, "stream")
field(FLNK, "$(P):$(NAME):UNSET-COUNTING")
}
record(longin, "$(P):$(NAME):M5")
{
field(DESC, "Counterbox CH5")
}
record(longin, "$(P):$(NAME):M6")
{
field(DESC, "Counterbox CH6")
}
record(longin, "$(P):$(NAME):M7")
{
field(DESC, "Counterbox CH7")
}
record(longin, "$(P):$(NAME):M8")
{
field(DESC, "Counterbox CH8")
}

View File

@ -229,26 +229,6 @@ record(longin, "$(P):$(NAME):M4")
field(DESC, "Counterbox CH4")
}
record(longin, "$(P):$(NAME):M5")
{
field(DESC, "Counterbox CH5")
}
record(longin, "$(P):$(NAME):M6")
{
field(DESC, "Counterbox CH6")
}
record(longin, "$(P):$(NAME):M7")
{
field(DESC, "Counterbox CH7")
}
record(longin, "$(P):$(NAME):M8")
{
field(DESC, "Counterbox CH8")
}
# Not yet sure whether we want to support this
# record(longin, "$(P):$(NAME):R1")
# {

View File

@ -24,6 +24,13 @@ record(longin, "$(P):$(NAME):MONITOR-CHANNEL_RBV")
field(SCAN, "5 second")
}
record(longin, "$(P):$(NAME):CHANNELS")
{
field(DESC, "Total Supported Channels")
field(VAL, 10)
field(DISP, 1)
}
################################################################################
# Count Commands
@ -47,6 +54,26 @@ record(ai, "$(P):$(NAME):READALL")
field(FLNK, "$(P):$(NAME):UNSET-COUNTING")
}
record(longin, "$(P):$(NAME):M5")
{
field(DESC, "Counterbox CH5")
}
record(longin, "$(P):$(NAME):M6")
{
field(DESC, "Counterbox CH6")
}
record(longin, "$(P):$(NAME):M7")
{
field(DESC, "Counterbox CH7")
}
record(longin, "$(P):$(NAME):M8")
{
field(DESC, "Counterbox CH8")
}
record(longin, "$(P):$(NAME):M9")
{
field(DESC, "Counterbox CH9")

View File

@ -1,13 +0,0 @@
require asyn
# Need to be set by user
# epicsEnvSet("CNTBOX_HOST", "testinst-daq1:2000")
# epicsEnvSet("ASYN_PORT", "el737")
# epicsEnvSet("PREFIX", "SQ:SINQTEST")
# epicsEnvSet("NAME", "COUNTERBOX")
epicsEnvSet("PROTO", "$(sinq_DB)counterbox.proto")
drvAsynIPPortConfigure("$(ASYN_PORT)", "$(CNTBOX_HOST)", 0, 0, 0)
dbLoadRecords("$(sinq_DB)counterbox_common.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")
dbLoadRecords("$(sinq_DB)counterbox.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")

View File

@ -0,0 +1,7 @@
require asyn
require stream
epicsEnvSet("PROTO", "$(sinq_DB)counterbox.proto")
drvAsynIPPortConfigure("$(ASYN_PORT)", "$(CNTBOX_HOST)", 0, 0, 0)
dbLoadRecords("$(sinq_DB)counterbox_common.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")
dbLoadRecords("$(sinq_DB)counterbox_4ch.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")

View File

@ -0,0 +1,7 @@
require asyn
require stream
epicsEnvSet("PROTO", "$(sinq_DB)counterbox.proto")
drvAsynIPPortConfigure("$(ASYN_PORT)", "$(CNTBOX_HOST)", 0, 0, 0)
dbLoadRecords("$(sinq_DB)counterbox_common.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")
dbLoadRecords("$(sinq_DB)counterbox_8ch.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")

View File

@ -1,13 +1,7 @@
require asyn
# Need to be set by user
# epicsEnvSet("CNTBOX_HOST", "testinst-daq1:2000")
# epicsEnvSet("ASYN_PORT", "el737")
# epicsEnvSet("PREFIX", "SQ:SINQTEST")
# epicsEnvSet("NAME", "COUNTERBOX")
require stream
epicsEnvSet("PROTO", "$(sinq_DB)counterbox.proto")
drvAsynIPPortConfigure("$(ASYN_PORT)", "$(CNTBOX_HOST)", 0, 0, 0)
dbLoadRecords("$(sinq_DB)counterbox_common.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")
dbLoadRecords("$(sinq_DB)counterbox_v2.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")