Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

WatchDog.hpp

00001 #ifndef WATCH_DOG
00002 #define WATCH_DOG
00003 
00004 #include "ace/Task.h"
00005 #include "ace/Synch.h"
00006 #include "FeeIclAck.hpp"
00007 #include "AnswerStruct.hpp"
00008 #include "FedCommand.hpp"
00009 
00010 
00011 namespace ztt{
00012         namespace dcs{
00013 
00014 
00015 
00024 class WatchDog : public ACE_Task<ACE_MT_SYNCH>
00025 {
00026 public:
00034         WatchDog(const char* channelName, AnswerStruct* pAnswerStr,bool* commandBusy):mutex(),condition(mutex),pAnswerStruct(pAnswerStr),
00035                 mpFeeIclAck(FeeIclAck::createInstance()),mcChannelName(channelName),mpCommandChannelBusyFlag(commandBusy){};
00036         ~WatchDog(void){
00037                 mutex.remove();
00038         };
00042         virtual int svc(void);
00046         void wakeUp(void);
00047         /*
00048         * processTimeOut is the main function of the watchDog. It calculates the timeout.
00049         *
00050         * @param mb contain the id of the commmand. mb is used to transport this information into the thread.
00051         */
00052         void processTimeOut(ACE_Message_Block* mb);
00053         void setCommandHandler(FedCommand* fedCom);
00054         
00055 
00056 private:
00057         //mcChannelName store the name of the correspondend command channel
00058         const char* mcChannelName;
00059         //condition is used to notify the thread via a condition value
00060         ACE_Condition<ACE_Thread_Mutex> condition;
00061         //mutex is required to initialize the condition value.
00062         ACE_Thread_Mutex mutex;
00063         //points to the ack id list of each command channel
00064         AnswerStruct* pAnswerStruct;
00065         //mpFeeIclAck points to the acknowledge channel of the InterComLayer
00066         FeeIclAck* mpFeeIclAck;
00067         bool* mpCommandChannelBusyFlag;
00068 
00069 };
00070 inline void WatchDog::wakeUp(){
00071         condition.signal();
00072 }
00073         }}
00074 
00075 #endif

Generated on Fri Mar 30 02:54:34 2007 for InterComLayer by doxygen 1.3.5