1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Record for a running sum |
From: | "Hu, Yong via Tech-talk" <[email protected]> |
To: | Donny Domagoj Cosic <[email protected]>, "[email protected]" <[email protected]> |
Date: | Thu, 5 Dec 2019 21:14:26 +0000 |
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]> 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 |