Counting from nicos works, but time preset is not correct
This commit is contained in:
1
Makefile
1
Makefile
@@ -20,6 +20,7 @@ TEMPLATES += db/daq_common.db
|
|||||||
TEMPLATES += db/daq_2nd_gen.db
|
TEMPLATES += db/daq_2nd_gen.db
|
||||||
TEMPLATES += db/daq_2nd_gen_test.db
|
TEMPLATES += db/daq_2nd_gen_test.db
|
||||||
TEMPLATES += db/daq.proto
|
TEMPLATES += db/daq.proto
|
||||||
|
TEMPLATES += db/daq_soft_proton.db
|
||||||
|
|
||||||
# Just for simulation
|
# Just for simulation
|
||||||
TEMPLATES += db/daq_simcontrol.db
|
TEMPLATES += db/daq_simcontrol.db
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# EPICS database for counterbox-like interface using proton current,
|
|
||||||
# as retrieved via network from HIPA.
|
# as retrieved via network from HIPA.
|
||||||
#
|
#
|
||||||
# This is created to be able reuse the SinqDAQ interface
|
# This is created to be able reuse the SinqDAQ interface
|
||||||
@@ -52,10 +51,11 @@ record(bi, "$(INSTR)$(NAME):IS_LOWRATE")
|
|||||||
# Commands
|
# Commands
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
record(int64in, "$(INSTR)$(NAME):PRESET-COUNT")
|
record(ao, "$(INSTR)$(NAME):PRESET-COUNT")
|
||||||
{
|
{
|
||||||
field(DESC, "Count until preset reached")
|
field(DESC, "Count until preset reached")
|
||||||
field(VAL, 0)
|
field(VAL, 0)
|
||||||
|
field(PREC, 2)
|
||||||
field(FLNK, "$(INSTR)$(NAME):PRESET-COUNT-TRIG")
|
field(FLNK, "$(INSTR)$(NAME):PRESET-COUNT-TRIG")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,58 +68,75 @@ record(longout, "$(INSTR)$(NAME):PRESET-COUNT-TRIG")
|
|||||||
field(FLNK, "$(INSTR)$(NAME):COUNT-TYPE")
|
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(DESC, "Count for specified time")
|
||||||
field(VAL, 0)
|
field(VAL, 0)
|
||||||
field(PREC, 2)
|
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
|
# Signal count preset as command
|
||||||
field(OCAL, 2)
|
field(VAL, 2)
|
||||||
field(OOPT, "Every Time")
|
|
||||||
field(DOPT, "Use OCAL")
|
|
||||||
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
||||||
field(FLNK, "$(INSTR)$(NAME):COUNT-TYPE")
|
field(FLNK, "$(INSTR)$(NAME):COUNT-TYPE")
|
||||||
}
|
}
|
||||||
|
|
||||||
record(calcout, "$(INSTR)$(NAME):PAUSE")
|
record(longout, "$(INSTR)$(NAME):PAUSE")
|
||||||
{
|
{
|
||||||
field(DESC, "Pause the current count")
|
field(DESC, "Pause the current count")
|
||||||
field(VAL, 0)
|
field(VAL, 3)
|
||||||
field(OCAL, 3)
|
field(DRVL, 3)
|
||||||
field(OOPT, "Every Time")
|
field(DRVH, 3)
|
||||||
field(DOPT, "Use OCAL")
|
|
||||||
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
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(DESC, "Continue with a count that was paused")
|
||||||
field(VAL, "0")
|
field(VAL, 4)
|
||||||
field(OCAL, 4)
|
field(DRVL, 4)
|
||||||
field(OOPT, "Every Time")
|
field(DRVH, 4)
|
||||||
field(DOPT, "Use OCAL")
|
|
||||||
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
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(DESC, "Stop the current counting operation")
|
||||||
field(OCAL, 5)
|
field(VAL, 5)
|
||||||
field(OOPT, "Every Time")
|
field(DRVL, 5)
|
||||||
field(DOPT, "Use OCAL")
|
field(DRVH, 5)
|
||||||
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
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(DESC, "Perform full reset")
|
||||||
field(OCAL, 6)
|
field(VAL, 6)
|
||||||
field(OOPT, "Every Time")
|
field(DRVL, 6)
|
||||||
field(DOPT, "Use OCAL")
|
field(DRVH, 6)
|
||||||
field(OUT, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
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.
|
# 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
|
# It's set back to no command from the emulated counter subroutine record
|
||||||
record(mbbi, "$(INSTR)$(NAME):COMMAND-TRIG")
|
record(mbbi, "$(INSTR)$(NAME):COMMAND-TRIG")
|
||||||
@@ -138,8 +155,8 @@ record(mbbi, "$(INSTR)$(NAME):COMMAND-TRIG")
|
|||||||
field(FRVL, 4)
|
field(FRVL, 4)
|
||||||
field(FVST, "Stop command")
|
field(FVST, "Stop command")
|
||||||
field(FVVL, 5)
|
field(FVVL, 5)
|
||||||
field(FVST, "Full reset command")
|
field(SXST, "Full reset command")
|
||||||
field(FVVL, 6)
|
field(SXVL, 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy COMMAND-TRIG to memorize what type of count is on-going
|
# 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(DESC, "DAQ Measured Time")
|
||||||
field(EGU, "sec")
|
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
|
# 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
|
# The first 4 inputs are also mapped as the first 4 outputs
|
||||||
field(INPA, "$(INSTR)$(NAME):STATUS")
|
field(INPA, "$(INSTR)$(NAME):STATUS")
|
||||||
field(FTA, "ULONG")
|
field(FTA, "ULONG")
|
||||||
field(INPB, "$(INSTR)$(NAME):M0")
|
field(INPB, "$(INSTR)$(NAME):M1")
|
||||||
field(FTB, "INT64")
|
field(FTB, "INT64")
|
||||||
field(INPC, "$(INSTR)$(NAME):ELAPSED-TIME")
|
field(INPC, "$(INSTR)$(NAME):ELAPSED-TIME")
|
||||||
field(FTC, "DOUBLE")
|
field(FTC, "DOUBLE")
|
||||||
field(OUTD, "$(INSTR)$(NAME):COMMAND-TRIG")
|
field(INPD, "$(INSTR)$(NAME):COMMAND-TRIG")
|
||||||
field(FTD, "ULONG")
|
field(FTD, "ULONG")
|
||||||
field(OUTE, "$(INSTR)$(NAME):THRESHOLD")
|
field(INPE, "$(INSTR)$(NAME):THRESHOLD")
|
||||||
field(FTE, "DOUBLE")
|
field(FTE, "DOUBLE")
|
||||||
|
|
||||||
# Address the PV which are mapped as input backwards
|
# Address the PV which are mapped as input backwards
|
||||||
field(INPF, "$(INSTR)$(NAME):COUNT-TYPE")
|
field(INPF, "$(INSTR)$(NAME):COUNT-TYPE")
|
||||||
field(FTF, "ULONG")
|
field(FTF, "ULONG")
|
||||||
field(INPG, "$(INSTR)$(NAME):PRESET-COUNT")
|
field(INPG, "$(INSTR)$(NAME):PRESET-COUNT")
|
||||||
field(FTG, "INT64")
|
field(FTG, "DOUBLE")
|
||||||
field(INPH, "$(INSTR)$(NAME):PRESET-TIME")
|
field(INPH, "$(INSTR)$(NAME):PRESET-TIME")
|
||||||
field(FTH, "DOUBLE")
|
field(FTH, "DOUBLE")
|
||||||
# L is last input before EPICS 7.0.10
|
# 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(FTJ, "DOUBLE")
|
||||||
field(INPL, "$(INSTR)$(NAME):R0 PP")
|
field(INPL, "$(INSTR)$(NAME):R1 PP")
|
||||||
field(FTL, "DOUBLE")
|
field(FTL, "DOUBLE")
|
||||||
|
|
||||||
# The first 4 outputs are also mapped as the first 4 inputs
|
# The first 4 outputs are also mapped as the first 4 inputs
|
||||||
field(OUTA, "$(INSTR)$(NAME):STATUS PP")
|
field(OUTA, "$(INSTR)$(NAME):STATUS PP")
|
||||||
field(FTVA, "ULONG")
|
field(FTVA, "ULONG")
|
||||||
field(OUTB, "$(INSTR)$(NAME):M0 PP")
|
field(OUTB, "$(INSTR)$(NAME):M1 PP")
|
||||||
field(FTVB, "INT64")
|
field(FTVB, "INT64")
|
||||||
field(OUTC, "$(INSTR)$(NAME):ELAPSED-TIME PP")
|
field(OUTC, "$(INSTR)$(NAME):ELAPSED-TIME PP")
|
||||||
field(FTVC, "DOUBLE")
|
field(FTVC, "DOUBLE")
|
||||||
field(OUTD, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
field(OUTD, "$(INSTR)$(NAME):COMMAND-TRIG PP")
|
||||||
field(FTVD, "ULONG")
|
field(FTVD, "ULONG")
|
||||||
field(OUTE, "$(INSTR)$(NAME):R0-PREV PP")
|
field(OUTE, "$(INSTR)$(NAME):R1-PREV PP")
|
||||||
field(FTVE, "DOUBLE")
|
field(FTVE, "DOUBLE")
|
||||||
field(OUTF, "$(INSTR)$(NAME):IS_LOWRATE PP")
|
field(OUTF, "$(INSTR)$(NAME):IS_LOWRATE PP")
|
||||||
field(FTVF, "ULONG")
|
field(FTVF, "ULONG")
|
||||||
field(OUTF, "$(INSTR)$(NAME):MSG_TXT PP")
|
field(OUTF, "$(INSTR)$(NAME):MsgTxt PP")
|
||||||
field(FTVF, "CHAR")
|
field(FTVF, "CHAR")
|
||||||
|
field(NEVF, 40)
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Channel interface
|
# Channel interface
|
||||||
#######################
|
#######################
|
||||||
record(int64in, "$(INSTR)$(NAME):M0")
|
record(int64in, "$(INSTR)$(NAME):M1")
|
||||||
{
|
{
|
||||||
field(DESC, "DAQ CH0, proton current")
|
field(DESC, "DAQ CH0, proton current")
|
||||||
field(EGU, "cts")
|
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
|
# 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.
|
# 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(DESC, "Rate of DAQ CH0 proton current")
|
||||||
#field(INPA, "$(REMOTE_RATE_PV) CA")
|
#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
|
# 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")
|
field(DESC, "Previous rate of DAQ CH0 proton current")
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clear channel, has to be calcout due to client
|
# Emulate clearing channel
|
||||||
# writing 1 to it.
|
# 0. set status to busy
|
||||||
record(calcout, "$(INSTR)$(NAME):C0")
|
# 1. set elapsed time to 0
|
||||||
|
# 2. set status to OK
|
||||||
|
record(seq, "$(INSTR)$(NAME):C1")
|
||||||
{
|
{
|
||||||
field(DESC, "Clear the current channel count")
|
field(SELM, "All")
|
||||||
field(OOPT, "Every Time")
|
field(LNK0, "$(INSTR)$(NAME):S1 PP")
|
||||||
field(DOPT, "Use OCAL")
|
field(DO0, 1)
|
||||||
field(OCAL, "0")
|
field(LNK1, "$(INSTR)$(NAME):M1 PP")
|
||||||
field(OUT, "$(INSTR)$(NAME):M0 PP")
|
field(DO1, 0)
|
||||||
|
field(LNK2, "$(INSTR)$(NAME):S1 PP")
|
||||||
|
field(DO2, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Current Status of Channel, i.e. is it ready to count?
|
# Current Status of Channel
|
||||||
# This is probbably only need to satify the interface.
|
# This is only to satify the interface.
|
||||||
record(bi, "$(INSTR)$(NAME):S0")
|
record(bi, "$(INSTR)$(NAME):S1")
|
||||||
{
|
{
|
||||||
field(DESC, "Channel Status")
|
field(DESC, "Channel Status")
|
||||||
field(VAL, 0)
|
field(VAL, 0)
|
||||||
@@ -279,7 +330,7 @@ record(bi, "$(INSTR)$(NAME):S0")
|
|||||||
|
|
||||||
record(calc, "$(INSTR)$(NAME):PROTON_CURR") {
|
record(calc, "$(INSTR)$(NAME):PROTON_CURR") {
|
||||||
field(SCAN, ".1 second")
|
field(SCAN, ".1 second")
|
||||||
field(CALC, "1500 * 101 * SIN(A)")
|
field(CALC, "1500 + 101 * SIN(A)")
|
||||||
field(INPA, "$(INSTR)$(NAME):PROTON_CURR_VAR PP")
|
field(INPA, "$(INSTR)$(NAME):PROTON_CURR_VAR PP")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
require sinqDAQ, soederqvist_a
|
||||||
|
|
||||||
|
|
||||||
var softProtonDebug=1
|
var softProtonDebug 1
|
||||||
|
|
||||||
dbLoadRecords("$(sinqDAQ_DB)daq_soft_proton.db", "INSTR=$(INSTR), NAME=$(NAME), PROTO=$(PROTO), ASYN_PORT=ASYN_$(NAME), CHANNELS=4")
|
dbLoadRecords("$(sinqDAQ_DB)daq_soft_proton.db", "INSTR=$(INSTR), NAME=$(NAME), REMOTE_RATE_PV=NULL")
|
||||||
|
|
||||||
|
iocInit
|
||||||
|
|
||||||
|
dbpr SQ:TEST:SPC:EMULATION
|
||||||
|
|||||||
@@ -4,3 +4,4 @@
|
|||||||
|
|
||||||
device(stringin, INST_IO, devDAQStringError, "devDAQStringError")
|
device(stringin, INST_IO, devDAQStringError, "devDAQStringError")
|
||||||
function(processEmulatedCounter)
|
function(processEmulatedCounter)
|
||||||
|
variable("softProtonDebug", int)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct spc_internal {
|
|||||||
epicsFloat64 proton_rate;
|
epicsFloat64 proton_rate;
|
||||||
epicsFloat64 prev_proton_rate;
|
epicsFloat64 prev_proton_rate;
|
||||||
epicsUInt32 count_type;
|
epicsUInt32 count_type;
|
||||||
epicsInt64 preset_count;
|
epicsFloat64 preset_count;
|
||||||
epicsFloat64 preset_time;
|
epicsFloat64 preset_time;
|
||||||
epicsFloat64 average_rate;
|
epicsFloat64 average_rate;
|
||||||
};
|
};
|
||||||
@@ -61,6 +61,7 @@ enum status {
|
|||||||
|
|
||||||
int handleNoop(struct spc_internal* spc, epicsOldString* msg_text) {
|
int handleNoop(struct spc_internal* spc, epicsOldString* msg_text) {
|
||||||
const char* funcstr = "handleNoop";
|
const char* funcstr = "handleNoop";
|
||||||
|
//if (softProtonDebug) printf("%s was called\n", funcstr);
|
||||||
/* This shouldn't happen, but let's handle it just in case */
|
/* This shouldn't happen, but let's handle it just in case */
|
||||||
if (spc->status >= INVALID || spc->command_trig > FULL_RESET) {
|
if (spc->status >= INVALID || spc->command_trig > FULL_RESET) {
|
||||||
strcpy(*msg_text, "INVALID STATE!");
|
strcpy(*msg_text, "INVALID STATE!");
|
||||||
@@ -122,7 +123,7 @@ int handleNoop(struct spc_internal* spc, epicsOldString* msg_text) {
|
|||||||
static long processEmulatedCounter(struct aSubRecord *psub)
|
static long processEmulatedCounter(struct aSubRecord *psub)
|
||||||
{
|
{
|
||||||
const char* funcstr = "processEmulatedCounter";
|
const char* funcstr = "processEmulatedCounter";
|
||||||
if (softProtonDebug) printf("%s was called\n", funcstr);
|
//if (softProtonDebug) printf("%s was called\n", funcstr);
|
||||||
|
|
||||||
/* Declare internal variable */
|
/* Declare internal variable */
|
||||||
struct spc_internal spc_int;
|
struct spc_internal spc_int;
|
||||||
@@ -136,7 +137,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
spc->command_trig = *(epicsUInt32*)psub->d;
|
spc->command_trig = *(epicsUInt32*)psub->d;
|
||||||
spc->threshold = *(epicsFloat64*)psub->e;
|
spc->threshold = *(epicsFloat64*)psub->e;
|
||||||
spc->count_type = *(epicsUInt32*)psub->f;
|
spc->count_type = *(epicsUInt32*)psub->f;
|
||||||
spc->preset_count = *(epicsInt64*)psub->g;
|
spc->preset_count = *(epicsFloat64*)psub->g;
|
||||||
spc->preset_time = *(epicsFloat64*)psub->h;
|
spc->preset_time = *(epicsFloat64*)psub->h;
|
||||||
spc->prev_proton_rate = *(epicsFloat64*)psub->j;
|
spc->prev_proton_rate = *(epicsFloat64*)psub->j;
|
||||||
spc->proton_rate = *(epicsFloat64*)psub->l;
|
spc->proton_rate = *(epicsFloat64*)psub->l;
|
||||||
@@ -157,9 +158,16 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
*prev_proton_rate_out = spc->proton_rate;
|
*prev_proton_rate_out = spc->proton_rate;
|
||||||
|
|
||||||
if (spc->average_rate < spc->threshold) {
|
if (spc->average_rate < spc->threshold) {
|
||||||
*is_low_rate_out = 0; /* Illogical but 0 is low_rate, 1 high rate */
|
*is_low_rate_out = 1;
|
||||||
} else {
|
} else {
|
||||||
*is_low_rate_out = 1; /* Illogical but 0 is low_rate, 1 high rate */
|
*is_low_rate_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (softProtonDebug) {
|
||||||
|
printf("%s: DEBUG:\n"
|
||||||
|
"Status has value %d, \n"
|
||||||
|
"Command trigger has value %d\n",
|
||||||
|
funcstr, spc->status, spc->command_trig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle noop situations both valid and invalid */
|
/* Handle noop situations both valid and invalid */
|
||||||
@@ -178,7 +186,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
*command_trig_out = NONE;
|
*command_trig_out = NONE;
|
||||||
if (softProtonDebug) printf("%s: Full reset done!\n", funcstr);
|
if (softProtonDebug) printf("%s: Full reset done!\n", funcstr);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (spc->command_trig == STOP ||
|
} else if (spc->command_trig == STOP ||
|
||||||
(spc->status == IDLE && spc->command_trig == NONE)) {
|
(spc->status == IDLE && spc->command_trig == NONE)) {
|
||||||
/* Stop is always valid, retains everything except status goes to idle.
|
/* Stop is always valid, retains everything except status goes to idle.
|
||||||
* This happens to be the same case as when IDLE and no command received */
|
* This happens to be the same case as when IDLE and no command received */
|
||||||
@@ -186,6 +194,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
*command_trig_out = NONE;
|
*command_trig_out = NONE;
|
||||||
*monitor_count_out = spc->monitor_count;
|
*monitor_count_out = spc->monitor_count;
|
||||||
*elapsed_time_out = spc->elapsed_time;
|
*elapsed_time_out = spc->elapsed_time;
|
||||||
|
if (softProtonDebug) printf("%s: Case STOP or IDLE!\n", funcstr);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (((spc->status == COUNTING || spc->status == LOW_RATE)
|
} else if (((spc->status == COUNTING || spc->status == LOW_RATE)
|
||||||
&& spc->command_trig == PAUSE) ||
|
&& spc->command_trig == PAUSE) ||
|
||||||
@@ -198,6 +207,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
*command_trig_out = NONE;
|
*command_trig_out = NONE;
|
||||||
*monitor_count_out = spc->monitor_count;
|
*monitor_count_out = spc->monitor_count;
|
||||||
*elapsed_time_out = spc->elapsed_time;
|
*elapsed_time_out = spc->elapsed_time;
|
||||||
|
if (softProtonDebug) printf("%s: Case PAUSE!\n", funcstr);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (spc->status == IDLE &&
|
} else if (spc->status == IDLE &&
|
||||||
(spc->command_trig == COUNT_PRESET || spc->command_trig == TIME_PRESET)) {
|
(spc->command_trig == COUNT_PRESET || spc->command_trig == TIME_PRESET)) {
|
||||||
@@ -218,6 +228,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
} else {
|
} else {
|
||||||
*status_out = COUNTING;
|
*status_out = COUNTING;
|
||||||
}
|
}
|
||||||
|
if (softProtonDebug) printf("%s: Case received COUNT command!\n", funcstr);
|
||||||
return 0;
|
return 0;
|
||||||
} else if ((((spc->status == LOW_RATE && spc->command_trig == NONE) ||
|
} else if ((((spc->status == LOW_RATE && spc->command_trig == NONE) ||
|
||||||
(spc->status == LOW_RATE && spc->command_trig == CONTINUE)))
|
(spc->status == LOW_RATE && spc->command_trig == CONTINUE)))
|
||||||
@@ -228,9 +239,11 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
/* Maintain same counter and time*/
|
/* Maintain same counter and time*/
|
||||||
*monitor_count_out = spc->monitor_count;
|
*monitor_count_out = spc->monitor_count;
|
||||||
*elapsed_time_out = spc->elapsed_time;
|
*elapsed_time_out = spc->elapsed_time;
|
||||||
|
if (softProtonDebug) printf("%s: Case LOW_RATE!\n", funcstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (softProtonDebug) printf("%s: Case COUNT incremental cycle!\n", funcstr);
|
||||||
/* Ending up here means:
|
/* Ending up here means:
|
||||||
* 1. status == COUNTING && command_trig == NONE
|
* 1. status == COUNTING && command_trig == NONE
|
||||||
* 2. status == COUNTING && command_trig == CONTINUE
|
* 2. status == COUNTING && command_trig == CONTINUE
|
||||||
@@ -262,7 +275,7 @@ static long processEmulatedCounter(struct aSubRecord *psub)
|
|||||||
(*elapsed_time_out >= spc->preset_time &&
|
(*elapsed_time_out >= spc->preset_time &&
|
||||||
spc->count_type == TIME_PRESET) ||
|
spc->count_type == TIME_PRESET) ||
|
||||||
/* Monitor based count finished */
|
/* Monitor based count finished */
|
||||||
(*monitor_count_out >= spc->preset_time &&
|
(*monitor_count_out >= spc->preset_count &&
|
||||||
spc->count_type == COUNT_PRESET)) {
|
spc->count_type == COUNT_PRESET)) {
|
||||||
*status_out = IDLE;
|
*status_out = IDLE;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user