00001
00002 #include <boost/asio.hpp>
00003
00014 using namespace std;
00015 using boost::asio::ip::udp;
00016
00017 template<class T>
00018 class mdDevice {
00019 public:
00020
00021 bool isSingleton;
00022 int clieverGroup,
00023 handle,mdStdDevIdx;
00024 md_device type;
00025 mdState state;
00026
00027 udp::endpoint ip;
00028
00029
00030 InstructionSet cmds;
00031
00032
00033
00034
00035 ~mdDevice() {}
00036 mdDevice(md_device t) : type(t) {clieverGroup = handle = mdStdDevIdx = -1;}
00037
00038 void lxi_control(T* device,std::string scpiText);
00039 T* registeR(md_device t);
00040
00041 xmlrpc_c::value* fetchCommands(std::string subSystem);
00042 void registerCmd(const char *cmdName,const mdIncoming &mdI);
00043
00044 };
00045
00046 class mdClientServer;
00047 class mdClientServer : public mdDevice<mdClientServer> {
00048 public:
00049
00050 mdClientServer() : mdDevice<mdClientServer>( MDDEV_CD ) {};
00051 mdClientServer *validateClient(int handle, mdResponse &r);
00052 };
00053
00054 class mdMachine;
00055 class mdMachine : public mdDevice<mdMachine> {
00056 public:
00057
00058 mdMachine() : mdDevice<mdMachine>( MACHINE )
00059 { cmds["RST"] = new mdCommand(MD_SCPI,std::string("RST")); }
00060 mdMachine *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
00061 void registerCmd(const char *cmdName,const mdIncoming &mdI);
00062 };
00063
00064 class mdInstrument;
00065 class mdInstrument : public mdDevice<mdInstrument> {
00066 public:
00067
00068 mdInstrument() : mdDevice<mdInstrument>( MDDEV_INSTRUMENT )
00069 { cmds["RST"] = new mdCommand(MD_SCPI,std::string("RST")); }
00070 mdInstrument *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
00071 void registerCmd(const char *cmdName,const mdIncoming &mdI);
00072 };
00073
00074 class mdDataClient;
00075 class mdDataClient : public mdDevice<mdDataClient> {
00076 public:
00077
00078 mdDataClient() : mdDevice<mdDataClient>( MDDEV_DATACLIENT ) {};
00079 mdDataClient *validateClient(int handle);
00080 };
00081
00082 class masterDaemon;
00083 class mdDeviceFabrik : public mdDevice<masterDaemon>
00084 {public:
00085
00086 mdDeviceFabrik() : mdDevice<masterDaemon>( MDDEV_MD ) {}
00087 void newFromHeartbeat(const mdClientBirth &itsAWhat);
00088 std::string newFromAPI(md_device type,std::string signature);
00089
00090 };