00001
00008 class registerDevice : public xmlrpc_c::method {
00009 private:
00010 masterDaemonConfig *_cfg;
00011 public:
00012 registerDevice(masterDaemonConfig *cfg) {
00013 _cfg = cfg;
00014 _signature = "i:is";
00015 _help = "Register a client with the auc-md. The first parameter is the client type "
00016 "which should be the integer value of MDDEV_DATACLIENT (currently 4) "
00017 "or other md_dev type value. The string, specifies a signature identifying "
00018 "client. Normally the first call to the MD after connecting, the response "
00019 "if positive definite is a handle to use in further interaction referring "
00020 "to the registered client. This API is primarily intended for data integrators not "
00021 "device integrators but device integrators can also use if for diagnostic "
00022 "purposes. Execute this API with signature 'release' to remove a MD client "
00023 "in which case the first parameter should be the handle for the client to drop. "
00024 "Obviously this API can cause havoc with a production MD, so use with care.";
00025 }
00026 void
00027 execute(xmlrpc_c::paramList const& paramList,
00028 xmlrpc_c::value * const retvalP) {
00029
00030 int const handleOrType(paramList.getInt(0));
00031 std::string stringField(paramList.getString(1));
00032
00033 paramList.verifyEnd(2);
00034
00035 if (stringField == "release")
00036 *retvalP = xmlrpc_c::value_int(thisService->releaseDevice(handleOrType));
00037 else
00038 *retvalP = xmlrpc_c::value_int(thisService->getDeviceHandle(handleOrType,stringField));
00039
00040 }
00041
00042 };
00048 class getter : public xmlrpc_c::method, mdState {
00049 public:
00050 getter() {
00051 _signature = "S:is";
00052 _help = "Send handle, dataname, get structure answer. The the first "
00053 "character of the dataname determines its type: ODEs "
00054 "(Operational Data Elements) start with an underscore, otherwise "
00055 "the dataname is that of an expermental Observable. The first "
00056 "entry in the structure is always the state of the call which "
00057 "will either the supplied dataname indicating success or error text. "
00058 "The remainder of the structure is specific to the datatype.";
00059 }
00060
00061 void
00062 execute(xmlrpc_c::paramList const& paramList,
00063 xmlrpc_c::value * const retvalP) {
00064
00065 int const deviceHandle(paramList.getInt(0));
00066 std::string dataName(paramList.getString(1));
00067 paramList.verifyEnd(2);
00068
00069 *retvalP = *mdState::get(deviceHandle,dataName);
00070 }
00071
00072 };
00078 class setter : public xmlrpc_c::method, mdState {
00079 public:
00080 setter() {
00081
00082 _signature = "s:iS";
00083 _help = "Process a gotten structure with changes. "
00084 "Answers 'OK' or error text";
00085 }
00086
00087 void
00088 execute(xmlrpc_c::paramList const& paramList,
00089 xmlrpc_c::value * const retvalP) {
00090
00091 int const deviceHandle(paramList.getInt(0));
00092 xmlrpc_c::cstruct returnee(paramList.getStruct(1));
00093 paramList.verifyEnd(2);
00094
00095 *retvalP = xmlrpc_c::value_string(mdState::set(deviceHandle,returnee));
00096 }
00097 };
00103 class create : public xmlrpc_c::method, mdState {
00104 public:
00105 create() {
00106
00107 _signature = "s:iss";
00108 _help = "Given a device handle, focus type, and dataname create the element. "
00109 "The type string uses the standard xmplrpc-c single character "
00110 "type signatures and the name is an MD dataname whose first character "
00111 "determines whether an Observable or and ODEe. Any text "
00112 "following the type signature is preserved as a comment. "
00113 "Answers 'OK' or error text";
00114 }
00115
00116 void
00117 execute(xmlrpc_c::paramList const& paramList,
00118 xmlrpc_c::value * const retvalP) {
00119
00120 int const deviceHandle(paramList.getInt(0));
00121 std::string typeSpec(paramList.getString(1));
00122 std::string newName(paramList.getString(2));
00123 paramList.verifyEnd(3);
00124
00125 *retvalP = xmlrpc_c::value_string(mdState::create(deviceHandle,typeSpec,newName));
00126 }
00127
00128 };
00136 class cmdListFetch : public xmlrpc_c::method, mdCommand {
00137 public:
00138 cmdListFetch() {
00139
00140 _signature = "A:is";
00141 _help = "Send handle, md_dev type, and the SCPI subsystem or subcommand. "
00142 "Use empty string to get the full subsystem list. Reply will be "
00143 "an array of the available command/subsystems. Only MD clients "
00144 "of type MACHINE or MDDEV_INSTRUMENT can have SCPI commands defined "
00145 "so it is an error to specify any other type of MD client";
00146 }
00147
00148 void
00149 execute(xmlrpc_c::paramList const& paramList,
00150 xmlrpc_c::value * const retvalP) {
00151
00152 int const deviceHandle(paramList.getInt(0));
00153 int const deviceType(paramList.getInt(0));
00154 std::string commandSetSpecified(paramList.getString(2));
00155 paramList.verifyEnd(3);
00156
00157 if (deviceType != MACHINE && deviceType != MDDEV_INSTRUMENT)
00158 *retvalP = xmlrpc_c::value_string(std::string("Invalid MD client type."));
00159 else
00160 {if (thisService->validateHandleForCmds(deviceHandle))
00161 *retvalP = *thisService->fetchCommands(commandSetSpecified);
00162 else *retvalP = xmlrpc_c::value_string(std::string("Error: Device not in state where this API can execute."));
00163
00164 }
00165 }
00166 };
00172 class cmd : public xmlrpc_c::method, mdCommand {
00173 public:
00174 cmd() {
00175
00176 _signature = "s:iS";
00177 _help = "Given, a handle, device type, the full text of a SCPI "
00178 "sends the command to the MD and if accepted to the device. "
00179 "If the command is valid for the configured MD, MD answers OK "
00180 "and sends it, otherwise answers error text. Whether "
00181 "or not the OK indicates anything other than a valid command "
00182 "depends on the configured behavior of the device.";
00183 }
00184
00185 std::string head(std::string in) { return in; }
00186 std::string tail(std::string in) { return in; }
00187 void
00188 execute(xmlrpc_c::paramList const& paramList,
00189 xmlrpc_c::value * const retvalP) {
00190
00191 mdCommand *thisCommand;
00192 mdCommand local;
00193
00194 int deviceHandle(paramList.getInt(0));
00195 std::string commandText(paramList.getString(1));
00196 paramList.verifyEnd(2);
00197 std::string tails=tail(commandText);
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 }
00210 };
00211
00218 class getMDversion : public xmlrpc_c::method {
00219 public:
00220 getMDversion() {
00221
00222 _signature = "i:s";
00223 _help = "Accepts a device handle and returns the version identification "
00224 "of the MD. ";
00225
00226 }
00227
00228 void
00229 execute(xmlrpc_c::paramList const& paramList,
00230 xmlrpc_c::value * const retvalP) {
00231
00232 int const addend(paramList.getInt(0));
00233
00234 paramList.verifyEnd(1);
00235 *retvalP = xmlrpc_c::value_string("OpenAUC v 0.5");
00236 }
00237
00238 };
00239