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  <20172018  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  <20172018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: saving samples
From: Andrew Johnson <[email protected]>
To: Miguel Bordalo <[email protected]>
Cc: EPICS Tech Talk <[email protected]>
Date: Tue, 13 Jun 2017 13:41:16 -0500
On 06/13/2017 12:45 PM, Miguel Bordalo wrote:
> in your solution with calc. it is suppose that the INPA is the same as
> INPB ?  So that as u wrtore it enables you to store the last 2 samples
> of a given pv, is that correct?

Each calc record input has 2 associated fields; INPA contains a pointer
to the source of the data, while A is where the value fetched gets
stored. The record reads all of the links which have been set before
evaluating the expression.

My suggestion was this:

>     record(calc, "old-data") {
>       field(INPA, "input CP")
>       field(CALC, "C;C:=B;B:=A")
>     }

I pointed the INPA link at the source of the data, but didn't set INPB
or INPC at all, so the values in the B and C fields will not be modified
when the record reads all its inputs.

The CP flag in the INPA link means connect this link using Channel
Access, and set up a monitor, then whenever a new input value is seen
from the input record it will cause the calc record to process. Actually
in this case that might not be the best way to do this, because if two
subsequent input readings are identical the calc record will not
process, because the monitor won't normally fire in that case. You can
fix that by setting the input.MDEL field to -1, or don't use the CP flag
and just connect the input.FLNK field to "old-data".

":=" is the assignment operator for the CALC engine, and ";" separates
multiple expressions, exactly one of which must return a value (i.e. not
contain a ":=" operator), although it can be any of the expressions
given in the CALC field string.

The CALC expression "C;C:=B;B:=A" thus reads as follows: First take a
copy of the value in C and use that for the VAL field at the end of the
calculation. Next copy B into C (that was the previous value read from
input), and copy A into B (that was the latest value read from input).
The VAL field of the calc record will thus contain the last-but-one
value read from input, and old-data.B will contain the last value.

HTH,

- Andrew

> also can you explain me the CP meaning in :   field(INPA, "input CP")
> 
> also what do you sugegst if i only need to save the last sample? If the
> pv i want to stores samples from is actually a calc by it selft i could
> even store the last sample in itselft as the way you showed. right?
> 
> 
> Ty
> 
> 
> -------------------------------------------------------------------------
> *Miguel Bordalo*
> 
> Licenciado em Engenharia Electrotécnica e de Computadores
> Instituto Superior Técnico
> 
> [email protected] <mailto:[email protected]>
> 
> 
> On 13 June 2017 at 17:49, Andrew Johnson <[email protected]
> <mailto:[email protected]>> wrote:
> 
>     The compress record type that comes with Base can save a buffer of old
>     values (when its ALG field set to Circular Buffer). The documentation
>     for that record type is at
>       https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_Compression
>     <https://wiki-ext.aps.anl.gov/epics/index.php/RRM_3-14_Compression>
> 
>     Getting out a specific older value from its array is easy if you're
>     running Base-3.15.x because you can use a subarray server-side filter to
>     extract the last-but-one or last-but-two value from the array say.
> 
>     However instead of learning about those features there is a simpler way
>     using a single CALC record which is probably much easier to understand:
> 
>     record(calc, "old-data") {
>       field(INPA, "input CP")
>       field(CALC, "C;C:=B;B:=A")
>     }
> 
>     Whenever the "input" record reads a new input value it triggers the calc
>     record to process, which reads the new value into A. The calculation
>     processing then sets the VAL field to the previous C, then moves the
>     previous B into C and the new A into B. You can extend the chain as
>     necessary through D..L, and can also read intermediate values from the B
>     and/or C fields of the record.
> 
>     - Andrew
> 
>     On 06/13/2017 11:06 AM, Miguel Bordalo wrote:
>     > save in another PV the last sample (scalar) (or more samples) of other
>     > PV that is updated periodically.
>     > this is for example: i have the temperature of a room being updated
>     > periodically. I want another PV to act as a buffer that stores the last
>     > two samples of the room's temperature . And i want to be able to acess
>     > them individually of course.
>     > Thanks!
>     >
>     > -------------------------------------------------------------------------
>     > *Miguel Bordalo*
>     >
>     > Licenciado em Engenharia Electrotécnica e de Computadores
>     > Instituto Superior Técnico
>     >
>     > [email protected] <mailto:[email protected]>
>     <mailto:[email protected]
>     <mailto:[email protected]>>
>     >
>     >
>     > On 13 June 2017 at 16:01, Ralph Lange <[email protected] <mailto:[email protected]>
>     > <mailto:[email protected] <mailto:[email protected]>>> wrote:
>     >
>     >     Please clarify a bit further.
>     >
>     >     What do you mean by "save"?
>     >
>     >         Write to a file? Store in an archiver? Write to another record?
>     >
>     >     What kind of PV?
>     >
>     >         Scalar or array data?
>     >
>     >         If array: does "last" mean last array in time, or last element
>     >         in array?
>     >
>     >
>     >     Cheers,
>     >     ~Ralph
>     >
>     >
>     >     On Tue, Jun 13, 2017 at 4:18 PM, Miguel
>     >     <[email protected]
>     <mailto:[email protected]>
>     <mailto:[email protected]
>     <mailto:[email protected]>>>
>     >     wrote:
>     >
>     >         What is the easiest way to save periodicaly the last
>     sample (or
>     >         last 2/3 samples) of a certain PV ?
>     >
>     >         ty
>     >
>     >
>     >
> 
>     --
>     Arguing for surveillance because you have nothing to hide is no
>     different than making the claim, "I don't care about freedom of
>     speech because I have nothing to say." -- Edward Snowdon
> 
> 

-- 
Arguing for surveillance because you have nothing to hide is no
different than making the claim, "I don't care about freedom of
speech because I have nothing to say." -- Edward Snowdon

References:
saving samples Miguel
Re: saving samples Ralph Lange
Re: saving samples Miguel Bordalo
Re: saving samples Andrew Johnson
Re: saving samples Miguel Bordalo

Navigate by Date:
Prev: Re: How to add userTag to struct timeStamp in NTScalarArray Marty Kraimer
Next: Re: IOC Severity Report Matt Rippa
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: saving samples Miguel Bordalo
Next: Re: saving samples Ralph Lange
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <20172018  2019  2020  2021  2022  2023  2024 
ANJ, 21 Dec 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·