EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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  <20192020  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  <20192020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Count record that resets by date
From: Daniel Cuneo via Tech-talk <[email protected]>
To: Eric Norum <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Thu, 14 Mar 2019 14:30:37 -0700
Hi Eric, I'm not sure if I'm miss-understanding your example, or mis-stated my use case.

Use case: Every time a user presses "reset" on a display manager (caput), the counter increments. The counter resets to 0 everyday at 0 hour, providing a daily sum of resets.

In my adaption of your record scheme, I use the "now" record to simulate pressing  reset (caput on a bo).
I take the time stamp from that press, compare it to the time stored, and increment the count if the time is within the same period, (day, minute or hour depending on %j, %M %H). If the time component increments, then send the reset signal.


On Thu, Mar 14, 2019 at 12:12 PM Eric Norum <[email protected]> wrote:
I think that the code you show below won’t quite work right.  It will increment the count once per second.
Note the OOPT field in my example.  It pushes the value into the count record (and hence causes the ‘count’ record to process) only when the calculation is non-zero — i.e. only when the count record is to be cleared.

On Mar 14, 2019, at 11:32 AM, Daniel Cuneo via Tech-talk <[email protected]> wrote:

This is what I've decided on based on Eric's and Diego's examples:
I learned a lot from this. Many thanks to everyone for sharing their ideas.

One gotacha: The STRINGIN record translates the time stamp to a strftime conversion, %M for testing and %j for production. That output is still a string, "001" through "365". However, CALC takes this string and casts it into an integer. I haven't confirmed this assumed cast from base source code yet, so correct me if I'm wrong.

>cat db/counter.db 
record(bi, "$(user):now") {
    field(PINI, "YES")
    field(SCAN, "1 second")
    field(FLNK, "$(user):day")
}

record(stringin, "$(user):day") {
    field(DTYP, "Soft Timestamp")
    field(INP,  "@%M") # for testing purposes using 1 minute
    field(TSEL, "$(user):now.TIME")
    field(FLNK, "$(user):clear")
}

record(calcout, "$(user):clear") {
    field(INPA, "$(user):day NPP MS")
    field(INPB, "1000")
    field(CALC, "A>B?1:0;B:=A")
    field(DOPT, "Use CALC")
    field(OOPT, "Every Time")
    field(OUT,  "$(user):count.C PP")
}

record(calc, "$(user):count") {
    field(INPC, "$(user):clear.VAL")
    field(VAL,  "0")
    #field(TPRO, 1)
    field(CALC, "C?0:VAL+1")
}

-- 
Eric Norum
[email protected]




Replies:
Re: Count record that resets by date Eric Norum via Tech-talk
References:
Count record that resets by date Daniel Cuneo via Tech-talk
Re: Count record that resets by date Matt Newville via Tech-talk
Re: Count record that resets by date Daniel Cuneo via Tech-talk
Re: Count record that resets by date Daniel Cuneo via Tech-talk
Re: Count record that resets by date Eric Norum via Tech-talk

Navigate by Date:
Prev: Re: Count record that resets by date Eric Norum via Tech-talk
Next: Re: Count record that resets by date Eric Norum via Tech-talk
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  <20192020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Count record that resets by date Eric Norum via Tech-talk
Next: Re: Count record that resets by date Eric Norum via Tech-talk
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  <20192020  2021  2022  2023  2024 
ANJ, 14 Mar 2019 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·