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: CA client within Asyn
From: Benoit RAT <benoit@sevensols.com>
To: "Mark S. Engbretson" <Engbretson@anl.gov>
Cc: EPICS mailing list <tech-talk@aps.anl.gov>
Date: Wed, 12 Apr 2017 12:15:53 +0200
Hi,

The number of PV is not the problem... we are using this IOC to forward PV along with a very precise time scheduler to other IOC synchronized with the White Rabbit protocol.
Therefore I need to handle network latency to get the minimun delay, check that all PVs have arrived to all IOCs before the time that they were scheduled, etc... And this was not possible with the PVGateway or sequencer.

but thanks to the examples that Tim suggested me and by looking at the nice presentation http://www.aps.anl.gov/bcda/epicsgettingstarted/developtools/EPICSTraining.IntroductionToChannelAccessClients.ppt
I could make the CA work by
  • Creating a thread with a call to ca_pend_event() until I have nothing in my queue.
  • Attaching the ca_context_attach() to this new thread. 
I still need to do more tests but I think that I am making progress.... thank you anyway for your suggestion.

Best,

 


--
 

Benoit RAT LAMY

On Tue, Apr 11, 2017 at 7:12 PM, Mark S. Engbretson <Engbretson@anl.gov> wrote:

 

Just how many PV’s do you have that just creating records in db’s or template files don’t work?

 

I routinely have softIOC’s (Modbus) that talk to PV’s in other IOC’s, PVGateway’s, etc. and it all seems to work well dealing with dozens of external Pv’s.

 

 

From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of Eric Norum
Sent: Tuesday, April 11, 2017 10:00 AM
To: Benoit RAT <benoit@sevensols.com>
Cc: EPICS mailing list <tech-talk@aps.anl.gov>
Subject: Re: CA client within Asyn

 

Have you investigated the EPICS sequencer?  

I don’t think I’ve heard of anyone attempting to issue channel access calls from an ASYN thread.

 

On Apr 11, 2017, at 4:00 AM, Benoit RAT <benoit@sevensols.com> wrote:

 

Hi everybody,

 

Within my Asyn IOC I need sometime to modify some PV from other IOC. 

I did try to do this using the .db but the task was too complex and I am now trying to setup my own CA client inside Asyn.

As I am using Asyn I have also linked all the callback from CA to the one from Asyn... 

This seems to work more or less but I have some problems with the ca_put.

 

 

quick resume of what I am doing

===========================

 

--------------- # Part 1 (OK)

 

At the setup of the IOC I call:

 

ca_context_create (ca_enable_preemptive_callback);

...

ca_search_and_connect(pvext_write1->name,&(pvext_write1->chan_id),callback_coHaAr,NULL);

ca_search_and_connect(pvext_write2->name,&(pvext_write2->chan_id),callback_coHaAr,NULL);

...

ca_search_and_connect(pvext_writeN->name,&(pvext_writeN->chan_id),callback_coHaAr,NULL);

 

and at the end of the setup I call

 

ca_flush_io()

 

This work fine and after some seconds I enter callback_coHaAr() for each of the CA created.

 

--------------- # Part 2

 

Then at some point in my code, changes of value my internal PV, I modify external PV.

 

status=ca_put_callback (DBR_DOUBLE, pvext_write1->chan_id, &(pvext_write1->val.float64),callback_put,pvext_write1);

status=ca_put_callback (DBR_DOUBLE, pvext_write2->chan_id, &(pvext_write2->val.float64),callback_put,pvext_write2);

....

status=ca_put_callback (DBR_DOUBLE, pvext_writeN->chan_id, &(pvext_writeN->val.float64),callback_put,pvext_writeN);

 

And after all my writes has been put, I call

 

ca_flush_io()

 

 

And this is when sometime my hook callback_put() is correctly called back (Almost 90% the first time)

 

 callback_put() > chid:0x949a3a0 usr:0x94c86a8 (status:x1)

 

But then if I make succesive call, the hook callback_put() might be called back some more time.. and then never

 

 

However If I shutdown the remote IOC, all my callback appears

 

 

If only one was missing, I get on my epicConsole:

 

callback_put() > chid:0x95074c8 usr:0x9535860 (status:xc0) 
callback_coHaAr() > chid:0x95074c8 op:7 (down) 

 

 

If 4 were missing:

 

callback_put() > chid:0x98623f8 usr:0x9890790 (status:xc0)
callback_put() > chid:0x98623f8 usr:0x9890790 (status:xc0)
callback_put() > chid:0x98623f8 usr:0x9890790 (status:xc0)
callback_put() > chid:0x98623f8 usr:0x9890790 (status:xc0)
callback_coHaAr() > chid:0x98623f8 op:7 (down)

 

 

 

Conclusion

===========================

 

I think I am missing something while mixing the epicsThread of asyn and ca, but I really don't know what to try more and I don't find any good examples of ChannelAccess client with thread.

 

  • Where could I find a good documentation of ca client?
  • Do you think I am missing something?
  • Should I use ca_enable_preemptive_callback...? I am not sure that it is what I need within asyn...
  • Shouid I use something more than flush_io()...? 
  • Should I create a thread for this operation and call ca_pend_event() ... I did try to call ca_pend_event(2) for testing but it doesn't seem to correct my problems.

 

Best,

 

 

 

 

 

--

 

 

Benoit RAT LAMY

 

-- 
Eric Norum
eric@norum.ca




 



References:
CA client within Asyn Benoit RAT
Re: CA client within Asyn Eric Norum
RE: CA client within Asyn Mark S. Engbretson

Navigate by Date:
Prev: Re: [AsynPortDriver] "Multiple interrupt callbacks between processing" warning with multiple arrays Paweł Plewiński
Next: RE: [AsynPortDriver] "Multiple interrupt callbacks between processing" warning with multiple arrays Mark Rivers
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: RE: CA client within Asyn Mark S. Engbretson
Next: Archiver Appliance established multiple CA connections for one channel Wang, Lin
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, 12 Apr 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·