Counting from nicos works, but time preset is not correct

This commit is contained in:
2026-01-21 13:21:48 +01:00
parent de012d37ea
commit b584085218
5 changed files with 135 additions and 64 deletions

View File

@@ -1,4 +1,3 @@
# EPICS database for counterbox-like interface using proton current,
# as retrieved via network from HIPA.
#
# This is created to be able reuse the SinqDAQ interface
@@ -52,10 +51,11 @@ record(bi, "$(INSTR)$(NAME):IS_LOWRATE")
# Commands
################################################################################
record(int64in, "$(INSTR)$(NAME):PRESET-COUNT")
record(ao, "$(INSTR)$(NAME):PRESET-COUNT")
{
field(DESC, "Count until preset reached")
field(VAL, 0)
field(PREC, 2)
field(FLNK, "$(INSTR)$(NAME):PRESET-COUNT-TRIG")
}
@@ -68,58 +68,75 @@ record(longout, "$(INSTR)$(NAME):PRESET-COUNT-TRIG")
field(FLNK, "$(INSTR)$(NAME):COUNT-TYPE")
}
record(calcout, "$(INSTR)$(NAME):PRESET-TIME")
record(ao, "$(INSTR)$(NAME):PRESET-TIME")
{
field(DESC, "Count for specified time")
field(VAL, 0)
field(PREC, 2)
field(EGU, "seconds")
field(EGU, "seconds")
field(FLNK, "$(INSTR)$(NAME):PRESET-TIME-TRIG")
}
record(longout, "$(INSTR)$(NAME):PRESET-TIME-TRIG")
{
field(DESC, "Count until preset time reached")
# Signal count preset as command
field(OCAL, 2)
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(VAL, 2)
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
field(FLNK, "$(INSTR)$(NAME):COUNT-TYPE")
}
record(calcout, "$(INSTR)$(NAME):PAUSE")
record(longout, "$(INSTR)$(NAME):PAUSE")
{
field(DESC, "Pause the current count")
field(VAL, 0)
field(OCAL, 3)
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(VAL, 3)
field(DRVL, 3)
field(DRVH, 3)
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
}
record(calcout, "$(INSTR)$(NAME):CONTINUE")
record(longout, "$(INSTR)$(NAME):CONTINUE")
{
field(DESC, "Continue with a count that was paused")
field(VAL, "0")
field(OCAL, 4)
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(VAL, 4)
field(DRVL, 4)
field(DRVH, 4)
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
}
record(calcout, "$(INSTR)$(NAME):STOP")
record(longout, "$(INSTR)$(NAME):STOP")
{
field(DESC, "Stop the current counting operation")
field(OCAL, 5)
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(VAL, 5)
field(DRVL, 5)
field(DRVH, 5)
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
}
record(calcout, "$(INSTR)$(NAME):FULL-RESET")
record(longout, "$(INSTR)$(NAME):FULL-RESET")
{
field(DESC, "Reset the DAQ")
field(OCAL, 6)
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(DESC, "Perform full reset")
field(VAL, 6)
field(DRVL, 6)
field(DRVH, 6)
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
}
# Emulate Reset elapsed time
# 0. set status to busy
# 1. set elapsed time to 0
# 2. set status to OK
record(seq, "$(INSTR)$(NAME):CT")
{
field(SELM, "All")
field(LNK0, "$(INSTR)$(NAME):ETS PP")
field(DO0, 1)
field(LNK1, "$(INSTR)$(NAME):ELAPSED-TIME PP")
field(DO1, 0)
field(LNK2, "$(INSTR)$(NAME):ETS PP")
field(DO2, 0)
}
# Record is to signal command given by the client to the emulated counter.
# It's set back to no command from the emulated counter subroutine record
record(mbbi, "$(INSTR)$(NAME):COMMAND-TRIG")
@@ -138,8 +155,8 @@ record(mbbi, "$(INSTR)$(NAME):COMMAND-TRIG")
field(FRVL, 4)
field(FVST, "Stop command")
field(FVVL, 5)
field(FVST, "Full reset command")
field(FVVL, 6)
field(SXST, "Full reset command")
field(SXVL, 6)
}
# Copy COMMAND-TRIG to memorize what type of count is on-going
@@ -173,6 +190,35 @@ record(ai,"$(INSTR)$(NAME):ELAPSED-TIME")
{
field(DESC, "DAQ Measured Time")
field(EGU, "sec")
# We need to process ETS to signal to client
# field(FLNK, "$(INSTR)$(NAME):ETO")
}
# Trigger a change in status as value returned to 0
#record(seq, "$(INSTR)$(NAME):ETO")
#{
# field(DESC, "Trigger Returned to 0 Status")
# field(LNK0, "$(INSTR)$(NAME):ETS PP")
# field(DO0, 0)
# field(SELM, "Specified")
# field(SELL, "$(INSTR)$(NAME):ELAPSED-TIME.VAL")
#}
# Current Status of elapsed time
# This is only to satify the interface.
record(bi, "$(INSTR)$(NAME):ETS")
{
field(DESC, "Channel Status")
field(VAL, 0)
field(ZNAM, "OK")
field(ONAM, "CLEARING")
}
record(longout, "$(INSTR)$(NAME):MONITOR-CHANNEL")
{
alias("$(INSTR)$(NAME):MONITOR-CHANNEL_RBV")
field(DESC, "PRESET-COUNT Monitors this channel")
field(VAL, 1)
}
# Array Subroutine record which emulates the counterbox functionality
@@ -187,49 +233,50 @@ record(aSub, "$(INSTR)$(NAME):EMULATION")
# The first 4 inputs are also mapped as the first 4 outputs
field(INPA, "$(INSTR)$(NAME):STATUS")
field(FTA, "ULONG")
field(INPB, "$(INSTR)$(NAME):M0")
field(INPB, "$(INSTR)$(NAME):M1")
field(FTB, "INT64")
field(INPC, "$(INSTR)$(NAME):ELAPSED-TIME")
field(FTC, "DOUBLE")
field(OUTD, "$(INSTR)$(NAME):COMMAND-TRIG")
field(INPD, "$(INSTR)$(NAME):COMMAND-TRIG")
field(FTD, "ULONG")
field(OUTE, "$(INSTR)$(NAME):THRESHOLD")
field(INPE, "$(INSTR)$(NAME):THRESHOLD")
field(FTE, "DOUBLE")
# Address the PV which are mapped as input backwards
field(INPF, "$(INSTR)$(NAME):COUNT-TYPE")
field(FTF, "ULONG")
field(INPG, "$(INSTR)$(NAME):PRESET-COUNT")
field(FTG, "INT64")
field(FTG, "DOUBLE")
field(INPH, "$(INSTR)$(NAME):PRESET-TIME")
field(FTH, "DOUBLE")
# L is last input before EPICS 7.0.10
field(INPJ, "$(INSTR)$(NAME):R0-PREV")
field(INPJ, "$(INSTR)$(NAME):R1-PREV")
field(FTJ, "DOUBLE")
field(INPL, "$(INSTR)$(NAME):R0 PP")
field(INPL, "$(INSTR)$(NAME):R1 PP")
field(FTL, "DOUBLE")
# The first 4 outputs are also mapped as the first 4 inputs
field(OUTA, "$(INSTR)$(NAME):STATUS PP")
field(FTVA, "ULONG")
field(OUTB, "$(INSTR)$(NAME):M0 PP")
field(OUTB, "$(INSTR)$(NAME):M1 PP")
field(FTVB, "INT64")
field(OUTC, "$(INSTR)$(NAME):ELAPSED-TIME PP")
field(FTVC, "DOUBLE")
field(OUTD, "$(INSTR)$(NAME):COMMAND-TRIG PP")
field(FTVD, "ULONG")
field(OUTE, "$(INSTR)$(NAME):R0-PREV PP")
field(FTVE, "DOUBLE")
field(OUTE, "$(INSTR)$(NAME):R1-PREV PP")
field(FTVE, "DOUBLE")
field(OUTF, "$(INSTR)$(NAME):IS_LOWRATE PP")
field(FTVF, "ULONG")
field(OUTF, "$(INSTR)$(NAME):MSG_TXT PP")
field(FTVF, "CHAR")
field(FTVF, "ULONG")
field(OUTF, "$(INSTR)$(NAME):MsgTxt PP")
field(FTVF, "CHAR")
field(NEVF, 40)
}
#######################
# Channel interface
#######################
record(int64in, "$(INSTR)$(NAME):M0")
record(int64in, "$(INSTR)$(NAME):M1")
{
field(DESC, "DAQ CH0, proton current")
field(EGU, "cts")
@@ -237,7 +284,7 @@ record(int64in, "$(INSTR)$(NAME):M0")
# The proton rate take by a PV over the network, PV named indicated by $(REMOTE_RATE_PV) macro
# It emulates Zero rate if either shutter is closed.
record(calc, "$(INSTR)$(NAME):R0")
record(calc, "$(INSTR)$(NAME):R1")
{
field(DESC, "Rate of DAQ CH0 proton current")
#field(INPA, "$(REMOTE_RATE_PV) CA")
@@ -252,24 +299,28 @@ record(calc, "$(INSTR)$(NAME):R0")
}
# Store previous rate value, so we can average over the period
record(ai, "$(INSTR)$(NAME):R0-PREV") {
record(ai, "$(INSTR)$(NAME):R1-PREV") {
field(DESC, "Previous rate of DAQ CH0 proton current")
}
# Clear channel, has to be calcout due to client
# writing 1 to it.
record(calcout, "$(INSTR)$(NAME):C0")
# Emulate clearing channel
# 0. set status to busy
# 1. set elapsed time to 0
# 2. set status to OK
record(seq, "$(INSTR)$(NAME):C1")
{
field(DESC, "Clear the current channel count")
field(OOPT, "Every Time")
field(DOPT, "Use OCAL")
field(OCAL, "0")
field(OUT, "$(INSTR)$(NAME):M0 PP")
field(SELM, "All")
field(LNK0, "$(INSTR)$(NAME):S1 PP")
field(DO0, 1)
field(LNK1, "$(INSTR)$(NAME):M1 PP")
field(DO1, 0)
field(LNK2, "$(INSTR)$(NAME):S1 PP")
field(DO2, 0)
}
# Current Status of Channel, i.e. is it ready to count?
# This is probbably only need to satify the interface.
record(bi, "$(INSTR)$(NAME):S0")
# Current Status of Channel
# This is only to satify the interface.
record(bi, "$(INSTR)$(NAME):S1")
{
field(DESC, "Channel Status")
field(VAL, 0)
@@ -279,7 +330,7 @@ record(bi, "$(INSTR)$(NAME):S0")
record(calc, "$(INSTR)$(NAME):PROTON_CURR") {
field(SCAN, ".1 second")
field(CALC, "1500 * 101 * SIN(A)")
field(CALC, "1500 + 101 * SIN(A)")
field(INPA, "$(INSTR)$(NAME):PROTON_CURR_VAR PP")
}