Main Page | Namespace List | Class Hierarchy | Data Structures | File List | Data Fields | Globals | Related Pages

acq2xx_common.cpp

Go to the documentation of this file.
00001 #include "soapH.h"
00002 
00003 using namespace std;
00004 #include <iostream>
00005 #include <vector>
00006 
00007 #include "local.h"
00008 #include <stdio.h>
00009 #include <string.h>
00010 
00011 
00012 acq2xx__Object::acq2xx__Object()
00013 { 
00014         name = "Object";
00015 }
00016 
00017 acq2xx__Object::acq2xx__Object(const char *name)
00018 { 
00019         this->name = (char*)name;
00020 }
00021 
00022 acq2xx__Object::~acq2xx__Object()
00023 {
00024 }
00025 
00026 void acq2xx__Object::print()
00027 { 
00028         cout << "acq2xx:Object: " << (name?name:"") << endl;
00029 }
00030 
00031 const char* acq2xx__Object::getName() 
00032 {
00033         return name;
00034 }
00035 
00036 acq2xx__Transaction::acq2xx__Transaction() : 
00037         acq2xx__Object("Transaction"),
00038         abort_on_error(1),
00039         status(0),
00040         complete(0)
00041 {
00042 
00043 }
00044 
00045 
00046 acq2xx__Transaction::acq2xx__Transaction(const char* name) :
00047         acq2xx__Object(name),
00048         abort_on_error(1),
00049         status(0),
00050         complete(0)
00051 {
00052 
00053 }
00054 
00055 acq2xx__Transaction::~acq2xx__Transaction()
00056 {
00057 
00058 }
00059 
00060 void acq2xx__Transaction::print() 
00061 {
00062         acq2xx__Object::print();
00063         cout << "Transaction:" << 
00064                 " abort_on_error:" << abort_on_error <<
00065                 " status:" << status <<
00066                 " complete:" << complete << endl;
00067 }
00068 
00069 
00070 const char* acq2xx__Transaction::getCommand()
00071 {
00072         return getName();
00073 }
00074 
00075 const char* acq2xx__Transaction::getResult() 
00076 {
00077         if (complete){
00078                 return status == 0? "OK": "ERR";
00079         }else{
00080                 return "NOT COMPLETE";
00081         }
00082 }
00083 acq2xx__TransactionList::acq2xx__TransactionList() :
00084         acq2xx__Transaction("TransactionList")
00085 { 
00086         __ptr = 0;
00087         __size = 0;
00088 }
00089 
00090 acq2xx__TransactionList::acq2xx__TransactionList(int size) :
00091         acq2xx__Transaction("TransactionList")
00092 { 
00093         __ptr = (acq2xx__Transaction**)malloc(
00094                         size*sizeof(acq2xx__Transaction*));
00095          __size = size;
00096 }
00097 
00098 acq2xx__TransactionList::~acq2xx__TransactionList()
00099 {
00100 }
00101 
00102 acq2xx__Transaction*& acq2xx__TransactionList::operator[](int i)
00103 {
00104         return __ptr[i];
00105 }
00106 
00107 
00108 int acq2xx__TransactionList::getSize()
00109 {
00110         return __size;
00111 }
00112 
00113 void acq2xx__TransactionList::print()
00114 {
00115         cout << "List: "; acq2xx__Transaction::print();
00116         cout << "[" << endl;
00117         for (int i = 0; i < __size; i++){
00118                 __ptr[i]->print();
00119         }
00120         cout << "]" << endl;
00121 }
00122 
00123 acq2xx__ShellTransaction::acq2xx__ShellTransaction() : command(0), result(0)
00124 {
00125 }
00126 
00127 acq2xx__ShellTransaction::acq2xx__ShellTransaction(char* _command)  : result(0)
00128 {
00129         command = (char*)malloc(strlen(_command)+1);
00130         strcpy(command, _command);
00131 }
00132 
00133 acq2xx__ShellTransaction::~acq2xx__ShellTransaction()
00134 {
00135 /** @todo why was this dodgy?   
00136         if (command != 0) delete [] command;
00137 */
00138 }
00139 
00140 void acq2xx__ShellTransaction::initCommand(char command_buffer[])
00141 {
00142         assert(command == 0);
00143         command = (char*)malloc(strlen(command_buffer)+1);
00144 
00145         strcpy(command, command_buffer);        
00146 }
00147 
00148 
00149 void acq2xx__ShellTransaction::print()
00150 {
00151         cout << "acq2xx__ShellTransaction" << endl;
00152         acq2xx__Transaction::print();
00153         cout << "command: " << getCommand() << endl;
00154         if (complete){
00155                 cout << "respond: " << getResult() << endl;
00156         }
00157 }
00158 
00159 const char* acq2xx__ShellTransaction::getCommand()
00160 {
00161         return command == 0? "null": command;
00162 }
00163 const char* acq2xx__ShellTransaction::getResult()
00164 {
00165         return result == 0? "null": result;
00166 }
00167 
00168 
00169 /** functional API here */
00170 
00171 
00172 acq2xx__GetAvailableChannelsTransaction::
00173 	acq2xx__GetAvailableChannelsTransaction() :
00174         acq2xx__ShellTransaction("acqcmd getAvailableChannels"),
00175         AI(0), AO(0)
00176 {}
00177 
00178 
00179 acq2xx__GetVRangeTransaction::acq2xx__GetVRangeTransaction() :
00180         acq2xx__ShellTransaction("get.vin"),
00181         channels(0)
00182 {
00183         ranges.__ptr = 0;
00184         ranges.__size = 0;
00185 }
00186 
00187 
00188 static VRange dummy = { -100.0f, 100.0f };
00189 
00190 const struct VRange& 
00191 acq2xx__GetVRangeTransaction::getVRange(int channel) const
00192 {
00193         int ix = channel - 1;
00194         if (ix >= 0 && ix <= channels->AI){
00195                 return ranges.__ptr[ix];
00196         }
00197 
00198         return dummy;
00199 }
00200 
00201 void acq2xx__ModeSetTransaction::print()
00202 {
00203         acq2xx__ShellTransaction::print();
00204         cout << "Mode Set:" << mode << " pre:" << prelen << 
00205                 " post:" << postlen << endl;
00206 }
00207 
00208 
00209 acq2xx__ModeSetTransaction::acq2xx__ModeSetTransaction() :
00210         mode(MODE_SOFT_TRANSIENT), prelen(0), postlen(0)
00211 {
00212 
00213 }

Generated on Mon Aug 21 12:39:57 2006 for ACQ2XXWebServices by  doxygen 1.4.4