diff --git a/autogen_cafe3z_release.sh b/autogen_cafe3z_release.sh deleted file mode 100644 index 8bff51f..0000000 --- a/autogen_cafe3z_release.sh +++ /dev/null @@ -1,49 +0,0 @@ -#source usePy3 -aclocal --force -I m4 -libtoolize --force --copy -autoconf --force -autoheader --force -automake --force --add-missing --copy -autoreconf - -#Check what the EPICS RELEASE IS from ${EPICS}/base -#Used by ./configure -#Assumes format ${EPICS}/base-3.14.12 - - -EB=$(readlink ${EPICS}/base) -echo 'EPICS BASE IS=' $EB -EB1=$(echo $EB | sed -e "s/[a-zA-Z]*-//g") -EBMAJ=$(echo $EB1 | sed -e "s/[[:punct:]].*//g") -EBMIN1=$(echo $EB1 | sed -e "s/^[[:digit:]]*[[:punct:]]//g") -EBMIN=$(echo $EBMIN1 | sed -e "s/[[:punct:]][[:digit:]]*//g") -EBPAT=$(echo $EB1 | sed -e "s/[[:digit:]]*[[:punct:]]//g") -echo EPICS_MAJOR=$EBMAJ -echo EPICS_MINOR=$EBMIN -echo EPICS_PATCH=$EBPAT - -export CAFE_EPICS_V_MAJOR=$EBMAJ -export CAFE_EPICS_V_MINOR=$EBMIN -export CAFE_EPICS_V_PATCH=$EBPAT - -#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \ -CYCAFE_VERSION=cafez-1.3.0-alpha-1 - -./configure \ - --prefix=/opt/gfa/cafe/cpp/${CYCAFE_VERSION}/ \ - --libdir=/opt/gfa/cafe/cpp/${CYCAFE_VERSION}/lib \ - --enable-boost-inc --with-boost-inc=/opt/gfa/cafe/boost/boost_1_61_0/include \ - --enable-epics --with-epics=${EPICS}/base \ - --enable-qt4-lib --with-qt4-lib=/usr/lib64 \ - --enable-qt4-inc --with-qt4-inc=/usr/include \ - --enable-zeromq-inc --with-zeromq-inc=/opt/gfa/zmq/zeromq-4.1.5/include \ - --enable-zeromq-lib --with-zeromq-lib=/opt/gfa/zmq/zeromq-4.1.5/lib \ - --enable-json-inc --with-json-inc=/opt/gfa/zmsglog/json/jsoncpp-src-0.6.0-rc2/include \ - --enable-json-lib --with-json-lib=/opt/gfa/zmsglog/json/jsoncpp-src-0.6.0-rc2/libs/linux-gcc-4.4.7 - -unset CAFE_EPICS_V_MAJOR -unset CAFE_EPICS_V_MINOR -unset CAFE_EPICS_V_PATCH - -cp include/config.h include/os/Linux/cafe/config.h - diff --git a/autogen_cafepy3z_release.sh b/autogen_cafepy3z_release.sh deleted file mode 100644 index 2711dfa..0000000 --- a/autogen_cafepy3z_release.sh +++ /dev/null @@ -1,53 +0,0 @@ -source usePy3 -aclocal --force -I m4 -libtoolize --force --copy -autoconf --force -autoheader --force -automake --force --add-missing --copy -autoreconf - -#Check what the EPICS RELEASE IS from ${EPICS}/base -#Used by ./configure -#Assumes format ${EPICS}/base-3.14.12 - - -EB=$(readlink ${EPICS}/base) -echo 'EPICS BASE IS=' $EB -EB1=$(echo $EB | sed -e "s/[a-zA-Z]*-//g") -EBMAJ=$(echo $EB1 | sed -e "s/[[:punct:]].*//g") -EBMIN1=$(echo $EB1 | sed -e "s/^[[:digit:]]*[[:punct:]]//g") -EBMIN=$(echo $EBMIN1 | sed -e "s/[[:punct:]][[:digit:]]*//g") -EBPAT=$(echo $EB1 | sed -e "s/[[:digit:]]*[[:punct:]]//g") -echo EPICS_MAJOR=$EBMAJ -echo EPICS_MINOR=$EBMIN -echo EPICS_PATCH=$EBPAT - -export CAFE_EPICS_V_MAJOR=$EBMAJ -export CAFE_EPICS_V_MINOR=$EBMIN -export CAFE_EPICS_V_PATCH=$EBPAT - -#--enable-boost --with-boost=/afs/psi.ch/intranet/Controls/BD/deps/boost_1_57_0 \ -CYCAFE_VERSION=pyzcafe-1.3.0-alpha-1 - -./configure \ - --prefix=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/ \ - --libdir=/opt/gfa/cafe/python/python-3.5/${CYCAFE_VERSION}/lib \ - --enable-boost-inc --with-boost-inc=/opt/gfa/cafe/boost/boost_1_61_0/include \ - --enable-epics --with-epics=${EPICS}/base \ - --enable-qt4-lib --with-qt4-lib=/usr/lib64 \ - --enable-qt4-inc --with-qt4-inc=/usr/include \ - --enable-python-inc --with-python-inc=/opt/gfa/python-3.5/latest/include/python3.5m \ - --enable-python-lib --with-python-lib=/opt/gfa/python-3.5/latest/lib \ - --enable-zeromq-inc --with-zeromq-inc=/opt/gfa/zmq/zeromq-4.1.5/include \ - --enable-zeromq-lib --with-zeromq-lib=/opt/gfa/zmq/zeromq-4.1.5/lib \ - --enable-json-inc --with-json-inc=/opt/gfa/zmsglog/json/jsoncpp-src-0.6.0-rc2/include \ - --enable-json-lib --with-json-lib=/opt/gfa/zmsglog/json/jsoncpp-src-0.6.0-rc2/libs/linux-gcc-4.4.7 \ - --enable-curl-inc --with-curl-inc=/opt/gfa/python-3.5/2.4.1/include \ - --enable-curl-lib --with-curl-lib=/opt/gfa/python-3.5/2.4.1/lib - -unset CAFE_EPICS_V_MAJOR -unset CAFE_EPICS_V_MINOR -unset CAFE_EPICS_V_PATCH - -cp include/config.h include/os/Linux/pycafe35/config.h - diff --git a/examples/cafeTest/cafeTest b/examples/cafeTest/cafeTest index 65d5de8..a5df7dd 100755 Binary files a/examples/cafeTest/cafeTest and b/examples/cafeTest/cafeTest differ diff --git a/examples/cafeTest/cafeTest.cc b/examples/cafeTest/cafeTest.cc index f3d50e5..4a7f25c 100644 --- a/examples/cafeTest/cafeTest.cc +++ b/examples/cafeTest/cafeTest.cc @@ -3,39 +3,46 @@ // #include -#include "callbacks.h" +#include "callbacks.h" //ca callback funtions + + +// Test with 6 PVS +// PV_X1,PV_Y1 are scalar numerics +// PV_WF is a vector numeric +// PV_MBBI is an mbbi record with a number of enum vakues +// PV_X!_DESC is of data type dbr_string_t +// PV_JOKE is a non-existant channel (used to show CAFE response is such cases) #define PV_X1 "ARIDI-BPM-01LE:X-AVG" #define PV_Y1 "ARIDI-BPM-01LE:Y-AVG" #define PV_WF "ARIDI-BPM-01LE:WF-INT-1" //256 elements -//define PV_WF "SINSB04-ROPT-LOG:MON-MSG" #define PV_MBBI "ARIDI-BPM-01LE:GET-ENABLE" //mmbi #define PV_X1_DESC "ARIDI-BPM-01LE:X-AVG.DESC" //dbr_string_t - #define PV_JOKE "PV:JOKE" - - #define NHANDLES 6 // should match number of pvs above that we are to open. -template -std::pair flip_pair(const std::pair &p) -{ - return std::pair(p.second, p.first); -} - -template -std::multimap flip_map(const std::map & src) { - - std::multimap dst; - - std::transform(src.begin(), src.end(), std::inserter(dst, dst.begin()), - flip_pair); - - return dst; -} +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// (1) Establishing connections to EPICS Process Variables (PVs) +// (2) Simple single channel operations (and the PVData Object) +// Understanding the Status Error Code +// Waveforms and Arrays +// (5) Handling Enumerated Types +// (6) Multiple scalar operations, i.e., operations on several PVs with scalar values +// (7) Multiple'compound' operations, i.e., on several PVS with scalar/vector values +// (8) Multiple Struct operations on several PVS returning PVData Objects plus Multiple Sets for Scalars/Vectors +// (9) Asynchronous interactions and retrieving data from Cache +// (10) Synchronous group operations, also with externally defined groups +// (11) Monitors, either with or without user supplied callbacks (in essence, matlab scripts) +// (12) Control system parameters, i.e., operating limits, engineerimg units +// (13) Retrieve channel medadata, e.g., data type, native no. elements, connection state, read/write access, etc. +// (14) Setting timeouts for set/get operations +// (15) Setting synchronous group timeouts for set/get operations +// (16) Special Methods, e.g., setAndMatch +// (17:END) Gracefully terminate CAFE +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -43,82 +50,44 @@ int main( int argc, char *argv[] ) { using namespace std; - // Test with 6 PVS - // PV_X1,PV_Y1 are scalar numerics - // PV_WF is a vecror numeric - // PV_MBBI is anmbbi record witha number of enum vakues - // PV_X!_DESC is of data type dbr_string_t - // PV_JOKE is a non-existant channel (used to show CAFE response is such cases) string pvArray[NHANDLES]={PV_X1,PV_Y1,PV_WF,PV_MBBI,PV_X1_DESC,PV_JOKE}; unsigned int hArray[NHANDLES]; - //------------------------------------------------------------ - //(1) Preliminaries - //------------------------------------------------------------ - - cout << "------------------------------------------------------------" << endl; - cout << "START: (1) Preliminaries " << endl; - cout << "------------------------------------------------------------" << endl; //Instantaite CAFE + + CAFE * cafe = new CAFE(); - ChannelRequestPolicy channelRequestPolicyPutNew; - channelRequestPolicyPutNew.setPolicy(CAFENUM::FLUSH_AFTER_EACH_MESSAGE, - CAFENUM::NO_WAIT, CAFENUM::WITH_CALLBACK_DEFAULT); //W - - ChannelRequestPolicy channelRequestPolicyGetNew; - channelRequestPolicyGetNew.setPolicy(CAFENUM::FLUSH_AFTER_EACH_MESSAGE, - CAFENUM::WAIT, CAFENUM::WITHOUT_CALLBACK); - ChannelGetActionWhenMonitorPolicy cgawmp; - cgawmp.setActionKind(CAFENUM::GET_FROM_CACHE); - - - CAFE * cafe = new CAFE(); //channelRequestPolicyPutNew); - - - // cafe->channelRequestPolicyMasterPut.setPolicy(CAFENUM::FLUSH_AFTER_EACH_MESSAGE, - // CAFENUM::NO_WAIT, CAFENUM::WITH_CALLBACK_DEFAULT); //WITHOUT_CALLBACK) - - cout << "---1------------------------------------------------------ " << endl; - ChannelRequestPolicy * channelRequestPolicySet = new ChannelRequestPolicy(); - cout << "---2------------------------------------------------------ " << endl; - ChannelRequestPolicy channelRequestPolicySet2; - cout << "---3------------------------------------------------------ " << endl; unsigned int handle; int status; //Class with methods to report on the value and meaning of status codes CAFEStatus cstat; - //Classes defining value/name pairs of alarm status and and severity + //Classes defining value/name pairs of alarm status andseverity CAFEGlobalAlarmSeverity alarmSev; CAFEGlobalAlarmCondition alarmStat; - HandleHelper handleHelper; - - // This is optional - //Initialize ca (otherwise first cafe method call will initialize ca) - cout << "---4------------------------------------------------------ " << endl; - try { - status=cafe->init( ); // ca_disable_preemptive_callback - } - catch (CAFEException_init &e) { - cout << e.what() << endl; - exit(1); - } + //------------------------------------------------------------ + //(1) Establishing connections to EPICS Process Variables (PVs) + //------------------------------------------------------------ - - // This too is optional - // The first Cafe method invoked on this channel will otherwise enable the virtual circuit - // An open operation will pend the ioc for a default amount of time fiven by: + cout << "---------------------------------------------------------------------" << endl; + cout << "START: (1) Establishing connections to EPICS Process Variables (PVs) " << endl; + cout << "---------------------------------------------------------------------" << endl; + + + + // An open operation will pend the ioc for a default amount of time given by: // cafe->channelOpenPolicy.getDefaultTimeout() - // else otherwise specified. - cout << "---5------------------------------------------------------ " << endl; + // else otherwise specified. cafe->channelOpenPolicy.setTimeout(0.1); //pend 0.1 seconds - cout << "---6------------------------------------------------------ " << endl; + + + // Open one channel // It is not an error if the channel is not connected! - cout << "open " << endl; + try { cafe->open(pvArray[0].c_str(), handle); } @@ -126,52 +95,7 @@ int main( int argc, char *argv[] ) cout << e.what() << endl; exit(1); } - - cout << "------------------------------------------------------------" << endl; - cout << " END: (1) Preliminaries " << endl; - cout << "------------------------------------------------------------" << endl; - sleep(1); - - cout << "when /" << channelRequestPolicySet->getWhenToFlushSendBuffer() << endl; - cout << "wait /" << channelRequestPolicySet->getWaitKind() << endl; - cout << "method /" << channelRequestPolicySet->getMethodKind() << endl; - - cout << cafe->getPolicyHelper().getChannelRequestPolicyPut(1, *channelRequestPolicySet ) << endl; - - cout << "when /" << channelRequestPolicySet->getWhenToFlushSendBuffer() << endl; - cout << "wait /" << channelRequestPolicySet->getWaitKind() << endl; - cout << "method /" << channelRequestPolicySet->getMethodKind() << endl; - - - cout << cafe->getPolicyHelper().getChannelRequestPolicyGet(1, *channelRequestPolicySet ) << endl; - - cout << "when /" << channelRequestPolicySet->getWhenToFlushSendBuffer() << endl; - cout << "wait /" << channelRequestPolicySet->getWaitKind() << endl; - cout << "method /" << channelRequestPolicySet->getMethodKind() << endl; - - - ChannelGetActionWhenMonitorPolicy cm; - cout << cafe->getPolicyHelper().getChannelGetActionWhenMonitorPolicy(1, cm ) << endl; - cout << cm.getActionKind() << endl; - - - - cout << "when /" << channelRequestPolicySet2.getWhenToFlushSendBuffer() << endl; - cout << "wait /" << channelRequestPolicySet2.getWaitKind() << endl; - cout << "method /" << channelRequestPolicySet2.getMethodKind() << endl; - - cout << cafe->getPolicyHelper().getChannelRequestPolicyPut(1, channelRequestPolicySet2 ) << endl; - - cout << "when /" << channelRequestPolicySet2.getWhenToFlushSendBuffer() << endl; - cout << "wait /" << channelRequestPolicySet2.getWaitKind() << endl; - cout << "method /" << channelRequestPolicySet2.getMethodKind() << endl; - - - - - cout << "------------------------------------------------------------" << endl; - cout << "START: (1b) Opening and Closing Channels " << endl; - cout << "------------------------------------------------------------" << endl; + unsigned int hDesc; @@ -202,15 +126,20 @@ int main( int argc, char *argv[] ) cafe->openPrepare(); cafe->open(pvArray, hArray, NHANDLES); - cafe->open(PV_X1_DESC, hDesc); + + // Vector interfaces also exist + // vector pvVector + // vector hVector + // cafe->open(pvVector, hVector, NHANDLES); + - cafe->openNow() ; // and wait for cafe->channelOpenPolicy.getTimeout() + //cafe->openNow() ; // and wait for cafe->channelOpenPolicy.getTimeout() //or - cafe->openNowAndWait(0.5); //wait for specified time, here 3.0 seconds + cafe->openNowAndWait(0.5); //wait for specified time, here 0.5 seconds //Is the given channel connected? Returns true/false - bool ifYes= cafe->isChannelConnected(hDesc); + bool ifYes= cafe->isChannelConnected(hArray[0]); //Are all channels connected? Returns true/false ifYes= cafe->allChannelsConnected(); @@ -220,14 +149,11 @@ int main( int argc, char *argv[] ) cafe->printDisconnectedHandles(); } - - status=handleHelper.getDisconnectedHandles(hV, pvV); - status=handleHelper.getHandles(hV, pvV); - status=handleHelper.getHandleStates(hV, pvV,stateV); - - - //cafe->channelOpenPolicy.flushSendBufferNow(); //Now send open message - //cafe->channelOpenPolicy.setTimeoutToDefault(); //Reset timeout to default value + //Handle helper functions also provide information on PV handles and their connection states + status=cafe->getHandleHelper().getDisconnectedHandles(hV, pvV); + status=cafe->getHandleHelper().getHandles(hV, pvV); + status=cafe->getHandleHelper().getHandleStates(hV, pvV,stateV); + } catch(CAFEException_open & e) { @@ -238,271 +164,38 @@ int main( int argc, char *argv[] ) // To close channels within a given ca_client_context // To close a single Channel - //cafe->close(hDesc); + // cafe->close(hArray[0]); // To close many channels - //cafe->closeChannels(hArray, NHANDLES); + // cafe->closeChannels(hArray, NHANDLES); // To close alls channesl - //cafe->closeChannels(); + // cafe->closeChannels(); // If you wish to close channels that are in other threads // (i.e., with other ca_client_context) // use instead the following methods: // To close a single Channel irrespective of ca_client_context - // I.e. these will also close handle s in other threads - //cafe->closeHandle(hDesc); + // i.e. these will also close handles in other threads + // cafe->closeHandle(hArray[0[); // To close many handles - //cafe->closeHandles(hArray, NHANDLES); + // cafe->closeHandles(hArray, NHANDLES); // To close all handles - //cafe->closeHandles(); - - /* - cafe->loadCollectionsFromXML("cNodes.xml"); - cafe->loadGroupsFromXML("gDBPM.xml"); - //cafe->loadCollectionsFromXML("cSF_Aramis_bunch1.xml"); - //cafe->loadCollectionsFromXML("testVSUP.xml"); - //cafe->loadGroupsFromXML("bpmDisplaySFEnergyBunch1.xml"); - - vector _glist; - cafe->groupMemberList("gDBPM", _glist); - vector _hVA; - - cafe->openPrepare(); - cafe->open(_glist, _hVA); - - cafe->openNowAndWait(2.0); //wait for specified time, here 3.0 seconds - - */ - - vector _glist; - - vector _hVA; - - typedef std::map floatStringMap2; - floatStringMap2 posDev2; - floatStringMap2::iterator pos2; - - /* - cafe->devicePositionMap("cDBPM", posDev2); - - for (pos2 =posDev2.begin(); pos2 != posDev2.end(); ++pos2) { - cout << "position= " << pos2->first << " Dev " << pos2->second << endl; - //++pos; - } - */ - //cafe->readyDBPM(_hVA); - - - // cafe->prepareDBPM(_glist, _hVA, posDev2); - - - //cafe->devicePositionMap("cDBPM", posDev2); - - // for (pos2 =posDev2.begin(); pos2 != posDev2.end(); ++pos2) { - // cout << "position= " << pos2->first << " Dev " << pos2->second << endl; - - // } - - - //DBPMKeeper dbpm(_glist,_hVA,posDev2); - - - vector posV; vector devS; - cout << " HERE prepareDBPM" << endl; - - - cafe->prepareDBPM(_glist, _hVA, devS, posV); - - cout << " HERE " << endl; - - DBPMKeeper dbpm(_glist,_hVA, devS, posV); - - cafe->readDBPMOffsets(dbpm); - vector ox = dbpm.getOffsetX(); - vector oy = dbpm.getOffsetY(); - vector devis = dbpm.getDevice(); - - cout << "size x " << ox.size() << endl; - cout << "size y " << oy.size() << endl; - cout << "devis " << devis.size() << endl; - - for (int i=0; iterminate(); - exit(0); - - ////dbpm.setBS(true); - - ////vector x,y,q,E; - ////vector vx,vy,vq; - vector ddx, ddy, ddq, dde; - ChannelRequestStatus cre; - vector devices; - - cout << "STATUS GETCTRL = " << cafe->getHandleHelper().getChannelRequestStatusGetCtrl(8, cre) << endl; - cout << "Value 1 is PENDING, while 2 is COMPLETE: " << cre.getCallbackProgressKind() << endl; - - - system("date"); - for (int i=0; i<200; ++i ) { - if (i==0) dbpm.setBS(true); - status=cafe->getDBPM(dbpm); - - if (status > ICAFE_LINUX_ERROR) continue; - - //cout << i << " STATUS GETCTRL = " << cafe->getHandleHelper().getChannelRequestStatusGetCtrl(8, cre) << endl; - - //cout << i << " Value 1 is PENIDING, while 2 is COMPLETE: " << cre.getCallbackProgressKind() << endl; - cout << "STATUS " << status << " " << dbpm.status << endl; - - ddx=dbpm.getX(); - ddy=dbpm.getY(); - ddq=dbpm.getQ(); - dde=dbpm.getEnergy(); - - devices = dbpm.getDevice(); - - cout << " ddx.size " << ddx.size() << endl; - cout << " ddy.size " << ddy.size() << endl; - cout << " ddq.size " << ddq.size() << endl; - cout << " dde.size " << dde.size() << endl; - for (int j=0; jterminate(); - exit(0); - - - - - PVDataHolder * pdh = new PVDataHolder[_glist.size()]; - system("date"); - for (int i=0; i<1; ++i) { - status=cafe->get(_hVA, pdh); - } - system("date"); - cafe->closeHandles(_hVA); - - unsigned int _gh; - - cafe->groupOpen("gDBPM", _gh); - PVGroup _pvg; - system("date"); - status=cafe->groupGet(_gh, _pvg); - system("date"); - cout <<"status + " << status << endl; - - cafe->terminate(); - exit(0); - - - typedef std::map floatStringMap; - floatStringMap posDev; - floatStringMap::iterator pos; - - cafe->devicePositionMap("cDBPM", posDev); + // cafe->closeHandles(); - for (pos =posDev.begin(); pos != posDev.end(); ++pos) { - cout << "device= " << pos->first << " Pos " << pos->second << endl; - //++pos; - } - - - cafe->devicePositionMap("cDBPM", posDev); - - for (pos =posDev.begin(); pos != posDev.end(); ++pos) { - cout << "device= " << pos->first << " Pos " << pos->second << endl; - //++pos; - } - - posDev.clear(); - cafe->devicePositionMap("cVSUP", posDev); - - for (pos =posDev.begin(); pos != posDev.end(); ++pos) { - cout << "device= " << pos->first << " Pos " << pos->second << endl; - //++pos; - } - - vector deviceListV; - deviceListV.push_back("AB-CD"); - deviceListV.push_back("AB-EF"); - cafe->collectionDefine("cTest", deviceListV); - - posDev.clear(); - cafe->devicePositionMap("cTest", posDev); - - for (pos =posDev.begin(); pos != posDev.end(); ++pos) { - cout << "device= " << pos->first << " Pos " << pos->second << endl; - //++pos; - } - - double dValArray[12]; - int sAy[12]; - cafe->getCache(hArray, NHANDLES, dValArray, sAy); - - - for (int i=0; iterminate(); - //exit(1); - - vector gl; - cafe->collectionList(gl); - for (int i=0; i < gl.size(); ++i) { - cout << gl[i] << endl; - } - PVGroup pvgrp; - unsigned int ghan; - cafe->groupOpen("gDBPM", ghan); - cafe->groupGet(ghan, pvgrp); - //pvgrp.show(); + cout << "---------------------------------------------------------------------" << endl; + cout << "STOP: (1) Establishing connections to EPICS Process Variables (PVs) " << endl; + cout << "---------------------------------------------------------------------" << endl; - cout << "------------------------------------------------------------" << endl; - cout << " END: (1b) Opening and Closing Channels " << endl; - cout << "------------------------------------------------------------" << endl; - - sleep(3); - //------------------------------------------------------------ //(2) Basic Single Channel Operations //------------------------------------------------------------ @@ -516,8 +209,8 @@ int main( int argc, char *argv[] ) //------------------------------------------------------------ double d; - //get by handle - status=cafe->get(handle, d); + //get PV value by handle + status=cafe->get(hArray[0], d); if (status != ICAFE_NORMAL) { cout << "Status indicates an error at line no." << __LINE__ << endl; @@ -529,12 +222,13 @@ int main( int argc, char *argv[] ) cout << "Value d=" << d << endl; } + //get PV value, alarm, timeStamp by handle float f; short alarmStatus, alarmSeverity; epicsTimeStamp ets; status=cafe->get(handle, f, alarmStatus, alarmSeverity, ets); if (status != ICAFE_NORMAL) { cout << "Status indicates an error at line no." << __LINE__ << endl; - cafe->printStatus(handle,status); + cafe->printStatus(hArray[0],status); } else { cout << "Value f=" << f << endl; @@ -550,14 +244,16 @@ int main( int argc, char *argv[] ) cstat.report(status); //or cafe->printStatus(handle,status); + + + //To explicitly check on timeout error + if (cstat.csc.isTimeout(status)) { + cout << "Above is a timeout error" << endl; + } + } - //To explicitly check on timeout error - if (cstat.csc.isTimeout(status)) { - cout << "Above is a timeout error" << endl; - } - //To interchange between handle and array handle = cafe->getHandleFromPV(pvArray[0].c_str()); const char * pvName= cafe->getPVFromHandle(handle); @@ -568,31 +264,13 @@ int main( int argc, char *argv[] ) //------------------------------------------------------------ //Data retrieval methods returning structured data //------------------------------------------------------------ - unsigned int hWF; - status=cafe->open(PV_WF,hWF); - //status=cafe->open("XHIPA-STA:STA-ND1",hWF); - - - - double dwff; - cafe->get(hWF, dwff); - - cout << "wfd " << dwff << endl; - string ms; - cafe->getWFAsString(hWF, ms); - cout << "wf asstring 1st " << ms << endl; - - cafe->getWFAsString(hWF, ms); - cout << "wf asstring 2nd" << ms << endl; - - cafe->getWFAsStringCache(hWF, ms); - cout << "wf asstring 3rd" << ms << endl; - + + PVDataHolder pvd; - //pvd.setNelem(cafe->getNelemNative(hWF)); - pvd.setNelem(cafe->getNelemNative(hWF)); - status=cafe->get(hWF, pvd); + + pvd.setNelem(cafe->getNelemNative(hArray[2])); + status=cafe->get(hArray[2], pvd); if (status==ICAFE_NORMAL) { @@ -600,7 +278,7 @@ int main( int argc, char *argv[] ) //The PVDataHolder cout << "pvd.getAsString()" << endl; - for (int i=0; igetNelemRequest(hWF)); ++i) { + for (int i=0; igetNelemRequest(hArray[2])); ++i) { cout << pvd.getAsString(i) << " [" << i << "] "; } cout << endl; @@ -664,7 +342,7 @@ int main( int argc, char *argv[] ) cout << "Alarm Severity =" << alarmSev.asString(pvd.getAlarmSeverity()) << endl; //Information concerning the meaning of the status of the cafe operation - cout << cstat.severity(pvd.getStatus()) << endl; + cout << cstat.severity(pvd.getStatus()) << endl; //Whether WARNING OR ERROR cout << cstat.asString(pvd.getStatus()) << endl; cout << cstat.code(pvd.getStatus()) << endl; cout << cstat.info(pvd.getStatus()) << endl; @@ -672,10 +350,9 @@ int main( int argc, char *argv[] ) //print summary cstat.report(pvd.getStatus()); - - - + } // if status=ICAFE_NORMAL + //------------------------------------------------------------ //Set data //The set method is able to intrepret all data types, and can @@ -688,53 +365,14 @@ int main( int argc, char *argv[] ) cstat.report(status); } //or another way to print an error with pv name - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_X1),status); + cafe->printStatusIfError(cafe->getHandleFromPV(PV_X1),status); - - - //Now perform a get/set operation with a user supplied callback function - - - //Get original policy in case we want to use it again. - //ChannelRequestPolicy channelRequestPolicyGetOriginal; - //status=cafe->getPolicyHelper().getChannelRequestPolicyGet(hArray[0], channelRequestPolicyGetOriginal); - - - ChannelRequestPolicy channelRequestPolicyLocal; - //Supply user defined handle - channelRequestPolicyLocal.setHandler(handlerGet); - //Set policy to use - //ChannelWhenToFlushSendBufferPolicyKind CAFENUM::FLUSH_AFTER_EACH_MESSAGE - //ChannelWaitForResponsePolicyKind CAFENUM::WAIT - //ChannelRequestPolicyKind CAFENUM::WITH_CALLBACK_USER_SUPPLIED - channelRequestPolicyLocal.setPolicy(CAFENUM::FLUSH_AFTER_EACH_MESSAGE, - CAFENUM::WAIT, CAFENUM::WITH_CALLBACK_USER_SUPPLIED); - - //Now set this policy for GET operation for handle[0] - status=cafe->getPolicyHelper().setChannelRequestPolicyGet(hArray[0], channelRequestPolicyLocal); - //Modify policy to accept PutHandler - channelRequestPolicyLocal.setHandler(handlerPut); - //Now set this policy for PUT operation for hanlde[0] - status=cafe->getPolicyHelper().setChannelRequestPolicyPut(hArray[0], channelRequestPolicyLocal); - - status=cafe->set(PV_X1, 0.62453); - - - cafe->get(PV_X1, f); - - cout <getCache(PV_X1, f); - - cout <terminate(); - //exit(0); - + + + //------------------------------------------------------------ //(3) Waveforms and Arrays //------------------------------------------------------------ @@ -747,16 +385,9 @@ int main( int argc, char *argv[] ) //------------------------------------------------------------ //Data retrieval methods returning a waveform array //------------------------------------------------------------ - - PVDataHolder pvd_h; - pvd_h.setNelem(cafe->getNelemNative(hWF)); - status=cafe->get(hWF, pvd_h); - cout << "n elements " << pvd_h.getNelem() << endl; - status=cafe->getCache(hWF, pvd_h); - cout << "n elements " << pvd_h.getNelem() << endl; - - double * dwf = new double[cafe->getNelemNative(hWF)]; + + double * dwf = new double[cafe->getNelemNative(hArray[2])]; double inwf [20] = {1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,10, 11, 12, 13,14,15,16,17,18,19,20}; @@ -773,7 +404,7 @@ int main( int argc, char *argv[] ) else { cout << PV_WF << " successfully read out " << endl; cout << "First five elements have values: " << endl; - for (int i=0; igetNelemNative(hWF)); ++i) { + for (int i=0; igetNelemNative(hArray[2])); ++i) { cout << dwf[i] << " [" << i << "] "; } cout << endl; @@ -781,12 +412,12 @@ int main( int argc, char *argv[] ) //One may also set the number of elements to retrieve - //int nelem =cafe->getHandleHelper().setNelemToNative(hWF); - int nelem = cafe->getHandleHelper().setNelem(hWF, 10); //returns max(10, cafe->getNelemNative(handle)) + //int nelem =cafe->getHandleHelper().setNelemToNative(hArray[2]); + int nelem = cafe->getHandleHelper().setNelem(hArray[2], 10); //returns max(10, cafe->getNelemNative(handle)) //and offset - int offset = cafe->getHandleHelper().setOffset(hWF, 2); + int offset = cafe->getHandleHelper().setOffset(hArray[2], 2); //by Handle - status=cafe->get(hWF, dwf); + status=cafe->get(hArray[2], dwf); if (status != ICAFE_NORMAL) { cout << "Status indicates an error at line no." << __LINE__ << endl; cstat.report(status); @@ -801,10 +432,10 @@ int main( int argc, char *argv[] ) } //reset offset for read and the nelemtonative - cout << "Resetting nelem for wf to native value: " << cafe->getHandleHelper().setNelemToNative(hWF) - << " and resetting offset to: " << cafe->getHandleHelper().setOffset(hWF, 0) << endl; + cout << "Resetting nelem for wf to native value: " << cafe->getHandleHelper().setNelemToNative(hArray[2]) + << " and resetting offset to: " << cafe->getHandleHelper().setOffset(hArray[2], 0) << endl; - cafe->get(hWF); + cafe->get(hArray[2]); delete dwf; @@ -814,24 +445,27 @@ int main( int argc, char *argv[] ) vector dV; dbr_short_t alarmSta; dbr_short_t alarmSe; epicsTimeStamp tsta; - cout << "nELEM n: " << cafe->getHandleHelper().getNelemNative (hWF) << endl; - cout << "nELEM r: " << cafe->getHandleHelper().getNelemRequest(hWF) << endl; - cout << "nELEM c: " << cafe->getHandleHelper().getNelemClient (hWF) << endl; + cout << "nELEM n: " << cafe->getHandleHelper().getNelemNative (hArray[2]) << endl; + cout << "nELEM r: " << cafe->getHandleHelper().getNelemRequest(hArray[2]) << endl; + cout << "nELEM c: " << cafe->getHandleHelper().getNelemClient (hArray[2]) << endl; - cout << "set nelem to 16, get: " << cafe->getHandleHelper().setNelem(hWF,16) << endl;; + cout << "set nelem to 16, get: " << cafe->getHandleHelper().setNelem(hArray[2],16) << endl;; - cout << "nELEM n: " << cafe->getHandleHelper().getNelemNative (hWF) << endl; - cout << "nELEM r: " << cafe->getHandleHelper().getNelemRequest(hWF) << endl; - cout << "nELEM c: " << cafe->getHandleHelper().getNelemClient (hWF) << endl; + cout << "nELEM n: " << cafe->getHandleHelper().getNelemNative (hArray[2]) << endl; + cout << "nELEM r: " << cafe->getHandleHelper().getNelemRequest(hArray[2]) << endl; + cout << "nELEM c: " << cafe->getHandleHelper().getNelemClient (hArray[2]) << endl; - - cout << "get nelem cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCache(hWF) << endl; - cout << "set nelem cache to 18, get: " << cafe->getHandleHelper().setNelemToRetrieveFromCache(hWF,18) << endl; - cout << "get nelem cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCache(hWF) << endl; - - //status=cafe->get(hWF, dV); - //cout << "dV.size " << dV.size() << endl; - status=cafe->getCache(hWF, dV, alarmSta, alarmSe, tsta); + // + cout << "get nelem cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCache(hArray[2]) << endl; + cout << "set nelem cache to 12, get: " << cafe->getHandleHelper().setNelemToRetrieveFromCache(hArray[2],12) << endl; + cout << "get nelem cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCache(hArray[2]) << endl; + + //Will retrieve 16 elements + status=cafe->get(hArray[2], dV); + cout << "dV.size " << dV.size() << endl; + + //Will retrieve 12 elements from cache + status=cafe->getCache(hArray[2], dV, alarmSta, alarmSe, tsta); cout << "status " << status << endl; cout << "dV.size " << dV.size() << endl; if (status != ICAFE_NORMAL) { @@ -846,43 +480,11 @@ int main( int argc, char *argv[] ) } cout << endl; } - - //status=cafe->get(hWF, dV); - //cout << "dV.size " << dV.size() << endl; - - PVCtrlHolder pvc_h(cafe->getNelemNative(hWF)); - - pvc_h.setNelem(12); - - status=cafe->getCtrl(hWF, pvc_h); - cout << "n elements " << pvc_h.getNelem() << endl; - - - cout << "get nelem ctrl cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCtrlCache(hWF) << endl; - cout << "set nelem ctrl cache to 18, get: " << cafe->getHandleHelper().setNelemToRetrieveFromCtrlCache(hWF,18) << endl; - cout << "get nelem ctrl cache get: " << cafe->getHandleHelper().getNelemToRetrieveFromCtrlCache(hWF) << endl; - - status=cafe->getCtrlCache(hWF, pvc_h); - cout << "n elements " << pvc_h.setNelem(cafe->getHandleHelper().getNelemToRetrieveFromCtrlCache(hWF) ) << endl; - if (status != ICAFE_NORMAL) { - cout << "Status indicates an error at line no." << __LINE__ << endl; - cstat.report(status); - } - else { - cout << PV_WF << " successfully read out " << endl; - cout << "Elements of WF have values:" << endl; - for (int i=0; iget(hArray, NHANDLES, pvdArray)" << endl; - //cout << "---------------------------------------" << endl; + cout << "---------------------------------------" << endl; + cout << "status=cafe->get(hArray, NHANDLES, pvdArray)" << endl; + cout << "---------------------------------------" << endl; status=cafe->get(hArray, NHANDLES, pvdArray); //input vector of handles - //cout << "---------------------------------------" << endl; - //cout << "status=cafe->getPVArray(hV, pvdArray);" << endl; - //cout << "---------------------------------------" << endl; + cout << "---------------------------------------" << endl; + cout << "status=cafe->getPVArray(hV, pvdArray);" << endl; + cout << "---------------------------------------" << endl; status=cafe->getPVArray(hV, pvdArray); - //synchornous get + //Asynchronous get cout << "---------------------------------------" << endl; cout << "status=cafe->get(hArray, NHANDLES, statusArray);" << endl; cout << "---------------------------------------" << endl; @@ -1005,18 +607,22 @@ int main( int argc, char *argv[] ) //fill gvgroup with pv parameters from ghandle //Tis is optional; will be done by groupGet - cafe->groupAttach(gHandle, pvgroup); //do not use groupFetch which will set nelem to 1 for wfs! + cafe->groupAttach(gHandle, pvgroup); //also allocates memory for pvgroup members! PVDataHolder * pvdA = pvgroup.getPVData(); - pvdA[0].setNelem(1); + pvdA[0].setNelem(1); //just an example, only required if user wishes to set nelemens for wf from native cafe->groupGet(gHandle, pvgroup); - //pvgroup.print(); - pvgroup.print(pvgroup.getNPV(),25); // print all members; if wf, max 25 elements + // print all group memebers + // pvgroup.print(); + // print all members; if wf, max 25 elements + pvgroup.print(pvgroup.getNPV(),25); + + //Overwrite values for set method pvdA[0].set(1.111); double d4[4]= {1,2,3,4}; pvdA[2].set(d4); @@ -1042,12 +648,9 @@ int main( int argc, char *argv[] ) } + //Will send to /tmp cafe->snapshot2XML(pvgroup); - //cafe->loadSFGroups("VA"); - - - cout << "---------------------------" << endl; cout << "------------------------------------------------------------" << endl; @@ -1106,6 +709,19 @@ int main( int argc, char *argv[] ) cafe->printStatusIfError(hArray[0],status); } + + + + cout << "------------------------------------------------------------" << endl; + cout << " END: (7) Control System Parameters and Channel Information" << endl; + cout << "------------------------------------------------------------" << endl; + + cout << "------------------------------------------------------------" << endl; + cout << "START: (8) Channel Information" << endl; + cout << "------------------------------------------------------------" << endl; + + + ChannelRegalia chInfo; CAFEDataTypeCode cdt; status=cafe->getChannelInfo(hArray[0], chInfo); @@ -1132,12 +748,10 @@ int main( int argc, char *argv[] ) cout << "---------------------------------------\n" << endl; - - cout << "------------------------------------------------------------" << endl; - cout << " END: (7) Control System Parameters and Channel Information" << endl; + cout << " END: (8) Channel Information" << endl; cout << "------------------------------------------------------------" << endl; - + cout << "------------------------------------------------------------" << endl; cout << "START: (8) Monitors, either with or without user supplied callbacks " << endl; @@ -1166,15 +780,7 @@ int main( int argc, char *argv[] ) status=cafe->getPolicyHelper().setChannelRequestPolicyPut(hArray[0], channelRequestPolicyPut); //for single handle int NLOOPV =1; - // NLOOPV =100000; //double default) 60 secs 2) withoutcallback 54s - // NLOOPV =100000; float default) 43 secs 2) withoutcallback 43s - // NLOOPV =100000; short default) 51 secs 2) withoutcallback 46s - // NLOOPV =100000; short default) 52 secs 2) withoutcallback 56s //change policy to do conversion at ioc - // NLOOPV =100000; dbr_char_t default) 52 secs 2) withoutcallback 52s //change policy to do conversion at ioc - - //However for Waveforms 4084 elements - // NLOOPV =10000; dbr_char_t default) 80 secs 2) withoutcallback 73s //change policy to CAFENUM::NATIVE_DATATYPE - // NLOOPV =10000; dbr_char_t default) 64 secs 2) withoutcallback 63s //change policy to CAFENUM::LOWEST_DATATYPE + ChannelRequestDataTypePolicy channelRequestDataTypePolicy; channelRequestDataTypePolicy.setRequestKind(CAFENUM::LOWEST_DATATYPE); @@ -1244,8 +850,6 @@ int main( int argc, char *argv[] ) cout << " END: (8) Monitors, either with or without user supplied callbacks " << endl; cout << "------------------------------------------------------------" << endl; - cafe->terminate(); - exit(1); cout << "------------------------------------------------------------" << endl; cout << "START: (9) Asynchronous interactions and retrieving data from cache " << endl; @@ -1314,11 +918,11 @@ int main( int argc, char *argv[] ) cout << "START: (11) Special methods, match, setAndMatch " << endl; cout << "------------------------------------------------------------" << endl; - - status=cafe->setAndGet(hWF, 2.2, d); - cafe->printStatusIfError(hWF, status); + float fwf; + status=cafe->setAndGet(hArray[2], (dbr_float_t) 1.01, fwf); + cafe->printStatusIfError(hArray[2], status); - cout << "val should be 2.2 " << d << endl; + cout << "val should be 1.01 and actually reads " << fwf << endl; cout << "------------------------------------------------------------" << endl; @@ -1337,278 +941,14 @@ int main( int argc, char *argv[] ) cafe->printHandles(); - sleep(1); - cafe->closeHandles(hV); - cafe->printHandles(); - cafe->closeHandles(); cafe->groupClose(); - //cafe->groupHandleErase(); - cafe->printHandles(); + cafe->closeHandles(); + cafe->terminate(); - exit(0); + return 0; - - - //------------------------------------------------------------ - //(1) Quick Start - //------------------------------------------------------------ - - //status=cafe->get(PV_X1, d); - - //cafe->terminate(); - //exit(0); - - //2 write/read wf - float fArray[256] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; - status=cafe->set(PV_WF, fArray); - if (status!=ICAFE_NORMAL) { - cstat.report(status); - } - //or another way to print an error with pv name - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_WF),status); - - //zero array - std::fill(fArray, fArray+256, 0); - - //ask for 25 elements of the wf - cafe->getHandleHelper().setNelem(cafe->getInfo().getHandleFromPV(PV_WF),25); - - status=cafe->get(PV_WF, fArray); - if (status==ICAFE_NORMAL) { - cout << PV_WF << " is a wf; the first 25 elements have values: " << endl; - for (size_t i=0; i<25; ++i) { - cout << fArray[i] << " [" << i << "] " ; - } - cout << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_WF),status); - } - - - status=cafe->set(PV_WF, 3.2); - - double valD; - status=cafe->get(PV_WF, valD); - cout << "First Element of WF " << valD << endl; - - cout << "Request=" << cafe->getHandleHelper().getNelemRequest(cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - cout << "Native =" << cafe->getHandleHelper().getNelemNative (cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - cout << "Client =" << cafe->getHandleHelper().getNelemClient (cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - - - status=cafe->get(PV_WF, fArray); - - cout << "Request=" << cafe->getHandleHelper().getNelemRequest(cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - cout << "Native =" << cafe->getHandleHelper().getNelemNative (cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - cout << "Client =" << cafe->getHandleHelper().getNelemClient (cafe->getInfo().getHandleFromPV(PV_WF)) << endl; - - - if (status==ICAFE_NORMAL) { - cout << PV_WF << " is a wf; the first 25 elements have values: " << endl; - for (size_t i=0; igetHandleHelper().getNelemRequest(cafe->getInfo().getHandleFromPV(PV_WF)); ++i) { - cout << fArray[i] << " [" << i << "] " ; - } - cout << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_WF),status); - } - - //cafe->terminate(); - //exit(0); - - //3 write/read mbbi - - status=cafe->set(PV_MBBI, "on"); - if (status!=ICAFE_NORMAL) { - cstat.report(status); - } - //or another way to print an error with pv name - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_MBBI),status); - - dbr_string_t sData; // i.e. char[40] sData; - status=cafe->get(PV_MBBI, sData); - if (status==ICAFE_NORMAL) { - cout << PV_MBBI << " has value= " << sData << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_MBBI),status); - } - - unsigned short enumValue; // - status=cafe->get(PV_MBBI, enumValue); - if (status==ICAFE_NORMAL) { - cout << PV_MBBI << " has enumValue= " << enumValue << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_MBBI),status); - } - - - //Get Enum String from Index - cout << "String State = " << cafe->getInfo().getStringFromEnum(cafe->getInfo().getHandleFromPV(PV_MBBI), enumValue) << endl; - - cout << "String State = " << cafe->getInfo().getStringFromEnum(cafe->getInfo().getHandleFromPV(PV_MBBI), 88) << endl; - - cout << "String State = " << cafe->getInfo().getEnumFromString(cafe->getInfo().getHandleFromPV(PV_MBBI), " on 1") << endl; - //cafe->terminate(); - //exit(0); - - //4 Quick Start, reading alarmStatus, alarmSeverity, ts - - d=0.0; // zero d - status=cafe->get(cafe->getInfo().getHandleFromPV(PV_X1), d, alarmStatus, alarmSeverity, ets); - if (status==ICAFE_NORMAL) { - cout << PV_X1 << " has value= " << d << endl; - cout << "alarmStatus= " << alarmStatus << " alarmSeverity=" << alarmSeverity - << " timeStamp= " << ets.secPastEpoch << " sec. " << ets.nsec << " nsec " << endl; - } - else { - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_X1),status); - } - - //5 Quick start, same as above but reading strutured data - //PVDataHolder pvd; - //Allocate memory - pvd.setNelem(cafe->getInfo().getNelemNative(cafe->getInfo().getHandleFromPV(PV_WF))); //Important, else memory will not be allocated to receive data - status=cafe->get(PV_WF, pvd); - //status=cafe->get(cafe->getInfo().getHandleFromPV(PV_WF), pvd); - if (status==ICAFE_NORMAL) { - pvd.print(25); //just print first 25 elements of the waveform - // Access data explicitly - cout << "Value (string format): " << endl; - for (size_t i=0; i<25; ++i) { - cout << pvd.getAsString(i) << " [" << i << "] " ; - } - cout << endl; - cout << "Value ( float format) " << pvd.getAsFloat() << endl; - for (size_t i=0; i<25; ++i) { - cout << pvd.getAsFloat(i) << " [" << i << "] " ; - } - cout << endl; - cout << "Alarm Status = " << pvd.getAlarmStatus() << endl; - cout << "Alarm Severity= " << pvd.getAlarmSeverity() << endl; - cout << "Timestamp = " << pvd.getEpicsTimeStamp().secPastEpoch - << " sec. " << pvd.getEpicsTimeStamp().nsec << " nsec " << endl; - } - else { - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_WF),status); - } - - - // An example of a single get - // get string by handle - status=cafe->get(hArray[0], sData); //sData declared earlier - if (status==ICAFE_NORMAL) { - cout << PV_MBBI << " has value= " << sData << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(cafe->getInfo().getHandleFromPV(PV_MBBI),status); - } - - // Another example of a single get - // get string by handle - dbr_string_t sDesc; //char[40]; - status=cafe->get(hDesc, sDesc); - if (status==ICAFE_NORMAL) { - cout << PV_X1_DESC << " has value= " << sDesc << endl; - } - else { - //cstat.report(status); - cafe->printStatusIfError(hDesc,status); - } - - - - // An example of a single get with data, alarms and timestamp - // Get structured data by handle - PVDataHolder pvd2; - pvd2.setNelem(1); //Important if nelements>1, - //else memory will not be allocated to receive data - - status=cafe->get(hArray[0], pvd2); - if (status==ICAFE_NORMAL) { - pvd2.print(); //just print - // Access data explicitly - cout << "Value (string format): " << pvd2.getAsString() << endl; - cout << "Value ( float format) " << pvd2.getAsFloat() << endl; - cout << "Alarm Status = " << pvd2.getAlarmStatus() << endl; - cout << "Alarm Severity= " << pvd2.getAlarmSeverity() << endl; - cout << "Timestamp = " << pvd2.getEpicsTimeStamp().secPastEpoch - << " sec. " << pvd2.getEpicsTimeStamp().nsec << " nsec " << endl; - } - else { - cafe->printStatusIfError(hArray[0],status); - } - - - - //CA SYNCHRONOUS GROUPS - //Define a Group, and perform synchronous group - - - - for (size_t kl=0; kl<1; ++kl) { - - - //2. ANOTHER WAY TO DO A GET ON A COLLECTIONM OF CHANNELS - //2. Gathers gets and send in one call - status=cafe->get(hArray, NHANDLES, pvdArray); - - if (status != ICAFE_NORMAL) { - cstat.report(status); - } - - for (size_t i=0; iset(hArray[6],3.3) ; // change one value - if (status!=ICAFE_NORMAL) { - cafe->printStatusIfError(hArray[6],status); - } - - cout << "---------------------------" << endl; - - //3. Another way: gets and send in one call - //3. IN ESSENCE THIS IS THE SAME AS 2. but broken down into 2 parts - int statusArray[NHANDLES]; - status=cafe->get(hArray, NHANDLES, statusArray); - - if (status != ICAFE_NORMAL) { - //cstat.report(status); - for (size_t i=0; iprintStatusIfError(hArray[i],statusArray[i]); - } - } - - cout << "---------------------------" << endl; - status=cafe->getCache(hArray, NHANDLES, pvdArray); - - for (size_t i=0; iprintHandles(); - - - //Start Monitors on Group vector statusMonV; @@ -1681,19 +1021,4 @@ int main( int argc, char *argv[] ) } - #if HAVE_PYTHON - - cout << "HAVE PYTHON " << endl; - //dlopen("/opt/gfa/python-3.5/latest/lib/libpython3.5m.so", RTLD_GLOBAL|RTLD_LAZY); - Py_Finalize(); - - #endif - - - sleep(2); - //terminate cafe - - cafe->terminate(); - sleep(2); - return 0; } diff --git a/examples/cafeTest/makefile b/examples/cafeTest/makefile index a79146f..7e642ac 100644 --- a/examples/cafeTest/makefile +++ b/examples/cafeTest/makefile @@ -7,7 +7,7 @@ #CAFE version to link to -CAFE_VERSION=cafe-1.2.0-final-1 +CAFE_VERSION=cafe-1.3.0-final-1 #PYTHON_INCLUDE=/opt/gfa/python-3.5/latest/include/python3.5m #PYTHON_LIB=/opt/gfa/python-3.5/latest/lib diff --git a/include/cafe.h b/include/cafe.h index 89f0e2d..e3e5b68 100644 --- a/include/cafe.h +++ b/include/cafe.h @@ -182,17 +182,18 @@ public: return ss.str(); } + #if HAVE_ZEROMQ //cafeService.h - #if HAVE_ZEROMQ int calcDBPMStatus(int, int, string); - + + int getDBPM(DBPMHolder &dbpm); int getDBPM(DBPMKeeper &dbpm); int readDBPMOffsets(DBPMKeeper &dbpm); int prepareDBPM(vector &_glist, vector &_hV, std::vector &dev, std::vector &pos) ; int prepareDBPM(vector &_glist, vector &_hV, std::map &posDev) ; - #endif + #endif diff --git a/include/statusCodes.h b/include/statusCodes.h index 74a0369..c574562 100644 --- a/include/statusCodes.h +++ b/include/statusCodes.h @@ -668,10 +668,10 @@ public: mapStatusCode.insert(std::make_pair((int) ECAFE_LOAD_COLLECTION, "CAFE ERROR: ECAFE_LOAD_COLLECTION")); mapStatusCode.insert(std::make_pair((int) ECAFE_LOAD_GROUP, "CAFE ERROR: ECAFE_LOAD_GROUP")); - 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) LINUX_EAGAIN, "CAFE_ERROR: LINUX_EAGAIN " )); + mapStatusCode.insert(std::make_pair((int) LINUX_EAGAIN, "CAFE_WARN: LINUX_EAGAIN " )); mapStatusCode.insert(std::make_pair((int) LINUX_EFAULT, "CAFE_ERROR: LINUX_EFAULT" )); mapStatusCode.insert(std::make_pair((int) LINUX_ENOTSOCK, "CAFE_ERROR: LINUX_ENOTSOCK" )); mapStatusCode.insert(std::make_pair((int) LINUX_EPROTONOSUPPORT, "CAFE_ERROR: LINUX_EPROTONOSUPPORT" )); @@ -876,6 +876,13 @@ public: 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) LINUX_EAGAIN, "WARN" )); + mapStatusSeverity.insert(std::make_pair((int) LINUX_EFAULT, "ERROR")); + mapStatusSeverity.insert(std::make_pair((int) LINUX_ENOTSOCK, "ERROR")); + mapStatusSeverity.insert(std::make_pair((int) LINUX_EPROTONOSUPPORT, "ERROR" )); + + };