additional methods to handleHelper
This commit is contained in:
@@ -618,7 +618,7 @@ int CAFE::get(const char * pv, PVDataHolder & pvd) {
|
||||
int CAFE::get(const unsigned int handle, PVDataHolder & pvd) {
|
||||
#define __METHOD__ "CAFE::get(unsigned int handle, PVDataHolder & pvd)"
|
||||
|
||||
cout << __FILE__ << " " << __LINE__ << " " << __METHOD__ << endl;
|
||||
//cout << __FILE__ << " " << __LINE__ << " " << __METHOD__ << endl;
|
||||
|
||||
status=ICAFE_NORMAL;
|
||||
|
||||
|
||||
121
src/connect.cpp
121
src/connect.cpp
@@ -2298,6 +2298,127 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief print status information of given pv
|
||||
* \param pv input: pv for which handle is to be matched \n
|
||||
* \param status input: reporting status \n
|
||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE
|
||||
*/
|
||||
int Connect::printStatus(const char *pv, int status) {
|
||||
|
||||
unsigned int handle=handleHelper.getHandleFromPV(pv);
|
||||
|
||||
if (handle==0) {
|
||||
return ECAFE_INVALID_HANDLE;
|
||||
}
|
||||
return Connect::printStatus(handle, status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief print status information of given pv only on error
|
||||
* \param pv input: pv for which handle is to be matched\n
|
||||
* \param status input: reporting status \n
|
||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE
|
||||
*/
|
||||
int Connect::printStatusIfError(const char * pv, int status) {
|
||||
|
||||
if (status==ICAFE_NORMAL) {return ICAFE_NORMAL;};
|
||||
|
||||
unsigned int handle=handleHelper.getHandleFromPV(pv);
|
||||
|
||||
if (handle==0) {
|
||||
return ECAFE_INVALID_HANDLE;
|
||||
}
|
||||
return Connect::printStatus(handle, status);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief print status information of given PVs
|
||||
* \param pvV input: vector of pvs for which handles to conduit objects are to be matched\n
|
||||
* \param statusV input: vector of statuses \n
|
||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
|
||||
*/
|
||||
int Connect::printStatus(vector<string> pvV, vector<int> statusV) {
|
||||
|
||||
int overallStatus=ICAFE_NORMAL; bool isGood=true;
|
||||
int localStatus=ICAFE_NORMAL;
|
||||
for (unsigned int i=0; i < min(pvV.size(),statusV.size()); ++i) {
|
||||
localStatus=Connect::printStatus(pvV[i].c_str(), statusV[i]);
|
||||
if(isGood && localStatus!=ICAFE_NORMAL) {overallStatus=localStatus; isGood=false;}
|
||||
}
|
||||
return overallStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief print status information of given PVs only on error
|
||||
* \param pvV input: vector of PVs for which handles to Conduit objects are to be matched\n
|
||||
* \param statusV input: vector of statuses \n
|
||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
|
||||
*/
|
||||
int Connect::printStatusIfError(vector<string> pvV, vector<int> statusV) {
|
||||
int overallStatus=ICAFE_NORMAL; bool isGood=true;
|
||||
int localStatus=ICAFE_NORMAL;
|
||||
for (unsigned int i=0; i <min(pvV.size(),statusV.size()); ++i) {
|
||||
if (statusV[i]!=ICAFE_NORMAL) {
|
||||
localStatus=Connect::printStatus(pvV[i].c_str(), statusV[i]);
|
||||
if(isGood && localStatus!=ICAFE_NORMAL) {overallStatus=localStatus; isGood=false;}
|
||||
};
|
||||
}
|
||||
return overallStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief print status information of given PVs
|
||||
* \param pvArray input: array of PVs for which handles to conduit objects are to be matched\n
|
||||
* \param nelem input: size of array of PVs
|
||||
* \param statusArray input: array of statuses \n
|
||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
|
||||
*/
|
||||
int Connect::printStatus(const char * pvArray, unsigned int nelem, int *statusArray) {
|
||||
int overallStatus=ICAFE_NORMAL; bool isGood=true;
|
||||
int localStatus=ICAFE_NORMAL;
|
||||
for (unsigned int i=0; i <nelem; ++i) {
|
||||
localStatus=Connect::printStatus(pvArray[i], statusArray[i]);
|
||||
if(isGood && localStatus!=ICAFE_NORMAL) {overallStatus=localStatus; isGood=false;}
|
||||
}
|
||||
return overallStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief print status information of given PVs only on error
|
||||
* \param handleArray input: array of Handles to Conduit objects \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)
|
||||
*/
|
||||
int Connect::printStatusIfError(const char * pvArray, unsigned int nelem, int *statusArray) {
|
||||
int overallStatus=ICAFE_NORMAL; bool isGood=true;
|
||||
int localStatus=ICAFE_NORMAL;
|
||||
for (unsigned int i=0; i <nelem; ++i) {
|
||||
if (statusArray[i]!=ICAFE_NORMAL) {
|
||||
localStatus=Connect::printStatus(pvArray[i], statusArray[i]);
|
||||
if(isGood && localStatus!=ICAFE_NORMAL) {overallStatus=localStatus; isGood=false;}
|
||||
};
|
||||
}
|
||||
return overallStatus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \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
|
||||
|
||||
@@ -100,16 +100,19 @@ int HandleHelper::checkConsistency(unsigned int _handle) {
|
||||
std::cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << std::endl;
|
||||
std::cout << "Following Corrections Made:" << std::endl;
|
||||
std::cout << message << endl;
|
||||
}
|
||||
//else {
|
||||
// std::cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << std::endl;
|
||||
// std::cout << "CA CONSISTENCY VERIFIED " << std::endl;
|
||||
//}
|
||||
|
||||
|
||||
if(MUTEX){cafeMutex.lock();}
|
||||
handle_index.modify(it_handle, change_channelRegalia(chInfo));
|
||||
if(MUTEX){cafeMutex.unlock();}
|
||||
if(MUTEX){cafeMutex.lock();}
|
||||
handle_index.modify(it_handle, change_channelRegalia(chInfo));
|
||||
if(MUTEX){cafeMutex.unlock();}
|
||||
|
||||
return ECAFE_INCONSISTENT_CONTAINER_CORRECTED;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
@@ -1312,6 +1315,80 @@ int HandleHelper::getAlarmStatusSeverityAsString(unsigned int _handle, string as
|
||||
#undef __METHOD__
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Rerieves vector of handles for given vector of PVs
|
||||
* \param pvV input: vector of PVS
|
||||
* \retun handleV output: vector of handles
|
||||
*/
|
||||
vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV) {
|
||||
|
||||
ca_client_context * ccc = ca_current_context();
|
||||
|
||||
return getHandlesFromPVs(pvV,ccc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \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) {
|
||||
#define __METHOD__ "HandleHelper::getHandlesFromPVs()"
|
||||
|
||||
vector<unsigned int> handleV;
|
||||
|
||||
handleV.reserve(pvV.size());
|
||||
|
||||
|
||||
cafeConduit_set_by_pv & pv_index = cs.get<by_pv> ();
|
||||
cafeConduit_set_by_pv::iterator it_pv;
|
||||
|
||||
for (unsigned int i=0; i<pvV.size(); ++i) {
|
||||
|
||||
|
||||
char pv[PVNAME_SIZE];
|
||||
removeLeadingAndTrailingSpaces(pvV[i].c_str(), pv);
|
||||
|
||||
it_pv = pv_index.find(pv);
|
||||
|
||||
// Possibilities of getting a match!
|
||||
if (it_pv != pv_index.end()) {
|
||||
|
||||
// Examine ca_client_context noting that channels within a group don't count!
|
||||
if (ccc == (*it_pv).getClientContext() && (*it_pv).getGroupHandle()==0 ) {
|
||||
handleV.push_back((*it_pv).handle);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Loop through all elements and search for pv/ca_client_context match
|
||||
for (itcs = cs.begin(); itcs != cs.end(); ++itcs) {
|
||||
if((*itcs).getGroupHandle()>0) {continue;} // Channels within a group don't count!
|
||||
|
||||
if (!strcmp((*itcs).getPV(), pvV[i].c_str()) && (*itcs).getClientContext()== ccc) {
|
||||
|
||||
handleV.push_back((*itcs).handle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
handleV.push_back(0);
|
||||
}
|
||||
} //for
|
||||
|
||||
|
||||
|
||||
return handleV;
|
||||
#undef __METHOD__
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Prints Conduit member values for all given handles
|
||||
* \return ICAFE_NORMAL if all OK else ECAFE_INVALID_HANDLE
|
||||
|
||||
@@ -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/cpp/cafe-1.3.0-final-1/lib
|
||||
libdir = /opt/gfa/cafe/cpp/cafe-1.3.0-final-2/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/cpp/cafe-1.3.0-final-1
|
||||
prefix = /opt/gfa/cafe/cpp/cafe-1.3.0-final-2
|
||||
program_transform_name = s,x,x,
|
||||
psdir = ${docdir}
|
||||
sbindir = ${exec_prefix}/sbin
|
||||
|
||||
Reference in New Issue
Block a user