From 7e795504aa0a2c617e173e69ceae87a4e780a306 Mon Sep 17 00:00:00 2001 From: Edward Wall Date: Tue, 9 Jun 2026 13:14:16 +0200 Subject: [PATCH] updates soft proton current to functions with updated nicos device --- db/daq_soft_proton.db | 52 +++++++++++++++++++++++++++++++++++++++---- src/daq_soft_proton.c | 9 ++------ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/db/daq_soft_proton.db b/db/daq_soft_proton.db index f029240..4c3345c 100644 --- a/db/daq_soft_proton.db +++ b/db/daq_soft_proton.db @@ -167,7 +167,9 @@ record(dfanout, "$(INSTR)$(NAME):DB_POLL") # and count records to their final values field(OUTA, "$(INSTR)$(NAME):T_STS_RAW.PROC") field(OUTB, "$(INSTR)$(NAME):CH1_STS_RAW.PROC") - field(OUTB, "$(INSTR)$(NAME):STATUS.PROC") + field(OUTC, "$(INSTR)$(NAME):STATUS.PROC") + field(OUTD, "$(INSTR)$(NAME):T_PRESET_CLEAR.PROC") + field(OUTE, "$(INSTR)$(NAME):PRESET_CLEAR.PROC") } # Array Subroutine record which emulates the counterbox functionality @@ -258,6 +260,17 @@ record(ai,"$(INSTR)$(NAME):T") { field(DESC, "DAQ Measured Time") field(EGU, "sec") + field(PREC, 1) +} + +record(calcout, "$(INSTR)$(NAME):T_PRESET_CLEAR") +{ + field(INPA, "$(INSTR)$(NAME):STATUS NPP") + field(CALC, "A") + field(OOPT, "Transition To Zero") + field(DOPT, "Use OCAL") + field(OCAL, "0") + field(OUT, "$(INSTR)$(NAME):T_PRESET PP") } record(ai, "$(INSTR)$(NAME):T_PRESET") @@ -269,7 +282,7 @@ record(ai, "$(INSTR)$(NAME):T_PRESET") record(calc, "$(INSTR)$(NAME):T_STS_RAW") { field(DESC, "Raw time channel status") - field(INPA, "$(INSTR)$(NAME):STATUS NPP MS") + field(INPA, "$(INSTR)$(NAME):RAW_STATUS NPP MS") field(INPB, "$(INSTR)$(NAME):T_CLEARED NPP") field(CALC, "(0 < A && A < 4) || B") field(FLNK, "$(INSTR)$(NAME):T_STS") @@ -342,18 +355,49 @@ record(ai, "$(INSTR)$(NAME):CH1_RATE-PREV") { field(DESC, "Previous rate of DAQ CH0 proton current") } +record(calcout, "$(INSTR)$(NAME):PRESET_CLEAR") +{ + field(INPA, "$(INSTR)$(NAME):STATUS NPP") + field(CALC, "A") + field(OOPT, "Transition To Zero") + field(DOPT, "Use OCAL") + field(OCAL, "0") + field(OUT, "$(INSTR)$(NAME):CH1_PRESET PP") +} + record(int64in, "$(INSTR)$(NAME):CH1_PRESET") { field(DESC, "Monitor Count Preset") field(VAL, 0) + field(FLNK, "$(INSTR)$(NAME):CH1_SETTING") +} + +record(calcout, "$(INSTR)$(NAME):CH1_SETTING") +{ + field(INPA, "$(INSTR)$(NAME):CH1_PRESET NPP") + field(CALC, "A") + field(OOPT, "Transition To Non-zero") + field(DOPT, "Use OCAL") + field(OCAL, "1") + field(OUT, "$(INSTR)$(NAME):CH1_SET PP") +} + +record(bo, "$(INSTR)$(NAME):CH1_SET") +{ + field(DESC, "are hw counts being cleared") + field(ZNAM, "Set") + field(ONAM, "Setting") + field(HIGH, 0.1) # Emulate Waiting for HW setting preset + field(FLNK, "$(INSTR)$(NAME):CH1_STS_RAW") } record(calc, "$(INSTR)$(NAME):CH1_STS_RAW") { field(DESC, "Raw Channel Status") - field(INPA, "$(INSTR)$(NAME):STATUS NPP MS") + field(INPA, "$(INSTR)$(NAME):RAW_STATUS NPP MS") field(INPB, "$(INSTR)$(NAME):CH1_CLEARED NPP") - field(CALC, "(0 < A && A < 4) || B") + field(INPC, "$(INSTR)$(NAME):CH1_SET NPP") + field(CALC, "(0 < A && A < 4) || B || C") field(FLNK, "$(INSTR)$(NAME):CH1_STS") } diff --git a/src/daq_soft_proton.c b/src/daq_soft_proton.c index ed5c0e6..f28c711 100644 --- a/src/daq_soft_proton.c +++ b/src/daq_soft_proton.c @@ -220,12 +220,6 @@ static long processEmulatedCounter(struct aSubRecord *psub) { if (softProtonDebug) printf("%s: Starting Count! (time <= %f, count <= %d)\n", funcstr, spc->t_preset, spc->ch1_preset); - /* Sanity check that count type is properly stored */ - // if (spc->command_trig != spc->count_type) { - // if (softProtonDebug) - // printf("%s: Count type not stored!\n", funcstr); - // return -1; - // } /* Starting a new count * Reset counter and time */ *monitor_count_out = 0; @@ -283,7 +277,8 @@ static long processEmulatedCounter(struct aSubRecord *psub) { /* Check if count is finished normally. * Higher priority than low rate */ if ( - (spc->t_preset > 0 && *elapsed_time_out >= spc->t_preset) || + // The time only has precision 0.1 so we could make this somewhat less precise + (spc->t_preset > 0 && *elapsed_time_out >= spc->t_preset - 1e-6) || (spc->ch1_preset > 0 && *monitor_count_out >= spc->ch1_preset) ) { if (softProtonDebug)