Connection time optimized

This commit is contained in:
2017-11-14 09:18:27 +01:00
parent 4d9a8fd116
commit 350ddab997
47 changed files with 350899 additions and 701 deletions

98219
src/PyCafe2.cpp Normal file

File diff suppressed because it is too large Load Diff

68149
src/PyCafe2_March7.cpp Normal file

File diff suppressed because it is too large Load Diff

101266
src/PyCafe3_April.cpp Normal file

File diff suppressed because it is too large Load Diff

79031
src/PyCafe3_March7.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,7 @@
#include "conduitGroup.h"
#include <set>
bool MUTEX=true;
bool CHECK_CONSISTENCY_CA_STATE=true;
@@ -90,7 +91,7 @@ int CAFE::set(const unsigned int *handleArray, const unsigned int nelem, const
}
if ( channelInfo.getCafeConnectionState() != ICAFE_CS_NEVER_CONN) {
if ( channelInfo.getCafeConnectionState() != ICAFE_CS_NEVER_CONN && channelInfo.getCafeConnectionState() != ICAFE_CS_CLOSED ) {
if (channelInfo.getDataType()==DBF_STRING) {
chtMax=DBR_STRING;
break;
@@ -171,6 +172,10 @@ int CAFE::get(const unsigned int handle, long long * _val, \
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemNative(handle);
@@ -258,6 +263,9 @@ int CAFE::get(const unsigned int handle, long long * _val, \
CAFE::getChannelInfo(handle, channelInfo);
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemNative(handle);
@@ -344,6 +352,9 @@ int CAFE::get(const unsigned int handle, long long * _val){
CAFE::getChannelInfo(handle, channelInfo);
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemNative(handle);
@@ -3016,6 +3027,10 @@ int CAFE::set(unsigned int handle, const long long * val) { //5+ long long
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemNative(handle);

View File

@@ -69,7 +69,7 @@ int CAFE::getCache(const unsigned int *handleArray, unsigned int nelem, long l
nbyteChType=1;
}
if ( channelInfo.getCafeConnectionState() != ICAFE_CS_NEVER_CONN) {
if ( channelInfo.getCafeConnectionState() != ICAFE_CS_NEVER_CONN && channelInfo.getCafeConnectionState() != ICAFE_CS_CLOSED) {
if (channelInfo.getDataType()==DBF_STRING) {
chtMax=DBR_STRING;
break;
@@ -230,6 +230,10 @@ int CAFE::getCache(const unsigned int handle, long long * _val, \
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemRequest(handle);
@@ -318,6 +322,9 @@ int CAFE::getCache(const unsigned int handle, long long * _val, \
CAFE::getChannelInfo(handle, channelInfo);
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemRequest(handle);
@@ -406,6 +413,10 @@ int CAFE::getCache(const unsigned int handle, long long * _val){
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
int _status=ICAFE_NORMAL;
unsigned int nn=handleHelper.getNelemRequest(handle);

View File

@@ -60,8 +60,6 @@ int CAFE::groupAttach(const unsigned int _groupHandle, PVGroup &pvgroup) {
string s = handleHelper.getGroupNameFromGroupHandle(_groupHandle);
unsigned int iIdx;
if (s!="") {
@@ -450,13 +448,31 @@ int CAFE::groupSet(const unsigned int _groupHandle, PVGroup &pvgroup) {
}
} //while
if (ntries>0) {
if (ntries > 0 ) {
//if (ntries >= channelTimeoutPolicySGPut.getNtries() ) {
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
std::cout << "No of(additional) tries=" << ntries << std::endl;
if (gStatus==ECAFE_TIMEOUT) {
std::cout << "is the MAXIMUM allowed as configured through SGTimeoutPolicy! " << std::endl;
std::cout << "SETTING SELF-GOVERNING TIMEOUT FOR SG PUT OPERATIONS FOR THIS CHANNEL TO FALSE" << std::endl;
std::cout << "RESTORING TIMEOUT TO ORIGINAL SG PUT VALUE OF: " << originalTimeOut << " SECONDS " << std::endl;
channelTimeoutPolicySGPut.setSelfGoverningTimeout(false);
channelTimeoutPolicySGPut.setTimeout( originalTimeOut );
if(MUTEX){cafeMutex.lock();} //lock
groupHandle_index.modify(it_groupHandle,
change_channelTimeoutPolicySGPut(channelTimeoutPolicySGPut));
if(MUTEX){cafeMutex.unlock();} //unlock
}
else{
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
cout << "Changed SG PUT from intitial " << originalTimeOut << " to: " <<
(originalTimeOut +
channelTimeoutPolicySGPut.getDeltaTimeout()*ntries)
<< " seconds after " << ntries << " sg_put calls " <<endl;
}
}
} //IF
//Withdraw this test for now; not required
@@ -1264,14 +1280,16 @@ int CAFE::groupGet(const unsigned int _groupHandle, PVGroup &pvgroup) {
cout << "Changing SG GET timeout from: " << channelTimeoutPolicySGGet.getTimeout()
<< " to: " << (originalTimeOut + channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
<< " seconds" << endl;
channelTimeoutPolicySGGet.setTimeout( (originalTimeOut +
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries));
if(MUTEX){cafeMutex.lock();} //lock
groupHandle_index.modify(it_groupHandle,
change_channelTimeoutPolicySGGet(channelTimeoutPolicySGGet));
if(MUTEX){cafeMutex.unlock();} //unlock
if(MUTEX){cafeMutex.unlock();} //unlock
if (gStatus == ECA_TIMEOUT) {
gStatus=(*it_groupHandle).get();
@@ -1280,12 +1298,35 @@ int CAFE::groupGet(const unsigned int _groupHandle, PVGroup &pvgroup) {
} //while
if (ntries>0) {
//if (ntries >= channelTimeoutPolicySGGet.getNtries() ) {
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
cout << "Changed SG GET from intitial " << originalTimeOut << " to: " <<
std::cout << "No of(additional) tries=" << ntries << std::endl;
if (gStatus==ECAFE_TIMEOUT) {
std::cout << "is the MAXIMUM allowed as configured through SGTimeoutPolicy! " << std::endl;
std::cout << "SETTING SELF-GOVERNING TIMEOUT FOR SG GET OPERATIONS FOR THIS CHANNEL TO FALSE" << std::endl;
std::cout << "RESTORING TIMEOUT TO ORIGINAL SG GET VALUE OF: " << originalTimeOut << " SECONDS " << std::endl;
channelTimeoutPolicySGGet.setSelfGoverningTimeout(false);
channelTimeoutPolicySGGet.setTimeout( originalTimeOut );
if(MUTEX){cafeMutex.lock();} //lock
groupHandle_index.modify(it_groupHandle,
change_channelTimeoutPolicySGGet(channelTimeoutPolicySGGet));
if(MUTEX){cafeMutex.unlock();} //unlock
}
else {
cout << "Changed SG GET from intitial " << originalTimeOut << " to: " <<
(originalTimeOut +
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
<< " seconds after " << ntries << " sg_get calls " <<endl;
}
<< " seconds" << endl;
}
} //if
//Withdraw this test for now; not required
//if (ca_sg_test((*it_groupHandle).getGroupID()) == ECA_IOINPROGRESS) {

View File

@@ -451,7 +451,10 @@ int CAFE::get(const unsigned int _handle, vector<long long> & V,
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
unsigned int nelemThatWillBeRequested= (*it_handle).getChannelRegalia().getNelem();
//Reserve only what will be in the buffer.
@@ -2714,7 +2717,10 @@ int CAFE::set(const unsigned int _handle, vector<long long> V) {
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
switch ( channelInfo.getDataType()) {
case DBR_DOUBLE:

View File

@@ -49,6 +49,9 @@ Conduit::Conduit(const char * _pv, ca_client_context *_ccc, bool _pyCafeFlag) {
* \param _pv input: process variable
* \param _ccc input: ca_client_context
* \param _pyCafeFlag input: bool
* \param _channelRequestPolicyPut input: ChannelRequestPolicyPut
* \param _channelRequestPolicyGet input: ChannelRequestPolicyGet
* \param _channelGetActionWhenMonitorPolicyGet input: ChannelGetActionWhenPolicyGet
*/
Conduit::Conduit(const char * _pv, ca_client_context *_ccc,
ChannelRequestPolicy _channelRequestPolicyPut, ChannelRequestPolicy _channelRequestPolicyGet,
@@ -382,7 +385,7 @@ int Conduit::getPVDataHolder(PVDataHolder & _pvd) const {
chtype channelType = channelRequestMetaData.getDbrDataType();
CAFENUM::DBR_TYPE dbrTypeClass=helper.convertToCAFEDbrTypeClass(channelType);
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN ) {
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN && channelRegalia.getCafeConnectionState() != ICAFE_CS_CLOSED) {
switch(dbrTypeClass)
{
@@ -610,7 +613,7 @@ int Conduit::getPVDataHolder(PVDataHolder & _pvd) const {
break;
case TYPENOTCONN:
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN ) {
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN && channelRegalia.getCafeConnectionState() != ICAFE_CS_CLOSED ) {
cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
cout << "ERROR CAFE_TYPENOTCONN: dataType: "
<< channelType << " : " << dbr_type_to_text(channelType) << endl;
@@ -648,7 +651,7 @@ int Conduit::getPVCtrlHolder(PVCtrlHolder & _pvc) const {
CAFENUM::DBR_TYPE dbrTypeClass=helper.convertToCAFEDbrTypeClass(channelType);
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN ) {
if ( channelRegalia.getCafeConnectionState() != ICAFE_CS_NEVER_CONN && channelRegalia.getCafeConnectionState() != ICAFE_CS_CLOSED ) {
switch(dbrTypeClass)
{

View File

@@ -57,11 +57,10 @@ ConduitGroup::ConduitGroup(const char * _groupName, ca_client_context * _ccc, C
++groupHandleNext;
groupHandle = groupHandleNext;
mStatus = new int [nMember];
mRule = new bool[nMember];
for (unsigned int i=0; i<nMember; ++i) {
mRule[i]="true";
mRule[i]=true;
mStatus[i]=ICAFE_NORMAL;
}
};

View File

@@ -93,6 +93,9 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
if (status != ECA_NORMAL) {
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " ca_create_channel failed: " << endl;
if (status == ECA_EVDISALLOW) {
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " inappropriate function " << endl;
}
cafeStatus.report(status);
if(MUTEX){cafeMutex.lock();} //lock
@@ -101,18 +104,58 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
return (int) status;
}
//What is the POLICY!??
//To Flush or to Pend this is the question!
if (channelOpenPolicy.getWhenToFlushSendBuffer()==FLUSH_AFTER_EACH_CHANNEL_CREATION) {
using namespace boost::posix_time;
ptime timeStart(microsec_clock::local_time());
double timeElapsed=0;
unsigned int nPoll=0;
channelOpenPolicy.flushSendBufferNow();
channelOpenPolicy.flushSendBufferNow();
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
while ( !(*it_handle).isConnected() && timeElapsed <= channelOpenPolicy.getTimeout()){
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(1000));
#else
#if HAVE_LINUX
usleep(1000);
#endif
#endif
++nPoll;
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
}
/*
if ( (*it_handle).isConnected() ) {
cout << (*it_handle).getPV() << " // is connected //" << endl;
}
else {
cout << (*it_handle).getPV() << " // is not connected //" << endl;
}
cout << "timeElapsed for open " << timeElapsed << " nPoll = " << nPoll << endl;
*/
}
// Peculiar if true
/*
if (status == ECA_EVDISALLOW) {
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " inappropriate function " << endl;
cafeStatus.report(status);
@@ -120,6 +163,11 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
handle_index.modify(it_handle, change_status (status) );
if(MUTEX){cafeMutex.unlock();} //unlock
}
*/
//
}
else {
return ECAFE_INVALID_HANDLE;
@@ -1124,19 +1172,17 @@ int Connect::open(const char * _pv, const char * _pvAlias, unsigned int & hand
if (it_handle != handle_index.end()) {
if ((*it_handle).getChannelID() != NULL && cctLocal != NULL ) {
status = ca_clear_channel((*it_handle).getChannelID());
if (status != ECA_NORMAL) {
return status; //ECA_BADCHID
}
status = ca_pend_io(channelClosePolicy.getTimeout());
status = ca_pend_io(channelClosePolicy.getTimeout()); //See channelClosePolicy.setPolicy in connect.h
//channelClosePolicy.flushSendBufferNow();
if(MUTEX){cafeMutex.lock();}
handle_index.modify(it_handle, free_dataBuffers());
if(MUTEX){cafeMutex.unlock();}
@@ -1192,7 +1238,7 @@ int Connect::open(const char * _pv, const char * _pvAlias, unsigned int & hand
* \return ECA_NORMAL if all OK; error if one or more channelIDs fail to close
*/
int Connect::closeHandles(unsigned int * handleArray, unsigned int nHandles) {
#define __METHOD__ "Connect::closeHandles(unsigned int *) "
#define __METHOD__ "Connect::closeHandles(unsigned int *, unsigned int) "
//copy array to vector and remove dupliacte handles
@@ -1373,6 +1419,339 @@ int Connect::open(const char * _pv, const char * _pvAlias, unsigned int & hand
}
/**
* \brief Closes channel connections (even if in other thread) but does not delete handle. \n
* Note that this does NOT cause the channel's disconnect handler to be called. \n
* It does however invoke event handlers for subscriptions (i.e., monitors). \n
* The Conduit handle is NOT erased
* \param handle input
* \return ECA_NORMAL if all OK else error
*/
int Connect::closeChannelKeepHandle(unsigned int handle) {
#define __METHOD__ "Connect::closeChannelKeepHandle"
//We can close handle irrespective of ca_current_context!
ca_client_context * cctLocal= ca_current_context();
status=ICAFE_NORMAL;
ChannelRegalia channelRegalia;
cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
cafeConduit_set_by_handle::iterator it_handle;
it_handle = handle_index.find(handle);
bool statusFlag=false;
if (it_handle != handle_index.end()) {
if ((*it_handle).getChannelID() != NULL && cctLocal != NULL ) {
Connect::monitorStop(handle);
status = ca_clear_channel((*it_handle).getChannelID());
if (status != ECA_NORMAL) {
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_status (status) );
if(MUTEX){cafeMutex.unlock();} //unlock
return status; //ECA_BADCHID
}
channelRegalia=(*it_handle).getChannelRegalia();
//status = ca_pend_io(channelClosePolicy.getTimeout()); //See channelClosePolicy.setPolicy in connect.h
channelClosePolicy.flushSendBufferNow();
//Do not want to free buffers(!)
//if(MUTEX){cafeMutex.lock();}
//handle_index.modify(it_handle, free_dataBuffers());
//if(MUTEX){cafeMutex.unlock();}
statusFlag=true;
}
}
else {
// Loop through all elements
for (itcs = cs.begin(); itcs != cs.end();) {
//Conduit cc = *itcs;
//operator overload prints handle, pv and nelem
if ((*itcs).handle == handle) {
if ((*itcs).getChannelID() != NULL && cctLocal != NULL) {
Connect::monitorStop(handle);
status = ca_clear_channel((*itcs).getChannelID());
if (status != ECA_NORMAL) {
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_status (status) );
if(MUTEX){cafeMutex.unlock();} //unlock
return status; //ECA_BADCHID
}
channelRegalia=(*it_handle).getChannelRegalia();
//status = ca_pend_io(channelClosePolicy.getTimeout());
channelClosePolicy.flushSendBufferNow();
//if(MUTEX){cafeMutex.lock();}
//handle_index.modify(itcs, free_dataBuffers());
//if(MUTEX){cafeMutex.unlock();}
}
statusFlag=true;
break;
}
else {
++itcs;
}
}
return ECAFE_INVALID_HANDLE;
}
if (statusFlag) {
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_status (ICAFE_CS_CLOSED) );
if(MUTEX){cafeMutex.unlock();} //unlock
//Also callback done
ChannelRequestStatus channelRequestStatusGet;
ChannelRequestStatus channelRequestStatusPut;
channelRequestStatusGet.setCallbackKind(false, true); //fake completion
channelRequestStatusPut.setCallbackKind(false, true); //fake completion
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_channelRequestStatusGet (channelRequestStatusGet) );
handle_index.modify(it_handle, change_channelRequestStatusPut (channelRequestStatusPut) );
if(MUTEX){cafeMutex.unlock();} //unlock
channelRegalia.setCafeConnectionState(ICAFE_CS_CLOSED);
channelRegalia.setConnectFlag(false);
channelRegalia.setConnectionState(ICAFE_CA_OP_CONN_DOWN);
channelRegalia.channelID=NULL;
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_channelRegalia (channelRegalia) );
if(MUTEX){cafeMutex.unlock();} //unlock
}
return status;
#undef __METHOD__
}
/**
* \brief Closes given channel connections (even if in other threads) but does not deletes their handles. \n
* Note that this does NOT cause the channel's disconnect handler to be called. \n
* It does however invoke event subscriptions (for monitors). \n
* All corresponding Conduit handles are not erased.
* \param handleArray input: unsigned int *
* \param nHandles input: unsigned int
* \return ECA_NORMAL if all OK; error if one or more channelIDs fail to close
*/
int Connect::closeChannelsKeepHandles(unsigned int * handleArray, unsigned int nHandles) {
#define __METHOD__ "Connect::closeChannelsKeepHandles(unsigned int *, unsigned int) "
//copy array to vector and remove duplicate handles
vector<unsigned int> vec;
vec.reserve(nHandles);
vec.insert(vec.end(), &handleArray[0], &handleArray[nHandles]);
//Remove duplicate values
sort( vec.begin(), vec.end() );
vec.erase( unique( vec.begin(), vec.end() ), vec.end() );
int statusGroup = ECA_NORMAL;
int status = ICAFE_NORMAL;
bool isClearChannel = false;
ChannelRegalia channelRegalia;
vector<bool> isClearChannelV;
isClearChannelV.reserve(vec.size());
cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
cafeConduit_set_by_handle::iterator it_handle;
if (ca_current_context() != NULL) {
for (unsigned int i=0; i<vec.size(); ++i) {
isClearChannelV.push_back(false);
it_handle = handle_index.find(vec[i]);
if (it_handle != handle_index.end()) {
if ((*it_handle).getChannelID() != NULL ) {
Connect::monitorStop(vec[i]);
status = ca_clear_channel((*it_handle).getChannelID());
if (status != ECA_NORMAL) {
statusGroup=status; //ECA_BADCHID
}
}
isClearChannelV[i]=true;
isClearChannel=true;
}
else {
// Loop through all elements
for (itcs = cs.begin(); itcs != cs.end(); ++itcs) {
//if ((*itcs).getHandle()==handleArray[i]) {
if ((*itcs).getHandle()==vec[i]) {
if ((*itcs).getChannelID() != NULL ) {
Connect::monitorStop(vec[i]);
status = ca_clear_channel((*itcs).getChannelID());
//cout << "clear channel with handle: " << (*itcs).getHandle() << endl;
if (status != ECA_NORMAL){
statusGroup = status;
}
isClearChannelV[i]=true;
isClearChannel=true;
}
break;
}
}
}// else
} //for
}//if ca_current_context != NULL
if (isClearChannel) {
channelClosePolicy.flushSendBufferNow();
//status = ca_pend_io(channelClosePolicy.getTimeout());
//if (statusGroup == ECA_NORMAL) {
// statusGroup = status;
//}
//for (unsigned int i=0; i<nHandles; ++i) {
//it_handle = handle_index.find(handleArray[i]);
for (unsigned int i=0; i<vec.size(); ++i) {
it_handle = handle_index.find(vec[i]);
if (it_handle != handle_index.end() && isClearChannelV[i]) {
//if(MUTEX){cafeMutex.lock();}
//handle_index.modify(it_handle, free_dataBuffers());
//if(MUTEX){cafeMutex.unlock();}
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_status (ICAFE_CS_CLOSED) );
if(MUTEX){cafeMutex.unlock();} //unlock
//Also callback done
ChannelRequestStatus channelRequestStatusGet;
ChannelRequestStatus channelRequestStatusPut;
channelRequestStatusGet.setCallbackKind(false, true); //fake completion
channelRequestStatusPut.setCallbackKind(false, true); //fake completion
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_channelRequestStatusGet (channelRequestStatusGet) );
handle_index.modify(it_handle, change_channelRequestStatusPut (channelRequestStatusPut) );
if(MUTEX){cafeMutex.unlock();} //unlock
channelRegalia=(*it_handle).getChannelRegalia();
channelRegalia.setCafeConnectionState(ICAFE_CS_CLOSED);
channelRegalia.setConnectFlag(false);
channelRegalia.setConnectionState(ICAFE_CA_OP_CONN_DOWN);
channelRegalia.channelID=NULL;
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_channelRegalia (channelRegalia) );
if(MUTEX){cafeMutex.unlock();} //unlock
}
else {
// Loop through all elements
for (itcs = cs.begin(); itcs != cs.end();) {
//if ((*itcs).handle == handleArray[i]) {
if ((*itcs).handle == vec[i] && isClearChannelV[i]) {
//if(MUTEX){cafeMutex.lock();}
//handle_index.modify(itcs, free_dataBuffers());
// if(MUTEX){cafeMutex.unlock();}
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(itcs, change_status (ICAFE_CS_CLOSED) );
if(MUTEX){cafeMutex.unlock();} //unlock
//Also callback done
ChannelRequestStatus channelRequestStatusGet;
ChannelRequestStatus channelRequestStatusPut;
channelRequestStatusGet.setCallbackKind(false, true); //fake completion
channelRequestStatusPut.setCallbackKind(false, true); //fake completion
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(itcs, change_channelRequestStatusGet (channelRequestStatusGet) );
handle_index.modify(itcs, change_channelRequestStatusPut (channelRequestStatusPut) );
if(MUTEX){cafeMutex.unlock();} //unlock
channelRegalia=(*itcs).getChannelRegalia();
channelRegalia.setCafeConnectionState(ICAFE_CS_CLOSED);
channelRegalia.setConnectFlag(false);
channelRegalia.setConnectionState(ICAFE_CA_OP_CONN_DOWN);
channelRegalia.channelID=NULL;
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(itcs, change_channelRegalia (channelRegalia) );
if(MUTEX){cafeMutex.unlock();} //unlock
break;
}
else {
++itcs;
}
} //for itcs
}//if else
}//for
} //isClearChannel
return statusGroup;
#undef __METHOD__
}
/**
* \brief Closes channels for the given channel access client context. \n
* Shuts down the 'local' channel access client context and frees allocated resources \n
@@ -1829,7 +2208,8 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
//FIRST CHECK IF CONNECTED!
//Once connected, then we have this information stored
//
if ((*it_handle).getChannelRegalia().getCafeConnectionState() != ICAFE_CS_NEVER_CONN ) {
if ((*it_handle).getChannelRegalia().getCafeConnectionState() != ICAFE_CS_NEVER_CONN
&& (*it_handle).getChannelRegalia().getCafeConnectionState() != ICAFE_CS_CLOSED ) {
mp.setDataType((*it_handle).getChannelRegalia().getDataType());
mp.setNelem((*it_handle).getChannelRegalia().getNelem());
}
@@ -2186,6 +2566,74 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
}
/**
* \brief send the command to the ioc to open channels
* \param _timeout input: max pend time to establish connections \n
*/
void Connect::openNowAndWait(double _timeout) {
double dto = channelOpenPolicy.getTimeout();
channelOpenPolicy.setTimeout(_timeout);
//channelOpenPolicy.flushSendBufferNow();
//Time lapsed
using namespace boost::posix_time;
ptime timeStart(microsec_clock::local_time());
double timeElapsed=0;
unsigned int nPoll=0;
channelOpenPolicy.flushSendBufferNow();
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
while ( !handleHelper.allChannelsConnected() && (timeElapsed <= channelOpenPolicy.getTimeout())){
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(1000));
#else
#if HAVE_LINUX
usleep(1000);
#endif
#endif
++nPoll;
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
}
/*
if ( handleHelper.allChannelsConnected() ) {
cout << " // all is connected //" << endl;
}
else {
cout << " // all is not connected //" << endl;
}
cout << "timeElapsed for open " << timeElapsed << " nPoll = " << nPoll << endl;
*/
//reset
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
channelOpenPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
//channelOpenPolicy.setTimeoutToDefault();
channelOpenPolicy.setTimeout(dto);
return;
}
/**
* \brief print status information of given handle
* \param handle input: handle to Conduit object \n
@@ -2214,6 +2662,7 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
}
/**
* \brief print status information of given handle only on error
* \param handle input: handle to Conduit object \n
@@ -2394,7 +2843,7 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
/**
* \brief print status information of given PVs only on error
* \param handleArray input: array of Handles to Conduit objects \n
* \param pvArray input: array of PVnames \n
* \param nelem input: size of array of handles
* \param statusArray input: array of statuses \n
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
@@ -2419,6 +2868,9 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
/**
* \brief Closes all channels within the given context and their respective handles \n
* Shuts down the given channel access client context and frees allocated resources \n

View File

@@ -1128,9 +1128,9 @@ int Connect::collectionMemberList(const char * collectionName, vector<string> &l
/**
* \brief Connect::devicePositionOrderedMultiMap - returms a map of devices and their positions
* \brief Connect::devicePositionOrderedMultiMap - returns a map of devices and their positions
* \param collectionName input: name of collection
* \param devPos output: multimap of devices (string) and their positions (float) - odered in position
* \param posDev output: multimap of devices (string) and their positions (float) - odered in position
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
*/
int Connect::devicePositionOrderedMultiMap(const char * collectionName, std::multimap<float, string> &posDev) {
@@ -1171,9 +1171,9 @@ int Connect::devicePositionOrderedMultiMap(const char * collectionName, std::mul
/**
* \brief Connect::devicePositionMap - returms a map of devices and their positions
* \brief Connect::devicePositionMap - returns a map of devices and their positions
* \param collectionName input: name of collection
* \param devPos output: map of devices (string) and their positions (float) - not ordered
* \param posDev output: map of devices (string) and their positions (float) - not ordered
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
*/
int Connect::devicePositionMap(const char * collectionName, std::map<float, string> &posDev) {
@@ -1211,9 +1211,10 @@ int Connect::devicePositionMap(const char * collectionName, std::map<float, stri
/**
* \brief Connect::devicePositionMap - returms a map of devices and their positions
* \brief Connect::devicePositionV - returns a vector of devices and their positions
* \param collectionName input: name of collection
* \param devPos output: map of devices (string) and their positions (float) - not ordered
* \param dev output: vector of devices (string)
* \param pos output: vector of devices positions (float)
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
*/
int Connect::devicePositionV(const char * collectionName, std::vector<string> &dev, std::vector<float> &pos) {
@@ -1297,6 +1298,11 @@ int Connect::fetchIndexOfCollectionMember(const char *collectionName, const char
/**
* Establishes virtual circuit to epics process variable
* for each group member by calling Connect::open(pv, &handle)
@@ -1502,9 +1508,75 @@ int Connect::groupOpen(const char *groupName, unsigned int &groupHandle)
{
//Set timeout to a value that depends on the no of members: 1200 takes 3.5 seconds
double extraTime=nMember/NMEMBER_PER_SEC_SG_PEND_EVENT;
//if ( (DEFAULT_TIMEOUT_SG_PEND_EVENT + extraTime) > channelOpenGroupPolicy.getTimeout() ) {
if ( (channelOpenGroupPolicy.getDefaultTimeout() + extraTime) > channelOpenGroupPolicy.getTimeout() ) {
channelOpenGroupPolicy.setTimeout(channelOpenGroupPolicy.getDefaultTimeout()+ extraTime);
}
using namespace boost::posix_time;
ptime timeStart(microsec_clock::local_time());
double timeElapsed=0;
unsigned int nPoll=0;
channelOpenGroupPolicy.flushSendBufferNow();
bool allConnected=true;
for (unsigned int i = 0; i < nMember; ++i) {
it_handle = handle_index.find(memberHandle[i]);
if (it_handle != handle_index.end()) {
if (!(*it_handle).isConnected()) {
allConnected=false;
}
}
}
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
while ( !allConnected && timeElapsed <= channelOpenGroupPolicy.getTimeout()){
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(1000));
#else
#if HAVE_LINUX
usleep(1000);
#endif
#endif
++nPoll;
allConnected=true;
for (unsigned int i = 0; i < nMember; ++i) {
it_handle = handle_index.find(memberHandle[i]);
if (it_handle != handle_index.end()) {
if (!(*it_handle).isConnected()) {
allConnected=false;
}
}
}
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
}
/*
if (allConnected) {
cout << groupName << " // is all connected //" << endl;
}
else {
cout << groupName << " // is not all connected //" << endl;
}
cout << "timeElapsed for open " << timeElapsed << " nPoll = " << nPoll << endl;
*/
channelOpenGroupPolicy.setTimeout(DEFAULT_TIMEOUT_SG_PEND_EVENT + extraTime);
channelOpenGroupPolicy.flushSendBufferNow();
}
//memHandle must not be deleted; allocated memory for use elsewhere
@@ -1703,6 +1775,9 @@ int Connect::createChannelWithinGroup(unsigned int _handle, const char * pv, chi
if (status != ECA_NORMAL) {
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " ca_create_channel failed: " << endl;
if (status == ECA_EVDISALLOW) {
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " inappropriate function " << endl;
}
cafeStatus.report(status);
if(MUTEX){cafeMutex.lock();} //lock
@@ -1712,6 +1787,7 @@ int Connect::createChannelWithinGroup(unsigned int _handle, const char * pv, chi
}
// Peculiar if true
/*
if (status == ECA_EVDISALLOW) {
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " inappropriate function " << endl;
cafeStatus.report(status);
@@ -1719,7 +1795,7 @@ int Connect::createChannelWithinGroup(unsigned int _handle, const char * pv, chi
handle_index.modify(it_handle, change_status (status) );
if(MUTEX){cafeMutex.unlock();} //unlock
}
*/
}
else {
return ECAFE_INVALID_HANDLE;
@@ -1828,3 +1904,130 @@ int Connect::createHandleWithinGroup(const char * pv, ca_client_context * ccc,
}
/**
* \brief send the command to the ioc to open channels within all group(s).
* \param _timeout input: max pend time to establish connections \n
*/
void Connect::openGroupNowAndWait(double _timeout) {
double dto = channelOpenGroupPolicy.getTimeout();
channelOpenGroupPolicy.setTimeout(_timeout);
//Time lapsed
using namespace boost::posix_time;
ptime timeStart(microsec_clock::local_time());
double timeElapsed=0;
unsigned int nPoll=0;
channelOpenGroupPolicy.flushSendBufferNow();
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
while ( !handleHelper.allChannelsWithinGroupConnected() && (timeElapsed <= channelOpenGroupPolicy.getTimeout())){
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(1000));
#else
#if HAVE_LINUX
usleep(1000);
#endif
#endif
++nPoll;
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
}
if ( handleHelper.allChannelsWithinGroupConnected() ) {
cout << " // all group members are connected //" << endl;
}
else {
cout << " // not all group members are connected //" << endl;
}
cout << "timeElapsed for group open " << timeElapsed << " nPoll = " << nPoll << endl;
//reset
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
//channelOpenPolicy.setTimeoutToDefault();
channelOpenGroupPolicy.setTimeout(dto);
return;
}
/**
* \brief send the command to the ioc to open channels within given group(s).
* \param _timeout input: max pend time to establish connections \n
* \param gHandles input: vector of groups handles \n
*/
void Connect::openGroupNowAndWaitForInputGroups(double _timeout, vector<unsigned int> gHandles) {
double dto = channelOpenGroupPolicy.getTimeout();
channelOpenGroupPolicy.setTimeout(_timeout);
//Time lapsed
using namespace boost::posix_time;
ptime timeStart(microsec_clock::local_time());
double timeElapsed=0;
unsigned int nPoll=0;
channelOpenGroupPolicy.flushSendBufferNow();
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
while ( !handleHelper.allChannelsWithinGroupConnectedV(gHandles) && (timeElapsed <= channelOpenGroupPolicy.getTimeout())){
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(1000));
#else
#if HAVE_LINUX
usleep(1000);
#endif
#endif
++nPoll;
ptime timeEnd(microsec_clock::local_time());
time_duration duration(timeEnd-timeStart);
timeElapsed= (double) duration.total_microseconds()/1000000.0;
}
if ( handleHelper.allChannelsWithinGroupConnectedV(gHandles) ) {
cout << " // all group members of all groups are connected //" << endl;
}
else {
cout << " // not all group members of all groups are connected //" << endl;
}
cout << "timeElapsed for mulitple group open " << timeElapsed << " nPoll = " << nPoll << endl;
//reset
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
//channelOpenPolicy.setTimeoutToDefault();
channelOpenGroupPolicy.setTimeout(dto);
return;
}

View File

@@ -27,6 +27,10 @@ int Granules::channelVerifyPut(const unsigned int _handle, chtype _dbrType) {
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
status=helper.checkConsistency(_handle);
@@ -386,26 +390,26 @@ int Granules::channelExecutePut(const unsigned int _handle) {
if (status==ECAFE_TIMEOUT) {
std::cout << "is the MAXIMUM allowed as configured through TimeoutPolicy! " << std::endl;
std::cout << " SELF-GOVERNING TIMEOUT FOR SET OPERATIONS FOR THIS CHANNEL" << std::endl;
channelTimeoutPolicyPut.setSelfGoverningTimeout(false);
channelTimeoutPolicyPut.setTimeout( channelTimeoutPolicyPut.getTimeout() );
std::cout << " SELF-GOVERNING TIMEOUT FOR SET OPERATIONS FOR THIS CHANNEL" << std::endl;
channelTimeoutPolicyPut.setSelfGoverningTimeout(false);
channelTimeoutPolicyPut.setTimeout( channelTimeoutPolicyPut.getTimeout() );
}
else {
std::cout << "Changing timeout for handle/pv "
else {
std::cout << "Changing timeout for handle/pv "
<< _handle << "/" << (*it_handle).getPV() << " to: " <<
(channelTimeoutPolicyPut.getTimeout() +
channelTimeoutPolicyPut.getDeltaTimeout()*ntries) << " seconds" <<endl;
channelTimeoutPolicyPut.setTimeout( (channelTimeoutPolicyPut.getTimeout() +
channelTimeoutPolicyPut.setTimeout( (channelTimeoutPolicyPut.getTimeout() +
channelTimeoutPolicyPut.getDeltaTimeout()*ntries));
}
}
if(MUTEX){cafeMutex.lock();} //lock
handle_index.modify(it_handle, change_channelTimeoutPolicyPut(channelTimeoutPolicyPut));
if(MUTEX){cafeMutex.unlock();} //unlock
if(MUTEX){cafeMutex.unlock();} //unlock
if (status==ECAFE_TIMEOUT) {
std::cout << "CURRENT STATUS OF HANDLE: " << std::endl;
helper.printHandle(_handle);
}
if (status==ECAFE_TIMEOUT) {
std::cout << "CURRENT STATUS OF HANDLE: " << std::endl;
helper.printHandle(_handle);
}
} //isConnected
}
@@ -558,9 +562,15 @@ int Granules::channelVerifyGet(const unsigned int _handle, chtype _dbrType) {
if (it_handle != handle_index.end()) {
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
status=helper.checkConsistency(_handle);
@@ -579,7 +589,7 @@ int Granules::channelVerifyGet(const unsigned int _handle, chtype _dbrType) {
handle_index.modify(it_handle, change_channelRequestStatusGet(channelRequestStatusGet));
handle_index.modify(it_handle, change_status(ICAFE_CA_OP_CONN_DOWN)); //for return
if(MUTEX){cafeMutex.unlock();}//unlock
if(MUTEX){cafeMutex.unlock();}//unlock
return ICAFE_CA_OP_CONN_DOWN;
}
@@ -1447,15 +1457,15 @@ int Granules::waitForGetEvent(const unsigned int _handle, double _timeout) {
while (channelRequestStatusGet.getCallbackProgressKind() == CAFENUM::PENDING
&& timeElapsed < _timeout){
ca_flush_io();
ca_flush_io();
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(20));
#else
#if HAVE_LINUX
usleep(20);
#endif
#endif
#if HAVE_BOOST_THREAD
boost::this_thread::sleep_for(boost::chrono::microseconds(20));
#else
#if HAVE_LINUX
usleep(20);
#endif
#endif
++nPoll;
ptime timeEnd(microsec_clock::local_time());
@@ -1650,9 +1660,16 @@ int Granules::channelVerifyGetCtrl(const unsigned int _handle, chtype _dbrType
if (it_handle != handle_index.end()) {
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
return ICAFE_CS_NEVER_CONN;
}
else if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_CLOSED) {
return ICAFE_CS_CLOSED;
}
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
status=helper.checkConsistency(_handle);

View File

@@ -1112,7 +1112,7 @@ unsigned int HandleHelper::getHandleFromPVWithinGroup(const char * _pv,
* \return vector of handles within Group
*/
vector<unsigned int> HandleHelper::getHandlesFromWithinGroupV(unsigned int _groupHandle) {
#define __METHOD__ "HandleHelper::getGroupHandlesFromWithinGroup"
#define __METHOD__ "HandleHelper::getHandlesFromWithinGroupV"
cafeGroup_set_by_groupHandle & groupHandle_index = gs.get<by_groupHandle> ();
cafeGroup_set_by_groupHandle::iterator it_groupHandle;
@@ -1154,7 +1154,7 @@ vector<unsigned int> HandleHelper::getHandlesFromWithinGroupV(unsigned int _gr
* \return array of handles within Group
*/
unsigned int * HandleHelper::getHandlesFromWithinGroup(unsigned int _groupHandle) {
#define __METHOD__ "HandleHelper::getGroupHandlesFromWithinGroup"
#define __METHOD__ "HandleHelper::getHandlesFromWithinGroup"
cafeGroup_set_by_groupHandle & groupHandle_index = gs.get<by_groupHandle> ();
cafeGroup_set_by_groupHandle::iterator it_groupHandle;
@@ -1187,6 +1187,74 @@ unsigned int * HandleHelper::getHandlesFromWithinGroup(unsigned int _groupHand
#undef __METHOD__
}
/**
* \brief Retrieves all handles belonging to a group referenced by its groupHandle
* \param _groupHandle input: groupHandle
* \return vector of handles within Group
*/
vector<unsigned int> HandleHelper::getDisconnectedHandlesFromWithinGroupV(unsigned int _groupHandle) {
#define __METHOD__ "HandleHelper::getDisconnectedHandlesFromWithinGroupV"
cafeGroup_set_by_groupHandle & groupHandle_index = gs.get<by_groupHandle> ();
cafeGroup_set_by_groupHandle::iterator it_groupHandle;
it_groupHandle = groupHandle_index.find(_groupHandle);
vector<unsigned int> vhg;
if (it_groupHandle != groupHandle_index.end()) {
vhg.reserve( (*it_groupHandle).getNMember());
cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
cafeConduit_set_by_handle::iterator it_handle;
for (unsigned int i=0; i <(*it_groupHandle).getNMember(); ++i ) {
it_handle = handle_index.find((*it_groupHandle).mHandle[i]);
if (it_handle != handle_index.end()) {
if ( ! ((*it_handle).isConnected()) ) {
vhg.push_back((*it_groupHandle).mHandle[i]);
}
}
}
return vhg;
} else {
// Loop through all elements and search for grouphandle match
for (itgs = gs.begin(); itgs != gs.end(); ++itgs) {
if ((*itgs).getGroupHandle() == _groupHandle ) {
vhg.reserve( (*itgs).getNMember());
cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
cafeConduit_set_by_handle::iterator it_handle;
for (unsigned int i=0; i <(*itgs).getNMember(); ++i ) {
it_handle = handle_index.find((*itgs).mHandle[i]);
if (it_handle != handle_index.end()) {
if ( !((*it_handle).isConnected() ) ) {
vhg.push_back((*itgs).mHandle[i]);
}
}
}
return vhg;
}
}
}
cafeStatus.report(ECAFE_UNKNOWN_GROUP);
return vhg;
#undef __METHOD__
}
/**
* \brief Method returns true if channel is connected, else false
* \param handle input: handle
@@ -1205,6 +1273,72 @@ bool HandleHelper::isChannelConnected(unsigned int handle){
/**
* \brief Method returns true if all channels are connected, else false
* \return bool
*/
bool HandleHelper::allChannelsConnected() {
#define __METHOD__ "HandleHelper::allChannelsConnected"
ca_client_context * ccc = ca_current_context();
// Loop through all elements
for (itcs = cs.begin(); itcs != cs.end(); ++itcs) {
if (!(*itcs).isConnected() && (ccc ==(*itcs).getClientContext()) ) {
return false;
}
}
return true;
#undef __METHOD__
}
/**
* \brief Method returns true if all channels are connected, else false
* \return bool
*/
bool HandleHelper::allChannelsWithinGroupConnected() {
#define __METHOD__ "HandleHelper::allChannelsWithinGroupConnected"
ca_client_context * ccc = ca_current_context();
// Loop through all elements
for (itcs = cs.begin(); itcs != cs.end(); ++itcs) {
if (!(*itcs).isConnected() && (ccc ==(*itcs).getClientContext()) && (*itcs).getGroupHandle()>0 ) {
return false;
}
}
return true;
#undef __METHOD__
}
/**
* \brief Method returns true if all channels within the given vector of groups handles are connected, else false
* \param grpID input: vector of group handles
* \return bool
*/
bool HandleHelper::allChannelsWithinGroupConnectedV(vector<unsigned int> grpID) {
#define __METHOD__ "HandleHelper::allChannelsWithinGroupConnectedV"
if (grpID.size()==0) {
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
cout << "Input vector listing group handles is of zero size " << endl;
}
for (size_t i=0; i<grpID.size(); ++i) {
unsigned int nMem= HandleHelper::getDisconnectedHandlesFromWithinGroupV(grpID[i]).size();
if ( nMem > 0) {
//cout << "group handle " << grpID[i] << " NOT all members connected " << endl;
return false;
}
//cout << "group handle " << grpID[i] << " has all members connected " << endl;
}
return true;
#undef __METHOD__
}
/**
* \brief Retrieves last cached status information for given handle
* \param _handle input: handle
@@ -1321,7 +1455,7 @@ int HandleHelper::getAlarmStatusSeverityAsString(unsigned int _handle, string as
/**
* \brief Rerieves vector of handles for given vector of PVs
* \param pvV input: vector of PVS
* \retun handleV output: vector of handles
* \return vector of handles
*/
vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV) {
@@ -1336,7 +1470,6 @@ vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV) {
* \brief Rerieves vector of handles for given vector of PVs
* \param pvV input: vector of PVS
* \param ccc input: ca_client_context *
* \param handleV output: vector of handles
* \return ICAFE_NORMAL if all OK else ECAFE_INVALID_HANDLE
*/
vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV, ca_client_context * ccc) {

View File

@@ -111,8 +111,8 @@ AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
#if HAVE_ZEROMQ
#libcafe_la_SOURCES += cafeService.cpp
#endif
AM_CPPFLAGS = -fexceptions -fPIC -I/usr/local/epics/base/include/ -I/usr/local/epics/base/include/os/Linux -I/opt/gfa/cafe/boost/boost_1_61_0/include/boost -I/opt/gfa/cafe/boost/boost_1_61_0/include -I/usr/include/QtCore -I/usr/include/QtXml -I/opt/gfa/python-3.5/latest/include/python3.5m -I$(top_srcdir)/include
AM_LDFLAGS = -L/usr/local/epics/base/lib/SL6-x86_64 -Wl,-rpath,/usr/local/epics/base/lib/SL6-x86_64 -L/usr/lib64 -Wl,-rpath,/usr/lib64 -L/opt/gfa/python-3.5/latest/lib -Wl,-rpath,/opt/gfa/python-3.5/latest/lib
AM_CPPFLAGS = -fexceptions -fPIC -I/usr/local/epics/base/include/ -I/usr/local/epics/base/include/os/Linux -I/opt/gfa/cafe/boost/boost_1_61_0/include/boost -I/opt/gfa/cafe/boost/boost_1_61_0/include -I/usr/include/QtCore -I/usr/include/QtXml -I$(top_srcdir)/include
AM_LDFLAGS = -L/usr/local/epics/base/lib/SL6-x86_64 -Wl,-rpath,/usr/local/epics/base/lib/SL6-x86_64 -L/usr/lib64 -Wl,-rpath,/usr/lib64
AR = ar
AUTOCONF = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoconf
AUTOHEADER = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoheader
@@ -123,7 +123,7 @@ CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
CPPFLAGS = -fexceptions -fPIC -I/usr/local/epics/base/include/ -I/usr/local/epics/base/include/os/Linux -I/opt/gfa/cafe/boost/boost_1_61_0/include/boost -I/opt/gfa/cafe/boost/boost_1_61_0/include -I/usr/include/QtCore -I/usr/include/QtXml -I/opt/gfa/python-3.5/latest/include/python3.5m
CPPFLAGS = -fexceptions -fPIC -I/usr/local/epics/base/include/ -I/usr/local/epics/base/include/os/Linux -I/opt/gfa/cafe/boost/boost_1_61_0/include/boost -I/opt/gfa/cafe/boost/boost_1_61_0/include -I/usr/include/QtCore -I/usr/include/QtXml
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
@@ -146,9 +146,9 @@ INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
LD = /usr/bin/ld -m elf_x86_64
LDFLAGS = -L/usr/local/epics/base/lib/SL6-x86_64 -Wl,-rpath,/usr/local/epics/base/lib/SL6-x86_64 -L/usr/lib64 -Wl,-rpath,/usr/lib64 -L/opt/gfa/python-3.5/latest/lib -Wl,-rpath,/opt/gfa/python-3.5/latest/lib
LDFLAGS = -L/usr/local/epics/base/lib/SL6-x86_64 -Wl,-rpath,/usr/local/epics/base/lib/SL6-x86_64 -L/usr/lib64 -Wl,-rpath,/usr/lib64
LIBOBJS =
LIBS = -lpython3.5m -lQtXml -lQtCore
LIBS = -lQtXml -lQtCore
LIBTOOL = $(SHELL) $(top_builddir)/libtool
LIPO =
LN_S = ln -s
@@ -207,7 +207,7 @@ htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/install-sh
libdir = /opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2/lib
libdir = /opt/gfa/cafe/cpp/cafe-1.5.0-final-1/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
localstatedir = ${prefix}/var
@@ -216,7 +216,7 @@ mandir = ${datarootdir}/man
mkdir_p = /bin/mkdir -p
oldincludedir = /usr/include
pdfdir = ${docdir}
prefix = /opt/gfa/cafe/python/python-3.5/pycafe-1.3.0-final-2
prefix = /opt/gfa/cafe/cpp/cafe-1.5.0-final-1
program_transform_name = s,x,x,
psdir = ${docdir}
sbindir = ${exec_prefix}/sbin