callbacks.h

Go to the documentation of this file.
00001 //
00002 //  callbacks.h
00003 //
00004 
00005 void callbackHandlerCreate(struct connection_handler_args args) {
00006 
00007         ChannelCreatePolicy::callbackHandlerCreate(args);
00008         unsigned int  _handle = (unsigned long) ca_puser(args.chid);
00009         //cout << "LOCAL CALLBACK CALLED FOR HANDLE " << _handle << endl;
00010         if (args.op != CA_OP_CONN_UP) {
00011                 cout << "HANDLE DISCONNECTED " << _handle << endl;      
00012         }
00013         
00014 }
00015 
00016 void callbackHandlerCreate2(struct connection_handler_args args) {
00017         ChannelCreatePolicy::callbackHandlerCreate(args);
00018         unsigned int  _handle = (unsigned long) ca_puser(args.chid);
00019         //cout << "LOCAL CALLBACK2 CALLED FOR HANDLE " << _handle << endl;
00020         if (args.op != CA_OP_CONN_UP) {
00021                 cout << "HANDLE DISCONNECTED " << _handle << endl;      
00022         }       
00023 }
00024 
00025 void callbackHandlerMonitor( struct event_handler_args args)  {
00026 #define __METHOD__  "callbackHandlerMonitor"
00027 
00028     if (args.status !=ECA_NORMAL) {
00029         cout << __FILE__ << "//" << __LINE__ << "//" << __METHOD__ << endl;
00030         cout << "Status=" << args.status << " for channel " << ca_name (args.chid) << endl;
00031         return;
00032     }
00033 
00034     unsigned int _handle = (unsigned long) ca_puser(args.chid);// args.usr; // ca_puser(args.chid);
00035 
00036     cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
00037     cafeConduit_set_by_handle::iterator it_handle;
00038 
00039     it_handle = handle_index.find((unsigned int)_handle);
00040 
00041     if (it_handle != handle_index.end()) {
00042         //cout << (*it_handle).getPV() << " " << (*it_handle).getHandle() << endl;
00043         if(MUTEX){cafeMutex.lock();}
00044         handle_index.modify(it_handle, change_eventHandlerArgs   (args));
00045         if(MUTEX){cafeMutex.unlock();}
00046 
00047 
00048                                 //**** ADD USER CODE HERE ***//
00049                 
00050          if (args.type < DBR_GR_STRING) {
00051             PVDataHolder pvd(args.count);
00052             (*it_handle).getPVDataHolder(pvd);
00053             pvd.print();
00054             cout << "val/D//= " << pvd.getAsString(0) << endl;
00055 
00056          }
00057          else if (args.type < DBR_PUT_ACKT) {
00058             PVCtrlHolder pvc(args.count);
00059             (*it_handle).getPVCtrlHolder(pvc);
00060             pvc.print();
00061             cout << "val/C/= " << pvc.getAsString(0) << endl;
00062          }
00063                                  
00064                                  
00065                                 vector<MonitorPolicy> mpV = (*it_handle).getMonitorPolicyVector();
00066                                 
00067                                                         
00068                           cout <<  args.usr << endl;
00069                                 cout << (*it_handle).getUsrArgs() << endl;
00070                                 
00071                                 for (int i=0; i<mpV.size(); ++i) {
00072                                 
00073                                 cout << " i " << i << endl;
00074                                   cout <<  mpV[i].getUserArgs() << endl;
00075                                         mpV[i].print();
00076                                 }
00077                         
00078                                 //****  END USER CODE ***// 
00079                 
00080     }
00081     else {
00082         cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
00083         cout << " Internal CAFE ERROR! Unknown Handle! handle=" <<  _handle << endl;
00084     }
00085 
00086 return;
00087 #undef __METHOD__
00088 };
00089 
00090 
00095 void handlerPut( struct event_handler_args args)  {
00096 #define __METHOD__  "handlerPut"
00097 
00098     if (args.status !=ECA_NORMAL) {
00099         cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
00100         cout << "Status=" << args.status << " for channel " << ca_name (args.chid) << endl;
00101         return;
00102     }
00103 
00104     unsigned int _handle = (unsigned long) args.usr;
00105 
00106     cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
00107     cafeConduit_set_by_handle::iterator it_handle;
00108 
00109     it_handle = handle_index.find((unsigned int) _handle);
00110 
00111         if (it_handle != handle_index.end())  {
00112 
00113             if(MUTEX)cafeMutex.lock();
00114 
00115             ChannelRequestStatus  channelRequestStatusPut=(*it_handle).getChannelRequestStatusPut();
00116 
00117             channelRequestStatusPut.setCallbackKind(false, true);
00118 
00119             handle_index.modify(it_handle, change_channelRequestStatusPut(channelRequestStatusPut));
00120                                                 
00121                                                 cout << __METHOD__ << " WITH_CALLBACK_USER_SUPLLIED for PUT done " << (*it_handle).getChannelRequestStatusPut().getCallbackProgressKind() << endl;
00122 
00123             if(MUTEX)cafeMutex.unlock();
00124                                 
00125                                         //**** ADD USER CODE HERE ***//
00126                                 
00127                                                 
00128         }
00129         else {
00130                  cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
00131                  cout << " Internal CAFE ERROR! Unknown Handle! handle=" <<  _handle << endl;
00132         }
00133 
00134                                 
00135                                 
00136 
00137 return;
00138 #undef __METHOD__
00139 };
00140 
00141 
00142 
00148 void handlerGet( struct event_handler_args args)  {
00149 #define __METHOD__  "handlerGet"
00150 
00151     if (args.status !=ECA_NORMAL) {
00152         cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
00153         cout << "Status=" << args.status << " for channel " << ca_name (args.chid) << endl;
00154         return;
00155     }
00156 
00157     unsigned int _handle = (unsigned long)  args.usr; // ca_puser(args.chid);
00158 
00159 
00160     cafeConduit_set_by_handle & handle_index = cs.get<by_handle> ();
00161     cafeConduit_set_by_handle::iterator it_handle;
00162 
00163     it_handle = handle_index.find(_handle);
00164 
00165     if (it_handle != handle_index.end())  {
00166 
00167             ChannelRequestStatus  channelRequestStatusGet=(*it_handle).getChannelRequestStatusGet();
00168             channelRequestStatusGet.setCallbackKind(false, true);
00169 
00170                                                 if(MUTEX){cafeMutex.lock();}
00171             handle_index.modify(it_handle, change_eventHandlerArgs   (args));
00172                                                 handle_index.modify(it_handle, change_channelRequestStatusGet(channelRequestStatusGet));
00173                                                 //cout << __METHOD__ << " GET CALLBACK DONE " << (*it_handle).getChannelRequestStatusGet().getCallbackProgressKind() << endl;
00174                                                 if(MUTEX){cafeMutex.unlock();}
00175                                                 
00176                                                 
00177                         if (args.type < DBR_GR_STRING) {
00178                 PVDataHolder pvd(args.count);
00179                 (*it_handle).getPVDataHolder(pvd);
00180                 pvd.print();
00181                 cout << "val/D//= " << pvd.getAsString(0) << endl;
00182 
00183                         }
00184                         else if (args.type < DBR_PUT_ACKT) {
00185                 PVCtrlHolder pvc(args.count);
00186                 (*it_handle).getPVCtrlHolder(pvc);
00187                 pvc.print();
00188                 cout << "val/C/= " << pvc.getAsString(0) << endl;
00189                         }
00190                                  
00191                                                 
00192                                                 
00193     }
00194                 else {
00195                                 
00196                   cout << __FILE__ << "/" << __LINE__ << "/" << __METHOD__ << endl;
00197                   cout << " Internal CAFE ERROR! Unknown Handle! handle=" <<  _handle << endl;
00198     }
00199 
00200 
00201 return;
00202 #undef __METHOD__
00203 };
00204 
00205 

Generated on 28 May 2018 for CAFE by  doxygen 1.6.1