connect.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #ifndef CONNECT_H
00009 #define CONNECT_H
00010 
00011 // generated by autotools
00012 #include <config.h>
00013 #include <vector>
00014 #include <string>
00015 #include <iostream>
00016 #include <fstream>
00017 #include <sstream>
00018 
00019 #include <climits>
00020 
00021 #include <global.h>
00022 
00023 #include <exceptionsHelper.h>
00024 #include <handleHelper.h>
00025 #include <policyHelper.h>
00026 #include <hashConduitGroup.h>
00027 
00028 #include <boost/date_time/posix_time/posix_time.hpp>
00029 
00030 #if HAVE_BOOST_THREAD
00031 #include <boost/thread/thread_only.hpp>
00032 #include <boost/chrono.hpp>
00033 #endif
00034 
00035 
00036 
00037 
00038 class Connect
00039 {         
00040   protected:
00041   int  status;
00042   CAFEStatus cafeStatus;
00043   CAFEStatusSeverity cafeStatusSeverity;
00044  
00045   CAFEGlobalAlarmSeverity  epicsAlarmSeverity;
00046         CAFEGlobalAlarmCondition epicsAlarmStatus;
00047  
00048  
00049   cafeConduit_set::iterator itcs;
00050   cafeGroup_set::iterator itgs;
00051 
00052   CAFEDataTypeCode cafeDataTypeCode;
00053 
00054   ExceptionsHelper exceptionsHelper;
00055 
00056   
00057         
00058   PolicyHelper policyHelper;
00059   HandleHelper handleHelper;
00060   Helper helper;
00061 
00062   std::string deviceAttributeDeliminator;
00063 
00064   bool pyCafeFlag;
00065 
00066   //connectCallbacks.cc
00067   static void callbackHandlerAccessRights(struct access_rights_handler_args args);
00068 
00069   static void callbackHandlerException   (struct exception_handler_args     args);
00070 
00071   //connect.cpp
00072   int  createChannel(unsigned int  handle, const char * pv, chid &pCh);
00073         int  createHandle(const char * pv, ca_client_context * ccc, unsigned int  &handle)
00074   //int  createHandle(const char * pv, ca_client_context * ccc, ChannelRequestPolicy channelRequestPolicyPut, unsigned int  &handle)
00075           throw (CAFEException_pv);
00076 
00077   int  contextDestroy();
00078   int  contextDestroy(ca_client_context * cctLocal);
00079 
00080   unsigned short epicsVersion(unsigned short & major, unsigned short & minor, unsigned short & patch);
00081 
00082   //group functions
00083 
00084   int  createChannelWithinGroup(unsigned int  handle, const char * pv, chid &pCh);
00085   int  createHandleWithinGroup(const char  * pv, ca_client_context * ccc, unsigned int  & _handle)
00086           throw (CAFEException_pv);
00087 
00088   public:
00089         
00090         
00091   Connect(){
00092 
00093     channelMonitorPolicy.setPolicy(
00094        (ChannelWhenToFlushSendBufferPolicyKind) CAFENUM::FLUSH_AFTER_EACH_CHANNEL_SUBSCRIPTION,
00095                 CAFENUM::WITH_FLUSH_IO, DEFAULT_TIMEOUT_PEND_IO);
00096 
00097     channelOpenGroupPolicy.setPolicy(
00098                                      CAFENUM::FLUSH_AFTER_EACH_GROUP_CREATION,
00099                                                                                                                                                  CAFENUM::WITH_POLL, DEFAULT_TIMEOUT_SG_PEND_EVENT);
00100                                      //CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_SG_PEND_EVENT);
00101 
00102     channelOpenPolicy.setPolicy(
00103                                 CAFENUM::FLUSH_AFTER_EACH_CHANNEL_CREATION,
00104                                                                                                                                 CAFENUM::WITH_POLL, DEFAULT_TIMEOUT_PEND_EVENT);                                                                                                        
00105                                 //CAFENUM::WITH_PEND_EVENT, DEFAULT_TIMEOUT_PEND_EVENT);
00106                                                                                                                                 
00107                 channelClosePolicy.setPolicy(
00108                                 CAFENUM::FLUSH_AFTER_EACH_CHANNEL_CREATION,
00109                                 CAFENUM::WITH_PEND_IO, DEFAULT_TIMEOUT_PEND_IO);                                                                                                                
00110 
00111     deviceAttributeDeliminator=DEFAULT_DEVICE_ATTRIBUTE_DELIMINATOR;
00112                 
00113 #if HAVE_PYTHON_H
00114     pyCafeFlag=true;
00115 #else
00116                 pyCafeFlag=false;               
00117 #endif   
00118   };
00119 
00120   //these need to be public
00121 
00122   PrintErrorPolicy printErrorPolicy;
00123 
00124   ChannelCreatePolicy channelCreatePolicy;
00125 
00126   ChannelOpenPolicy channelOpenPolicy;
00127   ChannelOpenPolicy channelClosePolicy; //can also use for close
00128   ChannelOpenPolicy channelMonitorPolicy;
00129   ChannelOpenPolicy channelOpenGroupPolicy;
00130         
00131         
00132   //28 May 2017
00133   ChannelRequestPolicy channelRequestPolicyMasterPut;
00134         ChannelRequestPolicy channelRequestPolicyMasterGet;
00135         ChannelRequestPolicy channelRequestPolicyMasterGetCtrl;
00136         ChannelGetActionWhenMonitorPolicy channelGetActionWhenMonitorPolicyMaster;
00137 
00138   //ChannelOpenPolicy getChannelOpenPolicy(){return channelOpenPolicy;}
00139   //ChannelOpenPolicy getChannelClosePolicy(){return channelClosePolicy;}
00140   //ChannelOpenPolicy getChannelMonitorPolicy(){return channelMonitorPolicy;}
00141   //ChannelOpenPolicy getChannelOpenGroupPolicy(){return channelOpenGroupPolicy;}
00142 
00143   HandleHelper getHandleHelper()    {return handleHelper;}
00144   HandleHelper getInfo()    {return handleHelper;}
00145   PolicyHelper getPolicyHelper()  {return policyHelper;}
00146   PolicyHelper getPolicy()  {return policyHelper;}
00147 
00148   unsigned int getNelemClient(unsigned int h){ return handleHelper.getNelemClient(h);}
00149   unsigned int getNelemNative(unsigned int h){ return handleHelper.getNelemNative(h);}
00150   unsigned int getNelemRequest(unsigned int h){ return handleHelper.getNelemRequest(h);}
00151 
00152   int  getStatus() {return status;}
00153 
00154   CAFEStatus          getCafeStatus() {return cafeStatus;}
00155         CAFEStatusSeverity  getCafeStatusSeverity() {return cafeStatusSeverity;}
00156         
00157         CAFEGlobalAlarmCondition   getEpicsAlarmStatus() {return epicsAlarmStatus;}
00158   CAFEGlobalAlarmCondition   getEpicsAlarmCondition() {return epicsAlarmStatus;}
00159         CAFEGlobalAlarmSeverity    getEpicsAlarmSeverity() {return epicsAlarmSeverity;}
00160         
00161         int flushNow() {return ca_flush_io();}
00162         
00163         int _ca_flush_io(){return ca_flush_io();}
00164         int _ca_poll(){return ca_poll();}
00165         int _ca_pend_io(double t){return ca_pend_io(t);}
00166         int _ca_pend_event(double t){return ca_pend_event(t);}
00167         
00168   //connect.cc
00169         bool setPyCafe(bool b){return pyCafeFlag=b;};
00170         bool getPyCafe(){return pyCafeFlag;} ;
00171   int  init() throw (CAFEException_init);
00172   int  init(ca_preemptive_callback_select select)  throw (CAFEException_init);
00173 
00174   //std::string
00175   int  open(const std::string pvS, unsigned int  &handle) throw (CAFEException_open){
00176                         
00177       try { open (pvS.c_str(), handle);} catch(CAFEException_open &e) {throw e;};
00178   }
00179   int  open(const std::string pvS, const std::string pvAliasS, unsigned int  &handle)
00180           throw (CAFEException_open){
00181       try { open (pvS.c_str(), pvAliasS.c_str(), handle);} catch(CAFEException_open &e) {throw e;};
00182   }
00183   int  open(const std::string *pvArrayS, unsigned int *handleArray, const unsigned int nHandles)
00184           throw (CAFEException_open);
00185 
00186   //const char *pv
00187   int  open(const char *pv, unsigned int  &handle) throw (CAFEException_open);
00188   int  open(const char *pv, const char *pvAlias, unsigned int  &handle)
00189           throw (CAFEException_open);
00190 
00191   int  open(const char **pvArray, unsigned int *handleArray, const unsigned int nHandles)
00192           throw (CAFEException_open);
00193   int  open(std::vector<const char *>, std::vector<unsigned int> &) throw (CAFEException_open);
00194   int  open(std::vector<std::string>, std::vector<unsigned int> &) throw (CAFEException_open);
00195 
00196   int  openV(std::vector<std::string> s, std::vector<unsigned int> &i) throw (CAFEException_open)
00197   {return open(s,i); };
00198 
00199 
00200   
00201 //################################################################################      
00202 
00203         
00204         void openGroupPrepare(){
00205                 channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
00206                 channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
00207                 return; 
00208         }
00209                                                 
00210         void openGroupNowAndWait(double _timeout);
00211         
00212         void openGroupNowAndWaitForInputGroups(double _timeout, std::vector<unsigned int> gHandles);
00213         
00214         
00215         //Pends for default amount of time
00216   void openGroupNow() { 
00217           openGroupNowAndWait(channelOpenGroupPolicy.getTimeout());             
00218                 return;
00219         } 
00220         
00221         
00222         //Same as above - change nanmin convetnion      
00223         void groupOpenPrepare(){
00224                 channelOpenGroupPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
00225                 channelOpenGroupPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
00226                 return; 
00227         }
00228                                                 
00229         void groupOpenNowAndWait(double _timeout) { openGroupNowAndWait(_timeout); return; };
00230         void groupOpenNowAndWait(double _timeout, std::vector<unsigned int> gH) 
00231            { openGroupNowAndWaitForInputGroups(_timeout, gH); return; };
00232         
00233         //Pends for default amount of time
00234   void groupOpenNow() { 
00235           openGroupNowAndWait(channelOpenGroupPolicy.getTimeout());             
00236                 return;
00237         } 
00238         
00239         
00240         
00241   //-------------------------------------------------------------------------
00242   void openMonitorPrepare(){
00243         channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
00244           channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);     
00245                 return;
00246         }       
00247 
00248         void openMonitorNow(){
00249                 channelMonitorPolicy.flushSendBufferNow();
00250                 //reset
00251                 channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
00252                 channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);     
00253                 return;
00254         }
00255         
00256         void openMonitorNowAndWait(double _timeout){
00257                 channelMonitorPolicy.setTimeout(_timeout);       
00258                 channelMonitorPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);
00259                 channelMonitorPolicy.flushSendBufferNow();              
00260                 //reset
00261                 channelMonitorPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
00262                 channelMonitorPolicy.setFlushSendBufferKind(WITH_FLUSH_IO);             
00263                 return;
00264   }
00265   //------------------------------------------------------------------------
00266 
00267 
00268         double setOpenDefaultPendTime(double _timeout){
00269                 return channelOpenPolicy.setDefaultTimeout(_timeout);
00270         }
00271         
00272         double getOpenDefaultPendTime(){
00273                 return channelOpenPolicy.getDefaultTimeout();
00274         }
00275 
00276   //------------------------------------------------------------------------
00277   void openPrepare() {
00278      channelOpenPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
00279                  channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
00280                  return;
00281         } 
00282         
00283         //Same as openPrepare
00284         void openNoWait(){
00285                 channelOpenPolicy.setFlushSendBufferKind(WITH_PEND_EVENT);              
00286                 channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_DESIGNATED_TO_CLIENT);
00287                 return;
00288         }
00289                 
00290         //Pends for a maximimum of timeout seconds
00291   void openNowAndWait(double _timeout);
00292          
00293         
00294         //Pends for default amount of time
00295   void openNow() {      
00296           openNowAndWait(channelOpenPolicy.getTimeout());
00297                 /*
00298           channelOpenPolicy.flushSendBufferNow();
00299                 //reset
00300                 channelOpenPolicy.setWhenToFlushSendBuffer(FLUSH_NOW);
00301                 channelOpenPolicy.setFlushSendBufferKind(WITH_POLL); //PEND_EVENT);
00302                 */
00303                 return;
00304         } 
00305 
00306 //-------------------------------------------------------------------------
00307 
00308         
00309         bool initCallbackComplete(std::vector<unsigned int> hV) {
00310                 return initCallbackComplete(&hV[0], hV.size());
00311         }
00312         
00313         bool initCallbackComplete(unsigned int * hArray, unsigned int nelem);
00314 
00315         
00316         
00317         //#################################################################################                     
00318 
00319   unsigned int  printHandle(unsigned int  h){return handleHelper.printHandle(h);};
00320   unsigned int  printHandles(void){return handleHelper.printHandles();};
00321   unsigned int  printDisconnectedHandles(void){return handleHelper.printDisconnectedHandles();};
00322   unsigned int  getDisconnectedHandles(std::vector<unsigned int> &dhV, std::vector<std::string> &pvV)
00323         {return handleHelper.getDisconnectedHandles(dhV, pvV);};
00324 
00325 
00326   void printCAFEException_pv(CAFEException_pv & e){exceptionsHelper.printCAFEException_pv(e);};
00327   
00328         
00329 
00330         
00331   //closeChannel(s) only close within a context
00332         int  closeChannels(unsigned int * handleArray, unsigned int nHandles);
00333         int  closeChannels(std::vector<unsigned int> v){
00334         
00335           //unsigned int * handleArray = new unsigned int[v.size()];
00336                 //int status= closeChannels(handleArray, v.size());
00337                 //delete [] handleArray;
00338           //return status;
00339                 return closeChannels(&v[0], v.size());
00340         };
00341   int  closeChannelsV(std::vector<unsigned int> v){
00342           //unsigned int * handleArray = new unsigned int[v.size()];
00343                 //int status= closeChannels(handleArray, v.size());
00344                 //delete [] handleArray;                
00345           //return status;
00346                 return closeChannels(&v[0], v.size());
00347         };
00348         
00349         
00350   int  close(unsigned int  handle);
00351   int  closeChannel(unsigned int  handle){return close(handle);};
00352   int  closeChannels();
00353   int  closeChannels(ca_client_context * cctLocal);
00354   int  close(){return closeChannels();};
00355   
00356   //closeHandle(s) close regardless of context
00357         int  closeHandlesV(std::vector<unsigned int> v){ return closeHandles(&v[0], v.size());}
00358         int  closeHandles (std::vector<unsigned int> v){ return closeHandles(&v[0], v.size());}
00359         
00360         
00361   int  closeHandles(unsigned int * handleArray, unsigned int nHandles);
00362   int  closeHandle(unsigned int  handle);
00363   int  closeHandles();
00364         
00365         //Close Channel Keep Handle
00366         int  closeChannelKeepHandle(unsigned int  handle);
00367         int  closeChannelsKeepHandles(unsigned int  * handleArray,  unsigned int nHandles);
00368         int  closeChannelsKeepHandlesV(std::vector<unsigned int> v){ return closeChannelsKeepHandles(&v[0], v.size());}
00369         int  closeChannelsKeepHandles (std::vector<unsigned int> v){ return closeChannelsKeepHandles(&v[0], v.size());} 
00370  
00371   // Monitors
00372   int  monitorStart(unsigned int  handle, MonitorPolicy &mp);
00373   int  monitorStart(unsigned int  handle, unsigned int  & monitorID);
00374   int  monitorStart(unsigned int  handle) {
00375       unsigned int monitorID; return monitorStart(handle, monitorID);
00376   }
00377 
00378         int monitorPulseID();
00379         int monitorStopPulseID();
00380 
00381   int  monitorStop (unsigned int  handle, MonitorPolicy mp);
00382   int  monitorStop (unsigned int  handle, unsigned int  monitorID);
00383   int  monitorStopWithID (unsigned int  handle, unsigned int  monitorID){
00384       return monitorStop(handle, monitorID);}
00385   int  monitorStop (unsigned int  handle); //stop all monitors for this handle
00386   int  monitorStop ();
00387   int  monitorStopAll (){return monitorStop();};
00388   int  monitorStop (ca_client_context * ccc);
00389 
00390   // Monitors for arrays and vectors
00391   int  monitorStart(unsigned int  * handleArray, unsigned int  nelem) {
00392       int * statusArray = new int[nelem];
00393       MonitorPolicy * mpV = new MonitorPolicy[nelem];
00394       status = monitorStart (handleArray, nelem, statusArray, mpV);
00395       delete [] statusArray; delete [] mpV;
00396       return status;
00397   }
00398 
00399   int  monitorStart(unsigned int  * handleArray, unsigned int  nelem, int  *statusArray,
00400                     MonitorPolicy * mpV);
00401   int  monitorStart(unsigned int  * handleArray, unsigned int  nelem, int  *statusArray,
00402                     unsigned int  * monitorIDArray);
00403   int  monitorStart(std::vector<unsigned int> handleV, std::vector<int> &statusV,
00404                     std::vector<MonitorPolicy> &mpV);
00405   int  monitorStart(std::vector<unsigned int> handleV, std::vector<int> &statusV,
00406                     std::vector<unsigned int> &monitorIDV);
00407   int  monitorStop (unsigned int  * handleArray, unsigned int  nelem, int  *statusArray);
00408   int  monitorStop (std::vector<unsigned int> handleV, std::vector<int> &statusV);
00409 
00410   int  monitorStop(unsigned int  * handleArray, unsigned int  nelem) {
00411       int * statusArray = new int[nelem];
00412       status = monitorStop (handleArray, nelem, statusArray);
00413       delete [] statusArray;
00414       return status;                    
00415   }
00416 
00417 
00418   MonitorPolicy * createMonitorPolicyArray(const unsigned int nmp) {
00419                 MonitorPolicy * mpArray = new MonitorPolicy[nmp];
00420                 return mpArray;         
00421         }
00422 
00423   int  terminate();
00424   int  terminate(ca_client_context * cctLocal);
00425  
00426   unsigned int getHandleFromPV(const char * pv) {return handleHelper.getHandleFromPV(pv); }
00427   const char * getPVFromHandle(unsigned int handle){
00428       return handleHelper.getPVFromHandle(handle);
00429   }
00430 
00431 
00432 
00433   unsigned int getHandleFromPVWithinGroup(const char * pv, unsigned int grh) {
00434           return handleHelper.getHandleFromPVWithinGroup(pv, grh); }
00435 
00436 
00437   bool isEnum(unsigned int handle) {return handleHelper.isEnum(handle);}
00438 
00439   bool isValid(unsigned int handle) { for (itcs = cs.begin(); itcs != cs.end(); ++itcs)
00440     {if ((*itcs).getHandle()==handle) {return true;}} return false;}
00441 
00442   bool allChannelsConnected() { for (itcs = cs.begin(); itcs != cs.end(); ++itcs)
00443       {if (!(*itcs).isConnected()) {return false;}} return true;}
00444                         
00445   bool isConnected(unsigned int handle) {
00446       return isChannelConnected(handle);
00447   }
00448         
00449   bool isChannelConnected(unsigned int handle){cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00450         cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00451         if (it_handle != handle_index.end()) {return (*it_handle).isConnected();}
00452         else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl; return false;}}
00453   int  getChannelInfo(unsigned int handle, ChannelRegalia & channelInfo){
00454       cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00455       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00456       if (it_handle != handle_index.end()) {channelInfo=(*it_handle).getChannelRegalia(); return ICAFE_NORMAL;}
00457       else {return ECAFE_INVALID_HANDLE;}
00458   };    
00459   chid getChannelID(unsigned int handle){cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00460       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00461       if (it_handle != handle_index.end()) {return (*it_handle).getChannelID();}
00462       else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl; return NULL;}}
00463 
00464 
00465   ca_client_context * getClientContext(const char * pvname){
00466        return handleHelper.getContextFromPV(pvname);
00467   }
00468 
00469   ca_client_context * getClientContext(unsigned int handle){
00470        return handleHelper.getContextFromHandle(handle);
00471   }
00472 
00473   int attachContext(ca_client_context *ccc){
00474       if (ccc != NULL) {
00475         return ca_attach_context(ccc);
00476     } else { return ECAFE_NULLCONTEXT;}
00477   }
00478 
00479   int attachContextByPVName(const char * pvname){
00480       ca_client_context * ccc=getClientContext(pvname);
00481       if (ccc != NULL) {
00482         return ca_attach_context(ccc);
00483     } else { return ECAFE_NULLCONTEXT;}
00484   }
00485 
00486   int attachContextByHandle(unsigned int handle){
00487       ca_client_context * ccc=getClientContext(handle);
00488       if (ccc != NULL) {
00489         return ca_attach_context(ccc);
00490     } else { return ECAFE_NULLCONTEXT;}
00491   }
00492 
00493   //Add these methods for QCafe
00494   int updateAccessRead(unsigned int handle, int ar) {cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00495       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00496       if (it_handle != handle_index.end()) {
00497 
00498           if ( (*it_handle).getAccessRead() != ar ) {
00499               if(MUTEX){cafeMutex.lock();}
00500               handle_index.modify(it_handle, change_accessRead(ar));
00501               if(MUTEX){cafeMutex.unlock();}
00502           }
00503           return ICAFE_NORMAL;}
00504       else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl;
00505           return ECAFE_INVALID_HANDLE;}
00506   }
00507 
00508   int updateAccessWrite(unsigned int handle, int aw) {cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00509       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00510       if (it_handle != handle_index.end()) {
00511           if ( (*it_handle).getAccessWrite() != aw ) {
00512               if(MUTEX){cafeMutex.lock();}
00513               handle_index.modify(it_handle, change_accessWrite(aw));
00514               if(MUTEX){cafeMutex.unlock();}
00515           }
00516           return ICAFE_NORMAL;}
00517       else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl;
00518           return ECAFE_INVALID_HANDLE;}
00519   }
00520 
00521   bool getReadAccess(unsigned int handle){cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00522       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00523       if (it_handle != handle_index.end()) {return (bool) (*it_handle).getAccessRead();}
00524       else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl; return false;}}
00525 
00526   bool getWriteAccess(unsigned int handle){cafeConduit_set_by_handle & handle_index=cs.get<by_handle>();
00527       cafeConduit_set_by_handle::iterator it_handle; it_handle = handle_index.find(handle);
00528       if (it_handle != handle_index.end()) {return (bool) (*it_handle).getAccessWrite();}
00529       else {std::cout<< "Input handle " << handle << " does not exists! " << std::endl; return false;}}
00530 
00531   void printStatusMessage(int status) {
00532       std::string s =  getCafeStatus().csi.message(status);
00533       std::string c =  getCafeStatus().csc.message(status);
00534       printf("%s\n",c.c_str());
00535       printf("%s\n",s.c_str());
00536   }
00537 
00538   int  printStatus(unsigned int handle, int  status);
00539   int  printStatusIfError(unsigned int handle, int  status);
00540   int  printStatus(unsigned int * handleArray, unsigned int  nelem, int  * statusArray);
00541   int  printStatusIfError(unsigned int * handleArray, unsigned int  nelem, int  * statusArray);
00542   int  printStatus(std::vector<unsigned int> handleV, std::vector<int> statusV);
00543   int  printStatusIfError(std::vector<unsigned int> handleV, std::vector<int> statusV);
00544 
00545 
00546   int  printStatus(const char *pv, int  status);
00547   int  printStatusIfError(const char *pv, int  status);
00548   int  printStatus(const char * pvArray, unsigned int  nelem, int  * statusArray);
00549   int  printStatusIfError(const char * pvArray, unsigned int  nelem, int  * statusArray);
00550   int  printStatus(std::vector<std::string> pvV, std::vector<int> statusV);
00551   int  printStatusIfError(std::vector<std::string> pvV, std::vector<int> statusV);
00552 
00553   int  setPVAlias(unsigned int handle, const char * pv) throw (CAFEException_open);
00554 
00555   // GROUP FUNCTIONS
00556 
00557   PVDataHolder * getPVData(std::vector <unsigned int> handleArray);
00558 
00559   int  collectionDefine(const char * collectionName, std::vector<std::string> deviceV);
00560   int  collectionDefine(const char * collectionName, std::vector<const char *> deviceV);
00561   int  collectionDefine(const char * collectionName, pv_string_t * deviceArray, unsigned int  deviceLength);
00562   int  collectionFetch(const char * collectionName, std::vector<std::string> &deviceListV);
00563   int  collectionFetch(const char * collectionName, std::vector<const char *> &deviceListV);
00564   int  collectionFetch(const char * collectionName,deviceCollection &dC);
00565   std::vector<deviceCollection> getCollections() const {return deviceCollectionV;};
00566 
00567 
00568   //To do: Add shared_ptr for this method to ensure memory release
00569   int  collectionMemberList(const char * collectionName, boost::shared_ptr<pv_string_t []> &list, unsigned int  &listLength);
00570   //int  collectionMemberList(const char * collectionName, dbr_string_t * &list, unsigned int  &listLength);
00571 
00572   //To do: Add shared_ptr for this method to ensure memory release
00573   int  collectionList      (boost::shared_ptr<pv_string_t []> &clist, unsigned int  &listLength);
00574   //int  collectionList      (dbr_string_t * &clist, unsigned int  &listLength);
00575 
00576   int  collectionMemberList(const char * collectionName, std::vector<std::string> &list);
00577   int  collectionList      (std::vector<std::string> &clist);
00578 
00579         int  devicePositionOrderedMultiMap(const char * collectionName, std::multimap<float, std::string> &posDev);
00580         int  devicePositionMap(const char * collectionName, std::map<float, std::string> &posDev);
00581   int  devicePositionV(const char * collectionName, std::vector<std::string> &dev, std::vector<float> &pos);
00582 
00583 
00584   int  fetchIndexOfCollectionMember(const char *collectionName, const char * deviceName);
00585 
00586   bool isGroup(const char *);
00587   bool isCollection(const char *);
00588 
00589   int  groupOpen(const char *pv,   unsigned int  &groupHandle) throw (CAFEException_groupOpen);
00590   int  groupOpen(PVGroup &pvgroup, unsigned int  &groupHandle) throw (CAFEException_groupOpen);
00591 
00592 
00593   int  groupClose(unsigned int  groupHandle);
00594         int  groupClose();
00595         int  groupCloseAll(){return groupClose(); };
00596   int  groupHandleErase();
00597   int  groupHandleErase(ca_client_context *ccc);
00598 
00599   int  groupCombine(const char * newGroupName, const char * groupName1,
00600                             const char * groupName2);  // PVGroup &pvGroup);
00601   int  groupCombine(const char * newGroupName, std::vector<char *> groupName);// PVGroup &pvGroup);
00602 
00603 
00604   std::vector<std::string> generateChannelList(std::vector<std::string> inputStringV) {
00605                 return  getFromGlobalChannelList(inputStringV);
00606         }
00607  
00608   std::vector<std::string> getFromGlobalChannelList(std::vector<std::string>);
00609 
00610 
00611   int  groupDefine (const char * groupName, const char * collectionName, std::vector<std::string> attributeV);
00612   int  groupDefine (const char * groupName, const char * collectionName, std::vector<const char*> attributeV);
00613   int  groupDefine (const char * groupName, const char * collectionName,
00614                     pv_string_t * attributeArray, unsigned short attributeLength);
00615   int  groupDefine (const char * groupName, const char * collectionName, pv_string_t  attribute){
00616      pv_string_t aA[1]; strcpy(aA[0], attribute);
00617      return groupDefine(groupName, collectionName, aA, 1);
00618   }
00619 
00620   int  groupDefine (const char * groupName, std::vector<std::string> deviceV, std::vector<std::string> attributeV);// PVGroup &pvGroup);
00621   int  groupDefine (const char * groupName, std::vector<const char *> deviceV, std::vector<const char*> attributeV);
00622                     //PVGroup &pvGroup);
00623   int  groupDefine (const char * groupName, pv_string_t * deviceArray, unsigned int  deviceLength,
00624                     pv_string_t * attributeArray, unsigned short attributeLength); //
00625 
00626   int  groupDefine (const char * groupName, std::vector<std::string> pvArrayV); // PVGroup &pvGroup);
00627   int  groupDefine (const char * groupName, std::vector<const char *> pvArrayV); // PVGroup &pvGroup);
00628   int  groupDefine (const char * groupName, pv_string_t * pvArray, unsigned int  pvArrayLength);
00629                             //PVGroup &pvGroup);
00630 
00631   //To do: Add shared_ptr for this method to ensure memory release
00632 
00633   int  groupMemberList(const char * groupName, boost::shared_ptr<pv_string_t []> &list, unsigned int &listLength);
00634   //int  groupMemberList(const char * groupName, dbr_string_t * &list, unsigned int  &listLength);
00635 
00636   int  groupList      (boost::shared_ptr<pv_string_t []> &glist, unsigned int  &listLength);
00637   //int  groupList      (dbr_string_t * &glist, unsigned int  &listLength);
00638 
00639   int  groupMemberList(const char * groupName, std::vector<std::string> &list);
00640 
00641   int  groupList      (std::vector<std::string> &glist);
00642 
00643   int  fetchIndexOfGroupMember(const char *groupName, const char * pv);
00644 
00645   void setDeviceAttributeDeliminator(std::string d) {deviceAttributeDeliminator=d;};
00646   std::string getDeviceAttributeDeliminator() const {return deviceAttributeDeliminator;};
00647         
00648 
00649 };
00650 
00651 #endif // CONNECT_H

Generated on 28 May 2018 for CAFE by  doxygen 1.6.1