Experimental Physics and Industrial Control System
On Sunday 06 July 2008 12:06:10 Bertrand H.J. Biritz wrote:
> I should then implement a portion which checks the connection status
> to the PV's, correct?
Well you already pass your connectionChangedCB() function to the
ca_create_channel() routine and that callback should be checking to make sure
that it's being told about a connection coming up rather than going down.
You are calling ca_clear_channel() which should be tidying up everything
related to the channel, but then you just loop back around to make the
connections again, which rather pointless.
You will reduce the load on all your IOCs and your client machine if you make
the connections once and keep them up the whole time, as long as you're using
ca_get() or ca_get_callback() rather than ca_create_subscription() to fetch
the data â if you subscribe you'll get all the data from those PVs, which may
load your IOCs unnecessarily if the PVs process at any significant rate.
There are two fundamentally different ways to structure this kind of code,
using callbacks or procedurally, and I suspect your best option in this case
would be the procedural approach, which is probably easier to follow. That
would use a structure like this (adding status checks etc.):
ca_context_create();
for (...) {
ca_create_channel(pv[i], NULL, ...);
}
ca_pend_io(10.0);
while(!done) {
int getting[12];
for (...) {
if (ca_state(pCh[i]) == cs_conn) {
ca_get(DBR_..., pCh[i], &value[i]);
getting[i] = 1;
} else {
getting[i] = 0;
}
}
ca_pend_io(5.0);
for (...) {
if (getting[i]) {
// write value[i] to file
} else {
// write pv[i] not connected to file, if desired.
}
}
ca_pend_event(5.0*60); // 5 minute delay
}
for (...) {
ca_clear_channel(pCh[i]);
}
ca_context_destroy();
- Andrew
--
Talk is cheap. Show me the code. -- Linus Torvalds
- Replies:
- Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- References:
- CAC: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- Re: unable to create virtual circuit b/c "Too many open files" Andrew Johnson
- Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- Navigate by Date:
- Prev:
Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- Next:
Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- 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:
Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- Next:
Re: unable to create virtual circuit b/c "Too many open files" Bertrand H.J. Biritz
- 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