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 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
<== Date ==> <== Thread ==>

Subject: Re: monitor subscription in areaDetector
From: "Kasemir, Kay" <kasemirk@ornl.gov>
To: "Pearson, Matthew R." <pearsonmr@ornl.gov>, "tech-talk@aps.anl.gov list" <tech-talk@aps.anl.gov>
Date: Fri, 27 Jan 2017 17:51:24 +0000
Hi Matt:

I've been asking myself the same question, when to subscribe, how often to subscribe, and when to clear the subscription, albeit for Java based clients.

I found it best to only subscribe once, and have a flag to prevent multiple subscriptions.
When you get disconnected for some reason, you handle that (GUI: Show it's disconnected. archive: Log that you're disconnected).
When you then get reconnected, don't create another subscription. The CA client library will already remember that there was a subscription, so you would only create multiple subscriptions.

For a while I thought it'd be cleaner to call ca_clear_subscription() on a disconnect, but the problem with that is that the clear doesn't reach the IOC. Unplug the network cable, client will eventually disconnect, attempt to ca_clear_subscription(), but that doesn't actually reach the IOC (if I remember correctly the Java CA client will actually give you an error message).
Plug the network cable back in, client will reconnect, and the IOC still remembers the subscription, it wasn't deleted.


In CSS, the logic is now like this:

* On connect *
 if (subscription flag is set, already subscribed but the data type of the channel changed)
 {
   ca_clear_subscription();
   clear the subscription flag;
 }

 if (subscription flag is cleared, not already subscribed)
 {
   subscribe();
   set flag that we have subscribed;
 }

* On disconnect *
 Somehow indicate that we are disconnected,
 but don't do anything about the CA client lib


-Kay


________________________________________
From: tech-talk-bounces@aps.anl.gov <tech-talk-bounces@aps.anl.gov> on behalf of Pearson, Matthew R. <pearsonmr@ornl.gov>
Sent: Friday, January 27, 2017 12:25 PM
To: tech-talk@aps.anl.gov list
Subject: [UNTRUSTED] monitor subscription in areaDetector

Hi,

In areaDetector, for when we append NDAttribute data to NDArray objects, we have a class that can set up monitors on PVs. When a monitor event happens we record the data for use by the next NDArray object. However, we were setting a monitor callback handler for every connection event. This can result in multiple monitors being setup if the IOC that hosts the PV being monitored has been restarted a few times (resulting in a multiple connection events in the areaDetector IOC).

I was able to fix this in the same was as camonitor.c handles this, by using a flag to indicate that we’ve already connected (and set up a monitor) to a PV. Is this the most appropriate method to handle this? In the CA reference manual I see that there are functions like ca_clear_channel() and ca_clear_subscription() that we could possibly use on a disconnection event.

Cheers,
Matt


Data Acquisition and Control Engineer
Spallation Neutron Source
Oak Ridge National Lab









References:
monitor subscription in areaDetector Pearson, Matthew R.

Navigate by Date:
Prev: monitor subscription in areaDetector Pearson, Matthew R.
Next: Re: monitor subscription in areaDetector Andrew Johnson
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
Navigate by Thread:
Prev: monitor subscription in areaDetector Pearson, Matthew R.
Next: Re: monitor subscription in areaDetector Andrew Johnson
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
ANJ, 14 Feb 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·