Compare commits
2 Commits
pycafe-1.3
...
pycafe-1.5
| Author | SHA1 | Date | |
|---|---|---|---|
| 52fe50f14a | |||
| 350ddab997 |
@@ -27,7 +27,7 @@ export CAFE_EPICS_V_MINOR=$EBMIN
|
|||||||
export CAFE_EPICS_V_PATCH=$EBPAT
|
export CAFE_EPICS_V_PATCH=$EBPAT
|
||||||
|
|
||||||
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
||||||
CYCAFE_VERSION=pycafe-1.3.0-final-2
|
CYCAFE_VERSION=pycafe-1.5.0-final-2
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--prefix=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/ \
|
--prefix=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/ \
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export CAFE_EPICS_V_MINOR=$EBMIN
|
|||||||
export CAFE_EPICS_V_PATCH=$EBPAT
|
export CAFE_EPICS_V_PATCH=$EBPAT
|
||||||
|
|
||||||
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
||||||
CAFE_VERSION=cafe-1.0.0-beta-1
|
CAFE_VERSION=cafe-1.5.0-final-1
|
||||||
CYCAFE_VERSION=pycafe-noqt-1.0.0-beta-1
|
CYCAFE_VERSION=pycafe-noqt-1.5.0-final-1
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
--prefix=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/ \
|
--prefix=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/ \
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export CAFE_EPICS_V_MINOR=$EBMIN
|
|||||||
export CAFE_EPICS_V_PATCH=$EBPAT
|
export CAFE_EPICS_V_PATCH=$EBPAT
|
||||||
|
|
||||||
|
|
||||||
CAFE_VERSION=cafe-1.3.0-final-2
|
CAFE_VERSION=cafe-1.5.0-final-2
|
||||||
|
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export CAFE_EPICS_V_PATCH=$EBPAT
|
|||||||
|
|
||||||
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \
|
||||||
|
|
||||||
CAFE_VERSION=cafe-noqt-1.1.0-final-1
|
CAFE_VERSION=cafe-noqt-1.5.0-final-1
|
||||||
|
|
||||||
|
|
||||||
./configure \
|
./configure \
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "callbacks.h" //ca callback funtions
|
#include "callbacks.h" //ca callback funtions
|
||||||
|
|
||||||
|
|
||||||
// Test with 6 PVS
|
// Test with 6 PVS
|
||||||
// PV_X1,PV_Y1 are scalar numerics
|
// PV_X1,PV_Y1 are scalar numerics
|
||||||
// PV_WF is a vector numeric
|
// PV_WF is a vector numeric
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
|
|
||||||
#define PV_X1 "ARIDI-BPM-01LE:X-AVG"
|
#define PV_X1 "ARIDI-BPM-01LE:X-AVG"
|
||||||
#define PV_Y1 "ARIDI-BPM-01LE:Y-AVG"
|
#define PV_Y1 "ARIDI-BPM-01LE:Y-AVG"
|
||||||
#define PV_WF "ARIDI-BPM-01LE:WF-INT-1" //256 elements
|
#define PV_WF "ARIDI-BPM-01LE:WF-INT-2" //256 elements
|
||||||
#define PV_MBBI "ARIDI-BPM-01LE:GET-ENABLE" //mmbi
|
#define PV_MBBI "ARIDI-BPM-01LE:GET-ENABLE" //mmbi
|
||||||
#define PV_X1_DESC "ARIDI-BPM-01LE:X-AVG.DESC" //dbr_string_t
|
#define PV_X1_DESC "ARIDI-BPM-01LE:X-AVG.DESC" //dbr_string_t
|
||||||
#define PV_JOKE "PV:JOKE"
|
#define PV_JOKE "PV:JOKE"
|
||||||
@@ -255,7 +254,7 @@ int main( int argc, char *argv[] )
|
|||||||
cout << "Value d=" << d << endl;
|
cout << "Value d=" << d << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle and PV Mappring, i.e., to interchange between handle and pvName
|
//Handle and PV Mapping, i.e., to interchange between handle and pvName
|
||||||
handle = cafe->getHandleFromPV(pvArray[0].c_str());
|
handle = cafe->getHandleFromPV(pvArray[0].c_str());
|
||||||
const char * pvName = cafe->getPVFromHandle(handle);
|
const char * pvName = cafe->getPVFromHandle(handle);
|
||||||
|
|
||||||
@@ -263,7 +262,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
//Set data
|
//Set data
|
||||||
//The set method is able to intrepret all data types, and can
|
//The set method is able to interpret all data types, and can
|
||||||
//cater for scalar values and arrays
|
//cater for scalar values and arrays
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
@@ -614,7 +613,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
PVDataHolder pvDat;
|
PVDataHolder pvDat;
|
||||||
status= cafe->get(PV_MBBI, pvDat);
|
status= cafe->get(PV_MBBI, pvDat);
|
||||||
cout << "VALUE as string: " << pvDat.getAsString() << endl;
|
cout << "VALUE as string: " << pvDat.getAsString() << endl;
|
||||||
cout << "VALUE as int: " << pvDat.getAsUShort() << endl;
|
cout << "VALUE as int: " << pvDat.getAsUShort() << endl;
|
||||||
cout << "Integer Value as String: " << pvDat.getEnumIntegerValueAsString() << endl;
|
cout << "Integer Value as String: " << pvDat.getEnumIntegerValueAsString() << endl;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ private:
|
|||||||
|
|
||||||
Helper helper;
|
Helper helper;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PVCtrlHolder(){
|
PVCtrlHolder(){
|
||||||
@@ -205,12 +206,13 @@ private:
|
|||||||
print(nelem) ;
|
print(nelem) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void print(unsigned int nelemToPrint) {
|
void print(unsigned int nelemToPrint) {
|
||||||
|
|
||||||
nelemToPrint=min(nelemToPrint,nelem);
|
nelemToPrint=min(nelemToPrint,nelem);
|
||||||
std::cout << "------------------------------------------" << std::endl;
|
std::cout << "------------------------------------------" << std::endl;
|
||||||
std::cout << "PVCtrlHolder:" << std::endl;
|
std::cout << "PVCtrlHolder:" << std::endl;
|
||||||
std::cout << "processVariable= " << pv << std::endl;
|
std::cout << "processVariable= " << pv << std::endl;
|
||||||
if (strcmp(pvAlias,pv)) {
|
if (strcmp(pvAlias,pv)) {
|
||||||
std::cout << "pvAlias = " << pvAlias << std::endl;
|
std::cout << "pvAlias = " << pvAlias << std::endl;
|
||||||
}
|
}
|
||||||
@@ -220,11 +222,15 @@ private:
|
|||||||
<< " (" << dataType << ") " << std::endl;
|
<< " (" << dataType << ") " << std::endl;
|
||||||
std::cout << "dbrTypeRequest = " << dbr_type_to_text(dbrDataType)<< std::endl;
|
std::cout << "dbrTypeRequest = " << dbr_type_to_text(dbrDataType)<< std::endl;
|
||||||
if (dataType!=CAFE_NO_ACCESS || dataType != CAFE_TYPENOTCONN) {
|
if (dataType!=CAFE_NO_ACCESS || dataType != CAFE_TYPENOTCONN) {
|
||||||
std::cout << "nelem = " << nelem << std::endl;
|
std::cout << "nelem = " << nelem << std::endl;
|
||||||
|
|
||||||
std::cout << "alarmStatus = " << alarmStatus << std::endl;
|
//std::cout << "alarmStatus = " << alarmStatus << " [" << acond.asString(alarmStatus)<< "]" << std::endl;
|
||||||
std::cout << "alarmSeverity = " << alarmSeverity << std::endl;
|
//std::cout << "alarmSeverity = " << alarmSeverity << " [" << aseve.asString(alarmSeverity) << "]"<< std::endl;
|
||||||
std::cout << "precision = " << precision << std::endl;
|
std::cout << "alarmStatus = " << acond.asString(alarmStatus) << " (" << alarmStatus << ")" << std::endl;
|
||||||
|
std::cout << "alarmSeverity = " << aseve.asString(alarmSeverity) << " (" <<alarmSeverity << ")" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "precision = " << precision << std::endl;
|
||||||
std::cout << "units = " << units << std::endl;
|
std::cout << "units = " << units << std::endl;
|
||||||
/*
|
/*
|
||||||
if (dataType==CAFE_DOUBLE){
|
if (dataType==CAFE_DOUBLE){
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ public:
|
|||||||
std::cout << "Variable has not been applied to a get operation!" << std::endl;
|
std::cout << "Variable has not been applied to a get operation!" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "------------------------------------------" << std::endl;
|
std::cout << "------------------------------------------" << std::endl;
|
||||||
//std::cout << "PVDataHolder:" << std::endl;
|
//std::cout << "PVDataHolder:" << std::endl;
|
||||||
|
|
||||||
@@ -171,7 +172,8 @@ public:
|
|||||||
std::cout << "attrib = " << attrib << std::endl;
|
std::cout << "attrib = " << attrib << std::endl;
|
||||||
std::cout << "dataType = " << cafeDataTypeCode.message(dataType).c_str()
|
std::cout << "dataType = " << cafeDataTypeCode.message(dataType).c_str()
|
||||||
<< " (" << dataType << ") " << std::endl;
|
<< " (" << dataType << ") " << std::endl;
|
||||||
std::cout << "dbrTypeRequest = " << dbr_type_to_text(dbrDataType)<< std::endl;
|
std::cout << "dbrTypeRequest = " << dbr_type_to_text(dbrDataType)
|
||||||
|
<< " (" << dbrDataType << ") " << std::endl;
|
||||||
|
|
||||||
//std::cout << "dataType = " << CAFEDataTypeCode.message(dataType).c_str() << std::endl;
|
//std::cout << "dataType = " << CAFEDataTypeCode.message(dataType).c_str() << std::endl;
|
||||||
|
|
||||||
@@ -187,15 +189,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dbr_type_is_STS(dbrDataType) || dbr_type_is_TIME(dbrDataType) ) {
|
if (dbr_type_is_STS(dbrDataType) || dbr_type_is_TIME(dbrDataType) ) {
|
||||||
std::cout << "alarmStatus = " << alarmStatus << std::endl;
|
|
||||||
std::cout << "alarmSeverity = " << alarmSeverity << std::endl;
|
std::cout << "alarmStatus = " << acond.asString(alarmStatus) << " (" << alarmStatus << ")" << std::endl;
|
||||||
|
std::cout << "alarmSeverity = " << aseve.asString(alarmSeverity) << " (" <<alarmSeverity << ")" << std::endl;
|
||||||
|
|
||||||
if (dbr_type_is_TIME(dbrDataType)) {
|
if (dbr_type_is_TIME(dbrDataType)) {
|
||||||
std::cout << "epicsTimeStamp = " << ts.secPastEpoch << " sec. and " << ts.nsec << " nsec" << std::endl;
|
std::cout << "epicsTimeStamp = " << ts.secPastEpoch << " sec. and " << ts.nsec << " nsec" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(beamEventNo!=0) {std::cout << "beamEventNo = " << beamEventNo << std::endl;};
|
if(beamEventNo!=0) {std::cout << "beamEventNo = " << beamEventNo << std::endl;};
|
||||||
std::cout << "status = " << cafeStatusCode.message(status).c_str() << std::endl;
|
std::cout << "status = " << cafeStatusCode.message(status).c_str() << " (" << status << ") " << std::endl;
|
||||||
std::cout << "value(s) = " ;
|
std::cout << "value(s) = " ;
|
||||||
|
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ public:
|
|||||||
CAFEStatus cstat; cstat.report(statusGroup);
|
CAFEStatus cstat; cstat.report(statusGroup);
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<npvToPrint; ++i) {
|
for (unsigned int i=0; i<npvToPrint; ++i) {
|
||||||
|
std::cout << "------------------------------------------" << std::endl;
|
||||||
|
std::cout << "Element [" << i << "] of " << npvToPrint << " in group: " << name << endl;
|
||||||
pvdata[i].print();
|
pvdata[i].print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,6 +171,8 @@ public:
|
|||||||
CAFEStatus cstat; cstat.report(statusGroup);
|
CAFEStatus cstat; cstat.report(statusGroup);
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<npvToPrint; ++i) {
|
for (unsigned int i=0; i<npvToPrint; ++i) {
|
||||||
|
std::cout << "------------------------------------------" << std::endl;
|
||||||
|
std::cout << "Element [" << i << "] of " << npvToPrint << " in group: " << name << endl;
|
||||||
pvdata[i].print(min(maxNelemWF,pvdata[i].getNelem()));
|
pvdata[i].print(min(maxNelemWF,pvdata[i].getNelem()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ protected:
|
|||||||
short alarmStatus; //alarm.h 0-22 0=NO_ALARM
|
short alarmStatus; //alarm.h 0-22 0=NO_ALARM
|
||||||
short alarmSeverity; //alarm.h 0=NO_ALARM 1=MINOR 2=MAJOR 3=INVALID
|
short alarmSeverity; //alarm.h 0=NO_ALARM 1=MINOR 2=MAJOR 3=INVALID
|
||||||
|
|
||||||
|
CAFEGlobalAlarmCondition acond;
|
||||||
|
CAFEGlobalAlarmSeverity aseve;
|
||||||
|
|
||||||
unsigned int userNo; //e.g. add handle
|
unsigned int userNo; //e.g. add handle
|
||||||
|
|
||||||
unsigned int beamEventNo;
|
unsigned int beamEventNo;
|
||||||
@@ -98,10 +101,14 @@ public:
|
|||||||
|
|
||||||
boost::shared_ptr<vector<double> > ValVD_ptr;
|
boost::shared_ptr<vector<double> > ValVD_ptr;
|
||||||
boost::shared_ptr<vector<float> > ValVF_ptr;
|
boost::shared_ptr<vector<float> > ValVF_ptr;
|
||||||
//boost::shared_ptr<vector<short> > ValVS_ptr;
|
boost::shared_ptr<vector<short> > ValVS_ptr;
|
||||||
boost::shared_ptr<vector<int> > ValVI_ptr;
|
boost::shared_ptr<vector<int> > ValVI_ptr;
|
||||||
//boost::shared_ptr<vector<unsigned char> > ValVC_ptr;
|
boost::shared_ptr<vector<long> > ValVL_ptr;
|
||||||
//boost::shared_ptr<vector<unsigned short> > ValVUS_ptr;
|
boost::shared_ptr<vector<unsigned long> > ValVUL_ptr;
|
||||||
|
boost::shared_ptr<vector<long long> > ValVLL_ptr;
|
||||||
|
boost::shared_ptr<vector<unsigned long long> > ValVULL_ptr;
|
||||||
|
boost::shared_ptr<vector<unsigned char> > ValVC_ptr;
|
||||||
|
boost::shared_ptr<vector<unsigned short> > ValVUS_ptr;
|
||||||
boost::shared_ptr<vector<string> > ValVStr_ptr;
|
boost::shared_ptr<vector<string> > ValVStr_ptr;
|
||||||
|
|
||||||
typedef boost::shared_ptr<double []> ValDPtr;
|
typedef boost::shared_ptr<double []> ValDPtr;
|
||||||
@@ -135,7 +142,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void setBSStatus(int st) {status=st;} //for bsread
|
||||||
|
|
||||||
const char * getPV() const {return pv;};
|
const char * getPV() const {return pv;};
|
||||||
const char * getPVName() const {return pv;};
|
const char * getPVName() const {return pv;};
|
||||||
@@ -148,12 +155,15 @@ public:
|
|||||||
CAFE_DATATYPE_UNION_SEQ getVal() const {return val.get();};
|
CAFE_DATATYPE_UNION_SEQ getVal() const {return val.get();};
|
||||||
|
|
||||||
|
|
||||||
short getAlarmStatus() const {return alarmStatus;};
|
short getAlarmStatus() const {return alarmStatus;};
|
||||||
short getAlarmSeverity() const {return alarmSeverity;};
|
short getAlarmSeverity() const {return alarmSeverity;};
|
||||||
|
|
||||||
|
string getAlarmStatusAsString() {return acond.asString(alarmStatus);};
|
||||||
|
string getAlarmSeverityAsString() {return aseve.asString(alarmSeverity);};
|
||||||
|
|
||||||
unsigned int getBeamEventNo() const {return beamEventNo;};
|
unsigned int getBeamEventNo() const {return beamEventNo;};
|
||||||
bool getRule() const {return rule;};
|
bool getRule() const {return rule;};
|
||||||
bool getHasAlarm() const{return hasAlarm;};
|
bool getHasAlarm() const{return hasAlarm;};
|
||||||
int getStatus() const {return status;};
|
int getStatus() const {return status;};
|
||||||
CAFE_DATATYPE getDataTypeClient() const {return dataType;};
|
CAFE_DATATYPE getDataTypeClient() const {return dataType;};
|
||||||
CAFE_DATATYPE getDataType() const {return dataType;};
|
CAFE_DATATYPE getDataType() const {return dataType;};
|
||||||
@@ -194,6 +204,8 @@ public:
|
|||||||
void setString(std::string str) {strcpy(val[0].str,str.c_str()); dataType=CAFE_STRING;};
|
void setString(std::string str) {strcpy(val[0].str,str.c_str()); dataType=CAFE_STRING;};
|
||||||
void setDouble(double d) {val[0].d=d; dataType=CAFE_DOUBLE;};
|
void setDouble(double d) {val[0].d=d; dataType=CAFE_DOUBLE;};
|
||||||
void setInt(int l) {val[0].l=l; dataType=CAFE_LONG;};
|
void setInt(int l) {val[0].l=l; dataType=CAFE_LONG;};
|
||||||
|
|
||||||
|
|
||||||
void setVString(vector<std::string> Vstr) {
|
void setVString(vector<std::string> Vstr) {
|
||||||
if(Vstr.size()!=nelem) {nelem=Vstr.size();}
|
if(Vstr.size()!=nelem) {nelem=Vstr.size();}
|
||||||
for (unsigned int i=0; i<nelem; ++ i) {
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
@@ -207,6 +219,64 @@ public:
|
|||||||
for (unsigned int i=0; i<nelem; ++ i) {
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
val[i].l=Vl[i];} dataType=CAFE_LONG;};
|
val[i].l=Vl[i];} dataType=CAFE_LONG;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void set(vector<std::string> Vstr) {
|
||||||
|
if(Vstr.size()!=nelem) {nelem=Vstr.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
strcpy(val[i].str,Vstr[i].c_str());} dataType=CAFE_STRING;};
|
||||||
|
void set(vector<double> Vd) {
|
||||||
|
if(Vd.size()!=nelem) {nelem=Vd.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].d=Vd[i];} dataType=CAFE_DOUBLE;};
|
||||||
|
void set(vector<float> Vf) {
|
||||||
|
if(Vf.size()!=nelem) {nelem=Vf.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].f=Vf[i];} dataType=CAFE_FLOAT;};
|
||||||
|
|
||||||
|
void set (vector<int> Vl) {
|
||||||
|
if(Vl.size()!=nelem) {nelem=Vl.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].l=Vl[i];} dataType=CAFE_LONG;};
|
||||||
|
|
||||||
|
void set (vector<long> Vl) {
|
||||||
|
if(Vl.size()!=nelem) {nelem=Vl.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].l=Vl[i];} dataType=CAFE_LONG;};
|
||||||
|
|
||||||
|
void set (vector<unsigned long> Vul) {
|
||||||
|
if(Vul.size()!=nelem) {nelem=Vul.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].d=Vul[i];} dataType=CAFE_DOUBLE;};
|
||||||
|
|
||||||
|
void set (vector<long long> Vll) {
|
||||||
|
if(Vll.size()!=nelem) {nelem=Vll.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].d=Vll[i];} dataType=CAFE_DOUBLE;};
|
||||||
|
|
||||||
|
void set (vector<unsigned long long> Vull) {
|
||||||
|
if(Vull.size()!=nelem) {nelem=Vull.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].d=Vull[i];} dataType=CAFE_DOUBLE;};
|
||||||
|
|
||||||
|
void set (vector<short> Vs) {
|
||||||
|
if(Vs.size()!=nelem) {nelem=Vs.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].s=Vs[i];} dataType=CAFE_SHORT;};
|
||||||
|
|
||||||
|
void set (vector<unsigned short> Vus) {
|
||||||
|
if(Vus.size()!=nelem) {nelem=Vus.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].us=Vus[i];} dataType=CAFE_ENUM;};
|
||||||
|
|
||||||
|
void set (vector<unsigned char> Vc) {
|
||||||
|
if(Vc.size()!=nelem) {nelem=Vc.size();}
|
||||||
|
for (unsigned int i=0; i<nelem; ++ i) {
|
||||||
|
val[i].ch=Vc[i];} dataType=CAFE_CHAR;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void set(unsigned int l) {val[0].l= (int) l; dataType=CAFE_LONG;};
|
void set(unsigned int l) {val[0].l= (int) l; dataType=CAFE_LONG;};
|
||||||
void set(unsigned short us) {val[0].us=us; dataType=CAFE_ENUM;};
|
void set(unsigned short us) {val[0].us=us; dataType=CAFE_ENUM;};
|
||||||
void set(unsigned char ch) {val[0].ch=ch; dataType=CAFE_CHAR;};
|
void set(unsigned char ch) {val[0].ch=ch; dataType=CAFE_CHAR;};
|
||||||
@@ -287,9 +357,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<vector<double> > getAsVDouble(){
|
boost::shared_ptr<vector<double> > getAsVDouble(){
|
||||||
#define __METHOD__ "PVHolder::getVDouble "
|
#define __METHOD__ "PVHolder::getAsVDouble "
|
||||||
|
|
||||||
ValVD_ptr.reset(new vector<double>());
|
ValVD_ptr.reset(new vector<double>());
|
||||||
|
ValVD_ptr->reserve(nelem);
|
||||||
|
|
||||||
switch (dataType)
|
switch (dataType)
|
||||||
{
|
{
|
||||||
@@ -322,9 +393,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<vector<float> > getAsVFloat(){
|
boost::shared_ptr<vector<float> > getAsVFloat(){
|
||||||
#define __METHOD__ "PVHolder::getVFloat "
|
#define __METHOD__ "PVHolder::getAsVFloat "
|
||||||
|
|
||||||
ValVF_ptr.reset(new vector<float>());
|
ValVF_ptr.reset(new vector<float>());
|
||||||
|
ValVF_ptr->reserve(nelem);
|
||||||
|
|
||||||
switch (dataType)
|
switch (dataType)
|
||||||
{
|
{
|
||||||
@@ -357,6 +429,10 @@ public:
|
|||||||
//cout << "size/// " << vf[0].size() << endl;
|
//cout << "size/// " << vf[0].size() << endl;
|
||||||
//cout << vf[0][0] << " val " << val[0].f << endl;
|
//cout << vf[0][0] << " val " << val[0].f << endl;
|
||||||
//cout << vf[0][1] << " val " << val[1].f << endl;
|
//cout << vf[0][1] << " val " << val[1].f << endl;
|
||||||
|
//vector<float> vf= *ValVF_ptr.get();
|
||||||
|
//cout << "size/// " << vf.size() << endl;
|
||||||
|
//cout << vf[0] << " val " << val[0].f << endl;
|
||||||
|
//cout << vf[1] << " val " << val[1].f << endl;
|
||||||
|
|
||||||
return ValVF_ptr;
|
return ValVF_ptr;
|
||||||
#undef __METHOD__
|
#undef __METHOD__
|
||||||
@@ -364,9 +440,10 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
boost::shared_ptr<vector<int> > getAsVInt(){
|
boost::shared_ptr<vector<int> > getAsVInt(){
|
||||||
#define __METHOD__ "PVHolder::getVInt "
|
#define __METHOD__ "PVHolder::getAsVInt "
|
||||||
|
|
||||||
ValVI_ptr.reset(new vector<int>());
|
ValVI_ptr.reset(new vector<int>());
|
||||||
|
ValVI_ptr->reserve(nelem);
|
||||||
|
|
||||||
switch (dataType)
|
switch (dataType)
|
||||||
{
|
{
|
||||||
@@ -398,16 +475,338 @@ public:
|
|||||||
#undef __METHOD__
|
#undef __METHOD__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<long> > getAsVLong(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVInt "
|
||||||
|
|
||||||
|
ValVL_ptr.reset(new vector<long>());
|
||||||
|
ValVL_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back((long) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVL_ptr->push_back( getAsLong(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVL_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<unsigned long> > getAsVULong(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVInt "
|
||||||
|
|
||||||
|
ValVUL_ptr.reset(new vector<unsigned long>());
|
||||||
|
ValVUL_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back((unsigned long) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUL_ptr->push_back( getAsULong(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVUL_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<long long> > getAsVLongLong(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVLongLong "
|
||||||
|
|
||||||
|
ValVLL_ptr.reset(new vector<long long>());
|
||||||
|
ValVLL_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back((long long) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVLL_ptr->push_back( getAsLongLong(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVLL_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<unsigned long long> > getAsVULongLong(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVLongLong "
|
||||||
|
|
||||||
|
ValVULL_ptr.reset(new vector<unsigned long long>());
|
||||||
|
ValVULL_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back((unsigned long long) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVULL_ptr->push_back( getAsULongLong(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVULL_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<short> > getAsVShort(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVShort "
|
||||||
|
|
||||||
|
ValVS_ptr.reset(new vector<short>());
|
||||||
|
ValVS_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back((short) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back((short) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back((short) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back(val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back((short) val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back((unsigned short) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVS_ptr->push_back( getAsShort(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVS_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<unsigned short> > getAsVUShort(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVUShort "
|
||||||
|
|
||||||
|
ValVUS_ptr.reset(new vector<unsigned short>());
|
||||||
|
ValVUS_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back((unsigned short) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back((unsigned short) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back((unsigned short) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back((unsigned short)val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back( val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back((unsigned short) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVUS_ptr->push_back( getAsUShort(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVUS_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<vector<unsigned char> > getAsVUChar(){
|
||||||
|
#define __METHOD__ "PVHolder::getAsVUChar "
|
||||||
|
|
||||||
|
ValVC_ptr.reset(new vector<unsigned char>());
|
||||||
|
ValVC_ptr->reserve(nelem);
|
||||||
|
|
||||||
|
switch (dataType)
|
||||||
|
{
|
||||||
|
case CAFE_DOUBLE:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back((unsigned char) val[i].d);}
|
||||||
|
break;
|
||||||
|
case CAFE_FLOAT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back((unsigned char) val[i].f);}
|
||||||
|
break;
|
||||||
|
case CAFE_LONG:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back((unsigned char) val[i].l);}
|
||||||
|
break;
|
||||||
|
case CAFE_SHORT:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back((unsigned char)val[i].s);}
|
||||||
|
break;
|
||||||
|
case CAFE_ENUM:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back( (unsigned char)val[i].us);}
|
||||||
|
break;
|
||||||
|
case CAFE_CHAR:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back((unsigned char) val[i].ch);}
|
||||||
|
break;
|
||||||
|
case CAFE_STRING:
|
||||||
|
default:
|
||||||
|
for (unsigned i=0; i<nelem; ++i) {ValVC_ptr->push_back( (unsigned char) getAsChar(i));}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValVC_ptr;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<vector<string> > getAsVString(){
|
boost::shared_ptr<vector<string> > getAsVString(){
|
||||||
#define __METHOD__ "PVHolder::getVString "
|
#define __METHOD__ "PVHolder::getAsVString "
|
||||||
|
|
||||||
ValVStr_ptr.reset(new vector<string>());
|
ValVStr_ptr.reset(new vector<string>());
|
||||||
|
ValVStr_ptr->reserve(nelem);
|
||||||
for (unsigned i=0; i<nelem; ++i) {ValVStr_ptr->push_back( getAsString(i));}
|
for (unsigned i=0; i<nelem; ++i) {ValVStr_ptr->push_back( getAsString(i));}
|
||||||
|
|
||||||
return ValVStr_ptr;
|
return ValVStr_ptr;
|
||||||
#undef __METHOD__
|
#undef __METHOD__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vector<string> getAsVectorString() {
|
||||||
|
boost::shared_ptr<vector<string> > spVs = getAsVString();
|
||||||
|
return *spVs.get();
|
||||||
|
}
|
||||||
|
vector<float> getAsVectorFloat() {
|
||||||
|
boost::shared_ptr<vector<float> > spVf = getAsVFloat();
|
||||||
|
return *spVf.get();
|
||||||
|
}
|
||||||
|
vector<double> getAsVectorDouble() {
|
||||||
|
boost::shared_ptr<vector<double> > spVd = getAsVDouble();
|
||||||
|
return *spVd.get();
|
||||||
|
}
|
||||||
|
vector<int> getAsVectorInt() {
|
||||||
|
boost::shared_ptr<vector<int> > spVi = getAsVInt();
|
||||||
|
return *spVi.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<long> getAsVectorLong() {
|
||||||
|
boost::shared_ptr<vector<long> > spVl = getAsVLong();
|
||||||
|
return *spVl.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<unsigned long> getAsVectorULong() {
|
||||||
|
boost::shared_ptr<vector<unsigned long> > spVul = getAsVULong();
|
||||||
|
return *spVul.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<long long> getAsVectorLongLong() {
|
||||||
|
boost::shared_ptr<vector<long long> > spVll = getAsVLongLong();
|
||||||
|
return *spVll.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<unsigned long long> getAsVectorULongLong() {
|
||||||
|
boost::shared_ptr<vector<unsigned long long> > spVull = getAsVULongLong();
|
||||||
|
return *spVull.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<short> getAsVectorShort() {
|
||||||
|
boost::shared_ptr<vector<short> > spVsh = getAsVShort();
|
||||||
|
return *spVsh.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<unsigned short> getAsVectorUShort() {
|
||||||
|
boost::shared_ptr<vector<unsigned short> > spVus = getAsVUShort();
|
||||||
|
return *spVus.get();
|
||||||
|
}
|
||||||
|
vector<unsigned char> getAsVectorUChar() {
|
||||||
|
boost::shared_ptr<vector<unsigned char> > spVc = getAsVUChar();
|
||||||
|
return *spVc.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ValDPtr getDouble(){
|
ValDPtr getDouble(){
|
||||||
#define __METHOD__ "PVHolder::getDouble "
|
#define __METHOD__ "PVHolder::getDouble "
|
||||||
if (dataType!=CAFE_DOUBLE) {
|
if (dataType!=CAFE_DOUBLE) {
|
||||||
|
|||||||
115
include/PyCafe2_api.h
Normal file
115
include/PyCafe2_api.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/* Generated by Cython 0.23.4 */
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_API__PyCafe
|
||||||
|
#define __PYX_HAVE_API__PyCafe
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_wrapper)(PVDataHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_wrapper __pyx_api_f_6PyCafe_py_cb_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper)(PVCtrlHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_ctrl_wrapper __pyx_api_f_6PyCafe_py_cb_ctrl_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_wrapper __pyx_api_f_6PyCafe_py_cb_handle_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper)(unsigned int, unsigned long) = 0;
|
||||||
|
#define py_cb_handle_monid_wrapper __pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_get_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_get_wrapper __pyx_api_f_6PyCafe_py_cb_handle_get_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_put_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_put_wrapper __pyx_api_f_6PyCafe_py_cb_handle_put_wrapper
|
||||||
|
#if !defined(__Pyx_PyIdentifier_FromString)
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
|
||||||
|
#else
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportModule
|
||||||
|
#define __PYX_HAVE_RT_ImportModule
|
||||||
|
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||||
|
PyObject *py_name = 0;
|
||||||
|
PyObject *py_module = 0;
|
||||||
|
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||||
|
if (!py_name)
|
||||||
|
goto bad;
|
||||||
|
py_module = PyImport_Import(py_name);
|
||||||
|
Py_DECREF(py_name);
|
||||||
|
return py_module;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(py_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||||
|
#define __PYX_HAVE_RT_ImportFunction
|
||||||
|
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||||
|
PyObject *d = 0;
|
||||||
|
PyObject *cobj = 0;
|
||||||
|
union {
|
||||||
|
void (*fp)(void);
|
||||||
|
void *p;
|
||||||
|
} tmp;
|
||||||
|
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
||||||
|
if (!d)
|
||||||
|
goto bad;
|
||||||
|
cobj = PyDict_GetItemString(d, funcname);
|
||||||
|
if (!cobj) {
|
||||||
|
PyErr_Format(PyExc_ImportError,
|
||||||
|
"%.200s does not export expected C function %.200s",
|
||||||
|
PyModule_GetName(module), funcname);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
#if PY_VERSION_HEX >= 0x02070000
|
||||||
|
if (!PyCapsule_IsValid(cobj, sig)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
||||||
|
#else
|
||||||
|
{const char *desc, *s1, *s2;
|
||||||
|
desc = (const char *)PyCObject_GetDesc(cobj);
|
||||||
|
if (!desc)
|
||||||
|
goto bad;
|
||||||
|
s1 = desc; s2 = sig;
|
||||||
|
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, desc);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCObject_AsVoidPtr(cobj);}
|
||||||
|
#endif
|
||||||
|
*f = tmp.fp;
|
||||||
|
if (!(*f))
|
||||||
|
goto bad;
|
||||||
|
Py_DECREF(d);
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int import_PyCafe(void) {
|
||||||
|
PyObject *module = 0;
|
||||||
|
module = __Pyx_ImportModule("PyCafe");
|
||||||
|
if (!module) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_wrapper, "void (PVDataHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_ctrl_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper, "void (PVCtrlHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_monid_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper, "void (unsigned int, unsigned long)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_get_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_get_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_put_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_put_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
Py_DECREF(module); module = 0;
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(module);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__PYX_HAVE_API__PyCafe */
|
||||||
107
include/PyCafe2_api_March7.h
Normal file
107
include/PyCafe2_api_March7.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
#ifndef __PYX_HAVE_API__PyCafe
|
||||||
|
#define __PYX_HAVE_API__PyCafe
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
static void (*__pyx_f_6PyCafe_py_cb_wrapper)(PVDataHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_wrapper __pyx_f_6PyCafe_py_cb_wrapper
|
||||||
|
static void (*__pyx_f_6PyCafe_py_cb_ctrl_wrapper)(PVCtrlHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_ctrl_wrapper __pyx_f_6PyCafe_py_cb_ctrl_wrapper
|
||||||
|
static void (*__pyx_f_6PyCafe_py_cb_handle_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_wrapper __pyx_f_6PyCafe_py_cb_handle_wrapper
|
||||||
|
static void (*__pyx_f_6PyCafe_py_cb_handle_monid_wrapper)(unsigned int, unsigned long) = 0;
|
||||||
|
#define py_cb_handle_monid_wrapper __pyx_f_6PyCafe_py_cb_handle_monid_wrapper
|
||||||
|
#if !defined(__Pyx_PyIdentifier_FromString)
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
|
||||||
|
#else
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportModule
|
||||||
|
#define __PYX_HAVE_RT_ImportModule
|
||||||
|
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||||
|
PyObject *py_name = 0;
|
||||||
|
PyObject *py_module = 0;
|
||||||
|
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||||
|
if (!py_name)
|
||||||
|
goto bad;
|
||||||
|
py_module = PyImport_Import(py_name);
|
||||||
|
Py_DECREF(py_name);
|
||||||
|
return py_module;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(py_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||||
|
#define __PYX_HAVE_RT_ImportFunction
|
||||||
|
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||||
|
PyObject *d = 0;
|
||||||
|
PyObject *cobj = 0;
|
||||||
|
union {
|
||||||
|
void (*fp)(void);
|
||||||
|
void *p;
|
||||||
|
} tmp;
|
||||||
|
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
||||||
|
if (!d)
|
||||||
|
goto bad;
|
||||||
|
cobj = PyDict_GetItemString(d, funcname);
|
||||||
|
if (!cobj) {
|
||||||
|
PyErr_Format(PyExc_ImportError,
|
||||||
|
"%.200s does not export expected C function %.200s",
|
||||||
|
PyModule_GetName(module), funcname);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
#if PY_VERSION_HEX >= 0x02070000
|
||||||
|
if (!PyCapsule_IsValid(cobj, sig)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
||||||
|
#else
|
||||||
|
{const char *desc, *s1, *s2;
|
||||||
|
desc = (const char *)PyCObject_GetDesc(cobj);
|
||||||
|
if (!desc)
|
||||||
|
goto bad;
|
||||||
|
s1 = desc; s2 = sig;
|
||||||
|
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, desc);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCObject_AsVoidPtr(cobj);}
|
||||||
|
#endif
|
||||||
|
*f = tmp.fp;
|
||||||
|
if (!(*f))
|
||||||
|
goto bad;
|
||||||
|
Py_DECREF(d);
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int import_PyCafe(void) {
|
||||||
|
PyObject *module = 0;
|
||||||
|
module = __Pyx_ImportModule("PyCafe");
|
||||||
|
if (!module) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_wrapper", (void (**)(void))&__pyx_f_6PyCafe_py_cb_wrapper, "void (PVDataHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_ctrl_wrapper", (void (**)(void))&__pyx_f_6PyCafe_py_cb_ctrl_wrapper, "void (PVCtrlHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_wrapper", (void (**)(void))&__pyx_f_6PyCafe_py_cb_handle_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_monid_wrapper", (void (**)(void))&__pyx_f_6PyCafe_py_cb_handle_monid_wrapper, "void (unsigned int, unsigned long)") < 0) goto bad;
|
||||||
|
Py_DECREF(module); module = 0;
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(module);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__PYX_HAVE_API__PyCafe */
|
||||||
109
include/PyCafe3_api_March7.h
Normal file
109
include/PyCafe3_api_March7.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/* Generated by Cython 0.23.4 */
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_API__PyCafe
|
||||||
|
#define __PYX_HAVE_API__PyCafe
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_wrapper)(PVDataHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_wrapper __pyx_api_f_6PyCafe_py_cb_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper)(PVCtrlHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_ctrl_wrapper __pyx_api_f_6PyCafe_py_cb_ctrl_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_wrapper __pyx_api_f_6PyCafe_py_cb_handle_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper)(unsigned int, unsigned long) = 0;
|
||||||
|
#define py_cb_handle_monid_wrapper __pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper
|
||||||
|
#if !defined(__Pyx_PyIdentifier_FromString)
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
|
||||||
|
#else
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportModule
|
||||||
|
#define __PYX_HAVE_RT_ImportModule
|
||||||
|
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||||
|
PyObject *py_name = 0;
|
||||||
|
PyObject *py_module = 0;
|
||||||
|
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||||
|
if (!py_name)
|
||||||
|
goto bad;
|
||||||
|
py_module = PyImport_Import(py_name);
|
||||||
|
Py_DECREF(py_name);
|
||||||
|
return py_module;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(py_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||||
|
#define __PYX_HAVE_RT_ImportFunction
|
||||||
|
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||||
|
PyObject *d = 0;
|
||||||
|
PyObject *cobj = 0;
|
||||||
|
union {
|
||||||
|
void (*fp)(void);
|
||||||
|
void *p;
|
||||||
|
} tmp;
|
||||||
|
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
||||||
|
if (!d)
|
||||||
|
goto bad;
|
||||||
|
cobj = PyDict_GetItemString(d, funcname);
|
||||||
|
if (!cobj) {
|
||||||
|
PyErr_Format(PyExc_ImportError,
|
||||||
|
"%.200s does not export expected C function %.200s",
|
||||||
|
PyModule_GetName(module), funcname);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
#if PY_VERSION_HEX >= 0x02070000
|
||||||
|
if (!PyCapsule_IsValid(cobj, sig)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
||||||
|
#else
|
||||||
|
{const char *desc, *s1, *s2;
|
||||||
|
desc = (const char *)PyCObject_GetDesc(cobj);
|
||||||
|
if (!desc)
|
||||||
|
goto bad;
|
||||||
|
s1 = desc; s2 = sig;
|
||||||
|
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, desc);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCObject_AsVoidPtr(cobj);}
|
||||||
|
#endif
|
||||||
|
*f = tmp.fp;
|
||||||
|
if (!(*f))
|
||||||
|
goto bad;
|
||||||
|
Py_DECREF(d);
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int import_PyCafe(void) {
|
||||||
|
PyObject *module = 0;
|
||||||
|
module = __Pyx_ImportModule("PyCafe");
|
||||||
|
if (!module) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_wrapper, "void (PVDataHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_ctrl_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper, "void (PVCtrlHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_monid_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper, "void (unsigned int, unsigned long)") < 0) goto bad;
|
||||||
|
Py_DECREF(module); module = 0;
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(module);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__PYX_HAVE_API__PyCafe */
|
||||||
115
include/PyCafe3_api_Sep22.h
Normal file
115
include/PyCafe3_api_Sep22.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/* Generated by Cython 0.23.4 */
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_API__PyCafe
|
||||||
|
#define __PYX_HAVE_API__PyCafe
|
||||||
|
#include "Python.h"
|
||||||
|
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_wrapper)(PVDataHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_wrapper __pyx_api_f_6PyCafe_py_cb_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper)(PVCtrlHolder, unsigned int, std::string) = 0;
|
||||||
|
#define py_cb_ctrl_wrapper __pyx_api_f_6PyCafe_py_cb_ctrl_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_wrapper __pyx_api_f_6PyCafe_py_cb_handle_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper)(unsigned int, unsigned long) = 0;
|
||||||
|
#define py_cb_handle_monid_wrapper __pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_get_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_get_wrapper __pyx_api_f_6PyCafe_py_cb_handle_get_wrapper
|
||||||
|
static void (*__pyx_api_f_6PyCafe_py_cb_handle_put_wrapper)(unsigned int) = 0;
|
||||||
|
#define py_cb_handle_put_wrapper __pyx_api_f_6PyCafe_py_cb_handle_put_wrapper
|
||||||
|
#if !defined(__Pyx_PyIdentifier_FromString)
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
|
||||||
|
#else
|
||||||
|
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportModule
|
||||||
|
#define __PYX_HAVE_RT_ImportModule
|
||||||
|
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||||
|
PyObject *py_name = 0;
|
||||||
|
PyObject *py_module = 0;
|
||||||
|
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||||
|
if (!py_name)
|
||||||
|
goto bad;
|
||||||
|
py_module = PyImport_Import(py_name);
|
||||||
|
Py_DECREF(py_name);
|
||||||
|
return py_module;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(py_name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||||
|
#define __PYX_HAVE_RT_ImportFunction
|
||||||
|
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||||
|
PyObject *d = 0;
|
||||||
|
PyObject *cobj = 0;
|
||||||
|
union {
|
||||||
|
void (*fp)(void);
|
||||||
|
void *p;
|
||||||
|
} tmp;
|
||||||
|
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
||||||
|
if (!d)
|
||||||
|
goto bad;
|
||||||
|
cobj = PyDict_GetItemString(d, funcname);
|
||||||
|
if (!cobj) {
|
||||||
|
PyErr_Format(PyExc_ImportError,
|
||||||
|
"%.200s does not export expected C function %.200s",
|
||||||
|
PyModule_GetName(module), funcname);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
#if PY_VERSION_HEX >= 0x02070000
|
||||||
|
if (!PyCapsule_IsValid(cobj, sig)) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
||||||
|
#else
|
||||||
|
{const char *desc, *s1, *s2;
|
||||||
|
desc = (const char *)PyCObject_GetDesc(cobj);
|
||||||
|
if (!desc)
|
||||||
|
goto bad;
|
||||||
|
s1 = desc; s2 = sig;
|
||||||
|
while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
|
||||||
|
if (*s1 != *s2) {
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
||||||
|
PyModule_GetName(module), funcname, sig, desc);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp.p = PyCObject_AsVoidPtr(cobj);}
|
||||||
|
#endif
|
||||||
|
*f = tmp.fp;
|
||||||
|
if (!(*f))
|
||||||
|
goto bad;
|
||||||
|
Py_DECREF(d);
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(d);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static int import_PyCafe(void) {
|
||||||
|
PyObject *module = 0;
|
||||||
|
module = __Pyx_ImportModule("PyCafe");
|
||||||
|
if (!module) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_wrapper, "void (PVDataHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_ctrl_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_ctrl_wrapper, "void (PVCtrlHolder, unsigned int, std::string)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_monid_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_monid_wrapper, "void (unsigned int, unsigned long)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_get_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_get_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
if (__Pyx_ImportFunction(module, "py_cb_handle_put_wrapper", (void (**)(void))&__pyx_api_f_6PyCafe_py_cb_handle_put_wrapper, "void (unsigned int)") < 0) goto bad;
|
||||||
|
Py_DECREF(module); module = 0;
|
||||||
|
return 0;
|
||||||
|
bad:
|
||||||
|
Py_XDECREF(module);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__PYX_HAVE_API__PyCafe */
|
||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
int calcDBPMStatus(int, int, string);
|
int calcDBPMStatus(int, int, string);
|
||||||
|
|
||||||
|
|
||||||
int getDBPM(DBPMHolder &dbpm);
|
int getBS(BSDataHolder &bsd);
|
||||||
int getDBPM(DBPMKeeper &dbpm);
|
int getDBPM(DBPMKeeper &dbpm);
|
||||||
int readDBPMOffsets(DBPMKeeper &dbpm);
|
int readDBPMOffsets(DBPMKeeper &dbpm);
|
||||||
|
|
||||||
@@ -990,10 +990,22 @@ public:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Closes channels but does not delete handle
|
||||||
|
vector<unsigned int> closeDisconnectedChannelsFromWithinGroupV(const unsigned int groupHandle) {
|
||||||
|
vector<unsigned int> dhV=handleHelper.getDisconnectedHandlesFromWithinGroupV(groupHandle);
|
||||||
|
if (dhV.size() >0) {closeChannelsKeepHandles(dhV);}
|
||||||
|
return dhV;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<unsigned int> getDisconnectedHandlesFromWithinGroupV(const unsigned int groupHandle) {
|
||||||
|
return handleHelper.getDisconnectedHandlesFromWithinGroupV(groupHandle);
|
||||||
|
}
|
||||||
|
|
||||||
vector<unsigned int> getHandlesFromWithinGroupV(const unsigned int groupHandle) {
|
vector<unsigned int> getHandlesFromWithinGroupV(const unsigned int groupHandle) {
|
||||||
return handleHelper.getHandlesFromWithinGroupV(groupHandle);
|
return handleHelper.getHandlesFromWithinGroupV(groupHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int * getHandlesFromWithinGroup(const unsigned int groupHandle) {
|
unsigned int * getHandlesFromWithinGroup(const unsigned int groupHandle) {
|
||||||
return handleHelper.getHandlesFromWithinGroup(groupHandle);
|
return handleHelper.getHandlesFromWithinGroup(groupHandle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,6 +383,135 @@ int setAndMatchMany(vector<unsigned int> handleSetV, vector<string> valSetV, vec
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_double_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_double_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeDoppio.setMany (handleSet, DBR_DOUBLE, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeDoppio.compareAndMatchMany(handleSet, DBR_DOUBLE, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_float_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_float_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeFrappuccino.setMany (handleSet, DBR_FLOAT, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeFrappuccino.compareAndMatchMany(handleSet, DBR_FLOAT, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_char_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_char_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeCappuccino.setMany (handleSet, DBR_CHAR, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeCappuccino.compareAndMatchMany(handleSet, DBR_CHAR, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_enum_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_enum_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeEspresso.setMany (handleSet, DBR_ENUM, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeEspresso.compareAndMatchMany(handleSet, DBR_ENUM, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_short_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_short_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeSchale.setMany (handleSet, DBR_SHORT, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeSchale.compareAndMatchMany(handleSet, DBR_SHORT, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<dbr_long_t> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
dbr_long_t tolerance, double timeout, bool printFlag){
|
||||||
|
cafeLatte.setMany (handleSet, DBR_LONG, valSet, false);
|
||||||
|
cafeSoluble.setManyString (handleAction, valAction, false);
|
||||||
|
return cafeLatte.compareAndMatchMany(handleSet, DBR_LONG, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSet, vector<long long> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
long long tolerance, double timeout, bool printFlag){
|
||||||
|
|
||||||
|
vector<dbr_double_t> valSetDoubleV;
|
||||||
|
valSetDoubleV.reserve(valSet.size());
|
||||||
|
|
||||||
|
std::copy(valSet.begin(), valSet.end(),
|
||||||
|
std::back_inserter(valSetDoubleV));
|
||||||
|
|
||||||
|
dbr_double_t toleranceDouble = tolerance;
|
||||||
|
|
||||||
|
return gameSetAndMatch(handleSet, valSetDoubleV,
|
||||||
|
handleAction, valAction, handleMatch, toleranceDouble, timeout, printFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int gameSetAndMatch(vector<unsigned int> handleSetV, vector<string> valSetV,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatchV,
|
||||||
|
string tolerance, double timeout, bool printFlag){
|
||||||
|
#define __METHOD__ "gameSetAndMatch (vector<unsigned int> handleSetV, vector<string> valSetV, \
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatchV, \
|
||||||
|
string tolerance, double timeout, bool printFlag)"
|
||||||
|
|
||||||
|
vector<dbr_double_t> valSetDoubleV;
|
||||||
|
|
||||||
|
istringstream ss;
|
||||||
|
dbr_double_t d=0; dbr_double_t toleranceDouble = 0;
|
||||||
|
for (size_t i=0; i< valSetV.size(); ++i) {
|
||||||
|
d=0;
|
||||||
|
ss.clear();
|
||||||
|
ss.str(valSetV[i]);
|
||||||
|
ss>>d;
|
||||||
|
|
||||||
|
if ( !ss.fail()) {
|
||||||
|
valSetDoubleV.push_back(d);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << __METHOD__ << __LINE__ << endl;
|
||||||
|
cout << "***WARNING*** NO STRING TO DBR_DOUBLE CONVERSION " << endl;
|
||||||
|
cout << "***WARNING*** COULD NOT CONVERT: ";
|
||||||
|
cout << valSetV[i];
|
||||||
|
cout << " TO DOUBLE!" << endl;
|
||||||
|
return ECAFE_NO_CONVERT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d=0;
|
||||||
|
ss.clear();
|
||||||
|
ss.str(tolerance);
|
||||||
|
ss>>d;
|
||||||
|
|
||||||
|
if ( !ss.fail()) {
|
||||||
|
toleranceDouble=d;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << __METHOD__ << __LINE__ << endl;
|
||||||
|
cout << "***WARNING*** NO STRING TO DBR_DOUBLE CONVERSION " << endl;
|
||||||
|
cout << "***WARNING*** COULD NOT CONVERT: ";
|
||||||
|
cout << tolerance;
|
||||||
|
cout << " TO DOUBLE!" << endl;
|
||||||
|
return ECAFE_NO_CONVERT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameSetAndMatch(handleSetV, valSetDoubleV, handleAction, valAction, handleMatchV, toleranceDouble, timeout, printFlag);
|
||||||
|
#undef __METHOD__
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int setAndMatch(const unsigned int handleSet, dbr_double_t valSet, const unsigned int handleMatch,
|
int setAndMatch(const unsigned int handleSet, dbr_double_t valSet, const unsigned int handleMatch,
|
||||||
dbr_double_t tolerance, double timeout, bool printFlag){
|
dbr_double_t tolerance, double timeout, bool printFlag){
|
||||||
return cafeDoppio.setAndMatch(handleSet, DBR_DOUBLE, valSet, handleMatch, tolerance, timeout, printFlag);
|
return cafeDoppio.setAndMatch(handleSet, DBR_DOUBLE, valSet, handleMatch, tolerance, timeout, printFlag);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
///
|
///
|
||||||
/// \file cafeService.h
|
/// \file cafeService.h
|
||||||
/// \author Jan Chrin, PSI
|
/// \author Jan Chrin, PSI
|
||||||
/// \date Release July: 2017
|
/// \date Release October 2017
|
||||||
/// \version CAFE 1.3.0
|
/// \version CAFE 1.4.0
|
||||||
///
|
///
|
||||||
|
|
||||||
#ifndef CAFE_SERVICE_H
|
#ifndef CAFE_SERVICE_H
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#if HAVE_ZEROMQ
|
#if HAVE_ZEROMQ
|
||||||
//include <zhelpers.h>
|
|
||||||
#include <zmq.h>
|
#include <zmq.h>
|
||||||
#if HAVE_JSON
|
#if HAVE_JSON
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
@@ -26,22 +25,331 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
class BSData{
|
|
||||||
friend class CAFE;
|
|
||||||
private:
|
|
||||||
double val;
|
|
||||||
epicsTimeStamp ets;
|
|
||||||
int status;
|
|
||||||
public:
|
|
||||||
double getValue() {return val;}
|
|
||||||
epicsTimeStamp getEpicsTimeStamp() {return ets;}
|
|
||||||
int getStatus() { return status;}
|
|
||||||
|
|
||||||
BSData(){};
|
class BSChannel {
|
||||||
|
private:
|
||||||
|
string name;
|
||||||
|
int modulo;
|
||||||
|
int offset;
|
||||||
|
HandleHelper helper;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PVDataHolder pvd;
|
||||||
|
std::vector<std::string> pv;
|
||||||
|
//void setName(string _name) { name=_name;}
|
||||||
|
void setOffset(int _offset) { offset=_offset;}
|
||||||
|
void setModulo(int _modulo) { modulo=_modulo;}
|
||||||
|
string getName(){return name;}
|
||||||
|
int getModulo(){return modulo;}
|
||||||
|
int getOffset(){return offset;}
|
||||||
|
BSChannel(string _name): modulo(1), offset(0) {
|
||||||
|
char pv[PVNAME_SIZE];
|
||||||
|
helper.removeLeadingAndTrailingSpaces(_name.c_str(), pv);
|
||||||
|
name=(string) pv;};
|
||||||
|
BSChannel(string _name, int _modulo): offset(0) {
|
||||||
|
char pv[PVNAME_SIZE];
|
||||||
|
helper.removeLeadingAndTrailingSpaces(_name.c_str(), pv);
|
||||||
|
name=(string) pv; modulo=_modulo;};
|
||||||
|
BSChannel(string _name, int _modulo, int _offset) {
|
||||||
|
char pv[PVNAME_SIZE];
|
||||||
|
helper.removeLeadingAndTrailingSpaces(_name.c_str(), pv);
|
||||||
|
name=(string) pv; modulo=_modulo; offset=_offset;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BSDataHolder{
|
||||||
|
friend class CAFE;
|
||||||
|
private:
|
||||||
|
int overallStatus;
|
||||||
|
unsigned long long pulse_id;
|
||||||
|
vector<BSChannel> bsChannel;
|
||||||
|
HandleHelper helper;
|
||||||
|
|
||||||
|
std::vector<std::string> pv;
|
||||||
|
|
||||||
|
bool isBS;
|
||||||
|
bool BSInitialized;
|
||||||
|
void *context;
|
||||||
|
|
||||||
|
void *receiver;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
#if HAVE_JSON
|
||||||
|
Json::Value parsedFromString;
|
||||||
|
Json::Reader reader;
|
||||||
|
#endif
|
||||||
|
bool parsingSuccessful;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
BSDataHolder(){};
|
||||||
|
|
||||||
|
void *subscriber;
|
||||||
|
|
||||||
|
vector<double> getAsDoubleV() {
|
||||||
|
vector<double> V;
|
||||||
|
V.reserve(bsChannel.size());
|
||||||
|
for (size_t i=0; i<bsChannel.size(); ++i){
|
||||||
|
V.push_back(bsChannel[i].pvd.getAsDouble());
|
||||||
|
}
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<string> getAsStringV() {
|
||||||
|
vector<string> V;
|
||||||
|
V.reserve(bsChannel.size());
|
||||||
|
for (size_t i=0; i<bsChannel.size(); ++i){
|
||||||
|
V.push_back(bsChannel[i].pvd.getAsString());
|
||||||
|
}
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<int> getAsIntV() {
|
||||||
|
vector<int> V;
|
||||||
|
V.reserve(bsChannel.size());
|
||||||
|
for (size_t i=0; i<bsChannel.size(); ++i){
|
||||||
|
V.push_back(bsChannel[i].pvd.getAsInt());
|
||||||
|
}
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<double> getAttributeAsDoubleV(string attribute) {
|
||||||
|
vector<double> V;
|
||||||
|
V.reserve(bsChannel.size());
|
||||||
|
char pvAtt[PVNAME_SIZE];
|
||||||
|
helper.removeLeadingAndTrailingSpaces(attribute.c_str(), pvAtt);
|
||||||
|
for (size_t i=0; i<bsChannel.size(); ++i){
|
||||||
|
if ( ((string)pvAtt).compare((string) bsChannel[i].pvd.getAttribute()) ==0){
|
||||||
|
V.push_back(bsChannel[i].pvd.getAsDouble());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
|
PVDataHolder getPVData(unsigned int idx) {
|
||||||
|
if (idx > (bsChannel.size()-1)) {
|
||||||
|
idx=bsChannel.size()-1;
|
||||||
|
}
|
||||||
|
return bsChannel[idx].pvd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PVDataHolder getPVData(string name) {
|
||||||
|
|
||||||
|
for (size_t i=0; i< bsChannel.size(); ++i) {
|
||||||
|
if (bsChannel[i].getName().compare(name) ==0 ) {
|
||||||
|
return bsChannel[i].pvd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getStatus() { return overallStatus;}
|
||||||
|
|
||||||
|
|
||||||
|
static size_t RecvResponseCallback(char * contents, size_t size, size_t nmemb, void * up) {
|
||||||
|
|
||||||
|
++nCBs;
|
||||||
|
//cout << "Callback called: " << nCBs << endl;
|
||||||
|
//cout << "SIZE No. of Bytes " << size*nmemb << endl;
|
||||||
|
|
||||||
|
string sLocal=contents;
|
||||||
|
|
||||||
|
//remove \n for newline
|
||||||
|
std::size_t found = sLocal.find('\n');
|
||||||
|
|
||||||
|
if (found != std::string::npos) {
|
||||||
|
|
||||||
|
sLocal=sLocal.substr(0, found);
|
||||||
|
}
|
||||||
|
|
||||||
|
contentsBS=contentsBS+sLocal;
|
||||||
|
|
||||||
|
return (size_t) size * nmemb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool setBS(bool BSFlag) {
|
||||||
|
|
||||||
|
if(MUTEX){cafeMutex.lock();}
|
||||||
|
|
||||||
|
if (BSFlag) {
|
||||||
|
#if HAVE_CURL
|
||||||
|
|
||||||
|
string dataChannels=string("{\"channels\":[");
|
||||||
|
vector<string> pvNew=pv;
|
||||||
|
|
||||||
|
#if HAVE_ZEROMQ
|
||||||
|
|
||||||
|
if (!BSInitialized) {
|
||||||
|
|
||||||
|
//size_t found;
|
||||||
|
dataChannels= dataChannels + string("{\"name\":\"");
|
||||||
|
dataChannels= dataChannels + pvNew[0];
|
||||||
|
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}" );
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=1; i < pvNew.size(); ++i) {
|
||||||
|
dataChannels= dataChannels + string(",{\"name\":\"");
|
||||||
|
dataChannels= dataChannels + pvNew[i];
|
||||||
|
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}");
|
||||||
|
}
|
||||||
|
|
||||||
|
dataChannels= dataChannels + string("],");
|
||||||
|
dataChannels= dataChannels + "\"mapping\":{\"incomplete\":\"fill-null\"},\"channelValidation\":{\"inconsistency\":\"keep-as-is\"},\"sendBehaviour\":{\"strategy\":\"complete-all\"}}";
|
||||||
|
|
||||||
|
cout << dataChannels << endl;
|
||||||
|
|
||||||
|
const char * data = dataChannels.c_str();
|
||||||
|
|
||||||
|
///cout << "SIZE OF DATA --------------->" << sizeof(data) << endl;
|
||||||
|
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res;
|
||||||
|
struct curl_slist * slist;
|
||||||
|
slist = NULL;
|
||||||
|
|
||||||
|
slist = curl_slist_append(slist, "Content-Type: application/json");
|
||||||
|
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
|
||||||
|
if (curl) {
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "https://dispatcher-api.psi.ch/sf/stream");
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); //"-F file=@./dbpm.json"); //data); //
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
|
||||||
|
//cout << "WAITING FOR CALLBACK... " << endl;
|
||||||
|
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &RecvResponseCallback);
|
||||||
|
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
if (res != CURLE_OK) {
|
||||||
|
cout << "curl_easy_perform failed " << curl_easy_strerror(res) << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << " CALLBACK DONE" << endl;
|
||||||
|
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
curl_slist_free_all(slist);
|
||||||
|
|
||||||
|
slist=NULL;
|
||||||
|
}
|
||||||
|
}//if curl
|
||||||
|
|
||||||
|
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
||||||
|
curl_global_cleanup();
|
||||||
|
|
||||||
|
|
||||||
|
//cout << " //1// SHOW contentS " << endl;
|
||||||
|
//cout << contentsBS.c_str() << endl;
|
||||||
|
|
||||||
|
Json::Value parsedFromString;
|
||||||
|
Json::Reader reader;
|
||||||
|
bool parsingSuccessful;
|
||||||
|
|
||||||
|
Json::FastWriter fastWriter;
|
||||||
|
string globalBSZmqStream="";
|
||||||
|
//printf("value= %s\n", contentsBS.c_str());
|
||||||
|
|
||||||
|
if (contentsBS.size() > 2) {
|
||||||
|
parsingSuccessful=reader.parse(contentsBS.c_str(), parsedFromString);
|
||||||
|
if (parsingSuccessful) {
|
||||||
|
//Json::StyledWriter styledWriter;
|
||||||
|
//cout << "STYLED: --------------------------------" << endl;
|
||||||
|
//cout << styledWriter.write(parsedFromString) << endl;
|
||||||
|
//cout << "----------------------------------" << endl;
|
||||||
|
cout << parsedFromString["stream"] << endl;
|
||||||
|
|
||||||
|
cout << "----------------------------------" << endl;
|
||||||
|
globalBSZmqStream = fastWriter.write(parsedFromString["stream"]).c_str();
|
||||||
|
cout << globalBSZmqStream << endl;
|
||||||
|
|
||||||
|
if ( parsedFromString["stream"].isNull() ) {
|
||||||
|
globalBSZmqStream.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "PARSING IN CURL CALLBACK FUNCTION WAS UNSUCCESSFUL !!!" << endl;
|
||||||
|
cout << contentsBS.c_str() << endl;
|
||||||
|
cout << reader.getFormattedErrorMessages() << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (globalBSZmqStream.empty()) {
|
||||||
|
cout << "BS Data is not available " << endl;
|
||||||
|
return isBS=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
context = zmq_ctx_new ();
|
||||||
|
|
||||||
|
//// receiver = zmq_socket (context, ZMQ_PULL);
|
||||||
|
//HWM has no effect for PULL
|
||||||
|
//See documentation on zmq-socket
|
||||||
|
//WHEN PUSH Sender reachers HWM, then it blocks
|
||||||
|
//// int nhwm=10;
|
||||||
|
//// zmq_setsockopt (receiver,ZMQ_RCVHWM ,&nhwm, sizeof(int));
|
||||||
|
// rc = zmq_bind (receiver, "tcp://129.129.145.206:5558"); //ZMQ_PULL
|
||||||
|
//// assert (rc == 0);
|
||||||
|
|
||||||
|
subscriber = zmq_socket (context, ZMQ_SUB);
|
||||||
|
|
||||||
|
|
||||||
|
globalBSZmqStream=globalBSZmqStream.substr(1,globalBSZmqStream.size()-3);
|
||||||
|
//cout << " globalBSZmqStream.c_str() " << globalBSZmqStream.c_str() << endl;
|
||||||
|
|
||||||
|
rc = zmq_connect (subscriber, (const char *) globalBSZmqStream.c_str());
|
||||||
|
|
||||||
|
if (rc != 0 ) {
|
||||||
|
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
|
int nhwm=1;
|
||||||
|
int timeoutMS=200; //10; //-1 Wait for Ever
|
||||||
|
|
||||||
|
rc=zmq_setsockopt (subscriber,ZMQ_RCVHWM, &nhwm, sizeof(int));
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
|
rc=zmq_setsockopt (subscriber,ZMQ_RCVTIMEO, &timeoutMS, sizeof(int));
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
|
rc=zmq_setsockopt (subscriber,ZMQ_SUBSCRIBE,"",0);
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
|
BSInitialized=true;
|
||||||
|
|
||||||
|
}//is BS initialized
|
||||||
|
|
||||||
|
#endif //have zeromq
|
||||||
|
|
||||||
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
|
return isBS=BSFlag;
|
||||||
|
#else //have curl
|
||||||
|
|
||||||
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
|
return isBS=false;
|
||||||
|
#endif //have curl
|
||||||
|
}//isBSFlag
|
||||||
|
|
||||||
|
|
||||||
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
|
return isBS=BSFlag;
|
||||||
|
} // setBS
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
class RFData{
|
class RFData{
|
||||||
friend class CAFE;
|
friend class CAFE;
|
||||||
private:
|
private:
|
||||||
@@ -88,6 +396,8 @@ private:
|
|||||||
std::vector<double> offs_x;
|
std::vector<double> offs_x;
|
||||||
std::vector<double> offs_y;
|
std::vector<double> offs_y;
|
||||||
|
|
||||||
|
unsigned long long pulse_id;
|
||||||
|
|
||||||
bool isAllXOK;
|
bool isAllXOK;
|
||||||
bool isAllYOK;
|
bool isAllYOK;
|
||||||
bool isAllQOK;
|
bool isAllQOK;
|
||||||
@@ -102,24 +412,22 @@ private:
|
|||||||
size_t nDBPM;
|
size_t nDBPM;
|
||||||
size_t nPV;
|
size_t nPV;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool isBS;
|
bool isBS;
|
||||||
bool BSInitialized;
|
bool BSInitialized;
|
||||||
void *context;
|
void *context;
|
||||||
|
|
||||||
void *receiver;
|
void *receiver;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
#if HAVE_JSON
|
#if HAVE_JSON
|
||||||
Json::Value parsedFromString;
|
Json::Value parsedFromString;
|
||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
bool parsingSuccessful;
|
|
||||||
#endif
|
#endif
|
||||||
|
bool parsingSuccessful;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
std::vector<DBPMData> getX() { return x;}
|
std::vector<DBPMData> getX() { return x;}
|
||||||
std::vector<DBPMData> getY() { return y;}
|
std::vector<DBPMData> getY() { return y;}
|
||||||
std::vector<DBPMData> getQ() { return q;}
|
std::vector<DBPMData> getQ() { return q;}
|
||||||
std::vector<DBPMData> getEnergy() { return energy;}
|
std::vector<DBPMData> getEnergy() { return energy;}
|
||||||
@@ -135,7 +443,7 @@ public:
|
|||||||
bool getIsAllOK() {return isAllOK;}
|
bool getIsAllOK() {return isAllOK;}
|
||||||
|
|
||||||
std::vector<std::string> getPV(){ return pv;}
|
std::vector<std::string> getPV(){ return pv;}
|
||||||
std::vector<unsigned int> getHandle() { return handle;}
|
std::vector<unsigned int> getHandle() { return handle;}
|
||||||
std::vector<std::string> getDevice() { return device;}
|
std::vector<std::string> getDevice() { return device;}
|
||||||
std::vector<float> getS() { return s;}
|
std::vector<float> getS() { return s;}
|
||||||
size_t getNDBPM() {return nDBPM;}
|
size_t getNDBPM() {return nDBPM;}
|
||||||
@@ -144,16 +452,18 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
int getPVIdx(string _pv) {
|
int getPVIdx(string _pv) {
|
||||||
|
|
||||||
for (size_t i=0; i< pv.size(); ++i) {
|
for (size_t i=0; i< pv.size(); ++i) {
|
||||||
|
|
||||||
if ( pv[i].compare(_pv) == 0) {
|
if ( pv[i].compare(_pv) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long long getPulse_id(){return pulse_id;}
|
||||||
|
void setPulse_id(unsigned long long _pulse_id){pulse_id=_pulse_id;}
|
||||||
|
|
||||||
PVDataHolder * pvd;
|
PVDataHolder * pvd;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@@ -168,26 +478,15 @@ public:
|
|||||||
|
|
||||||
void *subscriber;
|
void *subscriber;
|
||||||
|
|
||||||
//struct MemoryStruct {
|
|
||||||
// char *memory;
|
|
||||||
// size_t size;
|
|
||||||
//};
|
|
||||||
|
|
||||||
static size_t RecvResponseCallback(char * contents, size_t size, size_t nmemb, void * up) {
|
static size_t RecvResponseCallback(char * contents, size_t size, size_t nmemb, void * up) {
|
||||||
|
|
||||||
++nCBs;
|
++nCBs;
|
||||||
cout << "Callback called: " << nCBs << endl;
|
//cout << "Callback called: " << nCBs << endl;
|
||||||
|
//cout << "SIZE No. of Bytes " << size*nmemb << endl;
|
||||||
///Json::Value parsedFromString;
|
|
||||||
///Json::Reader reader;
|
|
||||||
///bool parsingSuccessful;
|
|
||||||
|
|
||||||
///Json::FastWriter fastWriter;
|
|
||||||
|
|
||||||
cout << "SIZE No. of Bytes " << size*nmemb << endl;
|
|
||||||
|
|
||||||
string sLocal=contents;
|
string sLocal=contents;
|
||||||
|
|
||||||
|
//remove \n for newline
|
||||||
std::size_t found = sLocal.find('\n');
|
std::size_t found = sLocal.find('\n');
|
||||||
|
|
||||||
if (found != std::string::npos) {
|
if (found != std::string::npos) {
|
||||||
@@ -197,85 +496,12 @@ public:
|
|||||||
|
|
||||||
contentsS=contentsS+sLocal;
|
contentsS=contentsS+sLocal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if (nCBs%3==1) {
|
|
||||||
// return size*nmemb;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//printf("value= %s\n", contents);
|
|
||||||
/*
|
|
||||||
if (contents != NULL) {
|
|
||||||
parsingSuccessful=reader.parse(contentsS.c_str(), parsedFromString);
|
|
||||||
if (parsingSuccessful) {
|
|
||||||
//Json::StyledWriter styledWriter;
|
|
||||||
cout << "STYLED: --------------------------------" << endl;
|
|
||||||
//cout << styledWriter.write(parsedFromString) << endl;
|
|
||||||
//cout << "----------------------------------" << endl;
|
|
||||||
cout << parsedFromString["stream"] << endl;
|
|
||||||
|
|
||||||
cout << "----------------------------------" << endl;
|
|
||||||
globalZmqStream = fastWriter.write(parsedFromString["stream"]).c_str();
|
|
||||||
cout << globalZmqStream << endl;
|
|
||||||
|
|
||||||
if ( parsedFromString["stream"].isNull() ) {
|
|
||||||
globalZmqStream.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cout << "PARSING IN CURL CALLBACK FUNCTION WAS UNSUCCESSFUL !!!" << endl;
|
|
||||||
|
|
||||||
cout << reader.getFormattedErrorMessages() << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
contentsS="";
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
size_t realsize = size * nmemb;
|
|
||||||
struct MemoryStruct *mem = (struct MemoryStruct *)data;
|
|
||||||
|
|
||||||
mem->memory = (char *) realloc(mem->memory, (mem->size + realsize + 1));
|
|
||||||
|
|
||||||
if(mem->memory == NULL) {
|
|
||||||
|
|
||||||
printf("not enough memory (realloc returned NULL)\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&(mem->memory[mem->size]), contents, realsize);
|
|
||||||
mem->size += realsize;
|
|
||||||
mem->memory[mem->size] = 0;
|
|
||||||
|
|
||||||
//return realsize;
|
|
||||||
|
|
||||||
printf("value= %s\n",mem->memory);
|
|
||||||
if (mem->memory != NULL) {
|
|
||||||
parsingSuccessful=reader.parse(mem->memory, parsedFromString);
|
|
||||||
if (parsingSuccessful) {
|
|
||||||
Json::StyledWriter styledWriter;
|
|
||||||
cout << "STYLED: --------------------------------" << endl;
|
|
||||||
cout << styledWriter.write(parsedFromString) << endl;
|
|
||||||
cout << "----------------------------------" << endl;
|
|
||||||
cout << parsedFromString["stream"] << endl;
|
|
||||||
|
|
||||||
cout << "----------------------------------" << endl;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return (size_t) size * nmemb;
|
return (size_t) size * nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
bool resetBS() {
|
||||||
|
|
||||||
|
|
||||||
bool resetBS() {
|
|
||||||
closeBS();
|
closeBS();
|
||||||
return setBS(true);
|
return setBS(true);
|
||||||
}
|
}
|
||||||
@@ -283,93 +509,50 @@ public:
|
|||||||
|
|
||||||
bool setBS(bool BSFlag) {
|
bool setBS(bool BSFlag) {
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.lock();}
|
if(MUTEX){cafeMutex.lock();}
|
||||||
|
|
||||||
|
if (BSFlag) {
|
||||||
|
#if HAVE_CURL
|
||||||
|
|
||||||
if (BSFlag) {
|
string dataChannels=string("{\"channels\":[");
|
||||||
#if HAVE_CURL
|
vector<string> pvNew=pv;
|
||||||
/*
|
|
||||||
//Complete all or complete latest
|
|
||||||
//const char * data="{\"channels\":[{\"name\":\"S10BC01-DBPM010:X1\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}, \
|
|
||||||
{\"name\":\"S10BC01-DBPM010:X1-VALID\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0} \
|
|
||||||
],\"mapping\":{\"incomplete\":\"fill-null\"},\"channelValidation\":{\"inconsistency\":\"adjust-global\"},\"sendBehaviour\":{\"strategy\":\"complete-all\"}}";
|
|
||||||
*/
|
|
||||||
string dataChannels=string("{\"channels\":[");
|
|
||||||
|
|
||||||
vector<string> pvNew=pv;
|
#if HAVE_ZEROMQ
|
||||||
#if HAVE_ZEROMQ
|
|
||||||
if (!BSInitialized) {
|
if (!BSInitialized) {
|
||||||
//pvNew.push_back("SINEG01-DBPM340:X1") ;
|
|
||||||
//pvNew.push_back("SINSB01-DBPM150:X1") ;
|
|
||||||
//pvNew.push_back("SINSB02-DBPM150:X1") ;
|
|
||||||
//pvNew.push_back("SINLH01-DBPM060:X1") ;
|
|
||||||
//pvNew.push_back("SINLH02-DBPM210:X1") ;
|
|
||||||
//pvNew.push_back("SINLH02-DBPM240:X1") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM010:X1") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM050:X1") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM090:X1") ;
|
|
||||||
//pvNew.push_back("SINSB03-DBPM120:X1") ;
|
|
||||||
//pvNew.push_back("SINSB03-DBPM220:X1") ;
|
|
||||||
//pvNew.push_back("SINSB04-DBPM120:X1") ;
|
|
||||||
//pvNew.push_back("SINSB04-DBPM220:X1") ;
|
|
||||||
|
|
||||||
//pvNew.push_back("SINEG01-DBPM340:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB01-DBPM150:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB02-DBPM150:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH01-DBPM060:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH02-DBPM210:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH02-DBPM240:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM010:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM050:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINLH03-DBPM090:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB03-DBPM120:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB03-DBPM220:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB04-DBPM120:X1-VALID") ;
|
|
||||||
//pvNew.push_back("SINSB04-DBPM220:X1-VALID") ;
|
|
||||||
size_t found;
|
size_t found;
|
||||||
dataChannels= dataChannels + string("{\"name\":\"");
|
dataChannels= dataChannels + string("{\"name\":\"");
|
||||||
dataChannels= dataChannels + pvNew[0];
|
dataChannels= dataChannels + pvNew[0];
|
||||||
//dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\"}" );
|
//dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\"}" );
|
||||||
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}" );
|
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}" );
|
||||||
|
|
||||||
|
|
||||||
for (size_t i=1; i < pvNew.size(); ++i) {
|
for (size_t i=1; i < pvNew.size(); ++i) {
|
||||||
|
|
||||||
|
found = pvNew[i].find("SARUN08-DBPM210");
|
||||||
found = pvNew[i].find("SARUN08-DBPM210");
|
|
||||||
if (found != std::string::npos) continue;
|
if (found != std::string::npos) continue;
|
||||||
found = pvNew[i].find("SARUN08-DBPM410");
|
found = pvNew[i].find("SARUN08-DBPM410");
|
||||||
if (found != std::string::npos) continue;
|
if (found != std::string::npos) continue;
|
||||||
//found = pvNew[i].find("Y1");
|
|
||||||
//if (found != std::string::npos) continue;
|
|
||||||
//found = pvNew[i].find("X1");
|
|
||||||
//if (found != std::string::npos) continue;
|
|
||||||
found = pvNew[i].find("ENERGY");
|
found = pvNew[i].find("ENERGY");
|
||||||
if (found != std::string::npos) continue;
|
if (found != std::string::npos) continue;
|
||||||
|
|
||||||
|
|
||||||
dataChannels= dataChannels + string(",{\"name\":\"");
|
dataChannels= dataChannels + string(",{\"name\":\"");
|
||||||
dataChannels= dataChannels + pvNew[i];
|
dataChannels= dataChannels + pvNew[i];
|
||||||
|
|
||||||
//found = pv[i+1].find("ENERGY");
|
|
||||||
//if (found != std::string::npos) break;
|
|
||||||
//dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\"}");
|
|
||||||
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}");
|
dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\",\"modulo\":1,\"offset\":0}");
|
||||||
|
|
||||||
}
|
}
|
||||||
//dataChannels= dataChannels + string("{\"name\":\"");
|
|
||||||
//dataChannels= dataChannels + pv[pv.size()-1];
|
dataChannels= dataChannels + string("],");
|
||||||
//dataChannels= dataChannels + string("\",\"backend\":\"sf-databuffer\"}],");
|
dataChannels= dataChannels + "\"mapping\":{\"incomplete\":\"fill-null\"},\"channelValidation\":{\"inconsistency\":\"keep-as-is\"},\"sendBehaviour\":{\"strategy\":\"complete-all\"}}";
|
||||||
dataChannels= dataChannels + string("],");
|
|
||||||
dataChannels= dataChannels + "\"mapping\":{\"incomplete\":\"fill-null\"},\"channelValidation\":{\"inconsistency\":\"keep-as-is\"},\"sendBehaviour\":{\"strategy\":\"complete-all\"}}";
|
|
||||||
|
|
||||||
cout << dataChannels << endl;
|
cout << dataChannels << endl;
|
||||||
|
|
||||||
//sleep(1);
|
|
||||||
const char * data = dataChannels.c_str();
|
const char * data = dataChannels.c_str();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///cout << "SIZE OF DATA --------------->" << sizeof(data) << endl;
|
///cout << "SIZE OF DATA --------------->" << sizeof(data) << endl;
|
||||||
|
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
@@ -381,173 +564,142 @@ if (!BSInitialized) {
|
|||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (curl) {
|
if (curl) {
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "https://dispatcher-api.psi.ch/sf/stream");
|
curl_easy_setopt(curl, CURLOPT_URL, "https://dispatcher-api.psi.ch/sf/stream");
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); //"-F file=@./request.json"); //data); //
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); //"-F file=@./dbpm.json"); //data); //
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
|
||||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
|
|
||||||
cout << "WAITING FOR CALLBACK " << endl;
|
//cout << "WAITING FOR CALLBACK... " << endl;
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &RecvResponseCallback);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &RecvResponseCallback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
if (res != CURLE_OK) {
|
if (res != CURLE_OK) {
|
||||||
cout << "curl_easy_perform failed " << curl_easy_strerror(res) << endl;
|
cout << "curl_easy_perform failed " << curl_easy_strerror(res) << endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cout << " CALLBACK DONE" << endl;
|
cout << " CALLBACK DONE" << endl;
|
||||||
|
|
||||||
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
curl_easy_cleanup(curl);
|
curl_slist_free_all(slist);
|
||||||
|
|
||||||
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
slist=NULL;
|
||||||
curl=NULL;
|
|
||||||
|
|
||||||
curl_slist_free_all(slist);
|
|
||||||
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
|
||||||
slist=NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}//if curl
|
||||||
|
|
||||||
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//cout << " //1// SHOW contentS " << endl;
|
//cout << " //1// SHOW contentS " << endl;
|
||||||
//cout << contentsS.c_str() << endl;
|
//cout << contentsS.c_str() << endl;
|
||||||
|
|
||||||
|
|
||||||
//sleep(1);
|
|
||||||
|
|
||||||
Json::Value parsedFromString;
|
Json::Value parsedFromString;
|
||||||
Json::Reader reader;
|
Json::Reader reader;
|
||||||
bool parsingSuccessful;
|
bool parsingSuccessful;
|
||||||
|
|
||||||
Json::FastWriter fastWriter;
|
Json::FastWriter fastWriter;
|
||||||
|
string globalZmqStream;
|
||||||
|
|
||||||
|
|
||||||
//printf("value= %s\n", contentsS.c_str());
|
//printf("value= %s\n", contentsS.c_str());
|
||||||
|
|
||||||
|
|
||||||
if (contentsS.size() > 2) {
|
if (contentsS.size() > 2) {
|
||||||
parsingSuccessful=reader.parse(contentsS.c_str(), parsedFromString);
|
parsingSuccessful=reader.parse(contentsS.c_str(), parsedFromString);
|
||||||
if (parsingSuccessful) {
|
if (parsingSuccessful) {
|
||||||
//Json::StyledWriter styledWriter;
|
//Json::StyledWriter styledWriter;
|
||||||
cout << "STYLED: --------------------------------" << endl;
|
cout << "STYLED: --------------------------------" << endl;
|
||||||
//cout << styledWriter.write(parsedFromString) << endl;
|
//cout << styledWriter.write(parsedFromString) << endl;
|
||||||
//cout << "----------------------------------" << endl;
|
//cout << "----------------------------------" << endl;
|
||||||
cout << parsedFromString["stream"] << endl;
|
cout << parsedFromString["stream"] << endl;
|
||||||
|
|
||||||
cout << "----------------------------------" << endl;
|
cout << "----------------------------------" << endl;
|
||||||
globalZmqStream = fastWriter.write(parsedFromString["stream"]).c_str();
|
globalZmqStream = fastWriter.write(parsedFromString["stream"]).c_str();
|
||||||
cout << globalZmqStream << endl;
|
cout << globalZmqStream << endl;
|
||||||
|
|
||||||
if ( parsedFromString["stream"].isNull() ) {
|
if ( parsedFromString["stream"].isNull() ) {
|
||||||
globalZmqStream.clear();
|
globalZmqStream.clear();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
cout << "PARSING IN CURL CALLBACK FUNCTION WAS UNSUCCESSFUL !!!" << endl;
|
else {
|
||||||
cout << contentsS.c_str() << endl;
|
cout << "PARSING IN CURL CALLBACK FUNCTION WAS UNSUCCESSFUL !!!" << endl;
|
||||||
cout << reader.getFormattedErrorMessages() << endl;
|
cout << contentsS.c_str() << endl;
|
||||||
|
cout << reader.getFormattedErrorMessages() << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (globalZmqStream.empty()) {
|
||||||
|
cout << "BS Data is not available " << endl;
|
||||||
|
return isBS=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
context = zmq_ctx_new ();
|
||||||
|
|
||||||
//
|
//// receiver = zmq_socket (context, ZMQ_PULL);
|
||||||
//#if HAVE_ZEROMQ
|
//HWM has no effect for PULL
|
||||||
//if (!BSInitialized) {
|
//See documentation on zmq-socket
|
||||||
|
//WHEN PUSH Sender reachers HWM, then it blocks
|
||||||
|
//// int nhwm=10;
|
||||||
|
//// zmq_setsockopt (receiver,ZMQ_RCVHWM ,&nhwm, sizeof(int));
|
||||||
|
// rc = zmq_bind (receiver, "tcp://129.129.145.206:5558"); //ZMQ_PULL
|
||||||
|
//// assert (rc == 0);
|
||||||
|
|
||||||
|
subscriber = zmq_socket (context, ZMQ_SUB);
|
||||||
|
//rc = zmq_connect (subscriber, "tcp://129.129.145.206:5556");
|
||||||
|
//rc = zmq_connect (subscriber, "tcp://SIN-CVME-DBPM0421:9000");
|
||||||
|
|
||||||
cout << "TESTING STREAM... " << endl;
|
globalZmqStream=globalZmqStream.substr(1,globalZmqStream.size()-3);
|
||||||
|
//cout << " globalZmqStream.c_str() " << globalZmqStream.c_str() << endl;
|
||||||
|
|
||||||
|
rc = zmq_connect (subscriber, (const char *) globalZmqStream.c_str()); //"tcp://sf-daqbuf-30.psi.ch:39927");
|
||||||
|
|
||||||
if (globalZmqStream.empty()) {
|
if (rc != 0 ) {
|
||||||
cout << "BS Data is not available " << endl;
|
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
||||||
return isBS=false;
|
}
|
||||||
}
|
|
||||||
// else {
|
|
||||||
// cout << globalZmqStream.c_str() << " is not empty " << endl;
|
|
||||||
|
|
||||||
// }
|
//rc = zmq_connect (subscriber, "tcp://*:9999");
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
|
int nhwm=1;
|
||||||
|
int timeoutMS=200; //10; //-1 Wait for Ever
|
||||||
|
|
||||||
context = zmq_ctx_new ();
|
rc=zmq_setsockopt (subscriber,ZMQ_RCVHWM, &nhwm, sizeof(int));
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
/// receiver = zmq_socket (context, ZMQ_PULL);
|
rc=zmq_setsockopt (subscriber,ZMQ_RCVTIMEO, &timeoutMS, sizeof(int));
|
||||||
//HWM has no effect for PULL
|
assert (rc == 0);
|
||||||
//See documentation on zmq-socket
|
|
||||||
//WHEN PUSH Sender reachers HWM, then it blocks
|
|
||||||
/// int nhwm=10;
|
|
||||||
/// zmq_setsockopt (receiver,ZMQ_RCVHWM ,&nhwm, sizeof(int));
|
|
||||||
//rc = zmq_bind (receiver, "tcp://129.129.145.206:5558"); //ZMQ_PULL
|
|
||||||
/// rc = zmq_bind (receiver, "tcp://SIN-CVME-DBPM0421:9000");
|
|
||||||
/// assert (rc == 0);
|
|
||||||
|
|
||||||
|
rc=zmq_setsockopt (subscriber,ZMQ_SUBSCRIBE,"",0);
|
||||||
|
assert (rc == 0);
|
||||||
|
|
||||||
subscriber = zmq_socket (context, ZMQ_SUB);
|
BSInitialized=true;
|
||||||
//rc = zmq_connect (subscriber, "tcp://129.129.145.206:5556");
|
|
||||||
//rc = zmq_connect (subscriber, "tcp://SIN-CVME-DBPM0421:9000");
|
|
||||||
|
|
||||||
|
}//is BS initialized
|
||||||
|
|
||||||
|
#endif //have zeromq
|
||||||
globalZmqStream=globalZmqStream.substr(1,globalZmqStream.size()-3);
|
|
||||||
//cout << " globalZmqStream.c_str() " << globalZmqStream.c_str() << endl;
|
|
||||||
//sleep(1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rc = zmq_connect (subscriber, (const char *) globalZmqStream.c_str()); // "tcp://sf-daqbuf-28.psi.ch:42465"); // //"tcp://sf-daqbuf-30.psi.ch:39927");
|
|
||||||
|
|
||||||
if (rc != 0 ) {
|
|
||||||
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
//rc = zmq_connect (subscriber, "tcp://*:9999");
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
int nhwm=1;
|
|
||||||
int timeoutMS=400; //10; //-1 Wait for Ever
|
|
||||||
|
|
||||||
rc=zmq_setsockopt (subscriber,ZMQ_RCVHWM ,&nhwm, sizeof(int));
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
rc=zmq_setsockopt (subscriber,ZMQ_RCVTIMEO ,&timeoutMS, sizeof(int));
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
rc=zmq_setsockopt (subscriber,ZMQ_SUBSCRIBE,"",0);
|
|
||||||
assert (rc == 0);
|
|
||||||
|
|
||||||
BSInitialized=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.unlock();}
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
return isBS=BSFlag;
|
return isBS=BSFlag;
|
||||||
#else
|
#else //have curl
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.unlock();}
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
return isBS=false;
|
return isBS=false;
|
||||||
#endif
|
#endif //have curl
|
||||||
}
|
}//isBSFlag
|
||||||
|
|
||||||
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
|
return isBS=BSFlag;
|
||||||
|
} // setBS
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.unlock();}
|
|
||||||
return isBS=BSFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool setCA(bool CAFlag) {
|
bool setCA(bool CAFlag) {
|
||||||
return CAFlag;
|
return CAFlag;
|
||||||
@@ -582,13 +734,13 @@ if (!BSInitialized) {
|
|||||||
s.push_back(pos->first); device.push_back(pos->second);
|
s.push_back(pos->first); device.push_back(pos->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
pvd = new PVDataHolder[handle.size()];
|
pvd = new PVDataHolder[handle.size()];
|
||||||
|
|
||||||
//for (int i=0; i< handle.size(); ++i) {
|
//for (int i=0; i< handle.size(); ++i) {
|
||||||
// pvd[i].setNelem(1);
|
// pvd[i].setNelem(1);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
nDBPM=device.size();
|
nDBPM=device.size();
|
||||||
nPV=_pv.size();
|
nPV=_pv.size();
|
||||||
status=ICAFE_NORMAL;
|
status=ICAFE_NORMAL;
|
||||||
|
|
||||||
@@ -612,13 +764,13 @@ if (!BSInitialized) {
|
|||||||
device.assign(_dev.begin(), _dev.end());
|
device.assign(_dev.begin(), _dev.end());
|
||||||
s.assign(_pos.begin(), _pos.end());
|
s.assign(_pos.begin(), _pos.end());
|
||||||
|
|
||||||
pvd = new PVDataHolder[handle.size()];
|
pvd = new PVDataHolder[handle.size()];
|
||||||
|
|
||||||
//for (int i=0; i< handle.size(); ++i) {
|
//for (int i=0; i< handle.size(); ++i) {
|
||||||
// pvd[i].setNelem(1);
|
// pvd[i].setNelem(1);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
nDBPM=device.size();
|
nDBPM=device.size();
|
||||||
nPV=_pv.size();
|
nPV=_pv.size();
|
||||||
status=ICAFE_NORMAL;
|
status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
friend struct change_connectionHandlerArgs;
|
friend struct change_connectionHandlerArgs;
|
||||||
friend struct change_eventHandlerArgs;
|
friend struct change_eventHandlerArgs;
|
||||||
//friend struct change_channelRegalia;
|
//friend struct change_channelRegalia;
|
||||||
//friend class Connect;
|
friend class Connect;
|
||||||
friend class HandleHelper;
|
friend class HandleHelper;
|
||||||
friend class Conduit;
|
friend class Conduit;
|
||||||
friend class ConduitGroup;
|
friend class ConduitGroup;
|
||||||
@@ -64,8 +64,8 @@ protected:
|
|||||||
void setReadAccess (unsigned short r){accessRead=r;};
|
void setReadAccess (unsigned short r){accessRead=r;};
|
||||||
void setWriteAccess(unsigned short w){accessWrite=w;};
|
void setWriteAccess(unsigned short w){accessWrite=w;};
|
||||||
void setNelem (unsigned int n) {nelem=n;};
|
void setNelem (unsigned int n) {nelem=n;};
|
||||||
void setConnectionState (long cs) {connectionState=cs;};
|
void setConnectionState (int cs) {connectionState=cs;};
|
||||||
void setCafeConnectionState (long ccs) {cafeConnectionState=ccs;};
|
void setCafeConnectionState (int ccs) {cafeConnectionState=ccs;};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
chid getChannelID() const {return channelID;};
|
chid getChannelID() const {return channelID;};
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ struct change_connectionHandlerArgs
|
|||||||
c.channelRegalia.cafeConnectionState =ICAFE_CS_DISCONN;
|
c.channelRegalia.cafeConnectionState =ICAFE_CS_DISCONN;
|
||||||
c.channelRegalia.connectFlag = false;
|
c.channelRegalia.connectFlag = false;
|
||||||
c.status = ICAFE_CA_OP_CONN_DOWN;
|
c.status = ICAFE_CA_OP_CONN_DOWN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ public:
|
|||||||
|
|
||||||
unsigned int * mHandle;
|
unsigned int * mHandle;
|
||||||
|
|
||||||
|
|
||||||
virtual ~ConduitGroup();
|
virtual ~ConduitGroup();
|
||||||
|
|
||||||
ConduitGroup();
|
ConduitGroup();
|
||||||
@@ -80,6 +81,7 @@ public:
|
|||||||
unsigned int getGroupHandle(void) const {return groupHandle;};
|
unsigned int getGroupHandle(void) const {return groupHandle;};
|
||||||
ChannelTimeoutPolicy getChannelTimeoutPolicySGPut(void) const {return channelTimeoutPolicySGPut;};
|
ChannelTimeoutPolicy getChannelTimeoutPolicySGPut(void) const {return channelTimeoutPolicySGPut;};
|
||||||
ChannelTimeoutPolicy getChannelTimeoutPolicySGGet(void) const {return channelTimeoutPolicySGGet;};
|
ChannelTimeoutPolicy getChannelTimeoutPolicySGGet(void) const {return channelTimeoutPolicySGGet;};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
#include <policyHelper.h>
|
#include <policyHelper.h>
|
||||||
#include <hashConduitGroup.h>
|
#include <hashConduitGroup.h>
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
#if HAVE_BOOST_THREAD
|
#if HAVE_BOOST_THREAD
|
||||||
#include <boost/thread/thread_only.hpp>
|
#include <boost/thread/thread_only.hpp>
|
||||||
#include <boost/chrono.hpp>
|
#include <boost/chrono.hpp>
|
||||||
@@ -51,7 +53,7 @@ class Connect
|
|||||||
|
|
||||||
ExceptionsHelper exceptionsHelper;
|
ExceptionsHelper exceptionsHelper;
|
||||||
|
|
||||||
ChannelCreatePolicy channelCreatePolicy;
|
|
||||||
|
|
||||||
PolicyHelper policyHelper;
|
PolicyHelper policyHelper;
|
||||||
HandleHelper handleHelper;
|
HandleHelper handleHelper;
|
||||||
@@ -94,11 +96,17 @@ class Connect
|
|||||||
|
|
||||||
channelOpenGroupPolicy.setPolicy(
|
channelOpenGroupPolicy.setPolicy(
|
||||||
CAFENUM::FLUSH_AFTER_EACH_GROUP_CREATION,
|
CAFENUM::FLUSH_AFTER_EACH_GROUP_CREATION,
|
||||||
CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_SG_PEND_EVENT);
|
CAFENUM::WITH_POLL, DEFAULT_TIMEOUT_SG_PEND_EVENT);
|
||||||
|
//CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_SG_PEND_EVENT);
|
||||||
|
|
||||||
channelOpenPolicy.setPolicy(
|
channelOpenPolicy.setPolicy(
|
||||||
CAFENUM::FLUSH_AFTER_EACH_CHANNEL_CREATION,
|
CAFENUM::FLUSH_AFTER_EACH_CHANNEL_CREATION,
|
||||||
CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_PEND_EVENT);
|
CAFENUM::WITH_POLL, DEFAULT_TIMEOUT_PEND_EVENT);
|
||||||
|
//CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_PEND_EVENT);
|
||||||
|
|
||||||
|
channelClosePolicy.setPolicy(
|
||||||
|
CAFENUM::FLUSH_AFTER_EACH_CHANNEL_CREATION,
|
||||||
|
CAFENUM::WITH_PEND_IO, DEFAULT_TIMEOUT_PEND_IO);
|
||||||
|
|
||||||
deviceAttributeDeliminator=DEFAULT_DEVICE_ATTRIBUTE_DELIMINATOR;
|
deviceAttributeDeliminator=DEFAULT_DEVICE_ATTRIBUTE_DELIMINATOR;
|
||||||
|
|
||||||
@@ -113,6 +121,8 @@ class Connect
|
|||||||
|
|
||||||
PrintErrorPolicy printErrorPolicy;
|
PrintErrorPolicy printErrorPolicy;
|
||||||
|
|
||||||
|
ChannelCreatePolicy channelCreatePolicy;
|
||||||
|
|
||||||
ChannelOpenPolicy channelOpenPolicy;
|
ChannelOpenPolicy channelOpenPolicy;
|
||||||
ChannelOpenPolicy channelClosePolicy; //can also use for close
|
ChannelOpenPolicy channelClosePolicy; //can also use for close
|
||||||
ChannelOpenPolicy channelMonitorPolicy;
|
ChannelOpenPolicy channelMonitorPolicy;
|
||||||
@@ -148,7 +158,6 @@ class Connect
|
|||||||
CAFEGlobalAlarmCondition getEpicsAlarmCondition() {return epicsAlarmStatus;}
|
CAFEGlobalAlarmCondition getEpicsAlarmCondition() {return epicsAlarmStatus;}
|
||||||
CAFEGlobalAlarmSeverity getEpicsAlarmSeverity() {return epicsAlarmSeverity;}
|
CAFEGlobalAlarmSeverity getEpicsAlarmSeverity() {return epicsAlarmSeverity;}
|
||||||
|
|
||||||
|
|
||||||
int flushNow() {return ca_flush_io();}
|
int flushNow() {return ca_flush_io();}
|
||||||
|
|
||||||
int _ca_flush_io(){return ca_flush_io();}
|
int _ca_flush_io(){return ca_flush_io();}
|
||||||
@@ -191,36 +200,46 @@ class Connect
|
|||||||
|
|
||||||
|
|
||||||
void openGroupPrepare(){
|
void openGroupPrepare(){
|
||||||
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
|
||||||
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openMonitorPrepare(){
|
void openGroupNowAndWait(double _timeout);
|
||||||
channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);
|
|
||||||
channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
void openGroupNowAndWaitForInputGroups(double _timeout, vector<unsigned int> gHandles);
|
||||||
|
|
||||||
|
|
||||||
|
//Pends for default amount of time
|
||||||
|
void openGroupNow() {
|
||||||
|
openGroupNowAndWait(channelOpenGroupPolicy.getTimeout());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double setOpenDefaultPendTime(double _timeout){
|
|
||||||
return channelOpenPolicy.setDefaultTimeout(_timeout);
|
//Same as above - change nanmin convetnion
|
||||||
|
void groupOpenPrepare(){
|
||||||
|
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
|
||||||
|
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getOpenDefaultPendTime(){
|
void groupOpenNowAndWait(double _timeout) { openGroupNowAndWait(_timeout); return; };
|
||||||
return channelOpenPolicy.getDefaultTimeout();
|
void groupOpenNowAndWait(double _timeout, vector<unsigned int> gH)
|
||||||
|
{ openGroupNowAndWaitForInputGroups(_timeout, gH); return; };
|
||||||
|
|
||||||
|
//Pends for default amount of time
|
||||||
|
void groupOpenNow() {
|
||||||
|
openGroupNowAndWait(channelOpenGroupPolicy.getTimeout());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void openGroupNowAndWait(double _timeout){
|
|
||||||
double dto = channelOpenGroupPolicy.getTimeout();
|
//-------------------------------------------------------------------------
|
||||||
channelOpenGroupPolicy.setTimeout(_timeout);
|
void openMonitorPrepare(){
|
||||||
channelOpenGroupPolicy.flushSendBufferNow();
|
channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
||||||
//
|
channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);
|
||||||
//reset
|
|
||||||
channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
|
||||||
channelOpenGroupPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
|
||||||
//channelOpenGroupPolicy.setTimeoutToDefault();
|
|
||||||
channelOpenGroupPolicy.setTimeout(dto);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,44 +253,57 @@ class Connect
|
|||||||
|
|
||||||
void openMonitorNowAndWait(double _timeout){
|
void openMonitorNowAndWait(double _timeout){
|
||||||
channelMonitorPolicy.setTimeout(_timeout);
|
channelMonitorPolicy.setTimeout(_timeout);
|
||||||
|
channelMonitorPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
||||||
channelMonitorPolicy.flushSendBufferNow();
|
channelMonitorPolicy.flushSendBufferNow();
|
||||||
//reset
|
//reset
|
||||||
channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
||||||
channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);
|
channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
double setOpenDefaultPendTime(double _timeout){
|
||||||
|
return channelOpenPolicy.setDefaultTimeout(_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
double getOpenDefaultPendTime(){
|
||||||
|
return channelOpenPolicy.getDefaultTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
void openPrepare() {
|
void openPrepare() {
|
||||||
channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
channelOpenPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
|
||||||
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openNowAndWait(double _timeout) {
|
//Same as openPrepare
|
||||||
double dto = channelOpenPolicy.getTimeout();
|
|
||||||
channelOpenPolicy.setTimeout(_timeout);
|
|
||||||
channelOpenPolicy.flushSendBufferNow();
|
|
||||||
//reset
|
|
||||||
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
|
||||||
channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
|
||||||
//channelOpenPolicy.setTimeoutToDefault();
|
|
||||||
channelOpenPolicy.setTimeout(dto);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void openNow() {
|
|
||||||
channelOpenPolicy.flushSendBufferNow();
|
|
||||||
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
|
||||||
channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void openNoWait(){
|
void openNoWait(){
|
||||||
channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
|
||||||
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Pends for a maximimum of timeout seconds
|
||||||
|
void openNowAndWait(double _timeout);
|
||||||
|
|
||||||
|
|
||||||
|
//Pends for default amount of time
|
||||||
|
void openNow() {
|
||||||
|
openNowAndWait(channelOpenPolicy.getTimeout());
|
||||||
|
/*
|
||||||
|
channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//reset
|
||||||
|
channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
|
||||||
|
channelOpenPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
bool initCallbackComplete(vector<unsigned int> hV) {
|
bool initCallbackComplete(vector<unsigned int> hV) {
|
||||||
return initCallbackComplete(&hV[0], hV.size());
|
return initCallbackComplete(&hV[0], hV.size());
|
||||||
}
|
}
|
||||||
@@ -294,8 +326,6 @@ class Connect
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//closeChannel(s) only close within a context
|
//closeChannel(s) only close within a context
|
||||||
int closeChannels(unsigned int * handleArray, unsigned int nHandles);
|
int closeChannels(unsigned int * handleArray, unsigned int nHandles);
|
||||||
int closeChannels(vector<unsigned int> v){
|
int closeChannels(vector<unsigned int> v){
|
||||||
@@ -330,6 +360,12 @@ class Connect
|
|||||||
int closeHandle(unsigned int handle);
|
int closeHandle(unsigned int handle);
|
||||||
int closeHandles();
|
int closeHandles();
|
||||||
|
|
||||||
|
//Close Channel Keep Handle
|
||||||
|
int closeChannelKeepHandle(unsigned int handle);
|
||||||
|
int closeChannelsKeepHandles(unsigned int * handleArray, unsigned int nHandles);
|
||||||
|
int closeChannelsKeepHandlesV(vector<unsigned int> v){ return closeChannelsKeepHandles(&v[0], v.size());}
|
||||||
|
int closeChannelsKeepHandles (vector<unsigned int> v){ return closeChannelsKeepHandles(&v[0], v.size());}
|
||||||
|
|
||||||
// Monitors
|
// Monitors
|
||||||
int monitorStart(unsigned int handle, MonitorPolicy &mp);
|
int monitorStart(unsigned int handle, MonitorPolicy &mp);
|
||||||
int monitorStart(unsigned int handle, unsigned int & monitorID);
|
int monitorStart(unsigned int handle, unsigned int & monitorID);
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#define EV EPICSVERSION(HAVE_EPICS)
|
#define EV EPICSVERSION(HAVE_EPICS)
|
||||||
|
|
||||||
#if (EPICS_VERSION==3) && (EPICS_MAJOR==14) && (EPICS_MINOR>=11)
|
#if (EPICS_MAJOR==3) && (EPICS_MINOR==14) && (EPICS_PATCH>=11)
|
||||||
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM | DBE_PROPERTY
|
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM | DBE_PROPERTY
|
||||||
#elif (EPICS_VERSION==3) && (EPICS_MAJOR>14)
|
#elif (EPICS_MAJOR==3) && (EPICS_MINOR>14)
|
||||||
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM | DBE_PROPERTY
|
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM | DBE_PROPERTY
|
||||||
#else
|
#else
|
||||||
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM
|
#define MASK_CTRL DBE_VALUE | DBE_LOG | DBE_ALARM
|
||||||
@@ -55,7 +55,7 @@ typedef char pv_string_t[PVNAME_SIZE];
|
|||||||
const bool DEFAULT_SELF_GOVERNING_TIMEOUT = true;
|
const bool DEFAULT_SELF_GOVERNING_TIMEOUT = true;
|
||||||
|
|
||||||
const double DEFAULT_TIMEOUT_PEND_IO_WF = 5.0;
|
const double DEFAULT_TIMEOUT_PEND_IO_WF = 5.0;
|
||||||
const double TIMEOUT_PEND_IO_MIN = 0.00001;
|
const double TIMEOUT_PEND_IO_MIN = 0.0001;
|
||||||
const double TIMEOUT_PEND_IO_MAX = 20.0; // max timeout for first attempt (ntries=1)
|
const double TIMEOUT_PEND_IO_MAX = 20.0; // max timeout for first attempt (ntries=1)
|
||||||
const unsigned short DEFAULT_PEND_IO_NO_TRIES = 2;
|
const unsigned short DEFAULT_PEND_IO_NO_TRIES = 2;
|
||||||
const unsigned short PEND_IO_MAX_TRIES = 10; // safety net
|
const unsigned short PEND_IO_MAX_TRIES = 10; // safety net
|
||||||
@@ -63,7 +63,7 @@ const double DEFAULT_PEND_IO_INCREMENT_TIME = 2.0;
|
|||||||
const double PEND_IO_INCREMENT_TIME_MIN= 0.05;
|
const double PEND_IO_INCREMENT_TIME_MIN= 0.05;
|
||||||
const double PEND_IO_INCREMENT_TIME_MAX= 10.0;
|
const double PEND_IO_INCREMENT_TIME_MAX= 10.0;
|
||||||
const double DEFAULT_TIMEOUT_PEND_EVENT = 0.4;
|
const double DEFAULT_TIMEOUT_PEND_EVENT = 0.4;
|
||||||
const double DEFAULT_TIMEOUT_PEND_IO = 3.0;
|
const double DEFAULT_TIMEOUT_PEND_IO = 0.4; // previously 3.0
|
||||||
const double DEFAULT_TIMEOUT_SG_PEND_EVENT = 0.5; // plus nMember/NMEMBER_PER_SEC_SG_PEND_EVENT
|
const double DEFAULT_TIMEOUT_SG_PEND_EVENT = 0.5; // plus nMember/NMEMBER_PER_SEC_SG_PEND_EVENT
|
||||||
const double NMEMBER_PER_SEC_SG_PEND_EVENT = 400; //
|
const double NMEMBER_PER_SEC_SG_PEND_EVENT = 400; //
|
||||||
const double DEFAULT_TIMEOUT_SG_PEND_IO = 5.0;
|
const double DEFAULT_TIMEOUT_SG_PEND_IO = 5.0;
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
extern bool CHECK_CONSISTENCY_CA_STATE;
|
extern bool CHECK_CONSISTENCY_CA_STATE;
|
||||||
extern bool MUTEX;
|
extern bool MUTEX;
|
||||||
extern epicsMutex cafeMutex;
|
extern epicsMutex cafeMutex;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern cafeConduit_set cs;
|
extern cafeConduit_set cs;
|
||||||
extern cafeGroup_set gs;
|
extern cafeGroup_set gs;
|
||||||
extern vector<PVGroup> PVGroupV;
|
extern vector<PVGroup> PVGroupV;
|
||||||
@@ -29,8 +32,9 @@ extern map<vector<unsigned int>, string> groupPseudoMap;
|
|||||||
|
|
||||||
extern vector<string> globalChannelList;
|
extern vector<string> globalChannelList;
|
||||||
|
|
||||||
extern string globalZmqStream;
|
|
||||||
extern string contentsS;
|
extern string contentsS;
|
||||||
|
extern string contentsBS;
|
||||||
extern unsigned long nCBs;
|
extern unsigned long nCBs;
|
||||||
|
|
||||||
#endif // GLOBAL_H
|
#endif // GLOBAL_H
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class HandleHelper : public Helper {
|
|||||||
vector<unsigned int> getHandlesFromPVs(vector<string> pvV, ca_client_context * ccc);
|
vector<unsigned int> getHandlesFromPVs(vector<string> pvV, ca_client_context * ccc);
|
||||||
vector<unsigned int> getHandlesFromPVs(vector<string> pvV);
|
vector<unsigned int> getHandlesFromPVs(vector<string> pvV);
|
||||||
|
|
||||||
|
vector<unsigned int> getDisconnectedHandlesFromWithinGroupV(unsigned int gh);
|
||||||
|
|
||||||
vector<unsigned int> getHandlesFromWithinGroupV(unsigned int gh);
|
vector<unsigned int> getHandlesFromWithinGroupV(unsigned int gh);
|
||||||
unsigned int * getHandlesFromWithinGroup(unsigned int gh);
|
unsigned int * getHandlesFromWithinGroup(unsigned int gh);
|
||||||
|
|
||||||
@@ -167,6 +169,9 @@ class HandleHelper : public Helper {
|
|||||||
unsigned int getNextFreeHandle();
|
unsigned int getNextFreeHandle();
|
||||||
|
|
||||||
bool isChannelConnected(unsigned int handle);
|
bool isChannelConnected(unsigned int handle);
|
||||||
|
bool allChannelsConnected();
|
||||||
|
bool allChannelsWithinGroupConnected();
|
||||||
|
bool allChannelsWithinGroupConnectedV(vector<unsigned int>);
|
||||||
|
|
||||||
int printHandle (unsigned int h);
|
int printHandle (unsigned int h);
|
||||||
int printHandlesV(vector<unsigned int> handleV);
|
int printHandlesV(vector<unsigned int> handleV);
|
||||||
|
|||||||
@@ -237,6 +237,11 @@ template <class CTYPE> int Instant<CTYPE>::getCache(const unsigned int _handle
|
|||||||
|
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (_dbrType > DBR_CTRL_DOUBLE) {
|
if (_dbrType > DBR_CTRL_DOUBLE) {
|
||||||
@@ -764,15 +769,15 @@ template <class CTYPE> int Instant<CTYPE>::clientRequests(
|
|||||||
|
|
||||||
if (it_handle != handle_index.end()) {
|
if (it_handle != handle_index.end()) {
|
||||||
|
|
||||||
//union db_access_val * PVDataL;
|
union db_access_val * PVDataL;
|
||||||
//unsigned int nelem;
|
unsigned int nelem;
|
||||||
|
//unsigned int offset;
|
||||||
|
chtype dbrTypeRequest_DataBuffer;
|
||||||
|
|
||||||
//chtype dbrTypeRequest_DataBuffer;
|
PVDataL = (*it_handle).getPutBuffer ();
|
||||||
|
nelem = (*it_handle).getChannelRequestMetaPrimitive().getNelem();
|
||||||
|
|
||||||
//PVDataL = (*it_handle).getPutBuffer ();
|
dbrTypeRequest_DataBuffer = (*it_handle).getChannelRequestMetaPrimitive().getDbrDataType();
|
||||||
//nelem = (*it_handle).getChannelRequestMetaPrimitive().getNelem();
|
|
||||||
|
|
||||||
//dbrTypeRequest_DataBuffer = (*it_handle).getChannelRequestMetaPrimitive().getDbrDataType();
|
|
||||||
|
|
||||||
switch(_dbrType) {
|
switch(_dbrType) {
|
||||||
case DBR_STRING:
|
case DBR_STRING:
|
||||||
@@ -805,7 +810,15 @@ template <class CTYPE> int Instant<CTYPE>::clientRequests(
|
|||||||
return ECAFE_INVALID_SWITCH_CASE;
|
return ECAFE_INVALID_SWITCH_CASE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
epicsTimeStamp ts;
|
||||||
|
ts.secPastEpoch= 0; // default value if cache does not have timeStamp
|
||||||
|
ts.nsec = 0; // default value if cache does not have timeStamp
|
||||||
|
dbr_short_t alarmStatus =-1; // default value if cache does not have alarmStatus
|
||||||
|
dbr_short_t alarmSeverity =-1; // default value if cache does not have alarmSeverity
|
||||||
|
//helper function to set TimeStamps!
|
||||||
|
helper.setSTS(_handle, alarmStatus, alarmSeverity, ts);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@@ -876,6 +889,549 @@ template <class CTYPE> int Instant<CTYPE>::setAndGet(const unsigned int handleS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template <class CTYPE> int Instant<CTYPE>::setMany(vector<unsigned int> handleSet, const chtype dbrType, vector<CTYPE> valSet, bool printFlag) {
|
||||||
|
|
||||||
|
#define __METHOD__ "Instant<CTYPE>::setMany(vector<unsigned int>handleSet, chtype, vector<CTYPE>valSet)"
|
||||||
|
|
||||||
|
CAFEStatus cstat;
|
||||||
|
|
||||||
|
CTYPE valSetA[1];
|
||||||
|
|
||||||
|
status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
if (handleSet.size() != valSet.size() ) {
|
||||||
|
return ECAFE_HANDLE_MISMATCH_SET_AND_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
if (!helper.isChannelConnected(handleSet[i])) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "NOT ALL CHANNELS CONNECTED: " << endl;
|
||||||
|
if (!helper.isChannelConnected(handleSet[i])) {
|
||||||
|
helper.printHandle(handleSet[i]);
|
||||||
|
status=helper.getStatus(handleSet[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {return status;}
|
||||||
|
|
||||||
|
if(printFlag) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (printFlag) {
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
if (dbrType==DBR_CHAR) {
|
||||||
|
cout << "SETTING PV=" << helper.getPVFromHandle(handleSet[i]) << " to " << (unsigned short) valSet[i] << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "SETTING PV=" << helper.getPVFromHandle(handleSet[i]) << " to " << valSet[i] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} //for
|
||||||
|
|
||||||
|
} //if
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//set No of Elements to 1
|
||||||
|
|
||||||
|
unsigned int nelemPrevious, nelemRequestedCheck=0;
|
||||||
|
unsigned int nelemRequested=1;
|
||||||
|
|
||||||
|
nelemPrevious=helper.getNelemClient(handleSet[i]);
|
||||||
|
//Check the number of elements requested?
|
||||||
|
if (nelemPrevious>1) {
|
||||||
|
nelemRequestedCheck = helper.setNelem(handleSet[i],nelemRequested);
|
||||||
|
if (nelemRequestedCheck != nelemRequested) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to set the no. elements from: "
|
||||||
|
<< nelemPrevious << endl;
|
||||||
|
cout << "to: " << nelemRequested << " but got instead: "
|
||||||
|
<< nelemRequestedCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//policy set synchronous
|
||||||
|
ChannelRequestPolicy polPrevious, polNow;
|
||||||
|
|
||||||
|
policyHelper.getChannelRequestPolicyPut(handleSet[i], polPrevious);
|
||||||
|
|
||||||
|
polNow.setMethodKind(WITHOUT_CALLBACK);
|
||||||
|
polNow.setWaitKind(WAIT);
|
||||||
|
polNow.setWhenToFlushSendBuffer(FLUSH_AUTOMATIC);
|
||||||
|
|
||||||
|
policyHelper.setChannelRequestPolicyPut(handleSet[i], polNow);
|
||||||
|
|
||||||
|
valSetA[0] = (CTYPE) valSet[i];
|
||||||
|
|
||||||
|
status=set(handleSet[i], dbrType, valSetA);
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cstat.report(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
policyHelper.setChannelRequestPolicyPut(handleSet[i], polPrevious);
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int nelemPreviousCheck=nelemPrevious;
|
||||||
|
nelemRequested=1;
|
||||||
|
//Switch back to previous value
|
||||||
|
//if (nelemPrevious>1) {
|
||||||
|
if(helper.getNelemRequest(handleSet[i])!= nelemPrevious) {
|
||||||
|
nelemPreviousCheck= helper.setNelem(handleSet[i],nelemPrevious);
|
||||||
|
if (nelemPreviousCheck != nelemPrevious) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to re-set the no. elements from: "
|
||||||
|
<< nelemRequested << endl;
|
||||||
|
cout << "to the previous: " << nelemPrevious << " but got instead: "
|
||||||
|
<< nelemPreviousCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} //for size_t
|
||||||
|
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
#undef __METHOD__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set Channels followed by a corresponding readback of Channels \n
|
||||||
|
* Method verifies whether or not the set/readback values agree within the given tolerance and timeout \n
|
||||||
|
* Method returns with ECA_NORMAL as soon as a match is reached
|
||||||
|
* \param handleSet input: vector of handleSet
|
||||||
|
* \param dbrType input: chtype of set value
|
||||||
|
* \param valSet input: vector of CTYPE values to set
|
||||||
|
* \param handleMatch input: vector of handles of readback channel
|
||||||
|
* \param tolerance input: CTYPE of tolerance margin
|
||||||
|
* \param timeout input: double value; maximum time allowed for agreement to occur
|
||||||
|
* \param printFlag input: bool, set to true for diagnostics
|
||||||
|
* \return ECA_NORMAL if all OK, else first ECAFE error encountered, else ECAFE_TIMEOUT_SET_AND_MATCH
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class CTYPE> int Instant<CTYPE>::compareAndMatchMany(vector<unsigned int> handleSet, const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
||||||
|
CTYPE tolerance, double timeout, bool printFlag){
|
||||||
|
//template <class CTYPE> int Instant<CTYPE>::setTriggerAndMatchMany(vector<unsigned int> handleSet, chtype dbrType, vector<CTYPE> valSet,
|
||||||
|
// vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
// CTYPE tolerance, double timeout, bool printFlag){
|
||||||
|
#define __METHOD__ "Instant<CTYPE>::compareAndMatchMany(chtype, vector<CTYPE>valSet, vector<unsigned int>handleMatch, tolerance, timeout, printFlag)"
|
||||||
|
|
||||||
|
|
||||||
|
Connect connect;
|
||||||
|
CAFEStatus cstat;
|
||||||
|
|
||||||
|
CTYPE valGetA[1]; //CTYPE valSetA[1];
|
||||||
|
|
||||||
|
status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
|
||||||
|
if (handleMatch.size() != valSet.size() ) {
|
||||||
|
return ECAFE_HANDLE_MISMATCH_SET_AND_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
|
||||||
|
if (!helper.isChannelConnected(handleMatch[i])) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "NOT ALL CHANNELS CONNECTED: " << endl;
|
||||||
|
|
||||||
|
if (!helper.isChannelConnected(handleMatch[i])) {helper.printHandle(handleMatch[i]); status=helper.getStatus(handleMatch[i]);}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {return status;}
|
||||||
|
|
||||||
|
if(printFlag) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printFlag) {
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
|
||||||
|
|
||||||
|
if (dbrType==DBR_CHAR) {
|
||||||
|
cout << "SETTING PV= " << helper.getPVFromHandle(handleSet[i]) << " to " << (unsigned short) valSet[i] << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "SETTING PV= " << helper.getPVFromHandle(handleSet[i]) << " to " << valSet[i] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "READBACK PV=" << helper.getPVFromHandle(handleMatch[i])
|
||||||
|
<< " tolerance= " << fabs( (double) tolerance) << endl;
|
||||||
|
cout << "TIME ALLOWED FOR MATCH IS " << timeout << " (sec) " << endl;
|
||||||
|
|
||||||
|
} //for
|
||||||
|
|
||||||
|
} //if
|
||||||
|
|
||||||
|
|
||||||
|
vector<CTYPE> valSetUpper; vector<CTYPE> valSetLower;
|
||||||
|
|
||||||
|
vector<unsigned int> monitorID;
|
||||||
|
vector<int> statMonitor;
|
||||||
|
vector<unsigned short> nMonitors;
|
||||||
|
vector<CTYPE> valGet;
|
||||||
|
|
||||||
|
|
||||||
|
vector<unsigned int> nelemPreviousCache;
|
||||||
|
|
||||||
|
valSetUpper.reserve( valSet.size());
|
||||||
|
|
||||||
|
|
||||||
|
valSetLower.reserve( valSet.size());
|
||||||
|
monitorID.reserve( valSet.size());
|
||||||
|
statMonitor.reserve( valSet.size());
|
||||||
|
valGet.reserve( valSet.size());
|
||||||
|
nMonitors.reserve( valSet.size() );
|
||||||
|
|
||||||
|
|
||||||
|
nelemPreviousCache.reserve( valSet.size());
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< valSet.size(); ++i) {
|
||||||
|
|
||||||
|
|
||||||
|
switch (dbrType) {
|
||||||
|
case DBR_LONG :
|
||||||
|
case DBR_SHORT :
|
||||||
|
case DBR_ENUM:
|
||||||
|
valSetUpper[i] = valSet[i] + abs((int)tolerance);
|
||||||
|
valSetLower[i] = valSet[i] - abs((int)tolerance);
|
||||||
|
break;
|
||||||
|
case DBR_CHAR :
|
||||||
|
valSetUpper[i] = (unsigned short) valSet[i] + abs((unsigned short) tolerance);
|
||||||
|
valSetLower[i] = (unsigned short) valSet[i] - abs((unsigned short) tolerance);
|
||||||
|
break;
|
||||||
|
case DBR_FLOAT:
|
||||||
|
case DBR_DOUBLE:
|
||||||
|
default:
|
||||||
|
|
||||||
|
valSetUpper[i] = (CTYPE) (valSet[i] + fabs((double)tolerance));
|
||||||
|
valSetLower[i] = (CTYPE) (valSet[i] - fabs((double)tolerance));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vector<MonitorPolicy> mpVMatch;
|
||||||
|
mpVMatch.clear();
|
||||||
|
|
||||||
|
helper.getMonitorPolicyVector(handleMatch[i], mpVMatch);
|
||||||
|
|
||||||
|
|
||||||
|
nMonitors[i]=mpVMatch.size();
|
||||||
|
|
||||||
|
monitorID[i]=0;
|
||||||
|
|
||||||
|
////valGetA[0][i]=0;
|
||||||
|
valGet[i]=0;
|
||||||
|
|
||||||
|
statMonitor[i]=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
|
||||||
|
//what is monitorpolicy??
|
||||||
|
if (nMonitors[i]==0) {
|
||||||
|
|
||||||
|
unsigned int _nelemPrevious, _nelemRequestedCheck=0;
|
||||||
|
unsigned int _nelemRequested=1;
|
||||||
|
_nelemPrevious=helper.getNelemClient(handleMatch[i]);
|
||||||
|
//Check the number of elements requested?
|
||||||
|
if (_nelemPrevious>1) {
|
||||||
|
_nelemRequestedCheck = helper.setNelem(handleMatch[i],_nelemRequested);
|
||||||
|
if (_nelemRequestedCheck != _nelemRequested) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to set the no. elements from: "
|
||||||
|
<< _nelemPrevious << endl;
|
||||||
|
cout << "to: " << _nelemRequested << " but got instead: "
|
||||||
|
<< _nelemRequestedCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//first do get to update cache before monitor starts
|
||||||
|
status=Instant::get(handleMatch[i], dbrType, valGetA);
|
||||||
|
|
||||||
|
valGet[i]=valGetA[0];
|
||||||
|
|
||||||
|
if (_nelemPrevious>1) {
|
||||||
|
helper.setNelem(handleMatch[i],_nelemPrevious);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cstat.report(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelWhenToFlushSendBufferPolicyKind whenKind=
|
||||||
|
connect.channelMonitorPolicy.getWhenToFlushSendBuffer();
|
||||||
|
connect.channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_AUTOMATIC);
|
||||||
|
|
||||||
|
statMonitor[i]=connect.monitorStart(handleMatch[i], monitorID[i]);
|
||||||
|
|
||||||
|
if (statMonitor[i]!=ICAFE_NORMAL) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cstat.report(statMonitor[i]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(printFlag) {cout << "MONITOR NOW IN PLACE FOR READBACK CHANNEL " << helper.getPVFromHandle(handleMatch[i]) << " WITH ID=" << monitorID[i] << endl;}
|
||||||
|
}
|
||||||
|
//revert to previous
|
||||||
|
if (whenKind != FLUSH_AUTOMATIC) {
|
||||||
|
connect.channelMonitorPolicy.setWhenToFlushSendBuffer(whenKind);
|
||||||
|
}
|
||||||
|
|
||||||
|
} //if nMonitors
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//No of elements to get from Cache
|
||||||
|
|
||||||
|
//unsigned int nelemPreviousCheck=0;
|
||||||
|
unsigned int nelemRequested=1; unsigned int nelemRequestedCheck=0;
|
||||||
|
nelemPreviousCache[i]=helper.getNelemRequest(handleMatch[i]);
|
||||||
|
|
||||||
|
//Check the number of elements requested
|
||||||
|
//See set and Match; this needs to be checked
|
||||||
|
//Avoid problem when readback channel is the very same as the set(!)
|
||||||
|
if (nelemPreviousCache[i]>0 && helper.getNelemNative(handleMatch[i])>1) {
|
||||||
|
nelemRequestedCheck = helper.setNelemToRetrieveFromCache(handleMatch[i],nelemRequested);
|
||||||
|
if (nelemRequestedCheck != nelemRequested) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to set the no. elements from: "
|
||||||
|
<< nelemPreviousCache[i] << endl;
|
||||||
|
cout << "to: " << nelemRequested << " but got instead: "
|
||||||
|
<< nelemRequestedCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} //for size_t
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//start time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double timeElapsed=0; double timeElapsed2=0;
|
||||||
|
double timeElapsedBase=0;
|
||||||
|
using namespace boost::posix_time;
|
||||||
|
|
||||||
|
ptime timeStart(microsec_clock::local_time());
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
|
||||||
|
valGetA[0]=0;
|
||||||
|
|
||||||
|
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
||||||
|
|
||||||
|
valGet[i]=valGetA[0];
|
||||||
|
|
||||||
|
|
||||||
|
if (status !=ICAFE_NORMAL) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cstat.report(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
///valGet[i]=valGetA[0][i];
|
||||||
|
if (dbrType==DBR_CHAR) {valGet[i] = (unsigned short) valGetA[0];}
|
||||||
|
|
||||||
|
if(printFlag) {
|
||||||
|
//cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
if (dbrType==DBR_CHAR) {
|
||||||
|
cout << "Current Cached Value = " << (unsigned short) valGet[i] << endl;
|
||||||
|
cout << "Lower/Upper Target Values = " << (unsigned short) valSetLower[i] << " and " << (unsigned short) valSetUpper[i] << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "Current Cached Value = " << valGet[i] << endl;
|
||||||
|
cout << "Lower/Upper Target Values = " << valSetLower[i] << " and " << valSetUpper[i] << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //for size_t
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ptime timeEnd(microsec_clock::local_time());
|
||||||
|
time_duration duration(timeEnd-timeStart);
|
||||||
|
timeElapsed= (double) duration.total_microseconds()/1000000.0;
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< valSet.size(); ++i) {
|
||||||
|
|
||||||
|
|
||||||
|
while ( (valGet[i]>valSetUpper[i] || valGet[i]<valSetLower[i] )
|
||||||
|
&& timeElapsed < timeout ) {
|
||||||
|
|
||||||
|
valGetA[0]=0;
|
||||||
|
|
||||||
|
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
||||||
|
|
||||||
|
valGet[i]=valGetA[0];
|
||||||
|
|
||||||
|
|
||||||
|
//cout <<"Cached value " << valGet[i] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (dbrType==DBR_CHAR) {valGet[i] = (unsigned short) valGetA[0];}
|
||||||
|
|
||||||
|
//cout << valSetUpper[i] << " U/L " << valSetLower[i] << endl;
|
||||||
|
|
||||||
|
ptime timeEnd(microsec_clock::local_time());
|
||||||
|
time_duration duration(timeEnd-timeStart);
|
||||||
|
timeElapsed= (double) duration.total_microseconds()/1000000.0;
|
||||||
|
|
||||||
|
timeElapsed2=timeElapsed-timeElapsedBase;
|
||||||
|
|
||||||
|
if (printFlag && timeElapsed2>1 && status==ICAFE_NORMAL) {
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t ij=0; ij< handleMatch.size(); ++ij) {
|
||||||
|
status=Instant::getCache(handleMatch[ij], dbrType, valGetA);
|
||||||
|
valGet[ij]=valGetA[0];
|
||||||
|
if (valGet[ij]>valSetUpper[ij] || valGet[ij]<valSetLower[ij]) {
|
||||||
|
|
||||||
|
if (dbrType==DBR_CHAR) {
|
||||||
|
|
||||||
|
cout << "REPORTING " << helper.getPVFromHandle(handleSet[ij])
|
||||||
|
<< " SET VALUE=" << (unsigned short) valSet[ij]
|
||||||
|
<< "; READBACK " << helper.getPVFromHandle(handleMatch[ij])
|
||||||
|
<< " HAS CURRENT VALUE=" << (unsigned short) valGet[ij]
|
||||||
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "REPORTING " << helper.getPVFromHandle(handleSet[ij])
|
||||||
|
<< " SET VALUE=" << valSet[ij]
|
||||||
|
<< "; READBACK " << helper.getPVFromHandle(handleMatch[ij])
|
||||||
|
<< " HAS CURRENT VALUE=" << valGet[ij]
|
||||||
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
timeElapsedBase=timeElapsed;
|
||||||
|
|
||||||
|
//cout << "REPORTING ON CHANNEL " << helper.getPVFromHandle(handleSet[i]) << " SET VALUE=" << valSet[i] << " // CURRENT READBACK VALUE=" << valGet[i]
|
||||||
|
// << " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
//timeElapsedBase=timeElapsed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_BOOST_THREAD
|
||||||
|
boost::this_thread::sleep_for(boost::chrono::microseconds(20));
|
||||||
|
#else
|
||||||
|
#if HAVE_LINUX
|
||||||
|
usleep(20);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} //for size_t
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (timeout <=timeElapsed ) {
|
||||||
|
cout << "*****TIMEOUT REACHED****** AFTER " << timeout << " (sec) " << endl;
|
||||||
|
cout << "*****NOT ALL READBACK CHANNELS REACHED THEIR DESIRED VALUES WITHIN THE GIVEN TOLERANCE AND TIME PERIOD*****" << endl;
|
||||||
|
status=ECAFE_TIMEOUT_SET_AND_MATCH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if (printFlag) {
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
|
||||||
|
valGetA[0]=0;
|
||||||
|
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
||||||
|
valGet[i]=valGetA[0];
|
||||||
|
if (dbrType==DBR_CHAR) {
|
||||||
|
cout << "GAME SET AND MATCH: " << helper.getPVFromHandle(handleSet[i]) << " SET VALUE= " << (unsigned short) valSet[i]
|
||||||
|
<< " // " << helper.getPVFromHandle(handleMatch[i]) << " READBACK VALUE= " << (unsigned short) valGet[i] //pvdMatch.getAsDouble()
|
||||||
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << "GAME SET AND MATCH: " << helper.getPVFromHandle(handleSet[i]) << " SET VALUE= " << valSet[i]
|
||||||
|
<< " // " << helper.getPVFromHandle(handleMatch[i]) << " READBACK VALUE= " << valGet[i] //pvdMatch.getAsDouble()
|
||||||
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
} //for
|
||||||
|
|
||||||
|
} //printFlag
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleMatch.size(); ++i) {
|
||||||
|
unsigned int nelemPreviousCheck;
|
||||||
|
unsigned int nelemRequested=1;
|
||||||
|
|
||||||
|
|
||||||
|
if (nelemPreviousCache[i]>1) {
|
||||||
|
nelemPreviousCheck= helper.setNelemToRetrieveFromCache(handleMatch[i],nelemPreviousCache[i]);
|
||||||
|
if (nelemPreviousCheck != nelemPreviousCache[i]) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to re-set the no. elements from: "
|
||||||
|
<< nelemRequested << endl;
|
||||||
|
cout << "to the previous: " << nelemPreviousCache[i] << " but got instead: "
|
||||||
|
<< nelemPreviousCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (nMonitors[i]==0 && statMonitor[i]==ICAFE_NORMAL && printFlag) {
|
||||||
|
cout << "MONITOR NOW STOPPED FOR READBACK CHANNEL " << helper.getPVFromHandle(handleMatch[i]) << " WITH ID =" << monitorID[i] << endl;
|
||||||
|
int statm;
|
||||||
|
statm=connect.monitorStop(handleMatch[i], monitorID[i]);
|
||||||
|
if (status==ICAFE_NORMAL) {status=statm;}
|
||||||
|
}
|
||||||
|
|
||||||
|
} //for
|
||||||
|
|
||||||
|
|
||||||
|
return status;
|
||||||
|
#undef __METHOD__
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -895,7 +1451,6 @@ template <class CTYPE> int Instant<CTYPE>::setAndMatchMany(vector<unsigned int>
|
|||||||
CTYPE tolerance, double timeout, bool printFlag){
|
CTYPE tolerance, double timeout, bool printFlag){
|
||||||
#define __METHOD__ "Instant<CTYPE>::setAndMatchMany(vector<unsigned int>handleSet, chtype, vector<CTYPE>valSet, vector<unsigned int>handleMatch, tolerance, timeout, printFlag)"
|
#define __METHOD__ "Instant<CTYPE>::setAndMatchMany(vector<unsigned int>handleSet, chtype, vector<CTYPE>valSet, vector<unsigned int>handleMatch, tolerance, timeout, printFlag)"
|
||||||
|
|
||||||
|
|
||||||
Connect connect;
|
Connect connect;
|
||||||
CAFEStatus cstat;
|
CAFEStatus cstat;
|
||||||
|
|
||||||
@@ -1296,10 +1851,10 @@ template <class CTYPE> int Instant<CTYPE>::setAndMatchMany(vector<unsigned int>
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
for (size_t i=0; i< handleSet.size(); ++i) {
|
if (printFlag) {
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
//if (printFlag) {cout << "MONITOR STARTED WITH ID/2-/=" << monitorID[i] << endl;}
|
|
||||||
if (printFlag) {
|
|
||||||
valGetA[0]=0;
|
valGetA[0]=0;
|
||||||
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
||||||
valGet[i]=valGetA[0];
|
valGet[i]=valGetA[0];
|
||||||
@@ -1314,9 +1869,9 @@ template <class CTYPE> int Instant<CTYPE>::setAndMatchMany(vector<unsigned int>
|
|||||||
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} //for
|
||||||
|
|
||||||
} //for
|
} //printFlag
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
@@ -1595,7 +2150,7 @@ template <class CTYPE> int Instant<CTYPE>::setAndMatch(const unsigned int handl
|
|||||||
//cout << __METHOD__ << endl;
|
//cout << __METHOD__ << endl;
|
||||||
cout << "Current Cached Value = " ;
|
cout << "Current Cached Value = " ;
|
||||||
if (dbrType==DBR_CHAR) {
|
if (dbrType==DBR_CHAR) {
|
||||||
cout << (unsigned short) valGetA[0] << cout << endl;
|
cout << (unsigned short) valGetA[0] << endl;
|
||||||
cout << "Lower/Upper Target Values = " << (unsigned short) valSetLower << " and " << (unsigned short) valSetUpper << endl;
|
cout << "Lower/Upper Target Values = " << (unsigned short) valSetLower << " and " << (unsigned short) valSetUpper << endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2083,7 +2638,7 @@ template <class CTYPE> int Instant<CTYPE>::matchMany(const chtype dbrType, vect
|
|||||||
valGetA[0]=0;
|
valGetA[0]=0;
|
||||||
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
status=Instant::getCache(handleMatch[i], dbrType, valGetA);
|
||||||
valGet[i]=valGetA[0];
|
valGet[i]=valGetA[0];
|
||||||
cout << "GAME SET AND MATCH: " << " SET VALUE= " << valSet[i] << " // " << helper.getPVFromHandle(handleMatch[i]) << " READBACK VALUE= " << valGet[i] //pvdMatch.getAsDouble()
|
cout << "GAME SET AND MATCH: " << " SET VALUE= " << valSet[i] << " // " << helper.getPVFromHandle(handleMatch[i]) << " READBACK VALUE= " << valGet[i] //pvdMatch.getAsDouble()
|
||||||
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
<< " TimeElapsed " << timeElapsed << " (sec) " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,12 +109,143 @@ public:
|
|||||||
int setAndMatchMany(vector<unsigned int> handleSetV, const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
int setAndMatchMany(vector<unsigned int> handleSetV, const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
||||||
CTYPE tolerance, double timeout, bool printFlag);
|
CTYPE tolerance, double timeout, bool printFlag);
|
||||||
|
|
||||||
|
int setTriggerAndMatchMany(vector<unsigned int> handleSetV, const chtype dbrType, vector<CTYPE> valSet,
|
||||||
|
vector<unsigned int> handleAction, vector<string> valAction, vector<unsigned int> handleMatch,
|
||||||
|
CTYPE tolerance, double timeout, bool printFlag);
|
||||||
|
|
||||||
int matchMany( const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
int matchMany( const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
||||||
CTYPE tolerance, double timeout, bool printFlag);
|
CTYPE tolerance, double timeout, bool printFlag);
|
||||||
|
|
||||||
int match( const chtype dbrType, CTYPE valSet, unsigned int handleMatch,
|
int match( const chtype dbrType, CTYPE valSet, unsigned int handleMatch,
|
||||||
CTYPE tolerance, double timeout, bool printFlag);
|
CTYPE tolerance, double timeout, bool printFlag);
|
||||||
|
|
||||||
|
int setMany(vector<unsigned int> handleSet, const chtype dbrType, vector<CTYPE> valSet, bool printFlag);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int compareAndMatchMany(vector<unsigned int> handleSet, const chtype dbrType, vector<CTYPE> valSet, vector<unsigned int> handleMatch,
|
||||||
|
CTYPE tolerance, double timeout, bool printFlag);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int setManyString(vector<unsigned int> handleSet, vector<string> valSet, bool printFlag) {
|
||||||
|
|
||||||
|
#define __METHOD__ "Instant<CTYPE>::setMany(vector<unsigned int>handleSet, chtype, vector<CTYPE>valSet)"
|
||||||
|
|
||||||
|
CAFEStatus cstat;
|
||||||
|
|
||||||
|
|
||||||
|
status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
if (handleSet.size() != valSet.size() ) {
|
||||||
|
return ECAFE_HANDLE_MISMATCH_SET_AND_MATCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
if (!helper.isChannelConnected(handleSet[i])) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "NOT ALL CHANNELS CONNECTED: " << endl;
|
||||||
|
if (!helper.isChannelConnected(handleSet[i])) {
|
||||||
|
helper.printHandle(handleSet[i]);
|
||||||
|
status=helper.getStatus(handleSet[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {return status;}
|
||||||
|
|
||||||
|
if(printFlag) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (printFlag) {
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
cout << "SETTING PV=" << helper.getPVFromHandle(handleSet[i]) << " to " << valSet[i] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
} //for
|
||||||
|
|
||||||
|
} //if
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i=0; i< handleSet.size(); ++i) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//set No of Elements to 1
|
||||||
|
|
||||||
|
unsigned int nelemPrevious, nelemRequestedCheck=0;
|
||||||
|
unsigned int nelemRequested=1;
|
||||||
|
|
||||||
|
nelemPrevious=helper.getNelemClient(handleSet[i]);
|
||||||
|
//Check the number of elements requested?
|
||||||
|
if (nelemPrevious>1) {
|
||||||
|
nelemRequestedCheck = helper.setNelem(handleSet[i],nelemRequested);
|
||||||
|
if (nelemRequestedCheck != nelemRequested) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to set the no. elements from: "
|
||||||
|
<< nelemPrevious << endl;
|
||||||
|
cout << "to: " << nelemRequested << " but got instead: "
|
||||||
|
<< nelemRequestedCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//policy set synchronous
|
||||||
|
ChannelRequestPolicy polPrevious, polNow;
|
||||||
|
|
||||||
|
policyHelper.getChannelRequestPolicyPut(handleSet[i], polPrevious);
|
||||||
|
|
||||||
|
polNow.setMethodKind(WITHOUT_CALLBACK);
|
||||||
|
polNow.setWaitKind(WAIT);
|
||||||
|
polNow.setWhenToFlushSendBuffer(FLUSH_AUTOMATIC);
|
||||||
|
|
||||||
|
policyHelper.setChannelRequestPolicyPut(handleSet[i], polNow);
|
||||||
|
|
||||||
|
dbr_string_t valSetA[1];
|
||||||
|
|
||||||
|
|
||||||
|
helper.removeLeadingAndTrailingSpaces(valSet[i].c_str(), valSetA[0]);
|
||||||
|
|
||||||
|
|
||||||
|
status=set(handleSet[i], DBR_STRING, valSetA);
|
||||||
|
|
||||||
|
if (status!=ICAFE_NORMAL) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cstat.report(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
policyHelper.setChannelRequestPolicyPut(handleSet[i], polPrevious);
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int nelemPreviousCheck=nelemPrevious;
|
||||||
|
nelemRequested=1;
|
||||||
|
//Switch back to previous value
|
||||||
|
//if (nelemPrevious>1) {
|
||||||
|
if(helper.getNelemRequest(handleSet[i])!= nelemPrevious) {
|
||||||
|
nelemPreviousCheck= helper.setNelem(handleSet[i],nelemPrevious);
|
||||||
|
if (nelemPreviousCheck != nelemPrevious) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
|
cout << "Internal CAFE FUNNY: Wanted to re-set the no. elements from: "
|
||||||
|
<< nelemRequested << endl;
|
||||||
|
cout << "to the previous: " << nelemPrevious << " but got instead: "
|
||||||
|
<< nelemPreviousCheck << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} //for size_t
|
||||||
|
|
||||||
|
return status;
|
||||||
|
#undef __METHOD__
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set followed by an immediate get
|
* \brief Set followed by an immediate get
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ PRE_UNINSTALL = :
|
|||||||
POST_UNINSTALL = :
|
POST_UNINSTALL = :
|
||||||
build_triplet = x86_64-unknown-linux-gnu
|
build_triplet = x86_64-unknown-linux-gnu
|
||||||
host_triplet = x86_64-unknown-linux-gnu
|
host_triplet = x86_64-unknown-linux-gnu
|
||||||
am__append_1 = PyCafe_api.h
|
#am__append_1 = PyCafe_api.h
|
||||||
#am__append_2 = PyCafe.h
|
#am__append_2 = PyCafe.h
|
||||||
subdir = include
|
subdir = include
|
||||||
DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/makefile.am \
|
DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/makefile.am \
|
||||||
@@ -90,8 +90,8 @@ CTAGS = ctags
|
|||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
ACLOCAL = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run aclocal-1.11
|
ACLOCAL = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run aclocal-1.11
|
||||||
AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
|
AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
|
||||||
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
|
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
|
||||||
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_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
|
AR = ar
|
||||||
AUTOCONF = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoconf
|
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
|
AUTOHEADER = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoheader
|
||||||
@@ -102,7 +102,7 @@ CC = gcc
|
|||||||
CCDEPMODE = depmode=gcc3
|
CCDEPMODE = depmode=gcc3
|
||||||
CFLAGS = -g -O2
|
CFLAGS = -g -O2
|
||||||
CPP = gcc -E
|
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++
|
CXX = g++
|
||||||
CXXCPP = g++ -E
|
CXXCPP = g++ -E
|
||||||
CXXDEPMODE = depmode=gcc3
|
CXXDEPMODE = depmode=gcc3
|
||||||
@@ -125,9 +125,9 @@ INSTALL_PROGRAM = ${INSTALL}
|
|||||||
INSTALL_SCRIPT = ${INSTALL}
|
INSTALL_SCRIPT = ${INSTALL}
|
||||||
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
||||||
LD = /usr/bin/ld -m elf_x86_64
|
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 =
|
LIBOBJS =
|
||||||
LIBS = -lpython3.5m -lQtXml -lQtCore
|
LIBS = -lQtXml -lQtCore
|
||||||
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
||||||
LIPO =
|
LIPO =
|
||||||
LN_S = ln -s
|
LN_S = ln -s
|
||||||
@@ -186,7 +186,7 @@ htmldir = ${docdir}
|
|||||||
includedir = ${prefix}/include
|
includedir = ${prefix}/include
|
||||||
infodir = ${datarootdir}/info
|
infodir = ${datarootdir}/info
|
||||||
install_sh = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/install-sh
|
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-2/lib
|
||||||
libexecdir = ${exec_prefix}/libexec
|
libexecdir = ${exec_prefix}/libexec
|
||||||
localedir = ${datarootdir}/locale
|
localedir = ${datarootdir}/locale
|
||||||
localstatedir = ${prefix}/var
|
localstatedir = ${prefix}/var
|
||||||
@@ -195,7 +195,7 @@ mandir = ${datarootdir}/man
|
|||||||
mkdir_p = /bin/mkdir -p
|
mkdir_p = /bin/mkdir -p
|
||||||
oldincludedir = /usr/include
|
oldincludedir = /usr/include
|
||||||
pdfdir = ${docdir}
|
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-2
|
||||||
program_transform_name = s,x,x,
|
program_transform_name = s,x,x,
|
||||||
psdir = ${docdir}
|
psdir = ${docdir}
|
||||||
sbindir = ${exec_prefix}/sbin
|
sbindir = ${exec_prefix}/sbin
|
||||||
|
|||||||
@@ -64,10 +64,11 @@ public:
|
|||||||
class ChannelCreatePolicy{
|
class ChannelCreatePolicy{
|
||||||
private:
|
private:
|
||||||
unsigned short priority;
|
unsigned short priority;
|
||||||
static void callbackHandlerCreate(struct connection_handler_args args);
|
|
||||||
//special method to find handle thru conduit_set iterator
|
//special method to find handle thru conduit_set iterator
|
||||||
pCallbackConnection handler;
|
pCallbackConnection handler;
|
||||||
public:
|
public:
|
||||||
|
static void callbackHandlerCreate(struct connection_handler_args args);
|
||||||
pCallbackConnection getHandler(){return handler;};
|
pCallbackConnection getHandler(){return handler;};
|
||||||
void setHandler(pCallbackConnection h){handler=h;};
|
void setHandler(pCallbackConnection h){handler=h;};
|
||||||
unsigned short getPriority() const {return priority;}
|
unsigned short getPriority() const {return priority;}
|
||||||
@@ -411,7 +412,7 @@ private:
|
|||||||
int status; //output
|
int status; //output
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
|
||||||
static void callbackHandlerMonitor(struct event_handler_args args);
|
|
||||||
static void PyCallbackHandlerMonitorData(struct event_handler_args args); //pushes pvd,handle,pvname
|
static void PyCallbackHandlerMonitorData(struct event_handler_args args); //pushes pvd,handle,pvname
|
||||||
static void PyCallbackHandlerMonitor(struct event_handler_args args); //pushes handle
|
static void PyCallbackHandlerMonitor(struct event_handler_args args); //pushes handle
|
||||||
|
|
||||||
@@ -427,6 +428,9 @@ public:
|
|||||||
++idNext;
|
++idNext;
|
||||||
id = idNext;
|
id = idNext;
|
||||||
};
|
};
|
||||||
|
//Make public
|
||||||
|
static void callbackHandlerMonitor(struct event_handler_args args);
|
||||||
|
|
||||||
chtype getDataType() const {return dataType;};
|
chtype getDataType() const {return dataType;};
|
||||||
chtype getDbrDataType() const {return dbrDataType;};
|
chtype getDbrDataType() const {return dbrDataType;};
|
||||||
CAFENUM::DBR_TYPE getCafeDbrType() const {return cafeDbrType;};
|
CAFENUM::DBR_TYPE getCafeDbrType() const {return cafeDbrType;};
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const unsigned short ICAFE_STATUS_CA_OP = 800;
|
|||||||
const unsigned short ICAFE_STATUS_ERROR = 1000;
|
const unsigned short ICAFE_STATUS_ERROR = 1000;
|
||||||
const unsigned short ICAFE_FILE_ERROR = 1100;
|
const unsigned short ICAFE_FILE_ERROR = 1100;
|
||||||
const unsigned short ICAFE_SERVICE_ERROR =1200;
|
const unsigned short ICAFE_SERVICE_ERROR =1200;
|
||||||
const unsigned short ICAFE_LINUX_ERROR = 5000;
|
const unsigned short ICAFE_ERRNO_BASE = 5000;
|
||||||
const unsigned short ICAFE_SUCCESS = ECA_NORMAL;
|
const unsigned short ICAFE_SUCCESS = ECA_NORMAL;
|
||||||
const unsigned short ICAFE_NORMAL = ECA_NORMAL;
|
const unsigned short ICAFE_NORMAL = ECA_NORMAL;
|
||||||
|
|
||||||
@@ -119,11 +119,11 @@ enum CAFE_FILE_ERROR { ECAFE_LOAD_COLLECTION=ICAFE_FILE_ERROR,
|
|||||||
enum CAFE_SERVICE_ERROR { ECAFE_BPM_DATA_IS_INVALID=ICAFE_SERVICE_ERROR
|
enum CAFE_SERVICE_ERROR { ECAFE_BPM_DATA_IS_INVALID=ICAFE_SERVICE_ERROR
|
||||||
};
|
};
|
||||||
//Used by zeromq
|
//Used by zeromq
|
||||||
enum CAFE_LINUX_ERROR { LINUX_EINTR =ICAFE_LINUX_ERROR+4,
|
enum CAFE_ERRNO_ERROR { ERRNO_EINTR =ICAFE_ERRNO_BASE+4,
|
||||||
LINUX_EAGAIN=ICAFE_LINUX_ERROR+11,
|
ERRNO_EAGAIN=ICAFE_ERRNO_BASE+11,
|
||||||
LINUX_EFAULT=ICAFE_LINUX_ERROR+14,
|
ERRNO_EFAULT=ICAFE_ERRNO_BASE+14,
|
||||||
LINUX_ENOTSOCK=ICAFE_LINUX_ERROR+88,
|
ERRNO_ENOTSOCK=ICAFE_ERRNO_BASE+88,
|
||||||
LINUX_EPROTONOSUPPORT=ICAFE_LINUX_ERROR+93
|
ERRNO_EPROTONOSUPPORT=ICAFE_ERRNO_BASE+93
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -420,11 +420,11 @@ public:
|
|||||||
* 1100 ECAFE_LOAD_COLLECTION \n
|
* 1100 ECAFE_LOAD_COLLECTION \n
|
||||||
* 1101 ECAFE_LOAD_GROUP \n
|
* 1101 ECAFE_LOAD_GROUP \n
|
||||||
* 1200 ECAFE_BPM_DATA_IS_INVALID \n
|
* 1200 ECAFE_BPM_DATA_IS_INVALID \n
|
||||||
* 5004 LINUX_EINTR \n
|
* 5004 ERRNO_EINTR \n
|
||||||
* 5011 LINUX_EGAIN \n
|
* 5011 ERRNO_EGAIN \n
|
||||||
* 5014 LINUX_EFAULT \n
|
* 5014 ERRNO_EFAULT \n
|
||||||
* 5088 LINUX_ENOTSOCK \n
|
* 5088 ERRNO_ENOTSOCK \n
|
||||||
* 5093 LINUX_EPROTONOSUPPORT \n
|
* 5093 ERRNO_EPROTONOSUPPORT \n
|
||||||
*/
|
*/
|
||||||
class CAFEStatusInfo {
|
class CAFEStatusInfo {
|
||||||
typedef std::map<int, std::string> mapLongString;
|
typedef std::map<int, std::string> mapLongString;
|
||||||
@@ -511,17 +511,16 @@ public:
|
|||||||
mapStatusInfo.insert(std::make_pair((int) ECAFE_HANDLE_MISMATCH_SET_AND_MATCH, "Number of set/readback handles do not match"));
|
mapStatusInfo.insert(std::make_pair((int) ECAFE_HANDLE_MISMATCH_SET_AND_MATCH, "Number of set/readback handles do not match"));
|
||||||
mapStatusInfo.insert(std::make_pair((int) ECAFE_INCONSISTENT_CONTAINER_CORRECTED, "Boost container required update after consistency check"));
|
mapStatusInfo.insert(std::make_pair((int) ECAFE_INCONSISTENT_CONTAINER_CORRECTED, "Boost container required update after consistency check"));
|
||||||
|
|
||||||
|
|
||||||
mapStatusInfo.insert(std::make_pair((int) ECAFE_LOAD_COLLECTION, "CAFE collection could not be loaded from xml configuration file " ));
|
mapStatusInfo.insert(std::make_pair((int) ECAFE_LOAD_COLLECTION, "CAFE collection could not be loaded from xml configuration file " ));
|
||||||
mapStatusInfo.insert(std::make_pair((int) ECAFE_LOAD_GROUP, "CAFE group could not be loaded from group xml configuration file " ));
|
mapStatusInfo.insert(std::make_pair((int) ECAFE_LOAD_GROUP, "CAFE group could not be loaded from group xml configuration file " ));
|
||||||
|
|
||||||
mapStatusInfo.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "CAFE BPM Service: Data Validity channel reports BPM data is INVALID " ));
|
mapStatusInfo.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "CAFE BPM Service: Data Validity channel reports BPM data is INVALID " ));
|
||||||
|
|
||||||
mapStatusInfo.insert(std::make_pair((int) LINUX_EINTR, "C ERROR CODE IN LINUX: Interrupted system call" ));
|
mapStatusInfo.insert(std::make_pair((int) ERRNO_EINTR, "C ERRNO CODE: Interrupted system call" ));
|
||||||
mapStatusInfo.insert(std::make_pair((int) LINUX_EAGAIN, "C ERROR CODE IN LINUX: Try again" ));
|
mapStatusInfo.insert(std::make_pair((int) ERRNO_EAGAIN, "C ERRNO CODE: Try again" ));
|
||||||
mapStatusInfo.insert(std::make_pair((int) LINUX_EFAULT, "C ERROR CODE IN LINUX: Bad address" ));
|
mapStatusInfo.insert(std::make_pair((int) ERRNO_EFAULT, "C ERRNO CODE: Bad address" ));
|
||||||
mapStatusInfo.insert(std::make_pair((int) LINUX_ENOTSOCK, "C ERROR CODE IN LINUX: Socket operation on non-socket" ));
|
mapStatusInfo.insert(std::make_pair((int) ERRNO_ENOTSOCK, "C ERRNO CODE: Socket operation on non-socket" ));
|
||||||
mapStatusInfo.insert(std::make_pair((int) LINUX_EPROTONOSUPPORT, "C ERROR CODE IN LINUX: Protocol not supported" ));
|
mapStatusInfo.insert(std::make_pair((int) ERRNO_EPROTONOSUPPORT, "C ERRNO CODE: Protocol not supported" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
~CAFEStatusInfo() {};
|
~CAFEStatusInfo() {};
|
||||||
@@ -678,11 +677,11 @@ public:
|
|||||||
|
|
||||||
mapStatusCode.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "CAFE_ERROR: ECAFE_BPM_DATA_IS_INVALID" ));
|
mapStatusCode.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "CAFE_ERROR: ECAFE_BPM_DATA_IS_INVALID" ));
|
||||||
|
|
||||||
mapStatusCode.insert(std::make_pair((int) LINUX_EINTR, "CAFE_ERROR: LINUX_EINTR" ));
|
mapStatusCode.insert(std::make_pair((int) ERRNO_EINTR, "CAFE_ERROR: ERRNO_EINTR" ));
|
||||||
mapStatusCode.insert(std::make_pair((int) LINUX_EAGAIN, "CAFE_WARN: LINUX_EAGAIN " ));
|
mapStatusCode.insert(std::make_pair((int) ERRNO_EAGAIN, "CAFE_WARN: ERRNO_EAGAIN " ));
|
||||||
mapStatusCode.insert(std::make_pair((int) LINUX_EFAULT, "CAFE_ERROR: LINUX_EFAULT" ));
|
mapStatusCode.insert(std::make_pair((int) ERRNO_EFAULT, "CAFE_ERROR: ERRNO_EFAULT" ));
|
||||||
mapStatusCode.insert(std::make_pair((int) LINUX_ENOTSOCK, "CAFE_ERROR: LINUX_ENOTSOCK" ));
|
mapStatusCode.insert(std::make_pair((int) ERRNO_ENOTSOCK, "CAFE_ERROR: ERRNO_ENOTSOCK" ));
|
||||||
mapStatusCode.insert(std::make_pair((int) LINUX_EPROTONOSUPPORT, "CAFE_ERROR: LINUX_EPROTONOSUPPORT" ));
|
mapStatusCode.insert(std::make_pair((int) ERRNO_EPROTONOSUPPORT, "CAFE_ERROR: ERRNO_EPROTONOSUPPORT" ));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -887,11 +886,11 @@ public:
|
|||||||
|
|
||||||
mapStatusSeverity.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "WARN" ));
|
mapStatusSeverity.insert(std::make_pair((int) ECAFE_BPM_DATA_IS_INVALID, "WARN" ));
|
||||||
|
|
||||||
mapStatusSeverity.insert(std::make_pair((int) LINUX_EINTR, "ERROR" ));
|
mapStatusSeverity.insert(std::make_pair((int) ERRNO_EINTR, "ERROR" ));
|
||||||
mapStatusSeverity.insert(std::make_pair((int) LINUX_EAGAIN, "WARN" ));
|
mapStatusSeverity.insert(std::make_pair((int) ERRNO_EAGAIN, "WARN" ));
|
||||||
mapStatusSeverity.insert(std::make_pair((int) LINUX_EFAULT, "ERROR"));
|
mapStatusSeverity.insert(std::make_pair((int) ERRNO_EFAULT, "ERROR"));
|
||||||
mapStatusSeverity.insert(std::make_pair((int) LINUX_ENOTSOCK, "ERROR"));
|
mapStatusSeverity.insert(std::make_pair((int) ERRNO_ENOTSOCK, "ERROR"));
|
||||||
mapStatusSeverity.insert(std::make_pair((int) LINUX_EPROTONOSUPPORT, "ERROR" ));
|
mapStatusSeverity.insert(std::make_pair((int) ERRNO_EPROTONOSUPPORT, "ERROR" ));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -312,12 +312,6 @@ template <class CTYPE> int Transpose<CTYPE>::put(const unsigned int _handle,
|
|||||||
|
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
|
|
||||||
//cout << "dbrTypeRequest_DataBuffer " << dbrTypeRequest_DataBuffer << endl;
|
|
||||||
//cout << "_dbrType " << _dbrType << endl;
|
|
||||||
|
|
||||||
//cout << "nelem " << nelem << endl;
|
|
||||||
|
|
||||||
switch (dbrTypeRequest_DataBuffer)
|
switch (dbrTypeRequest_DataBuffer)
|
||||||
{
|
{
|
||||||
case DBR_STRING: // 0
|
case DBR_STRING: // 0
|
||||||
@@ -450,12 +444,9 @@ template <class CTYPE> int Transpose<CTYPE>::put(const unsigned int _handle,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DBR_DOUBLE: //6
|
case DBR_DOUBLE: //6
|
||||||
|
|
||||||
for (unsigned int i=0; i<nelem; ++i) {
|
for (unsigned int i=0; i<nelem; ++i) {
|
||||||
*((dbr_float_t *) (PVDataL) + i ) = (dbr_float_t) val[i] ;
|
*((dbr_float_t *) (PVDataL) + i ) = (dbr_float_t) val[i] ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DBR_STRING: //0
|
case DBR_STRING: //0
|
||||||
status=putString(_handle, (dbr_string_t *) val);
|
status=putString(_handle, (dbr_string_t *) val);
|
||||||
@@ -697,7 +688,7 @@ template <class CTYPE> int Transpose<CTYPE>::put(const unsigned int _handle,
|
|||||||
return ECAFE_INVALID_HANDLE;
|
return ECAFE_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "status " << status << endl;
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
@@ -1,51 +1,24 @@
|
|||||||
/* =====================================================================
|
|
||||||
zhelpers.h
|
|
||||||
|
|
||||||
Helper header file for example applications.
|
#ifndef ZHELPERS_H
|
||||||
=====================================================================
|
#define ZHELPERS_H
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __ZHELPERS_H_INCLUDED__
|
|
||||||
#define __ZHELPERS_H_INCLUDED__
|
|
||||||
|
|
||||||
#if HAVE_ZEROMQ
|
|
||||||
|
|
||||||
|
|
||||||
// Include a bunch of headers that we will need in the examples
|
|
||||||
|
|
||||||
#include <zmq.h>
|
#include <zmq.h>
|
||||||
|
|
||||||
|
/*
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
*/
|
||||||
#if (defined (WIN32))
|
|
||||||
# include <time.h>
|
|
||||||
#else
|
|
||||||
# include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
// Version checking, and patch up missing constants to match 2.1
|
|
||||||
#if ZMQ_VERSION_MAJOR == 2
|
|
||||||
# error "Please upgrade to ZeroMQ/3.2 for these examples"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Provide random number from 0..(num-1)
|
|
||||||
#if (defined (WIN32))
|
|
||||||
# define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0))
|
|
||||||
#else
|
|
||||||
# define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_JSON
|
#if HAVE_JSON
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cafeService.h>
|
#include <cafeService.h>
|
||||||
@@ -58,36 +31,6 @@ unsigned short hashOriginalFlag=0;
|
|||||||
bool fillBSPV=false;
|
bool fillBSPV=false;
|
||||||
vector<std::string> bsPV;
|
vector<std::string> bsPV;
|
||||||
|
|
||||||
// Receive 0MQ string from socket and convert into C string
|
|
||||||
// Caller must free returned string. Returns NULL if the context
|
|
||||||
// is being terminated.
|
|
||||||
static char *
|
|
||||||
s_recv (void *socket) {
|
|
||||||
char buffer [4096];
|
|
||||||
int size = zmq_recv (socket, buffer, 4096, 0); //ZMQ_DONTWAIT);
|
|
||||||
if (size == -1)
|
|
||||||
return NULL;
|
|
||||||
if (size > 4096)
|
|
||||||
size = 4096;
|
|
||||||
buffer [size] = 0;
|
|
||||||
return strdup (buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert C string to 0MQ string and send to socket
|
|
||||||
static int
|
|
||||||
s_send (void *socket, char *string) {
|
|
||||||
int size = zmq_send (socket, string, strlen (string), 0);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sends string as 0MQ string, as multipart non-terminal
|
|
||||||
static int
|
|
||||||
s_sendmore (void *socket, char *string) {
|
|
||||||
int size = zmq_send (socket, string, strlen (string), ZMQ_SNDMORE);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Receives all message parts from socket, prints neatly
|
// Receives all message parts from socket, prints neatly
|
||||||
//
|
//
|
||||||
@@ -97,7 +40,7 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
if (inDumpFlag==1) {
|
if (inDumpFlag==1) {
|
||||||
cout << "zeroMQ socket is busy " << endl;
|
cout << "zeroMQ socket is busy " << endl;
|
||||||
cout << "waiting got zmq timeout " << endl;
|
cout << "waiting for zmq timeout " << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts ("//START----------------------------------------//");
|
puts ("//START----------------------------------------//");
|
||||||
@@ -124,20 +67,21 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
cout << "df = " << inDumpFlag << endl;
|
cout << "df = " << inDumpFlag << endl;
|
||||||
|
|
||||||
while (inDumpFlag==1) {
|
while (inDumpFlag==1) {
|
||||||
cout << "df/ = " << inDumpFlag << endl;
|
cout << "df/ = " << inDumpFlag << endl;
|
||||||
cout << " sleeping " << endl;
|
cout << " sleeping " << endl;
|
||||||
sleep(1);
|
//sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int subMessage=0;
|
int subMessage=0;
|
||||||
int nSequentialHeader=0;
|
int nSequentialHeader=0;
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
inDumpFlag=1;
|
inDumpFlag=1;
|
||||||
|
|
||||||
// puts ("//WHILE LOOP ----------------------------------------//");
|
//puts ("//WHILE LOOP ----------------------------------------//");
|
||||||
//cout << "subMessage " << subMessage << endl;
|
//cout << "subMessage " << subMessage << endl;
|
||||||
// Process all parts of the message
|
// Process all parts of the message
|
||||||
zmq_msg_t message;
|
zmq_msg_t message;
|
||||||
zmq_msg_init (&message);
|
zmq_msg_init (&message);
|
||||||
@@ -149,18 +93,36 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
||||||
//Resource unavailable means that there is nothing to read now
|
//Resource unavailable means that there is nothing to read now
|
||||||
|
|
||||||
|
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
|
||||||
|
|
||||||
|
//cout << "message mulipart --> more == " << more << endl;
|
||||||
|
|
||||||
|
|
||||||
zmq_msg_close (&message);
|
zmq_msg_close (&message);
|
||||||
dbpm.status=ICAFE_LINUX_ERROR+zmq_errno() ;
|
|
||||||
|
|
||||||
|
//if (!more) {
|
||||||
|
// dbpm.status=ERRNO_EAGAIN; //ICAFE_ERRNO_BASE +zmq_errno() ;
|
||||||
|
// cout << "EARLY BREAK subMessage total: " << subMessage << endl;
|
||||||
|
// puts ("//------------------------------------END-------------------------------------//");
|
||||||
|
// break; // Last message
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dbpm.status=ICAFE_ERRNO_BASE+zmq_errno() ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if (size == 0) {
|
else if (size == 0) {
|
||||||
|
|
||||||
//cout << " Data of Zero SIZE for submessage " << subMessage << endl;
|
////cout << " Data of Zero SIZE for submessage " << subMessage << endl;
|
||||||
|
|
||||||
++nZeroSize;
|
++nZeroSize;
|
||||||
|
|
||||||
|
|
||||||
//zmq_msg_close (&message);
|
//zmq_msg_close (&message);
|
||||||
//dbpm.status=ECAFE_NODATA;
|
//dbpm.status=ECAFE_NODATA;
|
||||||
//break;
|
//break;
|
||||||
@@ -168,13 +130,15 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
if (nZeroSize%2==1) {
|
if (nZeroSize%2==1) {
|
||||||
++bsPVIdx;
|
++bsPVIdx;
|
||||||
|
|
||||||
// cout << " pv with zero size: " << bsPV[bsPVIdx] << endl;
|
|
||||||
|
|
||||||
|
if (bsPVIdx >0) {
|
||||||
|
cout << bsPV[bsPVIdx] << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++subMessage;
|
++subMessage;
|
||||||
|
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@@ -190,9 +154,16 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|| (unsigned char) data [char_nbr] > 127)
|
|| (unsigned char) data [char_nbr] > 127)
|
||||||
is_text = 0;
|
is_text = 0;
|
||||||
|
|
||||||
// printf (" SIZE [%03d] ", size);
|
|
||||||
|
//TExt is two header files
|
||||||
|
//non-text size=8 is X1, Y1, Q1
|
||||||
|
//non-text size=2 is -VALID
|
||||||
|
//non-text size=16 is timestamp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
printf (" SIZE [%03d] ", size);
|
||||||
|
|
||||||
|
|
||||||
if (is_text) {
|
if (is_text) {
|
||||||
cout << " TEXT +++++++++++ " << endl;
|
cout << " TEXT +++++++++++ " << endl;
|
||||||
}
|
}
|
||||||
@@ -230,11 +201,11 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
if (is_text) {
|
if (is_text) {
|
||||||
parsingSuccessful=reader.parse(data, parsedFromString);
|
parsingSuccessful=reader.parse(data, parsedFromString);
|
||||||
if (parsingSuccessful) {
|
if (parsingSuccessful) {
|
||||||
Json::StyledWriter styledWriter;
|
//Json::StyledWriter styledWriter;
|
||||||
//cout << "STYLED: --------------------------------" << endl;
|
//cout << "STYLED: --------------------------------" << endl;
|
||||||
//cout << styledWriter.write(parsedFromString) << endl;
|
//cout << styledWriter.write(parsedFromString) << endl;
|
||||||
//cout << "----------------------------------" << endl;
|
//cout << "----------------------------------" << endl;
|
||||||
cout << parsedFromString["htype"] << endl;
|
//cout << parsedFromString["htype"] << endl;
|
||||||
|
|
||||||
|
|
||||||
if (fastWriter.write(parsedFromString["htype"]).find("bsr_m-1.1") != std::string::npos) {
|
if (fastWriter.write(parsedFromString["htype"]).find("bsr_m-1.1") != std::string::npos) {
|
||||||
@@ -243,7 +214,7 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
hashIs=parsedFromString["hash"].asString();
|
hashIs=parsedFromString["hash"].asString();
|
||||||
|
|
||||||
if (hashOriginalFlag<2) {
|
if (hashOriginalFlag==0) {
|
||||||
cout << hashIs << " is different to original/// " << hashOriginal << endl;
|
cout << hashIs << " is different to original/// " << hashOriginal << endl;
|
||||||
hashOriginal=hashIs;
|
hashOriginal=hashIs;
|
||||||
++hashOriginalFlag;
|
++hashOriginalFlag;
|
||||||
@@ -252,10 +223,14 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
if (hashOriginal.compare(hashIs)!=0) {
|
if (hashOriginal.compare(hashIs)!=0) {
|
||||||
cout << hashIs << " is different to original " << hashOriginal << endl;
|
cout << hashIs << " is different to original " << hashOriginal << endl;
|
||||||
|
hashOriginal=hashIs;
|
||||||
|
++hashOriginalFlag;
|
||||||
fillBSPV=true;
|
fillBSPV=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
cout << "p id " << parsedFromString["pulse_id"].asUInt64() << endl;
|
cout << "p id " << parsedFromString["pulse_id"].asUInt64() << endl;
|
||||||
|
|
||||||
|
dbpm.setPulse_id(parsedFromString["pulse_id"].asUInt64());
|
||||||
|
|
||||||
//Reset values as a change of hash signifies that data from two pulse ids
|
//Reset values as a change of hash signifies that data from two pulse ids
|
||||||
//is being sent in one zeromq messages
|
//is being sent in one zeromq messages
|
||||||
@@ -283,9 +258,9 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
}
|
}
|
||||||
else if (fastWriter.write(parsedFromString["htype"]).find("bsr_d-1.1") != std::string::npos) {
|
else if (fastWriter.write(parsedFromString["htype"]).find("bsr_d-1.1") != std::string::npos) {
|
||||||
|
|
||||||
|
++nSequentialHeader;
|
||||||
|
|
||||||
|
if (fillBSPV) {
|
||||||
//if (fillBSPV) {
|
|
||||||
|
|
||||||
bsPV.clear();
|
bsPV.clear();
|
||||||
bsPV.reserve(dbpm.getNPV());
|
bsPV.reserve(dbpm.getNPV());
|
||||||
@@ -324,7 +299,7 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
//cout << "NEW FILL: size of bsPV " << bsPV.size() << endl;
|
//cout << "NEW FILL: size of bsPV " << bsPV.size() << endl;
|
||||||
fillBSPV=false;
|
fillBSPV=false;
|
||||||
//}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,26 +313,39 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//cout << "----------------------------------" << endl;
|
cout << "/----------------------------------/" << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (nSequentialHeader >5) {
|
if (nSequentialHeader >3 && is_text==1) {
|
||||||
cout << "WARNING: ZEROMQ SUB-MESSAGE DOES NOT CLOSE " << endl;
|
cout << "WARNING: ZEROMQ SUB-MESSAGE DOES NOT CLOSE " << endl;
|
||||||
cout << "WARNING: FORCING CLOSE AND BREAKING FROM LOOP " << endl;
|
cout << "WARNING: FORCING ZMQ_MSG_CLOSE " << endl;
|
||||||
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
|
||||||
|
|
||||||
zmq_msg_close (&message);
|
cout << "No of sequential headers " << nSequentialHeader << endl;
|
||||||
cout << "message mulipart --> more == " << more << endl;
|
cout << "is_text " << is_text << endl;
|
||||||
|
//zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
|
||||||
dbpm.status=LINUX_EAGAIN; //ICAFE_LINUX_ERROR +zmq_errno() ;
|
//zmq_msg_close (&message);
|
||||||
//break;
|
//cout << "message mulipart --> more == " << more << endl;
|
||||||
|
|
||||||
|
|
||||||
|
//nSequentialHeader=0;
|
||||||
|
//cannot break; results in seqmentation fault
|
||||||
|
|
||||||
|
//if (!more) {
|
||||||
|
// dbpm.status=ERRNO_EAGAIN; //ICAFE_ERRNO_BASE +zmq_errno() ;
|
||||||
|
// cout << "EARLY BREAK subMessage total: " << subMessage << endl;
|
||||||
|
// puts ("//------------------------------------END-------------------------------------//");
|
||||||
|
|
||||||
|
// break; // Last message
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
union foo
|
union foo
|
||||||
{
|
{
|
||||||
char c[sizeof(double)];
|
char c[sizeof(double)];
|
||||||
@@ -409,6 +397,8 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].set(v);
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].set(v);
|
||||||
|
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].setBSStatus(ICAFE_NORMAL);
|
||||||
|
|
||||||
//cout << " readback of value that was set = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].d << endl;
|
//cout << " readback of value that was set = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].d << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -465,6 +455,9 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//cout << "value DBPM = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].str << endl;
|
//cout << "value DBPM = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].str << endl;
|
||||||
|
|
||||||
|
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].setBSStatus(ICAFE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -501,19 +494,23 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
//cout << "subMessage above: " << subMessage << endl;
|
//cout << "subMessage above: " << subMessage << endl;
|
||||||
|
|
||||||
++subMessage;
|
++subMessage;
|
||||||
|
|
||||||
|
|
||||||
} //ifelse
|
} //ifelse
|
||||||
|
|
||||||
|
|
||||||
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
|
||||||
zmq_msg_close (&message);
|
zmq_msg_close (&message);
|
||||||
|
|
||||||
|
//cout << "value of more " << more << endl;
|
||||||
|
|
||||||
if (!more) {
|
if (!more) {
|
||||||
|
dbpm.status=ICAFE_NORMAL;
|
||||||
cout << "subMessage total: " << subMessage << endl;
|
cout << "subMessage total: " << subMessage << endl;
|
||||||
|
cout << " of which 0 size: " << nZeroSize << endl;
|
||||||
|
cout << " Percentage good: " << (subMessage-nZeroSize-2)*100/(subMessage-2);
|
||||||
puts ("//------------------------------------END-------------------------------------//");
|
puts ("//------------------------------------END-------------------------------------//");
|
||||||
|
|
||||||
break; // Last message part
|
break; // Last message part
|
||||||
@@ -522,6 +519,16 @@ s_dump (DBPMKeeper & dbpm)
|
|||||||
|
|
||||||
inDumpFlag=0;
|
inDumpFlag=0;
|
||||||
|
|
||||||
|
if (subMessage>2) {
|
||||||
|
dbpm.status=ICAFE_NORMAL;
|
||||||
|
cout << "subMessage total: " << subMessage << endl;
|
||||||
|
cout << " of which 0 size: " << nZeroSize << endl;
|
||||||
|
cout << " Percentage good: " << (subMessage-nZeroSize-2)*100/(subMessage-2);
|
||||||
|
puts ("//------------------------------------END-------------------------------------//");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cout << "end of loop " << endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -763,68 +770,6 @@ s_dump (void *socket)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set simple random printable identity on socket
|
|
||||||
//
|
|
||||||
static void
|
|
||||||
s_set_id (void *socket)
|
|
||||||
{
|
|
||||||
char identity [10];
|
|
||||||
sprintf (identity, "%04X-%04X", randof (0x10000), randof (0x10000));
|
|
||||||
zmq_setsockopt (socket, ZMQ_IDENTITY, identity, strlen (identity));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Sleep for a number of milliseconds
|
|
||||||
static void
|
|
||||||
s_sleep (int msecs)
|
|
||||||
{
|
|
||||||
#if (defined (WIN32))
|
|
||||||
Sleep (msecs);
|
|
||||||
#else
|
|
||||||
struct timespec t;
|
|
||||||
t.tv_sec = msecs / 1000;
|
|
||||||
t.tv_nsec = (msecs % 1000) * 1000000;
|
|
||||||
nanosleep (&t, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Return current system clock as milliseconds
|
#endif // ZHELPERS_H
|
||||||
static int64_t
|
|
||||||
s_clock (void)
|
|
||||||
{
|
|
||||||
#if (defined (WIN32))
|
|
||||||
SYSTEMTIME st;
|
|
||||||
GetSystemTime (&st);
|
|
||||||
return (int64_t) st.wSecond * 1000 + st.wMilliseconds;
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday (&tv, NULL);
|
|
||||||
return (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print formatted string to stdout, prefixed by date/time and
|
|
||||||
// terminated with a newline.
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void
|
|
||||||
s_console (const char *format, ...)
|
|
||||||
{
|
|
||||||
time_t curtime = time (NULL);
|
|
||||||
struct tm *loctime = localtime (&curtime);
|
|
||||||
char *formatted = (char*)malloc (20);
|
|
||||||
strftime (formatted, 20, "%y-%m-%d %H:%M:%S ", loctime);
|
|
||||||
printf ("%s", formatted);
|
|
||||||
free (formatted);
|
|
||||||
|
|
||||||
va_list argptr;
|
|
||||||
va_start (argptr, format);
|
|
||||||
vprintf (format, argptr);
|
|
||||||
va_end (argptr);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#endif // __ZHELPERS_H_INCLUDED__
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
830
include/zhelpers.h-
Normal file
830
include/zhelpers.h-
Normal file
@@ -0,0 +1,830 @@
|
|||||||
|
/* =====================================================================
|
||||||
|
zhelpers.h
|
||||||
|
|
||||||
|
Helper header file for example applications.
|
||||||
|
=====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __ZHELPERS_H_INCLUDED__
|
||||||
|
#define __ZHELPERS_H_INCLUDED__
|
||||||
|
|
||||||
|
#if HAVE_ZEROMQ
|
||||||
|
|
||||||
|
|
||||||
|
// Include a bunch of headers that we will need in the examples
|
||||||
|
|
||||||
|
#include <zmq.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if (defined (WIN32))
|
||||||
|
# include <time.h>
|
||||||
|
#else
|
||||||
|
# include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
// Version checking, and patch up missing constants to match 2.1
|
||||||
|
#if ZMQ_VERSION_MAJOR == 2
|
||||||
|
# error "Please upgrade to ZeroMQ/3.2 for these examples"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Provide random number from 0..(num-1)
|
||||||
|
#if (defined (WIN32))
|
||||||
|
# define randof(num) (int) ((float) (num) * rand () / (RAND_MAX + 1.0))
|
||||||
|
#else
|
||||||
|
# define randof(num) (int) ((float) (num) * random () / (RAND_MAX + 1.0))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_JSON
|
||||||
|
#include <json/json.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cafeService.h>
|
||||||
|
|
||||||
|
|
||||||
|
unsigned short inDumpFlag=2;
|
||||||
|
string hashIs="";
|
||||||
|
string hashOriginal="";
|
||||||
|
unsigned short hashOriginalFlag=0;
|
||||||
|
bool fillBSPV=false;
|
||||||
|
vector<std::string> bsPV;
|
||||||
|
|
||||||
|
// Receive 0MQ string from socket and convert into C string
|
||||||
|
// Caller must free returned string. Returns NULL if the context
|
||||||
|
// is being terminated.
|
||||||
|
static char *
|
||||||
|
s_recv (void *socket) {
|
||||||
|
char buffer [4096];
|
||||||
|
int size = zmq_recv (socket, buffer, 4096, 0); //ZMQ_DONTWAIT);
|
||||||
|
if (size == -1)
|
||||||
|
return NULL;
|
||||||
|
if (size > 4096)
|
||||||
|
size = 4096;
|
||||||
|
buffer [size] = 0;
|
||||||
|
return strdup (buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert C string to 0MQ string and send to socket
|
||||||
|
static int
|
||||||
|
s_send (void *socket, char *string) {
|
||||||
|
int size = zmq_send (socket, string, strlen (string), 0);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sends string as 0MQ string, as multipart non-terminal
|
||||||
|
static int
|
||||||
|
s_sendmore (void *socket, char *string) {
|
||||||
|
int size = zmq_send (socket, string, strlen (string), ZMQ_SNDMORE);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Receives all message parts from socket, prints neatly
|
||||||
|
//
|
||||||
|
static void
|
||||||
|
s_dump (DBPMKeeper & dbpm)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (inDumpFlag==1) {
|
||||||
|
cout << "zeroMQ socket is busy " << endl;
|
||||||
|
cout << "waiting got zmq timeout " << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
puts ("//START----------------------------------------//");
|
||||||
|
|
||||||
|
void * socket = dbpm.subscriber;
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_JSON
|
||||||
|
Json::Value parsedFromString;
|
||||||
|
Json::Reader reader;
|
||||||
|
bool parsingSuccessful;
|
||||||
|
Json::FastWriter fastWriter;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int64_t more; // Multipart detection
|
||||||
|
more = 0;
|
||||||
|
size_t more_size = sizeof (more);
|
||||||
|
|
||||||
|
int bsPVIdx=-1;
|
||||||
|
dbpm.status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
int nZeroSize=0;
|
||||||
|
|
||||||
|
cout << "df = " << inDumpFlag << endl;
|
||||||
|
|
||||||
|
while (inDumpFlag==1) {
|
||||||
|
cout << "df/ = " << inDumpFlag << endl;
|
||||||
|
cout << " sleeping " << endl;
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int subMessage=0;
|
||||||
|
int nSequentialHeader=0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
inDumpFlag=1;
|
||||||
|
|
||||||
|
// puts ("//WHILE LOOP ----------------------------------------//");
|
||||||
|
//cout << "subMessage " << subMessage << endl;
|
||||||
|
// Process all parts of the message
|
||||||
|
zmq_msg_t message;
|
||||||
|
zmq_msg_init (&message);
|
||||||
|
|
||||||
|
size_t size = zmq_msg_recv (&message, socket, 0);
|
||||||
|
//puts ("//MESSAGE RECEIVED ----------------------------------------//");
|
||||||
|
|
||||||
|
if (size == -1) {
|
||||||
|
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
||||||
|
//Resource unavailable means that there is nothing to read now
|
||||||
|
|
||||||
|
zmq_msg_close (&message);
|
||||||
|
dbpm.status=ICAFE_LINUX_ERROR+zmq_errno() ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (size == 0) {
|
||||||
|
|
||||||
|
//cout << " Data of Zero SIZE for submessage " << subMessage << endl;
|
||||||
|
|
||||||
|
++nZeroSize;
|
||||||
|
|
||||||
|
//zmq_msg_close (&message);
|
||||||
|
//dbpm.status=ECAFE_NODATA;
|
||||||
|
//break;
|
||||||
|
//Comes in pairs; one for val one for timestamp
|
||||||
|
if (nZeroSize%2==1) {
|
||||||
|
++bsPVIdx;
|
||||||
|
|
||||||
|
// cout << " pv with zero size: " << bsPV[bsPVIdx] << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
++subMessage;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Dump the message as text or binary
|
||||||
|
char *data = (char*)zmq_msg_data (&message);
|
||||||
|
int is_text = 1;
|
||||||
|
int char_nbr;
|
||||||
|
|
||||||
|
//char cmd[5000]="";
|
||||||
|
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++)
|
||||||
|
if ((unsigned char) data [char_nbr] < 32
|
||||||
|
|| (unsigned char) data [char_nbr] > 127)
|
||||||
|
is_text = 0;
|
||||||
|
|
||||||
|
// printf (" SIZE [%03d] ", size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (is_text) {
|
||||||
|
cout << " TEXT +++++++++++ " << endl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cout << " NOT TEXT +++++++++++ " << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
if (is_text) {
|
||||||
|
printf ("%c", data [char_nbr]);
|
||||||
|
//snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%c", data [char_nbr]);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf ("%02X", (unsigned char) data [char_nbr]);
|
||||||
|
//printf ("%d", (unsigned char) data [char_nbr]);
|
||||||
|
|
||||||
|
//snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%d", (unsigned char)data [char_nbr]);
|
||||||
|
|
||||||
|
//if (data[0] == '\x7') {
|
||||||
|
// cout << " little endian " << endl;
|
||||||
|
//}
|
||||||
|
//else {
|
||||||
|
// cout << "big endian " << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}//for
|
||||||
|
printf ("\n");
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (is_text) {
|
||||||
|
parsingSuccessful=reader.parse(data, parsedFromString);
|
||||||
|
if (parsingSuccessful) {
|
||||||
|
Json::StyledWriter styledWriter;
|
||||||
|
//cout << "STYLED: --------------------------------" << endl;
|
||||||
|
//cout << styledWriter.write(parsedFromString) << endl;
|
||||||
|
//cout << "----------------------------------" << endl;
|
||||||
|
cout << parsedFromString["htype"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (fastWriter.write(parsedFromString["htype"]).find("bsr_m-1.1") != std::string::npos) {
|
||||||
|
|
||||||
|
++nSequentialHeader;
|
||||||
|
|
||||||
|
hashIs=parsedFromString["hash"].asString();
|
||||||
|
|
||||||
|
if (hashOriginalFlag<2) {
|
||||||
|
cout << hashIs << " is different to original/// " << hashOriginal << endl;
|
||||||
|
hashOriginal=hashIs;
|
||||||
|
++hashOriginalFlag;
|
||||||
|
fillBSPV=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashOriginal.compare(hashIs)!=0) {
|
||||||
|
cout << hashIs << " is different to original " << hashOriginal << endl;
|
||||||
|
fillBSPV=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
cout << "p id " << parsedFromString["pulse_id"].asUInt64() << endl;
|
||||||
|
|
||||||
|
//Reset values as a change of hash signifies that data from two pulse ids
|
||||||
|
//is being sent in one zeromq messages
|
||||||
|
|
||||||
|
subMessage=0;
|
||||||
|
|
||||||
|
bsPVIdx=-1;
|
||||||
|
dbpm.status=ICAFE_NORMAL;
|
||||||
|
|
||||||
|
nZeroSize=0;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
cout << "(1)++++++++++++++++++++++++++++++++++++++++MAIN++++++++++++++++++++++++++++++++++++++++++" << endl;
|
||||||
|
|
||||||
|
cout << "hash " << parsedFromString["hash"] << endl;
|
||||||
|
cout << "p id " << parsedFromString["pulse_id"].asUInt64() << endl;
|
||||||
|
cout << "g ts " << parsedFromString["global_timestamp"] << endl;
|
||||||
|
cout << "comp " << parsedFromString["dh_compression"] << endl;
|
||||||
|
|
||||||
|
cout << "sec " << parsedFromString["global_timestamp"]["sec"].asUInt() << endl;
|
||||||
|
cout << "nsec " << parsedFromString["global_timestamp"]["ns"].asUInt() << endl;
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (fastWriter.write(parsedFromString["htype"]).find("bsr_d-1.1") != std::string::npos) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//if (fillBSPV) {
|
||||||
|
|
||||||
|
bsPV.clear();
|
||||||
|
bsPV.reserve(dbpm.getNPV());
|
||||||
|
/*
|
||||||
|
if (dbpm.getNPV() != parsedFromString["channels"].size() ) {
|
||||||
|
cout << "No of CONFIGURED BPMS: " << dbpm.getNPV()
|
||||||
|
<< " is diffent to that being channeled " << parsedFromString["channels"].size() << endl;
|
||||||
|
bsPV.reserve( max( (size_t) parsedFromString["channels"].size(),dbpm.getNPV()) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//cout << "chan " << parsedFromString["channels"] << endl;
|
||||||
|
|
||||||
|
cout << "No of channels " << parsedFromString["channels"].size() << endl;
|
||||||
|
|
||||||
|
cout << "(2)++++++++++++++++++++++++++++++++++++++++HEADER++++++++++++++++++++++++++++++++++++++++++" << endl;
|
||||||
|
|
||||||
|
for (Json::Value::ArrayIndex i=0; i < parsedFromString["channels"].size(); ++ i) {
|
||||||
|
|
||||||
|
//cout << "name " << parsedFromString["channels"][i]["name"].asString() << endl;
|
||||||
|
//cout << "enco " << parsedFromString["channels"][i]["encoding"] << endl;
|
||||||
|
//cout << "type " << parsedFromString["channels"][i]["type"] << endl;
|
||||||
|
|
||||||
|
bsPV.push_back( (parsedFromString["channels"][i]["name"]).asString());
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
cout << "LIST OF PVS " << endl;
|
||||||
|
for (size_t i=0; i< bsPV.size(); ++i ) {
|
||||||
|
cout << i << " // " << bsPV[i].c_str() << " " << endl;
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
*/
|
||||||
|
|
||||||
|
//cout << "NEW FILL: size of bsPV " << bsPV.size() << endl;
|
||||||
|
fillBSPV=false;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
cout << "HEADER IS SOMETHING ELSE: " << endl;
|
||||||
|
cout << parsedFromString["htype"] << endl;
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//cout << "----------------------------------" << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (nSequentialHeader >5) {
|
||||||
|
cout << "WARNING: ZEROMQ SUB-MESSAGE DOES NOT CLOSE " << endl;
|
||||||
|
cout << "WARNING: FORCING CLOSE AND BREAKING FROM LOOP " << endl;
|
||||||
|
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
|
||||||
|
zmq_msg_close (&message);
|
||||||
|
cout << "message mulipart --> more == " << more << endl;
|
||||||
|
|
||||||
|
dbpm.status=LINUX_EAGAIN; //ICAFE_LINUX_ERROR +zmq_errno() ;
|
||||||
|
//break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
union foo
|
||||||
|
{
|
||||||
|
char c[sizeof(double)];
|
||||||
|
double d;
|
||||||
|
|
||||||
|
} bar;
|
||||||
|
|
||||||
|
//SIZE 16 is timestamp
|
||||||
|
//SIZE 8 is x,y,Q
|
||||||
|
//SIZE 2 is valid
|
||||||
|
|
||||||
|
if (subMessage > 1430) {
|
||||||
|
cout << " SIZE " << size << " subMessage " << subMessage << endl;
|
||||||
|
cout << "size of bsPV " << bsPV.size() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subMessage > 0 && subMessage%2 ==0) {
|
||||||
|
if (size==8) {
|
||||||
|
|
||||||
|
// big endian
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
bar.c[char_nbr]=data[size-1-char_nbr]; // THis works for big engian
|
||||||
|
}
|
||||||
|
// little endian
|
||||||
|
//for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
// bar.c[char_nbr]=data[char_nbr];
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//cout << "UNION D " << bar.d << endl;
|
||||||
|
|
||||||
|
|
||||||
|
double v; // = (double*) data;
|
||||||
|
memcpy(&v, bar.c, sizeof(double));
|
||||||
|
//cout << " double val " << v << endl;
|
||||||
|
|
||||||
|
//This is BPM Data - value
|
||||||
|
++bsPVIdx;
|
||||||
|
|
||||||
|
if (dbpm.getPVIdx(bsPV[bsPVIdx]) <0) {
|
||||||
|
cout << " WARNING--> THIS CHANNEL WAS NOT REQUESTED IN CONFIGURATION FILE " << endl;
|
||||||
|
cout << " bsPV index = " << bsPVIdx << endl;
|
||||||
|
cout << " pv from bs = " << bsPV[bsPVIdx] << endl;
|
||||||
|
cout << " Illegal index Value =" << dbpm.getPVIdx(bsPV[bsPVIdx]) << endl;
|
||||||
|
cout << " SKIPPING THIS BPM... " << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].set(v);
|
||||||
|
|
||||||
|
//cout << " readback of value that was set = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].d << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (size==2) {
|
||||||
|
unsigned short iv;
|
||||||
|
//memcpy(&iv, cmd, size);
|
||||||
|
//big endian
|
||||||
|
for (size_t n=0; n < size; n++) {
|
||||||
|
iv = (iv << 8) + data[n];
|
||||||
|
}
|
||||||
|
//little endian
|
||||||
|
//for (size_t n = size; n >= 0; n--) {
|
||||||
|
// iv = (iv << 8) + data[n];
|
||||||
|
//}
|
||||||
|
|
||||||
|
//This is BPM Data - VALID/INVALID
|
||||||
|
|
||||||
|
//cout << "uint val (1 means valid) " << iv << endl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::copy(data, data + 32, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 8, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 4, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 2, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 1, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
|
||||||
|
*/
|
||||||
|
++bsPVIdx;
|
||||||
|
|
||||||
|
|
||||||
|
if (dbpm.getPVIdx(bsPV[bsPVIdx]) <0) {
|
||||||
|
cout << " WARNING--> THIS CHANNEL WAS NOT REQUESTED IN CONFIGURATION FILE " << endl;
|
||||||
|
cout << " bsPV index = " << bsPVIdx << endl;
|
||||||
|
cout << " pv from bs = " << bsPV[bsPVIdx] << endl;
|
||||||
|
cout << " Illegal index Value =" << dbpm.getPVIdx(bsPV[bsPVIdx]) << endl;
|
||||||
|
cout << " SKIPPING THIS BPM ENUM TYPE " << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (iv==1) {
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].set((std::string) "VALID");
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].set((std::string) "INVALID");
|
||||||
|
}
|
||||||
|
|
||||||
|
//cout << "value DBPM = " << dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].val[0].str << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (subMessage > 1 && subMessage%2 ==1) {
|
||||||
|
//cout << "timestamp " << endl;
|
||||||
|
unsigned int a,b;
|
||||||
|
for (size_t n=0; n < size/2; n++) {
|
||||||
|
a = (a << 8) + data[n];
|
||||||
|
}
|
||||||
|
for (size_t n=size/2; n < size; n++) {
|
||||||
|
b = (b << 8) + data[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
//cout << "a " << a << " b " << b << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (dbpm.getPVIdx(bsPV[bsPVIdx]) <0) {
|
||||||
|
cout << " WARNING--> THIS CHANNEL WAS NOT REQUESTED IN CONFIGURATION FILE " << endl;
|
||||||
|
cout << " bsPV index = " << bsPVIdx << endl;
|
||||||
|
cout << " pv from bs = " << bsPV[bsPVIdx] << endl;
|
||||||
|
cout << " Illegal index Value =" << dbpm.getPVIdx(bsPV[bsPVIdx]) << endl;
|
||||||
|
cout << " SKIPPING THIS BPM TIMESTAMP " << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].ts.secPastEpoch=a;
|
||||||
|
dbpm.pvd[dbpm.getPVIdx(bsPV[bsPVIdx])].ts.nsec=b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//cout << "subMessage above: " << subMessage << endl;
|
||||||
|
|
||||||
|
++subMessage;
|
||||||
|
|
||||||
|
|
||||||
|
} //ifelse
|
||||||
|
|
||||||
|
|
||||||
|
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
zmq_msg_close (&message);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!more) {
|
||||||
|
cout << "subMessage total: " << subMessage << endl;
|
||||||
|
puts ("//------------------------------------END-------------------------------------//");
|
||||||
|
|
||||||
|
break; // Last message part
|
||||||
|
}
|
||||||
|
} //while 1
|
||||||
|
|
||||||
|
inDumpFlag=0;
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Receives all message parts from socket, prints neatly
|
||||||
|
//
|
||||||
|
static void
|
||||||
|
s_dump (void *socket)
|
||||||
|
{
|
||||||
|
puts ("//START----------------------------------------//");
|
||||||
|
int subMessage=0;
|
||||||
|
#if HAVE_JSON
|
||||||
|
Json::Value parsedFromString;
|
||||||
|
Json::Reader reader;
|
||||||
|
bool parsingSuccessful;
|
||||||
|
Json::FastWriter fastWriter;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// Process all parts of the message
|
||||||
|
zmq_msg_t message;
|
||||||
|
zmq_msg_init (&message);
|
||||||
|
size_t size = zmq_msg_recv (&message, socket, 0);
|
||||||
|
|
||||||
|
if (size == -1) {
|
||||||
|
cout << " Error is " << zmq_errno() << " " << zmq_strerror(zmq_errno()) << endl;
|
||||||
|
//Resource unavailable means that there is nothing to read now
|
||||||
|
|
||||||
|
zmq_msg_close (&message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Dump the message as text or binary
|
||||||
|
char *data = (char*)zmq_msg_data (&message);
|
||||||
|
int is_text = 1;
|
||||||
|
int char_nbr;
|
||||||
|
|
||||||
|
//char cmd[5000]="";
|
||||||
|
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++)
|
||||||
|
if ((unsigned char) data [char_nbr] < 32
|
||||||
|
|| (unsigned char) data [char_nbr] > 127)
|
||||||
|
is_text = 0;
|
||||||
|
|
||||||
|
printf ("[%03d] ", size);
|
||||||
|
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
if (is_text) {
|
||||||
|
printf ("%c", data [char_nbr]);
|
||||||
|
//snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%c", data [char_nbr]);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf ("%02X", (unsigned char) data [char_nbr]);
|
||||||
|
//printf ("%d", (unsigned char) data [char_nbr]);
|
||||||
|
|
||||||
|
//snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%d", (unsigned char)data [char_nbr]);
|
||||||
|
|
||||||
|
//if (data[0] == '\x7') {
|
||||||
|
// cout << " little endian " << endl;
|
||||||
|
//}
|
||||||
|
//else {
|
||||||
|
// cout << "big endian " << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}//for
|
||||||
|
printf ("\n");
|
||||||
|
/*
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
if (is_text) {
|
||||||
|
printf ("%c", data [char_nbr]);
|
||||||
|
snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%c", data [char_nbr]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf ("%02X", (unsigned char) data [char_nbr]);
|
||||||
|
snprintf(cmd + strlen(cmd), (sizeof cmd) - strlen(cmd), "%02X", (unsigned char)data [size-1-char_nbr]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (is_text) {
|
||||||
|
parsingSuccessful=reader.parse(data, parsedFromString);
|
||||||
|
if (parsingSuccessful) {
|
||||||
|
Json::StyledWriter styledWriter;
|
||||||
|
cout << "STYLED: --------------------------------" << endl;
|
||||||
|
cout << styledWriter.write(parsedFromString) << endl;
|
||||||
|
cout << "----------------------------------" << endl;
|
||||||
|
cout << parsedFromString["htype"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (fastWriter.write(parsedFromString["htype"]).find("bsr_m-1.1") != std::string::npos) {
|
||||||
|
|
||||||
|
cout << "hash " << parsedFromString["hash"] << endl;
|
||||||
|
cout << "p id " << parsedFromString["pulse_id"].asUInt64() << endl;
|
||||||
|
cout << "g ts " << parsedFromString["global_timestamp"] << endl;
|
||||||
|
cout << "comp " << parsedFromString["dh_compression"] << endl;
|
||||||
|
|
||||||
|
cout << "sec " << parsedFromString["global_timestamp"]["sec"].asUInt() << endl;
|
||||||
|
cout << "nsec " << parsedFromString["global_timestamp"]["ns"].asUInt() << endl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (fastWriter.write(parsedFromString["htype"]).find("bsr_d-1.1") != std::string::npos) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cout << "chan " << parsedFromString["channels"] << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (Json::Value::ArrayIndex i=0; i < parsedFromString["channels"].size(); ++ i) {
|
||||||
|
|
||||||
|
cout << "name " << parsedFromString["channels"][i]["name"] << endl;
|
||||||
|
cout << "enco " << parsedFromString["channels"][i]["encoding"] << endl;
|
||||||
|
cout << "type " << parsedFromString["channels"][i]["type"] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cout << "----------------------------------" << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
union foo
|
||||||
|
{
|
||||||
|
char c[sizeof(double)];
|
||||||
|
double d;
|
||||||
|
|
||||||
|
} bar;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (subMessage > 0 && subMessage%2 ==0) {
|
||||||
|
if (size==8) {
|
||||||
|
|
||||||
|
// big endian
|
||||||
|
for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
bar.c[char_nbr]=data[size-1-char_nbr]; // THis works for big engian
|
||||||
|
}
|
||||||
|
// little endian
|
||||||
|
//for (char_nbr = 0; char_nbr < size; char_nbr++) {
|
||||||
|
// bar.c[char_nbr]=data[char_nbr];
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
cout << "UNION D " << bar.d << endl;
|
||||||
|
|
||||||
|
|
||||||
|
double v; // = (double*) data;
|
||||||
|
memcpy(&v, bar.c, sizeof(double));
|
||||||
|
cout << "double val " << v << endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (size==2) {
|
||||||
|
unsigned short i;
|
||||||
|
//memcpy(&i, cmd, size);
|
||||||
|
//big endian
|
||||||
|
for (size_t n=0; n < size; n++) {
|
||||||
|
i = (i << 8) + data[n];
|
||||||
|
}
|
||||||
|
//little endian
|
||||||
|
//for (size_t n = size; n >= 0; n--) {
|
||||||
|
// i = (i << 8) + data[n];
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
cout << "uint val " << i << endl;
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::copy(data, data + 32, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 8, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 4, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 2, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
std::copy(data, data + 1, reinterpret_cast<char *>(&i));
|
||||||
|
cout << "uint16 val " << i << endl;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (subMessage > 1 && subMessage%2 ==1) {
|
||||||
|
cout << "timestamp " << endl;
|
||||||
|
unsigned int a,b;
|
||||||
|
for (size_t n=0; n < size/2; n++) {
|
||||||
|
a = (a << 8) + data[n];
|
||||||
|
}
|
||||||
|
for (size_t n=size/2; n < size; n++) {
|
||||||
|
b = (b << 8) + data[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "a " << a << " b " << b << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
++subMessage;
|
||||||
|
|
||||||
|
} //ifelse
|
||||||
|
|
||||||
|
int64_t more; // Multipart detection
|
||||||
|
more = 0;
|
||||||
|
size_t more_size = sizeof (more);
|
||||||
|
zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size);
|
||||||
|
zmq_msg_close (&message);
|
||||||
|
if (!more) {
|
||||||
|
puts ("//END----------------------------------------//");
|
||||||
|
break; // Last message part
|
||||||
|
}
|
||||||
|
} //while 1
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set simple random printable identity on socket
|
||||||
|
//
|
||||||
|
static void
|
||||||
|
s_set_id (void *socket)
|
||||||
|
{
|
||||||
|
char identity [10];
|
||||||
|
sprintf (identity, "%04X-%04X", randof (0x10000), randof (0x10000));
|
||||||
|
zmq_setsockopt (socket, ZMQ_IDENTITY, identity, strlen (identity));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Sleep for a number of milliseconds
|
||||||
|
static void
|
||||||
|
s_sleep (int msecs)
|
||||||
|
{
|
||||||
|
#if (defined (WIN32))
|
||||||
|
Sleep (msecs);
|
||||||
|
#else
|
||||||
|
struct timespec t;
|
||||||
|
t.tv_sec = msecs / 1000;
|
||||||
|
t.tv_nsec = (msecs % 1000) * 1000000;
|
||||||
|
nanosleep (&t, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Return current system clock as milliseconds
|
||||||
|
static int64_t
|
||||||
|
s_clock (void)
|
||||||
|
{
|
||||||
|
#if (defined (WIN32))
|
||||||
|
SYSTEMTIME st;
|
||||||
|
GetSystemTime (&st);
|
||||||
|
return (int64_t) st.wSecond * 1000 + st.wMilliseconds;
|
||||||
|
#else
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday (&tv, NULL);
|
||||||
|
return (int64_t) (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print formatted string to stdout, prefixed by date/time and
|
||||||
|
// terminated with a newline.
|
||||||
|
|
||||||
|
/*
|
||||||
|
static void
|
||||||
|
s_console (const char *format, ...)
|
||||||
|
{
|
||||||
|
time_t curtime = time (NULL);
|
||||||
|
struct tm *loctime = localtime (&curtime);
|
||||||
|
char *formatted = (char*)malloc (20);
|
||||||
|
strftime (formatted, 20, "%y-%m-%d %H:%M:%S ", loctime);
|
||||||
|
printf ("%s", formatted);
|
||||||
|
free (formatted);
|
||||||
|
|
||||||
|
va_list argptr;
|
||||||
|
va_start (argptr, format);
|
||||||
|
vprintf (format, argptr);
|
||||||
|
va_end (argptr);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#endif // __ZHELPERS_H_INCLUDED__
|
||||||
|
|
||||||
|
#endif
|
||||||
14
makefile
14
makefile
@@ -131,8 +131,8 @@ distuninstallcheck_listfiles = find . -type f -print
|
|||||||
distcleancheck_listfiles = find . -type f -print
|
distcleancheck_listfiles = find . -type f -print
|
||||||
ACLOCAL = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run aclocal-1.11
|
ACLOCAL = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run aclocal-1.11
|
||||||
AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
|
AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
|
||||||
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_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 -L/opt/gfa/python-3.5/latest/lib -Wl,-rpath,/opt/gfa/python-3.5/latest/lib @CAFE_LIBS@
|
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 @CAFE_LIBS@
|
||||||
AR = ar
|
AR = ar
|
||||||
AUTOCONF = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoconf
|
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
|
AUTOHEADER = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoheader
|
||||||
@@ -143,7 +143,7 @@ CC = gcc
|
|||||||
CCDEPMODE = depmode=gcc3
|
CCDEPMODE = depmode=gcc3
|
||||||
CFLAGS = -g -O2
|
CFLAGS = -g -O2
|
||||||
CPP = gcc -E
|
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++
|
CXX = g++
|
||||||
CXXCPP = g++ -E
|
CXXCPP = g++ -E
|
||||||
CXXDEPMODE = depmode=gcc3
|
CXXDEPMODE = depmode=gcc3
|
||||||
@@ -166,9 +166,9 @@ INSTALL_PROGRAM = ${INSTALL}
|
|||||||
INSTALL_SCRIPT = ${INSTALL}
|
INSTALL_SCRIPT = ${INSTALL}
|
||||||
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
||||||
LD = /usr/bin/ld -m elf_x86_64
|
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 =
|
LIBOBJS =
|
||||||
LIBS = -lpython3.5m -lQtXml -lQtCore
|
LIBS = -lQtXml -lQtCore
|
||||||
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
||||||
LIPO =
|
LIPO =
|
||||||
LN_S = ln -s
|
LN_S = ln -s
|
||||||
@@ -227,7 +227,7 @@ htmldir = ${docdir}
|
|||||||
includedir = ${prefix}/include
|
includedir = ${prefix}/include
|
||||||
infodir = ${datarootdir}/info
|
infodir = ${datarootdir}/info
|
||||||
install_sh = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/install-sh
|
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-2/lib
|
||||||
libexecdir = ${exec_prefix}/libexec
|
libexecdir = ${exec_prefix}/libexec
|
||||||
localedir = ${datarootdir}/locale
|
localedir = ${datarootdir}/locale
|
||||||
localstatedir = ${prefix}/var
|
localstatedir = ${prefix}/var
|
||||||
@@ -236,7 +236,7 @@ mandir = ${datarootdir}/man
|
|||||||
mkdir_p = /bin/mkdir -p
|
mkdir_p = /bin/mkdir -p
|
||||||
oldincludedir = /usr/include
|
oldincludedir = /usr/include
|
||||||
pdfdir = ${docdir}
|
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-2
|
||||||
program_transform_name = s,x,x,
|
program_transform_name = s,x,x,
|
||||||
psdir = ${docdir}
|
psdir = ${docdir}
|
||||||
sbindir = ${exec_prefix}/sbin
|
sbindir = ${exec_prefix}/sbin
|
||||||
|
|||||||
98219
src/PyCafe2.cpp
Normal file
98219
src/PyCafe2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
68149
src/PyCafe2_March7.cpp
Normal file
68149
src/PyCafe2_March7.cpp
Normal file
File diff suppressed because it is too large
Load Diff
101266
src/PyCafe3_April.cpp
Normal file
101266
src/PyCafe3_April.cpp
Normal file
File diff suppressed because it is too large
Load Diff
79031
src/PyCafe3_March7.cpp
Normal file
79031
src/PyCafe3_March7.cpp
Normal file
File diff suppressed because it is too large
Load Diff
17
src/cafe.cpp
17
src/cafe.cpp
@@ -23,6 +23,7 @@
|
|||||||
#include "conduitGroup.h"
|
#include "conduitGroup.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
bool MUTEX=true;
|
bool MUTEX=true;
|
||||||
bool CHECK_CONSISTENCY_CA_STATE=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) {
|
if (channelInfo.getDataType()==DBF_STRING) {
|
||||||
chtMax=DBR_STRING;
|
chtMax=DBR_STRING;
|
||||||
break;
|
break;
|
||||||
@@ -171,6 +172,10 @@ int CAFE::get(const unsigned int handle, long long * _val, \
|
|||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
status=ICAFE_NORMAL;
|
status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemNative(handle);
|
unsigned int nn=handleHelper.getNelemNative(handle);
|
||||||
|
|
||||||
@@ -258,6 +263,9 @@ int CAFE::get(const unsigned int handle, long long * _val, \
|
|||||||
CAFE::getChannelInfo(handle, channelInfo);
|
CAFE::getChannelInfo(handle, channelInfo);
|
||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
}
|
}
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemNative(handle);
|
unsigned int nn=handleHelper.getNelemNative(handle);
|
||||||
@@ -344,6 +352,9 @@ int CAFE::get(const unsigned int handle, long long * _val){
|
|||||||
CAFE::getChannelInfo(handle, channelInfo);
|
CAFE::getChannelInfo(handle, channelInfo);
|
||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
}
|
}
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemNative(handle);
|
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) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemNative(handle);
|
unsigned int nn=handleHelper.getNelemNative(handle);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ int CAFE::getCache(const unsigned int *handleArray, unsigned int nelem, long l
|
|||||||
nbyteChType=1;
|
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) {
|
if (channelInfo.getDataType()==DBF_STRING) {
|
||||||
chtMax=DBR_STRING;
|
chtMax=DBR_STRING;
|
||||||
break;
|
break;
|
||||||
@@ -230,6 +230,10 @@ int CAFE::getCache(const unsigned int handle, long long * _val, \
|
|||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemRequest(handle);
|
unsigned int nn=handleHelper.getNelemRequest(handle);
|
||||||
|
|
||||||
@@ -318,6 +322,9 @@ int CAFE::getCache(const unsigned int handle, long long * _val, \
|
|||||||
CAFE::getChannelInfo(handle, channelInfo);
|
CAFE::getChannelInfo(handle, channelInfo);
|
||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
}
|
}
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemRequest(handle);
|
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) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
int _status=ICAFE_NORMAL;
|
int _status=ICAFE_NORMAL;
|
||||||
unsigned int nn=handleHelper.getNelemRequest(handle);
|
unsigned int nn=handleHelper.getNelemRequest(handle);
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ int CAFE::groupAttach(const unsigned int _groupHandle, PVGroup &pvgroup) {
|
|||||||
|
|
||||||
string s = handleHelper.getGroupNameFromGroupHandle(_groupHandle);
|
string s = handleHelper.getGroupNameFromGroupHandle(_groupHandle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int iIdx;
|
unsigned int iIdx;
|
||||||
|
|
||||||
if (s!="") {
|
if (s!="") {
|
||||||
@@ -450,13 +448,31 @@ int CAFE::groupSet(const unsigned int _groupHandle, PVGroup &pvgroup) {
|
|||||||
}
|
}
|
||||||
} //while
|
} //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 << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
||||||
cout << "Changed SG PUT from intitial " << originalTimeOut << " to: " <<
|
cout << "Changed SG PUT from intitial " << originalTimeOut << " to: " <<
|
||||||
(originalTimeOut +
|
(originalTimeOut +
|
||||||
channelTimeoutPolicySGPut.getDeltaTimeout()*ntries)
|
channelTimeoutPolicySGPut.getDeltaTimeout()*ntries)
|
||||||
<< " seconds after " << ntries << " sg_put calls " <<endl;
|
<< " seconds after " << ntries << " sg_put calls " <<endl;
|
||||||
}
|
}
|
||||||
|
} //IF
|
||||||
|
|
||||||
|
|
||||||
//Withdraw this test for now; not required
|
//Withdraw this test for now; not required
|
||||||
@@ -1265,6 +1281,7 @@ int CAFE::groupGet(const unsigned int _groupHandle, PVGroup &pvgroup) {
|
|||||||
<< " to: " << (originalTimeOut + channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
|
<< " to: " << (originalTimeOut + channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
|
||||||
<< " seconds" << endl;
|
<< " seconds" << endl;
|
||||||
|
|
||||||
|
|
||||||
channelTimeoutPolicySGGet.setTimeout( (originalTimeOut +
|
channelTimeoutPolicySGGet.setTimeout( (originalTimeOut +
|
||||||
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries));
|
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries));
|
||||||
|
|
||||||
@@ -1273,6 +1290,7 @@ int CAFE::groupGet(const unsigned int _groupHandle, PVGroup &pvgroup) {
|
|||||||
change_channelTimeoutPolicySGGet(channelTimeoutPolicySGGet));
|
change_channelTimeoutPolicySGGet(channelTimeoutPolicySGGet));
|
||||||
if(MUTEX){cafeMutex.unlock();} //unlock
|
if(MUTEX){cafeMutex.unlock();} //unlock
|
||||||
|
|
||||||
|
|
||||||
if (gStatus == ECA_TIMEOUT) {
|
if (gStatus == ECA_TIMEOUT) {
|
||||||
gStatus=(*it_groupHandle).get();
|
gStatus=(*it_groupHandle).get();
|
||||||
}
|
}
|
||||||
@@ -1280,12 +1298,35 @@ int CAFE::groupGet(const unsigned int _groupHandle, PVGroup &pvgroup) {
|
|||||||
} //while
|
} //while
|
||||||
|
|
||||||
if (ntries>0) {
|
if (ntries>0) {
|
||||||
|
//if (ntries >= channelTimeoutPolicySGGet.getNtries() ) {
|
||||||
cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
|
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 +
|
(originalTimeOut +
|
||||||
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
|
channelTimeoutPolicySGGet.getDeltaTimeout()*ntries)
|
||||||
<< " seconds after " << ntries << " sg_get calls " <<endl;
|
<< " seconds" << endl;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} //if
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Withdraw this test for now; not required
|
//Withdraw this test for now; not required
|
||||||
//if (ca_sg_test((*it_groupHandle).getGroupID()) == ECA_IOINPROGRESS) {
|
//if (ca_sg_test((*it_groupHandle).getGroupID()) == ECA_IOINPROGRESS) {
|
||||||
|
|||||||
@@ -451,6 +451,9 @@ int CAFE::get(const unsigned int _handle, vector<long long> & V,
|
|||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return 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();
|
unsigned int nelemThatWillBeRequested= (*it_handle).getChannelRegalia().getNelem();
|
||||||
|
|
||||||
@@ -2714,6 +2717,9 @@ int CAFE::set(const unsigned int _handle, vector<long long> V) {
|
|||||||
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
if ( channelInfo.getCafeConnectionState() == ICAFE_CS_NEVER_CONN) {
|
||||||
return ICAFE_CS_NEVER_CONN;
|
return ICAFE_CS_NEVER_CONN;
|
||||||
}
|
}
|
||||||
|
else if ( channelInfo.getCafeConnectionState()==ICAFE_CS_CLOSED) {
|
||||||
|
return ICAFE_CS_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
switch ( channelInfo.getDataType()) {
|
switch ( channelInfo.getDataType()) {
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ Conduit::Conduit(const char * _pv, ca_client_context *_ccc, bool _pyCafeFlag) {
|
|||||||
* \param _pv input: process variable
|
* \param _pv input: process variable
|
||||||
* \param _ccc input: ca_client_context
|
* \param _ccc input: ca_client_context
|
||||||
* \param _pyCafeFlag input: bool
|
* \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,
|
Conduit::Conduit(const char * _pv, ca_client_context *_ccc,
|
||||||
ChannelRequestPolicy _channelRequestPolicyPut, ChannelRequestPolicy _channelRequestPolicyGet,
|
ChannelRequestPolicy _channelRequestPolicyPut, ChannelRequestPolicy _channelRequestPolicyGet,
|
||||||
@@ -382,7 +385,7 @@ int Conduit::getPVDataHolder(PVDataHolder & _pvd) const {
|
|||||||
chtype channelType = channelRequestMetaData.getDbrDataType();
|
chtype channelType = channelRequestMetaData.getDbrDataType();
|
||||||
CAFENUM::DBR_TYPE dbrTypeClass=helper.convertToCAFEDbrTypeClass(channelType);
|
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)
|
switch(dbrTypeClass)
|
||||||
{
|
{
|
||||||
@@ -610,7 +613,7 @@ int Conduit::getPVDataHolder(PVDataHolder & _pvd) const {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPENOTCONN:
|
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 << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
|
||||||
cout << "ERROR CAFE_TYPENOTCONN: dataType: "
|
cout << "ERROR CAFE_TYPENOTCONN: dataType: "
|
||||||
<< channelType << " : " << dbr_type_to_text(channelType) << endl;
|
<< channelType << " : " << dbr_type_to_text(channelType) << endl;
|
||||||
@@ -648,7 +651,7 @@ int Conduit::getPVCtrlHolder(PVCtrlHolder & _pvc) const {
|
|||||||
|
|
||||||
CAFENUM::DBR_TYPE dbrTypeClass=helper.convertToCAFEDbrTypeClass(channelType);
|
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)
|
switch(dbrTypeClass)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,11 +57,10 @@ ConduitGroup::ConduitGroup(const char * _groupName, ca_client_context * _ccc, C
|
|||||||
++groupHandleNext;
|
++groupHandleNext;
|
||||||
groupHandle = groupHandleNext;
|
groupHandle = groupHandleNext;
|
||||||
|
|
||||||
|
|
||||||
mStatus = new int [nMember];
|
mStatus = new int [nMember];
|
||||||
mRule = new bool[nMember];
|
mRule = new bool[nMember];
|
||||||
for (unsigned int i=0; i<nMember; ++i) {
|
for (unsigned int i=0; i<nMember; ++i) {
|
||||||
mRule[i]="true";
|
mRule[i]=true;
|
||||||
mStatus[i]=ICAFE_NORMAL;
|
mStatus[i]=ICAFE_NORMAL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
510
src/connect.cpp
510
src/connect.cpp
@@ -93,6 +93,9 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
|
|||||||
|
|
||||||
if (status != ECA_NORMAL) {
|
if (status != ECA_NORMAL) {
|
||||||
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " ca_create_channel failed: " << endl;
|
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " ca_create_channel failed: " << endl;
|
||||||
|
if (status == ECA_EVDISALLOW) {
|
||||||
|
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " inappropriate function " << endl;
|
||||||
|
}
|
||||||
cafeStatus.report(status);
|
cafeStatus.report(status);
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.lock();} //lock
|
if(MUTEX){cafeMutex.lock();} //lock
|
||||||
@@ -108,11 +111,57 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
|
|||||||
|
|
||||||
if (channelOpenPolicy.getWhenToFlushSendBuffer()==FLUSH_AFTER_EACH_CHANNEL_CREATION) {
|
if (channelOpenPolicy.getWhenToFlushSendBuffer()==FLUSH_AFTER_EACH_CHANNEL_CREATION) {
|
||||||
|
|
||||||
channelOpenPolicy.flushSendBufferNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
//cout << "channelOpenPolicy.getTimeout() " << channelOpenPolicy.getTimeout() << endl;
|
||||||
|
|
||||||
|
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;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//else {
|
||||||
|
|
||||||
|
//cout << "channelOpenPolicy.getWhenToFlushSendBuffer() is " << channelOpenPolicy.getWhenToFlushSendBuffer() << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
// Peculiar if true
|
// Peculiar if true
|
||||||
|
/*
|
||||||
if (status == ECA_EVDISALLOW) {
|
if (status == ECA_EVDISALLOW) {
|
||||||
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " inappropriate function " << endl;
|
cout << __FILE__ << "//" << __LINE__ << "//"<< __METHOD__ << " inappropriate function " << endl;
|
||||||
cafeStatus.report(status);
|
cafeStatus.report(status);
|
||||||
@@ -120,6 +169,11 @@ int Connect::createChannel(unsigned int handle, const char * pv, chid &pCh) {
|
|||||||
handle_index.modify(it_handle, change_status (status) );
|
handle_index.modify(it_handle, change_status (status) );
|
||||||
if(MUTEX){cafeMutex.unlock();} //unlock
|
if(MUTEX){cafeMutex.unlock();} //unlock
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ECAFE_INVALID_HANDLE;
|
return ECAFE_INVALID_HANDLE;
|
||||||
@@ -420,7 +474,9 @@ int Connect::open(const char ** pvArray, unsigned int * handleArray,
|
|||||||
}
|
}
|
||||||
catch (CAFEException_open &e) {
|
catch (CAFEException_open &e) {
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw(e);
|
throw(e);
|
||||||
@@ -429,7 +485,9 @@ int Connect::open(const char ** pvArray, unsigned int * handleArray,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ICAFE_NORMAL;
|
return ICAFE_NORMAL;
|
||||||
@@ -471,7 +529,9 @@ int Connect::open(const string *pvArrayS, unsigned int *handleArray, const unsi
|
|||||||
}
|
}
|
||||||
catch (CAFEException_open &e) {
|
catch (CAFEException_open &e) {
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw(e);
|
throw(e);
|
||||||
@@ -480,7 +540,9 @@ int Connect::open(const string *pvArrayS, unsigned int *handleArray, const unsi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ICAFE_NORMAL;
|
return ICAFE_NORMAL;
|
||||||
@@ -527,7 +589,9 @@ int Connect::open(vector<string> pvV, vector<unsigned int> &handleV)
|
|||||||
}
|
}
|
||||||
catch (CAFEException_open &e) {
|
catch (CAFEException_open &e) {
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw(e);
|
throw(e);
|
||||||
@@ -536,7 +600,9 @@ int Connect::open(vector<string> pvV, vector<unsigned int> &handleV)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ICAFE_NORMAL;
|
return ICAFE_NORMAL;
|
||||||
@@ -582,7 +648,9 @@ int Connect::open(vector<const char *> pvV, vector<unsigned int> &handleV)
|
|||||||
}
|
}
|
||||||
catch (CAFEException_open &e) {
|
catch (CAFEException_open &e) {
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw(e);
|
throw(e);
|
||||||
@@ -591,7 +659,9 @@ int Connect::open(vector<const char *> pvV, vector<unsigned int> &handleV)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flushAtEndFlag) {
|
if (flushAtEndFlag) {
|
||||||
channelOpenPolicy.flushSendBufferNow(); //this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
//channelOpenPolicy.flushSendBufferNow();
|
||||||
|
//this also resets whenKind=FLUSH_AFTER_EACH_CHANNEL_CREATION
|
||||||
|
Connect::openNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1124,19 +1194,17 @@ int Connect::open(const char * _pv, const char * _pvAlias, unsigned int & hand
|
|||||||
|
|
||||||
if (it_handle != handle_index.end()) {
|
if (it_handle != handle_index.end()) {
|
||||||
|
|
||||||
|
|
||||||
if ((*it_handle).getChannelID() != NULL && cctLocal != NULL ) {
|
if ((*it_handle).getChannelID() != NULL && cctLocal != NULL ) {
|
||||||
|
|
||||||
|
|
||||||
status = ca_clear_channel((*it_handle).getChannelID());
|
status = ca_clear_channel((*it_handle).getChannelID());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (status != ECA_NORMAL) {
|
if (status != ECA_NORMAL) {
|
||||||
return status; //ECA_BADCHID
|
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();}
|
if(MUTEX){cafeMutex.lock();}
|
||||||
handle_index.modify(it_handle, free_dataBuffers());
|
handle_index.modify(it_handle, free_dataBuffers());
|
||||||
if(MUTEX){cafeMutex.unlock();}
|
if(MUTEX){cafeMutex.unlock();}
|
||||||
@@ -1192,7 +1260,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
|
* \return ECA_NORMAL if all OK; error if one or more channelIDs fail to close
|
||||||
*/
|
*/
|
||||||
int Connect::closeHandles(unsigned int * handleArray, unsigned int nHandles) {
|
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
|
//copy array to vector and remove dupliacte handles
|
||||||
@@ -1373,6 +1441,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
|
* \brief Closes channels for the given channel access client context. \n
|
||||||
* Shuts down the 'local' channel access client context and frees allocated resources \n
|
* Shuts down the 'local' channel access client context and frees allocated resources \n
|
||||||
@@ -1829,7 +2230,8 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
|
|||||||
//FIRST CHECK IF CONNECTED!
|
//FIRST CHECK IF CONNECTED!
|
||||||
//Once connected, then we have this information stored
|
//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.setDataType((*it_handle).getChannelRegalia().getDataType());
|
||||||
mp.setNelem((*it_handle).getChannelRegalia().getNelem());
|
mp.setNelem((*it_handle).getChannelRegalia().getNelem());
|
||||||
}
|
}
|
||||||
@@ -2186,6 +2588,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
|
* \brief print status information of given handle
|
||||||
* \param handle input: handle to Conduit object \n
|
* \param handle input: handle to Conduit object \n
|
||||||
@@ -2214,6 +2684,7 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief print status information of given handle only on error
|
* \brief print status information of given handle only on error
|
||||||
* \param handle input: handle to Conduit object \n
|
* \param handle input: handle to Conduit object \n
|
||||||
@@ -2394,7 +2865,7 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief print status information of given PVs only on error
|
* \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 nelem input: size of array of handles
|
||||||
* \param statusArray input: array of statuses \n
|
* \param statusArray input: array of statuses \n
|
||||||
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
|
* \return ECA_NORMAL if all OK else ECAFE_INVALID_HANDLE (if one or more handles are invalid)
|
||||||
@@ -2419,6 +2890,9 @@ int Connect::monitorStart(vector<unsigned int> handleV, vector<int> &statusV,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Closes all channels within the given context and their respective handles \n
|
* \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
|
* Shuts down the given channel access client context and frees allocated resources \n
|
||||||
|
|||||||
3043
src/connect.cpp-
Normal file
3043
src/connect.cpp-
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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 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
|
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
|
||||||
*/
|
*/
|
||||||
int Connect::devicePositionOrderedMultiMap(const char * collectionName, std::multimap<float, string> &posDev) {
|
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 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
|
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
|
||||||
*/
|
*/
|
||||||
int Connect::devicePositionMap(const char * collectionName, std::map<float, string> &posDev) {
|
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 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
|
* \return ICAFE_NORMAL is all OK else, ECAFE_UNKNOWN_COLLECTION
|
||||||
*/
|
*/
|
||||||
int Connect::devicePositionV(const char * collectionName, std::vector<string> &dev, std::vector<float> &pos) {
|
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
|
* Establishes virtual circuit to epics process variable
|
||||||
* for each group member by calling Connect::open(pv, &handle)
|
* 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
|
//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;
|
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
|
//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) {
|
if (status != ECA_NORMAL) {
|
||||||
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " ca_create_channel failed: " << endl;
|
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " ca_create_channel failed: " << endl;
|
||||||
|
if (status == ECA_EVDISALLOW) {
|
||||||
|
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " inappropriate function " << endl;
|
||||||
|
}
|
||||||
cafeStatus.report(status);
|
cafeStatus.report(status);
|
||||||
|
|
||||||
if(MUTEX){cafeMutex.lock();} //lock
|
if(MUTEX){cafeMutex.lock();} //lock
|
||||||
@@ -1712,6 +1787,7 @@ int Connect::createChannelWithinGroup(unsigned int _handle, const char * pv, chi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Peculiar if true
|
// Peculiar if true
|
||||||
|
/*
|
||||||
if (status == ECA_EVDISALLOW) {
|
if (status == ECA_EVDISALLOW) {
|
||||||
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " inappropriate function " << endl;
|
cout << __FILE__ << "/" << __LINE__ << "/"<< __METHOD__ << " inappropriate function " << endl;
|
||||||
cafeStatus.report(status);
|
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) );
|
handle_index.modify(it_handle, change_status (status) );
|
||||||
if(MUTEX){cafeMutex.unlock();} //unlock
|
if(MUTEX){cafeMutex.unlock();} //unlock
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ECAFE_INVALID_HANDLE;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ int Granules::channelVerifyPut(const unsigned int _handle, chtype _dbrType) {
|
|||||||
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
||||||
return 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()) {
|
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
|
||||||
status=helper.checkConsistency(_handle);
|
status=helper.checkConsistency(_handle);
|
||||||
@@ -386,26 +390,26 @@ int Granules::channelExecutePut(const unsigned int _handle) {
|
|||||||
if (status==ECAFE_TIMEOUT) {
|
if (status==ECAFE_TIMEOUT) {
|
||||||
std::cout << "is the MAXIMUM allowed as configured through TimeoutPolicy! " << std::endl;
|
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;
|
std::cout << " SELF-GOVERNING TIMEOUT FOR SET OPERATIONS FOR THIS CHANNEL" << std::endl;
|
||||||
channelTimeoutPolicyPut.setSelfGoverningTimeout(false);
|
channelTimeoutPolicyPut.setSelfGoverningTimeout(false);
|
||||||
channelTimeoutPolicyPut.setTimeout( channelTimeoutPolicyPut.getTimeout() );
|
channelTimeoutPolicyPut.setTimeout( channelTimeoutPolicyPut.getTimeout() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "Changing timeout for handle/pv "
|
std::cout << "Changing timeout for handle/pv "
|
||||||
<< _handle << "/" << (*it_handle).getPV() << " to: " <<
|
<< _handle << "/" << (*it_handle).getPV() << " to: " <<
|
||||||
(channelTimeoutPolicyPut.getTimeout() +
|
(channelTimeoutPolicyPut.getTimeout() +
|
||||||
channelTimeoutPolicyPut.getDeltaTimeout()*ntries) << " seconds" <<endl;
|
channelTimeoutPolicyPut.getDeltaTimeout()*ntries) << " seconds" <<endl;
|
||||||
channelTimeoutPolicyPut.setTimeout( (channelTimeoutPolicyPut.getTimeout() +
|
channelTimeoutPolicyPut.setTimeout( (channelTimeoutPolicyPut.getTimeout() +
|
||||||
channelTimeoutPolicyPut.getDeltaTimeout()*ntries));
|
channelTimeoutPolicyPut.getDeltaTimeout()*ntries));
|
||||||
}
|
}
|
||||||
if(MUTEX){cafeMutex.lock();} //lock
|
if(MUTEX){cafeMutex.lock();} //lock
|
||||||
handle_index.modify(it_handle, change_channelTimeoutPolicyPut(channelTimeoutPolicyPut));
|
handle_index.modify(it_handle, change_channelTimeoutPolicyPut(channelTimeoutPolicyPut));
|
||||||
if(MUTEX){cafeMutex.unlock();} //unlock
|
if(MUTEX){cafeMutex.unlock();} //unlock
|
||||||
|
|
||||||
if (status==ECAFE_TIMEOUT) {
|
if (status==ECAFE_TIMEOUT) {
|
||||||
std::cout << "CURRENT STATUS OF HANDLE: " << std::endl;
|
std::cout << "CURRENT STATUS OF HANDLE: " << std::endl;
|
||||||
helper.printHandle(_handle);
|
helper.printHandle(_handle);
|
||||||
}
|
}
|
||||||
} //isConnected
|
} //isConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,9 +562,15 @@ int Granules::channelVerifyGet(const unsigned int _handle, chtype _dbrType) {
|
|||||||
|
|
||||||
if (it_handle != handle_index.end()) {
|
if (it_handle != handle_index.end()) {
|
||||||
|
|
||||||
|
|
||||||
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
||||||
return 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()) {
|
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
|
||||||
status=helper.checkConsistency(_handle);
|
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_channelRequestStatusGet(channelRequestStatusGet));
|
||||||
|
|
||||||
handle_index.modify(it_handle, change_status(ICAFE_CA_OP_CONN_DOWN)); //for return
|
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;
|
return ICAFE_CA_OP_CONN_DOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1447,15 +1457,15 @@ int Granules::waitForGetEvent(const unsigned int _handle, double _timeout) {
|
|||||||
|
|
||||||
while (channelRequestStatusGet.getCallbackProgressKind() == CAFENUM::PENDING
|
while (channelRequestStatusGet.getCallbackProgressKind() == CAFENUM::PENDING
|
||||||
&& timeElapsed < _timeout){
|
&& timeElapsed < _timeout){
|
||||||
ca_flush_io();
|
ca_flush_io();
|
||||||
|
|
||||||
#if HAVE_BOOST_THREAD
|
#if HAVE_BOOST_THREAD
|
||||||
boost::this_thread::sleep_for(boost::chrono::microseconds(20));
|
boost::this_thread::sleep_for(boost::chrono::microseconds(20));
|
||||||
#else
|
#else
|
||||||
#if HAVE_LINUX
|
#if HAVE_LINUX
|
||||||
usleep(20);
|
usleep(20);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
++nPoll;
|
++nPoll;
|
||||||
|
|
||||||
ptime timeEnd(microsec_clock::local_time());
|
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 != handle_index.end()) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
if ( (*it_handle).getChannelRegalia().getCafeConnectionState()==ICAFE_CS_NEVER_CONN) {
|
||||||
return 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()) {
|
if ( CHECK_CONSISTENCY_CA_STATE && !(*it_handle).isConnected()) {
|
||||||
status=helper.checkConsistency(_handle);
|
status=helper.checkConsistency(_handle);
|
||||||
|
|||||||
@@ -1112,7 +1112,7 @@ unsigned int HandleHelper::getHandleFromPVWithinGroup(const char * _pv,
|
|||||||
* \return vector of handles within Group
|
* \return vector of handles within Group
|
||||||
*/
|
*/
|
||||||
vector<unsigned int> HandleHelper::getHandlesFromWithinGroupV(unsigned int _groupHandle) {
|
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 & groupHandle_index = gs.get<by_groupHandle> ();
|
||||||
cafeGroup_set_by_groupHandle::iterator it_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
|
* \return array of handles within Group
|
||||||
*/
|
*/
|
||||||
unsigned int * HandleHelper::getHandlesFromWithinGroup(unsigned int _groupHandle) {
|
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 & groupHandle_index = gs.get<by_groupHandle> ();
|
||||||
cafeGroup_set_by_groupHandle::iterator it_groupHandle;
|
cafeGroup_set_by_groupHandle::iterator it_groupHandle;
|
||||||
@@ -1187,6 +1187,74 @@ unsigned int * HandleHelper::getHandlesFromWithinGroup(unsigned int _groupHand
|
|||||||
#undef __METHOD__
|
#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
|
* \brief Method returns true if channel is connected, else false
|
||||||
* \param handle input: handle
|
* \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
|
* \brief Retrieves last cached status information for given handle
|
||||||
* \param _handle input: 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
|
* \brief Rerieves vector of handles for given vector of PVs
|
||||||
* \param pvV input: 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) {
|
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
|
* \brief Rerieves vector of handles for given vector of PVs
|
||||||
* \param pvV input: vector of PVS
|
* \param pvV input: vector of PVS
|
||||||
* \param ccc input: ca_client_context *
|
* \param ccc input: ca_client_context *
|
||||||
* \param handleV output: vector of handles
|
|
||||||
* \return ICAFE_NORMAL if all OK else ECAFE_INVALID_HANDLE
|
* \return ICAFE_NORMAL if all OK else ECAFE_INVALID_HANDLE
|
||||||
*/
|
*/
|
||||||
vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV, ca_client_context * ccc) {
|
vector<unsigned int> HandleHelper::getHandlesFromPVs(vector<string> pvV, ca_client_context * ccc) {
|
||||||
|
|||||||
14
src/makefile
14
src/makefile
@@ -111,8 +111,8 @@ AMTAR = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run tar
|
|||||||
#if HAVE_ZEROMQ
|
#if HAVE_ZEROMQ
|
||||||
#libcafe_la_SOURCES += cafeService.cpp
|
#libcafe_la_SOURCES += cafeService.cpp
|
||||||
#endif
|
#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_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 -L/opt/gfa/python-3.5/latest/lib -Wl,-rpath,/opt/gfa/python-3.5/latest/lib
|
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
|
AR = ar
|
||||||
AUTOCONF = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoconf
|
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
|
AUTOHEADER = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/missing --run autoheader
|
||||||
@@ -123,7 +123,7 @@ CC = gcc
|
|||||||
CCDEPMODE = depmode=gcc3
|
CCDEPMODE = depmode=gcc3
|
||||||
CFLAGS = -g -O2
|
CFLAGS = -g -O2
|
||||||
CPP = gcc -E
|
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++
|
CXX = g++
|
||||||
CXXCPP = g++ -E
|
CXXCPP = g++ -E
|
||||||
CXXDEPMODE = depmode=gcc3
|
CXXDEPMODE = depmode=gcc3
|
||||||
@@ -146,9 +146,9 @@ INSTALL_PROGRAM = ${INSTALL}
|
|||||||
INSTALL_SCRIPT = ${INSTALL}
|
INSTALL_SCRIPT = ${INSTALL}
|
||||||
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
||||||
LD = /usr/bin/ld -m elf_x86_64
|
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 =
|
LIBOBJS =
|
||||||
LIBS = -lpython3.5m -lQtXml -lQtCore
|
LIBS = -lQtXml -lQtCore
|
||||||
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
||||||
LIPO =
|
LIPO =
|
||||||
LN_S = ln -s
|
LN_S = ln -s
|
||||||
@@ -207,7 +207,7 @@ htmldir = ${docdir}
|
|||||||
includedir = ${prefix}/include
|
includedir = ${prefix}/include
|
||||||
infodir = ${datarootdir}/info
|
infodir = ${datarootdir}/info
|
||||||
install_sh = ${SHELL} /afs/psi.ch/project/cafe/gitlab/CAFE/cpp/install-sh
|
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-2/lib
|
||||||
libexecdir = ${exec_prefix}/libexec
|
libexecdir = ${exec_prefix}/libexec
|
||||||
localedir = ${datarootdir}/locale
|
localedir = ${datarootdir}/locale
|
||||||
localstatedir = ${prefix}/var
|
localstatedir = ${prefix}/var
|
||||||
@@ -216,7 +216,7 @@ mandir = ${datarootdir}/man
|
|||||||
mkdir_p = /bin/mkdir -p
|
mkdir_p = /bin/mkdir -p
|
||||||
oldincludedir = /usr/include
|
oldincludedir = /usr/include
|
||||||
pdfdir = ${docdir}
|
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-2
|
||||||
program_transform_name = s,x,x,
|
program_transform_name = s,x,x,
|
||||||
psdir = ${docdir}
|
psdir = ${docdir}
|
||||||
sbindir = ${exec_prefix}/sbin
|
sbindir = ${exec_prefix}/sbin
|
||||||
|
|||||||
Reference in New Issue
Block a user