00001 #ifndef CONTROLFERO 00002 #define CONTROLFERO 00003 00004 #include "FedCommand.hpp" 00005 #include <iostream> 00006 #include <vector> 00007 #include "SendWithoutCoCo.hpp" 00008 #include "FeeIclAck.hpp" 00009 #include <boost/scoped_ptr.hpp> 00010 #include "AnswerStruct.hpp" 00011 #include "WatchDog.hpp" 00012 00013 #include "ace/Synch.h" 00014 00015 #define CONTROLFERO_STRUCTURE "C:20;C" 00016 #define CTF_WATCH_DOG_TIMEOUT 5000L 00017 00018 namespace ztt{namespace dcs{ 00023 typedef struct ControlFeroStruct{ 00024 char name[20]; 00025 char payload[1000]; 00026 00027 ControlFeroStruct& operator=(const ControlFeroStruct& rhs){ 00028 if(this==&rhs){ 00029 return *this; 00030 } 00031 name[sprintf(name,rhs.name)]=0; 00032 memcpy(payload,rhs.payload,sizeof(rhs.payload)); 00033 00034 return *this; 00035 00036 } 00037 }ControlFeroStruct; 00038 00047 class ControlFero:public FedCommand{ 00048 00049 public: 00054 ControlFero(char* name,DimCommandHandler* handler):FedCommand(name,CONTROLFERO_STRUCTURE,handler),mutex(), 00055 cond(mutex),busy(false),localID(0),iclAck(FeeIclAck::createInstance()),mWatchDog("ControlFero",&mAnswerStruct,&busy){ 00056 mWatchDog.activate(THR_DETACHED|THR_NEW_LWP,5,1); 00057 mb = new ACE_Message_Block((char*)&localID); 00058 }; 00059 virtual ~ControlFero(); 00064 virtual bool handleCommand(); 00069 virtual bool setAnswerData(const int& ID); 00074 static void* watchDog(void* objectHandler); 00079 bool isBusy(); 00080 00081 00082 private: 00086 ACE_Thread_Mutex mutex; 00090 ACE_Condition<ACE_Thread_Mutex> cond; 00095 SendWithoutCoCo send; 00099 boost::scoped_ptr<FeeIclAck> iclAck; 00103 bool busy; 00107 int localID; 00111 AnswerStruct mAnswerStruct; 00112 WatchDog mWatchDog; 00113 ACE_Message_Block* mb; 00114 }; 00115 inline bool ControlFero::isBusy(){ 00116 return busy; 00117 } 00118 00119 }} 00120 00121 #endif