diff --git a/Makefile b/Makefile index 763a39d..bdfb942 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ REQUIRED+=stream TEMPLATES += db/counterbox_4ch.db TEMPLATES += db/counterbox_8ch.db TEMPLATES += db/counterbox_v2.db +TEMPLATES += db/counterbox_v2_test.db TEMPLATES += db/counterbox_common.db TEMPLATES += db/counterbox.proto diff --git a/README.md b/README.md index edefab9..dbac306 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,17 @@ runScript "$(counterbox_DIR)counterbox_v2.cmd" "NAME=COUNTERBOX, ASYN_PORT=CBOXV | \$(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) | + +## Testing + +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, ASYN_PORT=CBOXV2, CNTBOX_HOST=TestInst-DAQ1:2000" +``` + +See the file [counterbox\_v2\_test.db](./db/counterbox_v2_test.db) diff --git a/db/counterbox_4ch.db b/db/counterbox_4ch.db index 27feb97..dcff4b4 100644 --- a/db/counterbox_4ch.db +++ b/db/counterbox_4ch.db @@ -47,7 +47,6 @@ record(ai, "$(P):$(NAME):READALL") { field(DESC, "Reads monitors and elapsed time") field(INP, "@$(PROTO) readAll4($(P):$(NAME):) $(ASYN_PORT)") - field(SCAN, ".2 second") field(DTYP, "stream") - field(FLNK, "$(P):$(NAME):UNSET-COUNTING") + field(FLNK, "$(P):$(NAME):MAP-STATUS") } diff --git a/db/counterbox_8ch.db b/db/counterbox_8ch.db index cb6d494..5169e45 100644 --- a/db/counterbox_8ch.db +++ b/db/counterbox_8ch.db @@ -47,9 +47,8 @@ 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") + field(FLNK, "$(P):$(NAME):MAP-STATUS") } record(longin, "$(P):$(NAME):M5") diff --git a/db/counterbox_common.db b/db/counterbox_common.db index 452b32e..ab5d8d9 100644 --- a/db/counterbox_common.db +++ b/db/counterbox_common.db @@ -23,7 +23,7 @@ record(fanout, "$(P):$(NAME):INIT-BOX") field(DESC, "Rewrite PVs to Box") field(SELM, "All") field(LNK0, "$(P):$(NAME):MONITOR-CHANNEL_RBV PP") - field(LNK1, "$(P):$(NAME):READALL PP") + field(LNK1, "$(P):$(NAME):RAW-STATUS PP") field(LNK2, "$(P):$(NAME):THRESHOLD_RBV PP") } @@ -63,45 +63,17 @@ record(seq, "$(P):$(NAME):REINIT-CONF") field(SELL, "$(P):$(NAME):INVALID-CONFIG.VAL") } -# The COUNTING PV stays True until Counterbox has switched back to idle mode -# and the monitor counts have been read. Therefore, we know that the monitor -# values have been updated to represent their final values, when this switches -# back to False. -# -# This is accomplished via the explicit SET-COUNTING and UNSET-COUNTING seq -# records, that are triggered by a switch to the counting status -# (RAW-STATUS == 1 || 2) and a read of the monitors respectively. -record(bi, "$(P):$(NAME):COUNTING") -{ - field(DESC, "Counterbox is Counting") - field(VAL, 0) -} - -record(seq, "$(P):$(NAME):SET-COUNTING") -{ - field(LNK1, "$(P):$(NAME):COUNTING PP") - field(DO1, 1) - field(SELM, "Specified") - field(SELL, "$(P):$(NAME):MAP-STATUS.VAL") - field(FLNK, "$(P):$(NAME):STATUS") -} - -record(seq, "$(P):$(NAME):UNSET-COUNTING") -{ - field(LNK0, "$(P):$(NAME):COUNTING PP") - field(DO0, 0) - field(SELM, "Specified") - field(SELL, "$(P):$(NAME):RAW-STATUS.VAL") - field(FLNK, "$(P):$(NAME):MAP-STATUS") -} - +# Important! The "$(P):$(NAME):READALL" isn't configure with a SCAN. Instead, +# it must always be triggered after the value of $(P):$(NAME):RAW-STATUS is +# updated, so that it can't be the case that the status changes back from +# counting to idle, without having updated the time and count values. record(longin, "$(P):$(NAME):RAW-STATUS") { field(DESC, "Raw returned status value") field(DTYP, "stream") - field(SCAN, ".2 second") + field(SCAN, ".1 second") field(INP, "@$(PROTO) readStatus($(P):$(NAME):) $(ASYN_PORT)") - field(FLNK, "$(P):$(NAME):MAP-STATUS") + field(FLNK, "$(P):$(NAME):READALL") } record(calc, "$(P):$(NAME):MAP-STATUS") @@ -109,9 +81,8 @@ record(calc, "$(P):$(NAME):MAP-STATUS") field(DESC, "Maps Raw Status to State") field(INPA, "$(P):$(NAME):RAW-STATUS NPP") field(INPB, "$(P):$(NAME):INVALID-CONFIG NPP") - field(INPC, "$(P):$(NAME):COUNTING NPP") - field(CALC, "B=1?4:(C=1&&A=0)||A=1||A=2?1:A=0?0:A=5||A=6?2:A=9||A=13||A=10||A=14?3:4") - field(FLNK, "$(P):$(NAME):SET-COUNTING") + field(CALC, "B=1?4:A=0?0:(A=1||A=2)?1:(A=5||A=6)?2:(A=9||A=13||A=10||A=14)?3:4") + field(FLNK, "$(P):$(NAME):STATUS") } record(mbbi, "$(P):$(NAME):STATUS") diff --git a/db/counterbox_v2.db b/db/counterbox_v2.db index bfd245b..ddbf0d8 100644 --- a/db/counterbox_v2.db +++ b/db/counterbox_v2.db @@ -49,9 +49,8 @@ record(ai, "$(P):$(NAME):READALL") { field(DESC, "Reads monitors and elapsed time") field(INP, "@$(PROTO) readAll10($(P):$(NAME):) $(ASYN_PORT)") - field(SCAN, ".2 second") field(DTYP, "stream") - field(FLNK, "$(P):$(NAME):UNSET-COUNTING") + field(FLNK, "$(P):$(NAME):MAP-STATUS") } record(longin, "$(P):$(NAME):M5") @@ -83,33 +82,3 @@ record(longin, "$(P):$(NAME):M10") { field(DESC, "Counterbox CH10") } - -################################################################################ -# Testing Commands - -# These won't match the values on the machine after a full restart But I chose -# not to force their intialisation as they are only important for testing - -record(bo, "$(P):$(NAME):TESTGEN") -{ - field(DESC, "Turn on/off Testgen Signal") - field(DTYP, "stream") - field(OUT, "@$(PROTO) switchTestgenOnOff($(P):$(NAME):) $(ASYN_PORT)") - field(VAL, 0) -} - -record(longout, "$(P):$(NAME):TESTGEN-LOWRATE") -{ - field(DESC, "Set Minimum Testgen Rate") - field(DTYP, "stream") - field(OUT, "@$(PROTO) setTestSignal($(P):$(NAME):) $(ASYN_PORT)") - field(VAL, 1000) -} - -record(longout, "$(P):$(NAME):TESTGEN-HIGHRATE") -{ - field(DESC, "Set Maximum Testgen Rate") - field(DTYP, "stream") - field(OUT, "@$(PROTO) setTestSignal($(P):$(NAME):) $(ASYN_PORT)") - field(VAL, 1000) -} diff --git a/db/counterbox_v2_test.db b/db/counterbox_v2_test.db new file mode 100644 index 0000000..07b0f65 --- /dev/null +++ b/db/counterbox_v2_test.db @@ -0,0 +1,31 @@ +################################################################################ +# Testing Commands + +# These won't match the values on the machine after a full restart But I chose +# not to force their intialisation as they are only important for testing + +record(bo, "$(P):$(NAME):TESTGEN") +{ + field(DESC, "Turn on/off Testgen Signal") + field(DTYP, "stream") + field(OUT, "@$(PROTO) switchTestgenOnOff($(P):$(NAME):) $(ASYN_PORT)") + field(VAL, 0) + field(ZNAM, "OFF") + field(ONAM, "ON") +} + +record(longout, "$(P):$(NAME):TESTGEN-LOWRATE") +{ + field(DESC, "Set Minimum Testgen Rate") + field(DTYP, "stream") + field(OUT, "@$(PROTO) setTestSignal($(P):$(NAME):) $(ASYN_PORT)") + field(VAL, 1000) +} + +record(longout, "$(P):$(NAME):TESTGEN-HIGHRATE") +{ + field(DESC, "Set Maximum Testgen Rate") + field(DTYP, "stream") + field(OUT, "@$(PROTO) setTestSignal($(P):$(NAME):) $(ASYN_PORT)") + field(VAL, 1000) +} diff --git a/scripts/counterbox_v2.cmd b/scripts/counterbox_v2.cmd index 49cc49b..6a58428 100644 --- a/scripts/counterbox_v2.cmd +++ b/scripts/counterbox_v2.cmd @@ -5,3 +5,4 @@ epicsEnvSet("PROTO", "$(counterbox_DB)counterbox.proto") drvAsynIPPortConfigure("$(ASYN_PORT)", "$(CNTBOX_HOST)", 0, 0, 0) dbLoadRecords("$(counterbox_DB)counterbox_common.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)") dbLoadRecords("$(counterbox_DB)counterbox_v2.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)") +$(LOAD_TEST_PVS=#) $(LOAD_TEST_PVS) dbLoadRecords("$(counterbox_DB)counterbox_v2_test.db", "P=$(PREFIX), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=$(ASYN_PORT)")