Changeset 14314
- Timestamp:
- 08/06/12 11:57:06 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/agilentctrl.cc
r14313 r14314 31 31 bool fDump; 32 32 33 int fLineCounter; 34 35 33 36 ofstream fDumpStream; 34 37 … … 38 41 { 39 42 } 40 41 43 42 44 void Dump(const string &str) … … 93 95 } 94 96 95 96 97 istream is(&fBuffer); 97 98 // data should contain two floats: 99 // * measured output voltage in volts 100 // * measured ouput current in amperes 101 vector<float> data; 102 103 fLineCounter++; 104 105 if (fLineCounter == 1) 106 { 107 // this is the Agilent identity string, do nothing 108 string s; 109 is >> s; 110 Out() << "ID string: " << s << endl; 111 } 112 else if (fLineCounter == 2) 113 { 114 // this should be a float containing the measured voltage 115 float f; 116 is >> f; 117 data.push_back(f); 118 Out() << "voltage: " << f << endl; 119 } 120 else if (fLineCounter >= 3) 121 { 122 // this should be a float containing the measured voltage 123 float f; 124 is >> f; 125 data.push_back(f); 126 Out() << "current: " << f << endl; 127 fLineCounter = 0; 128 fSendRequest = true; 129 } 130 131 132 // int status=-1; 98 133 99 134 string buffer; … … 124 159 } 125 160 126 // vector data should have to elements: 127 // * the measured voltage 128 // * the measured current 129 vector<float> data; 161 130 162 UpdateDim(data); 131 163 … … 145 177 void ConnectionEstablished() 146 178 { 147 fBuffer.prepare(10000); 179 fLineCounter = 0; 180 fSendRequest = true; 181 fBuffer.prepare(1000); 182 fTime = Time(); 148 183 StartRead(); 149 184 } 150 185 151 186 public: 187 Time fTime; 188 bool fSendRequest; 189 152 190 ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 153 191 fIsVerbose(true), … … 171 209 if (b) 172 210 { 173 PostMessage( "outp on\n");211 PostMessage(string("outp on\n")); 174 212 } 175 213 else 176 214 { 177 PostMessage( "outp off\n");215 PostMessage(string("outp off\n")); 178 216 } 179 217 } … … 181 219 void Identify() 182 220 { 183 PostMessage( "*IDN?\n",6);184 PostMessage( "meas:volt?\n",11);185 PostMessage( "meas:curr?\n",11);221 PostMessage(string("*IDN?\n")); 222 PostMessage(string("meas:volt?\n")); 223 PostMessage(string("meas:curr?\n")); 186 224 } 187 225 }; … … 212 250 ConnectionAgilent(ioservice, imp), 213 251 fDim("AGILENT_CONTROL/DATA", "F:1;F:1", 214 "|U[V]: FACT supplyvoltage"215 "|I[A]: current consumed by the FACT camera")252 "|U[V]: output voltage" 253 "|I[A]: output current") 216 254 { 217 255 // nothing happens here. … … 267 305 // synchronously, i.e. within the call to poll_one() 268 306 poll_one(); 269 307 if (fAgilent.fSendRequest) 308 { 309 if (Time()-fAgilent.fTime > boost::posix_time::seconds(5)) 310 { 311 fAgilent.Identify(); 312 fAgilent.fTime = Time(); 313 fAgilent.fSendRequest = false; 314 } 315 } 270 316 return fAgilent.IsConnected() ? State::kConnected : State::kDisconnected; 271 317 } … … 358 404 "|[host][string]:new ethernet address in the form <host:port>"); 359 405 360 T::AddEvent("OUTPUT", "B:1" )406 T::AddEvent("OUTPUT", "B:1", State::kConnected) 361 407 (bind(&StateMachineAgilent::SetOutput, this, placeholders::_1)) 362 408 ("set output on or off" 363 409 "|[state][boolean]: output setting (1;0 or 'on';'off')"); 364 410 365 T::AddEvent("IDENTIFY" )411 T::AddEvent("IDENTIFY", State::kConnected) 366 412 (bind(&StateMachineAgilent::Identify, this)) 367 413 ("Request Agilent ID");
Note:
See TracChangeset
for help on using the changeset viewer.