EPICS Home

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: Camonitor with client dictated update rate
From: Matt Newville via Tech-talk <[email protected]>
To: Emanuele Laface <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Sun, 2 Jun 2019 17:56:38 -0500
Hi Emanuele,

On Sun, Jun 2, 2019 at 4:25 PM Emanuele Laface <[email protected]> wrote:
All of these approaches do not solve my issue.
I have this scenario: N PVs of waveforms (arrays) of 10^5 data in each PV.
The IOc runs at 14 Hz, it means that if I subscribe in monitor mode I will be updated 14 times per second with N x 10^5 numbers.

I'm not sure I understand what "The IOC runs at 14Hz" means.  Does that mean the device producing the waveforms updates them at 14 Hz?

I hadn't appreciated that the question was regarding many arrays.  You are right that *if* you monitor these, you will get N*14 events per second, one for each of the waveform PVs.  Whether that is a problem probably depends on N.


Now I have an interface that I want to update just once per second with the content of these waveforms.
If I am in monitor, I can easily get the value once per second but my python script will anyway use the bandwidth and the cpu to process at 14 Hz because the threads of the monitoring will be updated at that frequency.

You can create the pyepics PV object with `automonitor=False` to prevent it from automatically subscribing to all monitor events and then use `PV.get()` to actually do an explicit without relying on internally cached values.  

In fact, by default, `automonitor` is False for arrays with counts > 65536 to avoid the kinds of problems you describe.  So, if you really have arrays of 10^5 elements, they would *not* be auto-monitored, and `PV.get()` would really fetch the latest value.



If I use caget once per second I need to deal with all the timeouts that can occur if some pv is down, disconnected, unreachable etc.

In pyepics, `caget()` and `caput()` actually use cached PV objects, creating them if needed. This avoids making new connections for each call.  `caget()` uses the defaults for `automonitor`.  That means the simplest way to write what you want to do:

while True:
    time.sleep(1.0)
    for name in pvnames:
        print("  %s %s" % (name, epics.caget(name, as_string=True)))
might be *exactly* what you want.  If your arrays have > 65536 elements, PV objects will be created and reused and connections maintained (you could establish connection callbacks if desired), but they will not be monitored and generate network traffic for every change in value.  

Depending on your value of N, it might take some noticeable time to fetch all the waveforms.  That seems sort of inevitable to me: you are saying that you want to *not* get the waveforms asynchronously, but on demand.  That sort of implies having to wait for the response.


I haven’t find a reliable way to get the data once per second in a full asynchronous mode but without rejecting the data that anyway occupy bandwidth and cpu.

If your device is creating arrays at 14 Hz and you only want to use them at 1 Hz, what you are asking to do is to reject data.  If you want to dictate the rate and time of the data arrival, that really is not asynchronous. 

If that isn't what you're looking for, it might be that what you really want to do is slow down the device generating the events and arrays on the server end.

--Matt


References:
Camonitor with client dictated update rate Hinko Kocevar via Tech-talk
Re: Camonitor with client dictated update rate William Layne via Tech-talk
Re: Camonitor with client dictated update rate Hinko Kocevar via Tech-talk
Re: Camonitor with client dictated update rate Matt Newville via Tech-talk
Re: Camonitor with client dictated update rate Emanuele Laface via Tech-talk

Navigate by Date:
Prev: Re: Camonitor with client dictated update rate Emanuele Laface via Tech-talk
Next: Re: more setpoint oddities with pmac driver and CS axes giles.knap--- 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: Camonitor with client dictated update rate Emanuele Laface via Tech-talk
Next: Re: Camonitor with client dictated update rate Johnson, Andrew N. 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