DRDE/AusRegCliever/include/mdHost.h

84 lines
2.2 KiB
C
Raw Normal View History

2014-01-03 08:27:31 +00:00
#include <boost/asio.hpp>
/*! \brief mdHost
2014-01-03 08:27:31 +00:00
* General abstraction of all MD clients
*
* For historical reasons all clients are considered to be
* devices, though mdclient and US clients have a non-device
* client type. The central device of the system has zero
* device type.
*
*/
using namespace std;
using boost::asio::ip::udp;
template<class T>
class mdHost {
2014-01-03 08:27:31 +00:00
public:
bool isSingleton;
int clieverGroup, // masterDaemonConfig.thisMachineContext
handle,mdStdDevIdx;
md_device type;
udp::endpoint ip;
// Only Machine and Instrument use below
InstructionSet cmds;
2014-01-03 08:27:31 +00:00
// Some parameters initially here are now all uniformly ODEs
// defined in the COOL scripts.
~mdHost() {}
mdHost(md_device t) : type(t) {clieverGroup = handle = mdStdDevIdx = -1;}
2014-01-03 08:27:31 +00:00
T* registeR(md_device t);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
class mdClientServer;
class mdClientServer : public mdHost<mdClientServer> {
2014-01-03 08:27:31 +00:00
public:
mdClientServer() : mdHost<mdClientServer>( MDDEV_CD ) {};
2014-01-03 08:27:31 +00:00
mdClientServer *validateClient(int handle, mdResponse &r);
};
class mdMachine;
class mdMachine : public mdHost<mdMachine> {
2014-01-03 08:27:31 +00:00
public:
mdMachine() : mdHost<mdMachine>( MACHINE ) {}
2014-01-03 08:27:31 +00:00
mdMachine *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
2014-01-03 08:27:31 +00:00
class mdInstrument;
class mdInstrument : public mdHost<mdInstrument> {
2014-01-03 08:27:31 +00:00
public:
mdInstrument() : mdHost<mdInstrument>( MDDEV_PEER )
{
//rrj cmds["RST"] = new mdCommand(MD_SCPI,std::string("RST"));
cmds["RST"] = new mdCommand((md_mand)0,std::string("RST"));
}
2014-01-03 08:27:31 +00:00
mdInstrument *validateClient(int handle, const mdClientBirth &c, mdResponse &r);
void registerCmd(const char *cmdName,const mdIncoming &mdI);
};
class masterDaemon;
class mdHostFabrik : public mdHost<masterDaemon>
2014-01-03 08:27:31 +00:00
{public:
mdHostFabrik() : mdHost<masterDaemon>( MDDEV_MD ) {}
2014-01-03 08:27:31 +00:00
void newFromHeartbeat(const mdClientBirth &itsAWhat);
std::string newFromAPI(md_device type,std::string signature);
};