00001 #ifndef DEVICE_CORE
00002 #define DEVICE_CORE
00003
00004 using boost::asio::ip::udp;
00008 class mdEmbeddedTransaction : public mdProcess {void run() {};};
00012 void hbCallback(const boost::system::error_code& error);
00013 class mdDVHeartbeat : public mdEmbeddedTransaction {
00014
00015 boost::asio::deadline_timer *t0;
00016
00017 public:
00018
00019 mdDVHeartbeat() {}
00020
00021 void init() {
00022 t0 = new boost::asio::deadline_timer(io_, boost::posix_time::seconds(10));
00023 }
00024 void dispatch(mdWQitem*) {}
00025 void nextBeat(const boost::system::error_code& error);
00026 void run();
00027
00028 };
00034 class dvTransaction : public mdProcess {void run()=0;};
00035
00041 class mdEmbedded: public dvTransaction,
00042 public Listener<dvHeartbeat>,
00043 public Listener<dvTelemetryFrame>,
00044 public Listener<dvIncoming>,
00045 public Listener<dvQueryMD>,
00046 public Listener<dvResponse>,
00047 public Listener<dvShutdown>
00048 {
00049 public:
00050
00051 bool alive,connected,shuttingDown,shutDown;
00052 int mdStdDevIdx,myHandle, rc, sentBeats;
00053
00054 dvHeartbeat myPulse;
00055 deviceDaemonConfig *cfg;
00056 mdDVHeartbeat *pulse;
00057 mdDGChannel *md,*cd;
00058
00059
00060 mdEmbedded() {this->create();}
00061 mdEmbedded(deviceDaemonConfig *cmdCfg)
00062 { this->cfg = cmdCfg;
00063 this->create();
00064 }
00065
00066
00067 void additionalSystemMsgs();
00068 void dispatch(mdWQitem *);
00069 void create() {
00070 alive = connected = false;
00071 rc = OK;
00072 pulse = NULL;
00073 sentBeats = 0;
00074 shuttingDown = shutDown = false;
00075 myHandle = 0;
00076 mdStdDevIdx = MAX_CLIENTS+1;
00077 }
00078 void run();
00079
00080 virtual void processEvent(const dvHeartbeat &ev);
00081 virtual void processEvent(const dvIncoming &ev);
00082 virtual void processEvent(const dvQueryMD &ev);
00083 virtual void processEvent(const dvResponse &ev);
00084 virtual void processEvent(const dvShutdown &ev);
00085 virtual void processEvent(const dvTelemetryFrame &ev);
00086
00087 };
00088 #endif