00001 #ifndef CLIEVER_CORE
00002 #define CLIEVER_CORE
00003
00004
00005 using boost::asio::ip::udp;
00009 class mdClieverTransaction : public mdProcess {void run() {};};
00013 void hbCallback(const boost::system::error_code& error);
00014 class mdCDHeartbeat : public mdClieverTransaction {
00015
00016 boost::asio::deadline_timer *t0;
00017
00018 public:
00019
00020 mdCDHeartbeat() {}
00021
00022 void init() {
00023 t0 = new boost::asio::deadline_timer(io_bg, boost::posix_time::seconds(MD_HEARTBEAT));
00024 }
00025 void dispatch(mdWQitem*) {}
00026 void nextBeat(const boost::system::error_code& error);
00027 void run();
00028
00029 };
00035 class cdClieverTransaction : public mdProcess {void run()=0;};
00036
00042 class mdCliever: public mdProcess,
00043 public Listener<cdHeartbeat>,
00044 public Listener<cdTelemetryFrame>,
00045 public Listener<cdIncoming>,
00046 public Listener<cdInteractiveCommand>,
00047 public Listener<cdResponse>,
00048 public Listener<cdShutdown>
00049 {
00050 public:
00051
00052 bool alive,connected,shuttingDown,shutDown;
00053
00054 int instrumentHandle[MAX_INSTRUMENTS],
00055 myHandle,machineHandle,
00056 rc,
00057 sentMsgCount[N_MDDG_TYPES][CD_MAX_DEVICE];
00058
00059 cdHeartbeat myPulse;
00060 clientDaemonConfig *cfg;
00061 mdCDHeartbeat *pulse;
00062 mdDGChannel *bg,*fg;
00063
00064
00065 mdCliever() { alive = connected = false;
00066 rc = OK;
00067 pulse = NULL;
00068 shuttingDown = shutDown = false;
00069 memset(sentMsgCount,0,sizeof(sentMsgCount));
00070 memset(instrumentHandle,0,sizeof(instrumentHandle));
00071 myHandle = machineHandle = 0;
00072 }
00073 mdCliever(clientDaemonConfig *cmdCfg)
00074 { this->cfg = cmdCfg; }
00075
00076 void dispatch(mdWQitem *);
00077 void run() {}
00078
00079 virtual void processEvent(const cdHeartbeat &ev);
00080 virtual void processEvent(const cdTelemetryFrame &ev);
00081 virtual void processEvent(const cdInteractiveCommand &ev);
00082 virtual void processEvent(const cdIncoming &ev);
00083 virtual void processEvent(const cdResponse &ev);
00084 virtual void processEvent(const cdShutdown &ev);
00085
00086 };
00087 #endif