00001 #ifndef MASTER_DAEMON
00002 #define MASTER_DAEMON
00003
00004 #include <msgpack.hpp>
00005
00012 #ifdef MD_CORE
00013
00014 class masterDaemon *thisService;
00015
00016 #else
00017
00018 extern class masterDaemon *thisService;
00019
00020 #endif
00021
00022 using boost::asio::ip::udp;
00023
00024
00025 class masterDaemon : public mdProcess,
00026 public Listener<mdAttention>,
00027 public Listener<mdCDPulse>,
00028 public Listener<mdClientBirth>,
00029 public Listener<mdClientDeath>,
00030 public Listener<mdIncoming>,
00031 public Listener<mdResponse>,
00032 public Listener<mdTelemetryFrame>,
00033 public Listener<mdDeviceCommand> {
00034 public:
00035
00036 bool shuttingDown;
00037
00038 boost::asio::io_service io_;
00039
00040 int arCycles,
00041 dataClients[MAX_DATACLIENTS],
00042 instruments[MAX_INSTRUMENTS],
00043 nClievers,
00044 sentCommands;
00045
00046 masterDaemonConfig *cfg;
00047 mdDGChannel *bg,*fg;
00048
00049 std::string clievers[MAX_CLIEVER];
00050
00051 masterDaemon();
00052 ~masterDaemon() {}
00053
00054 masterDaemon(masterDaemonConfig *cmdCfg) { int i;
00055 thisService = this;
00056 cfg = cmdCfg;
00057 nClievers = 0;
00058 shuttingDown = false;
00059 memset(dataClients,0,sizeof(dataClients));
00060 memset(instruments,0,sizeof(instruments));
00061 }
00062
00063 int getDeviceHandle(int deviceMajor,std::string &deviceMinor) {};
00064 int initBaseAPI(void);
00065 int initDataLayer(void);
00066 int releaseDevice(int handle) {return( -1);}
00067 int validateHandleForCmds(int handle) {return(-1);}
00068 void dispatch(mdWQitem*);
00069 void dispatch(const mdIncoming&);
00070 void listen();
00071 xmlrpc_c::value* fetchCommands(std::string subSystem) {};
00072
00073 virtual void processEvent(const mdAttention &ev);
00074 virtual void processEvent(const mdCDPulse &ev);
00075 virtual void processEvent(const mdClientBirth &ev);
00076 virtual void processEvent(const mdClientDeath &ev);
00077 virtual void processEvent(const mdIncoming &ev);
00078 virtual void processEvent(const mdResponse &ev);
00079 virtual void processEvent(const mdTelemetryFrame &ev);
00080 virtual void processEvent(const mdDeviceCommand &ev);
00081
00082 void run();
00083
00084 };
00085
00086 #endif