00001 #ifndef CONFIGUREFERO
00002 #define CONFIGUREFERO
00003
00004 #include "FedCommand.hpp"
00005 #include <string>
00006 #include "SendViaCoCo.hpp"
00007 #include "FeeIclAck.hpp"
00008 #include "AnswerStruct.hpp"
00009 #include <boost/scoped_ptr.hpp>
00010 #include "WatchDog.hpp"
00011
00012
00013 #include "ace/Synch.h"
00014
00015
00019 #define CONFIGUREFERO_STRUCTURE "C:20;I"
00020
00023 #define CFF_WATCH_DOG_TIMEOUT 2000L
00024
00025 namespace ztt{namespace dcs{
00029 typedef struct ConfFero{
00031 char target[20];
00033 int tags[256];
00034
00035
00041 ConfFero& operator=(const ConfFero& rhs){
00042 if(this==&rhs){
00043 return *this;
00044 }
00045 memcpy(target,rhs.target,20);
00046 for(int i=0;i<10;i++){
00047 tags[0]=rhs.tags[i];
00048 }
00049 return *this;
00050
00051 }
00052
00053 }ConfFero;
00062 class ConfigureFero:public FedCommand{
00063
00064 public:
00070 ConfigureFero(char* name,DimCommandHandler* handler):FedCommand(name,CONFIGUREFERO_STRUCTURE,handler),
00071 mutex(),cond(mutex),busy(false),localID(0),iclAck(FeeIclAck::createInstance()),mWatchDog("ConfigureFero",&mAnswerStruct,&busy){
00072
00073 mWatchDog.activate(THR_DETACHED|THR_NEW_LWP,5,1);
00074 mb = new ACE_Message_Block((char*)&localID);
00075
00076 };
00081 virtual ~ConfigureFero();
00086 virtual bool handleCommand();
00094 virtual bool setAnswerData(const int& ID);
00101 static void* watchDog(void* objectHandler);
00106 bool isBusy();
00107 private:
00111 bool busy;
00115 ACE_Thread_Mutex mutex;
00120 ACE_Condition<ACE_Thread_Mutex> cond;
00124 SendViaCoCo send;
00125
00129 boost::scoped_ptr<FeeIclAck> iclAck;
00133 int localID;
00138 AnswerStruct mAnswerStruct;
00142 WatchDog mWatchDog;
00146 ACE_Message_Block* mb;
00147
00148 };
00149 inline bool ConfigureFero::isBusy(){
00150 return busy;
00151 }
00152
00153 }}
00154
00155 #endif