Hi Donny,
I did similar applications at NSLS-II: calculate hourly, daily,
monthly, yearly cumulative beam current in the Storage Ring.
Here is one example to test the cumulative dosage in one minute:
"DosagePV" is a simulated PV; "Dosage:1h" is the cumulative dosage;
Whenever one minute passes, the value of “TimeStamp” (@%M) will
change and "Dosage:1h-Reset_" will set "Dosage:1h" to 0.
To calculate hourly, daily, monthly, yearly dosage, simply change %M
in field(INP, "@%M") to %H, %d, %b, %Y.
To preserve the cumulative dosage, you should use EPICS AutoSave
(info(autosaveFields_pass0, "VAL")). Otherwise, the value will be 0
after your IOC is rebooted.
record(calc, "DosagePV") {
field(INPA, "DosagePV")
field(SCAN, "1 second")
field(CALC, "A+1")
field(FLNK, "TimeStamp")
}
record(stringin, "TimeStamp")
{
field(DTYP, "Soft Timestamp")
field(PINI,"YES")
#field(INP, "@%b %d, %Y %H:%M:%S.%03f")
field(INP, "@%M")
}
record(calcout, "Dosage:1h-Reset_")
{
field(INPA, "TimeStamp CP")
field(CALC, "0")
field(OUT, "Dosage:1h PP")
}
record(calcout, "Dosage:1h-Calc_")
{
field(INPA, "Dosage:1h")
field(INPB, "DosagePV CP")
field(CALC, "A+B")
field(OUT, "Dosage:1h PP")
}
record(ai, "Dosage:1h")
{
field(PREC, "3")
field(EGU, "blabla")
field(PINI,"YES")
info(autosaveFields_pass0, "VAL")
}
There are other ways to calculate the cumulative dosage: use compress
record.
I prefer the first approach above. The approach below works only if
“DosagePV” updates at a regular rate (i.e. 1Hz).
record(compress,"Dosage:1h-Com_")
{
field(INP,"DosagePV CP")
field(ALG,"N to 1 Average")
field(NSAM,"1")
field(N,"3600")
field(PREC,"3")
field(FLNK,"Dosage:1h_")
}
record(calc, "Dosage:1h_")
{
field(INPA, "Dosage:1h-Com_")
field(CALC, "3600*A")
field(PREC, "3")
}
HTH,
Yong Hu
NSLS-II Controls Group
FROM: Tech-talk <[email protected]> on behalf of
"[email protected]" <[email protected]>
ORGANIZATION: Institut Ruđer Bošković
REPLY-TO: Donny Domagoj Cosic <[email protected]>
DATE: Thursday, December 5, 2019 at 9:20 AM
TO: "[email protected]" <[email protected]>
SUBJECT: Record for a running sum
Hello,
I developed an IOC for the radiation monitors found throughout our
laboratory. Through this IOC I am able to read in the values of each
probe and display them nicely using CS-Studio. However I would like to
add the ability to the IOC to keep a running sum so I can calculate
the
cumulative monthly and yearly doses throughout the laboratory but I am
not sure how to implement this. I tried searching for similar projects
of examples, but without any luck. Would you be able to provide me
with
some pointers onto how to implement such a feature?
Regards,
Donny
--
Donny Domagoj Cosic
Institut Ruđer Bošković, Bijenička cesta 54, 10000 Zagreb,
Croatia