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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: Record for a running sum |
From: | "Hu, Yong via Tech-talk" <[email protected]> |
To: | Donny Domagoj Cosic <[email protected]> |
Cc: | "[email protected]" <[email protected]> |
Date: | Sat, 21 Dec 2019 04:39:36 +0000 |
Hi Donny, Firstly welcome to the EPICS community! You did very well in just one month. Yes, you are in the right direction. See below highlighted: just one small change and two more records that save "Dosage:1h" value to “PreviousDosage:1h” before every reset. Again, the example below only shows “reset every minute”. You said “…that saves the "Dosage:1h" values before every reset”. If you really mean “values” instead of “value”, then you need another compress record with field(ALG," Circular Buffer ") and field(INP," PreviousDosage:1h CP"). See
https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14 to find out more details on calcout, compress, etc. 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") field(FLNK,"PreviousDosage:1h-Calc_") } record(calcout, "PreviousDosage:1h-Calc_") { field(INPA,"Dosage:1h-Calc_") field(INPB,"Dosage:1h") field(CALC,"B") field(OOPT,"Transition To Zero" ) field(DOPT,"Use OCAL") field(OCAL,"A") field(OUT, "PreviousDosage:1h PP") } record(ai, "PreviousDosage:1h") { field(PREC, "3") field(EGU, "blabla") field(PINI,"YES") info(autosaveFields_pass0, "VAL") } On 12/11/19, 3:41 AM, "Donny Domagoj Cosic" <[email protected]> wrote: Hi Yong, Thank you very much for the detailed response. I follow your logic and
it seems like a good solution. All the solution that I came up with were
a lot more complicated so I really enjoy the simplicity of this
solution. The only thing that I had to add to your solution is a new
record that saves the "Dosage:1h" values before every reset. However
with my limited knowledge of EPICS (I just started working with EPICS a
month ago) I dont think i did it properly. I created a new calc record
that looks for the reset and forwards the old Dosage:1h value. Im sure
there is a better way to do this maybe using the OOPT field, however I
was not able to get it to work properly. Am I thinking about this in the
right way? Regards, Donny --- Donny Domagoj Cosic Institut Ruđer Bošković, Bijenička cesta 54, 10000 Zagreb, Croatia Dana 05.12.2019 22:14, Hu, Yong je napisao(la): > 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 |