From 848da9dfe3a9fbbfc6f0ecb8c7c0b9aa2e122b9c Mon Sep 17 00:00:00 2001 From: Edward Wall Date: Fri, 18 Oct 2024 09:22:10 +0200 Subject: [PATCH] SINQSW-107 adds missing commands that were in previous version --- sinqEPICSApp/Db/counterbox.db | 7 ++ sinqEPICSApp/Db/counterbox.proto | 22 ++++++ sinqEPICSApp/Db/counterbox_common.db | 112 +++++++++++++++++++-------- sinqEPICSApp/Db/counterbox_v2.db | 28 ++++++- 4 files changed, 135 insertions(+), 34 deletions(-) diff --git a/sinqEPICSApp/Db/counterbox.db b/sinqEPICSApp/Db/counterbox.db index 5b661ce..06ce6c7 100644 --- a/sinqEPICSApp/Db/counterbox.db +++ b/sinqEPICSApp/Db/counterbox.db @@ -25,6 +25,13 @@ record(longin, "$(P):$(NAME):MONITOR-CHANNEL_RBV") ################################################################################ # 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 diff --git a/sinqEPICSApp/Db/counterbox.proto b/sinqEPICSApp/Db/counterbox.proto index 5ee1adf..6f7d8d3 100644 --- a/sinqEPICSApp/Db/counterbox.proto +++ b/sinqEPICSApp/Db/counterbox.proto @@ -76,6 +76,22 @@ stopCount { @mismatch{in "%(\$1MsgTxt)s";} } +setMinRate{ + out "DL %(\$1THRESHOLD-MONITOR)d %(\$1THRESHOLD)d"; + in; + out "DR %(\$1THRESHOLD-MONITOR)d"; + in; + @mismatch{in "%(\$1MsgTxt)s";} +} + +readMinRate{ + out "DR"; + in "%(\$1THRESHOLD-MONITOR_RBV)d"; + out "DL %(\$1THRESHOLD-MONITOR_RBV)d"; + in "%(\$1THRESHOLD_RBV)d"; + @mismatch{in "%(\$1MsgTxt)s";} +} + ################################################################################ # Read Values From Monitors @@ -104,3 +120,9 @@ switchTestgenOnOff { out "TG %{off|on}"; @mismatch{in "%(\$1MsgTxt)s";} } + +# Only suppporting test channel 1 at the moment. (The first argument to TG) +setTestSignal { + out "TG 1 %(\$1TESTGEN-HIGHRATE)d %(\$1TESTGEN-LOWRATE)d"; + @mismatch{in "%(\$1MsgTxt)s";} +} diff --git a/sinqEPICSApp/Db/counterbox_common.db b/sinqEPICSApp/Db/counterbox_common.db index ae4a176..29d1f58 100644 --- a/sinqEPICSApp/Db/counterbox_common.db +++ b/sinqEPICSApp/Db/counterbox_common.db @@ -12,6 +12,19 @@ record(bo, "$(P):$(NAME):INIT-CONF") field(OUT, "@$(PROTO) initialise($(P):$(NAME):) $(ASYN_PORT)") field(PINI, "YES") # Run at init field(DTYP, "stream") + field(FLNK, "$(P):$(NAME):INIT-BOX") +} + +# As we aren't certain of the order that PINI exectutes PVs, we only set it to +# true on INIT-CONF to make sure the box is ready to receive commands, and then +# let INIT-CONF trigger the initialisation of other necessary records +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(LNK2, "$(P):$(NAME):THRESHOLD_RBV PP") } record(longout, "$(P):$(NAME):FULL-RESET") @@ -21,14 +34,6 @@ record(longout, "$(P):$(NAME):FULL-RESET") field(DTYP, "stream") } -record(seq, "$(P):$(NAME):REINIT-CONF") -{ - field(LNK1, "$(P):$(NAME):INIT-CONF PP") - field(DO1, 1) - field(SELM, "Specified") - field(SELL, "$(P):$(NAME):INVALID-CONFIG.VAL") -} - ################################################################################ # Status Variables @@ -39,6 +44,9 @@ record(stringin, "$(P):$(NAME):MsgTxt") field(FLNK, "$(P):$(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 +# on again or running a full reset record(scalcout, "$(P):$(NAME):INVALID-CONFIG") { field(DESC, "Has the counterbox been configured?") @@ -47,31 +55,28 @@ record(scalcout, "$(P):$(NAME):INVALID-CONFIG") field(FLNK, "$(P):$(NAME):REINIT-CONF") } -record(longin, "$(P):$(NAME):RAW-STATUS") +record(seq, "$(P):$(NAME):REINIT-CONF") { - field(DESC, "Raw returned status value") - field(DTYP, "stream") - field(SCAN, ".2 second") - field(INP, "@$(PROTO) readStatus($(P):$(NAME):) $(ASYN_PORT)") - field(FLNK, "$(P):$(NAME):MAP-STATUS") + field(LNK1, "$(P):$(NAME):INIT-CONF PP") + field(DO1, 1) + field(SELM, "Specified") + 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(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") -} - record(seq, "$(P):$(NAME):SET-COUNTING") { field(LNK1, "$(P):$(NAME):COUNTING PP") @@ -90,6 +95,25 @@ record(seq, "$(P):$(NAME):UNSET-COUNTING") field(FLNK, "$(P):$(NAME):MAP-STATUS") } +record(longin, "$(P):$(NAME):RAW-STATUS") +{ + field(DESC, "Raw returned status value") + field(DTYP, "stream") + field(SCAN, ".2 second") + field(INP, "@$(PROTO) readStatus($(P):$(NAME):) $(ASYN_PORT)") + field(FLNK, "$(P):$(NAME):MAP-STATUS") +} + +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") +} + record(mbbi, "$(P):$(NAME):STATUS") { field(DESC, "Counterbox Status") @@ -149,10 +173,33 @@ record(bo, "$(P):$(NAME):STOP") { field(DESC, "Stop the current counting operation") field(DTYP, "stream") - field(PINI, "YES") field(OUT, "@$(PROTO) stopCount($(P):$(NAME):) $(ASYN_PORT)") } +# TODO should changing the monitor also set things? +# or only when actually setting a threshold? +record(longout,"$(P):$(NAME):THRESHOLD") +{ + field(DESC, "Minimum rate for counting to proceed") + field(VAL, "0") # Rate + field(DRVL, "0") # Minimum Rate + field(DTYP, "stream") + field(OUT, "@$(PROTO) setMinRate($(P):$(NAME):) $(ASYN_PORT)") +} + +record(longin,"$(P):$(NAME):THRESHOLD_RBV") +{ + field(DESC, "Minimum rate for counting to proceed") + field(DTYP, "stream") + field(INP, "@$(PROTO) readMinRate($(P):$(NAME):) $(ASYN_PORT)") + field(SCAN, "2 second") +} + +record(longin,"$(P):$(NAME):THRESHOLD-MONITOR_RBV") +{ + field(DESC, "Channel monitored for minimum rate") +} + ################################################################################ # Read all monitors values @@ -202,10 +249,11 @@ record(longin, "$(P):$(NAME):M8") field(DESC, "Counterbox CH8") } -record(longin, "$(P):$(NAME):R1") -{ - field(DESC, "Counterbox Rate CH1") - field(INP, "@$(PROTO) readRate($(P):$(NAME):, 1) $(ASYN_PORT)") - field(SCAN, ".2 second") - field(DTYP, "stream") -} +# Not yet sure whether we want to support this +# record(longin, "$(P):$(NAME):R1") +# { +# field(DESC, "Counterbox Rate CH1") +# field(INP, "@$(PROTO) readRate($(P):$(NAME):, 1) $(ASYN_PORT)") +# field(SCAN, ".2 second") +# field(DTYP, "stream") +# } diff --git a/sinqEPICSApp/Db/counterbox_v2.db b/sinqEPICSApp/Db/counterbox_v2.db index c708eb3..665eb17 100644 --- a/sinqEPICSApp/Db/counterbox_v2.db +++ b/sinqEPICSApp/Db/counterbox_v2.db @@ -22,12 +22,18 @@ record(longin, "$(P):$(NAME):MONITOR-CHANNEL_RBV") field(DTYP, "stream") field(INP, "@$(PROTO) readPresetMonitor($(P):$(NAME):) $(ASYN_PORT)") field(SCAN, "5 second") - field(PINI, "YES") } ################################################################################ # 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, "10") # Largest Threshold Channel +} ################################################################################ # Read all monitors values @@ -54,11 +60,29 @@ record(longin, "$(P):$(NAME):M10") ################################################################################ # 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(PINI, "YES") +} + +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) }