00001 #ifdef INCLMD
00002 #include "auc-md.h"
00003 #endif
00004 #ifdef INCLDV
00005 #include "md_device.h"
00006 #endif
00007
00008 using namespace std;
00009 #ifndef INCLDV
00010 std::string mdObservable::create(int deviceHandle,std::string &typeSig,std::string &dataName) {
00011
00012 std::string rc("OK");
00013
00014 if (thisConfig->allClients[deviceHandle]->devType == MDDEV_INSTRUMENT) {
00015
00016 if ( thisConfig->instruments[deviceHandle]->state.observables.find(dataName) !=
00017 thisConfig->instruments[deviceHandle]->state.observables.end() ) { rc = string("Dataname already defined."); }
00018
00019 } else if (thisConfig->allClients[deviceHandle]->devType == MACHINE) {
00020
00021 if ( theMachine->state.observables.find(dataName) !=
00022 theMachine->state.observables.end() ) { rc = string("Dataname already defined."); }
00023
00024 }
00025
00026 if (rc == "OK")
00027 theseLogs->logNdebug(MAX_DEBUG/100,2,"New Observable: '%s' defined by device: %d.",dataName.c_str(),deviceHandle);
00028 else
00029 theseLogs->logNdebug(10,2,"Failed New Observable: '%s' attempt by device: %d: %s.",dataName.c_str(),deviceHandle,rc.c_str());
00030
00031 return rc;
00032 }
00033 void mdObservable::source(mdResponse *mdr) {
00034
00035 int sValSize;
00036 mdObsPOD *flat = (mdObsPOD *)(&mdr->reply.dg.payLoad[0]);
00037
00038 memcpy(flat,&this->obs,sizeof(mdObsPOD));
00039 strcpy(&flat->sVal,this->sValue.c_str());
00040 sValSize = this->sValue.length();
00041 flat->sValSize = sValSize + 1;
00042
00043 mdr->reply.dg.hdr.primeOffset = mdr->reply.dg.hdr.payloadSize = sizeof(mdObsPOD) + sValSize;
00044
00045 }
00046 #endif
00047 mdObservable::mdObservable() {
00048 _shared = false;
00049 obs = new mdObsPOD;
00050 obs->isPrivate = true;
00051 obs->focusType = 's';
00052 sValue = std::string("");
00053 obs->units = MD_UNITS_UNDEFINED;
00054 obs->hasBounds = false;
00055 obs->hasSource = false;
00056 obs->realtime = true;
00057 obs->outOfLimits = false;
00058 obs->rValue = 0.0;
00059 obs->rValueTarget = 0.0;
00060 obs->rValueLow = 0.0;
00061 obs->rValueHigh = 0.0;
00062 }
00063 mdObservable::mdObservable(mdObsPOD *sharedMem) {
00064 _shared = true;
00065 obs = sharedMem;
00066 sValue = std::string("");
00067 }
00068 unsigned short mdObservable::pack(char *frameData) {
00069
00070 int value = 0;
00071
00072 return value;
00073
00074 }
00075 void mdObservable::unpack(char **frameData) {
00076
00077
00078 }
00079 #ifndef INCLDV
00080 std::string mdObservable::setWith(xmlrpc_c::cstruct incoming) {
00081
00082 std::string rc("OK");
00083
00084 sValue = std::string(xmlrpc_c::value_string(incoming["sValue"]));
00085
00086 return rc;
00087
00088 }
00089 xmlrpc_c::value *mdObservable::shipIt(xmlrpc_c::cstruct outbound,std::string name)
00090 {
00091
00092 std::string focusTyp = std::string(" ");
00093 focusTyp.at(0) = obs->focusType;
00094
00095 outbound["dataname"] = xmlrpc_c::value_string(name);
00096 outbound["sValue"] = xmlrpc_c::value_string(sValue);
00097 outbound["intValue"] = xmlrpc_c::value_int(obs->intValue);
00098 outbound["intValueHigh"] = xmlrpc_c::value_int(obs->intValueHigh);
00099 outbound["intValueLow"] = xmlrpc_c::value_int(obs->intValueLow);
00100 outbound["intValueTarget"] = xmlrpc_c::value_int(obs->intValueTarget);
00101 outbound["rValue"] = xmlrpc_c::value_double(obs->rValue);
00102 outbound["rValueLow"] = xmlrpc_c::value_double(obs->rValueLow);
00103 outbound["rValueHigh"] = xmlrpc_c::value_double(obs->rValueHigh);
00104 outbound["units"] = xmlrpc_c::value_int((int)obs->units);
00105 outbound["focusType"] = xmlrpc_c::value_string(focusTyp);
00106 outbound["isPrivate"] = xmlrpc_c::value_boolean(obs->isPrivate);
00107 outbound["hasBounds"] = xmlrpc_c::value_boolean(obs->hasBounds);
00108 outbound["outOfLimits"] = xmlrpc_c::value_boolean(obs->outOfLimits);
00109
00110 return new xmlrpc_c::value_struct(outbound);
00111
00112 }
00113 #endif