Hi Eric,
On 11/08/2017 10:05 AM, Church, Eric D wrote:
> We are trying to use caput() and caget() from a C++ program. The IOC is
> up and I can issue caputs and cagets from the command line and put and
> retrieve reasonable values into our EPICS records. We’re having some
> difficulty in compiled C++, however.
>
> I include below the apparently necessary gymnastics to successfully
> ca_get() anything in C++. We want to do this with a total of about 48
> PVs once every 15 seconds. The first thing we note is we need to do a
> context_create and create_channel each of those 48 times each 15
> seconds. Which necessitates the channel clear and context destroy at the
> end. We can not use our class member chid over and over with each run
> through this function, it seems.
I want to make sure I understand your requirements first: Is the problem
you describe (that you continually have to create and destroy channels)
because your application is structured such that you don't have a single
long-running process, or because you're having problems coding it to
keep all those channels connected?
For efficiency reasons it is much better to connect everything once and
keep the connection to the IOC(s) open all the time, re-useing the same
chids every time you want to do some more I/O. You do have to make sure
that your client code can cope with the IOC shutting down, rebooting or
not being turned on until some time after the client has been started,
but that is generally just a matter of getting the code right.
Unfortunately our standard CA client code examples only really show the
quick-and-dirty approach of connecting channels, doing some I/O and then
shutting down again almost immediately. When you're writing a long-lived
client though you should generally only use the CA APIs that use
callbacks to notify you when the client library gets messages from the
IOC servers it's connected to. The ca_pend_io() routine is not suitable
for this style of programming, where your code generally consists of
routines that react to events from outside and work out what to do next.
It is legal to call most CA routines from within a callback (the CA
reference manual describes the 2 or 3 routines where that is not
allowed, ca_pend_io() being one of them).
I think I'm going to stop here and wait for your reply to the above
question before I write any more or review the code you posted.
- Andrew
--
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
- Replies:
- Re: caget() from C++ Church, Eric D
- References:
- caget() from C++ Church, Eric D
- Navigate by Date:
- Prev:
EPICS base R3.15.5-1.0 special CONFIG and RULE files Luchini, Kristi L.
- Next:
How to turn off spewing messaging from asyn/stream devicse. Luchini, Kristi L.
- 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
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
caget() from C++ Church, Eric D
- Next:
Re: caget() from C++ Church, Eric D
- 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
2019
2020
2021
2022
2023
2024
|