Changeset 14316
- Timestamp:
- 08/06/12 22:16:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/agilentctrl.cc
r14315 r14316 31 31 ofstream fDumpStream; 32 32 int fState; 33 float fMeasuredVoltage; 34 float fMeasuredCurrent; 33 35 34 36 … … 72 74 73 75 fCheckStatusTimer.expires_from_now(boost::posix_time::seconds(60)); 74 fCheckStatusTimer.async_wait(boost::bind(&Connection Weather::HandleRequest,76 fCheckStatusTimer.async_wait(boost::bind(&ConnectionAgilent::HandleRequest, 75 77 this, bapla::error)); 76 78 } … … 101 103 // may have moved the deadline before this actor had a chance 102 104 // to run. 103 if (f KeepAlive.expires_at() > ba::deadline_timer::traits_type::now())105 if (fCheckStatusTimer.expires_at() > ba::deadline_timer::traits_type::now()) 104 106 return; 105 107 … … 112 114 void ReceivedStatusHandler(const bs::error_code& err, size_t bytes_received, int /*type*/) 113 115 { 114 float measured_voltage;115 float measured_current;116 116 117 117 // Do not schedule a new read if the connection failed. … … 137 137 if (fIsVerbose) 138 138 Out() << kBold << "Received (" << bytes_received << " bytes):" << endl; 139 /* 139 140 if (fDump) 140 141 { … … 143 144 Dump(msg.str()); 144 145 } 145 146 */ 146 147 istream is(&fBuffer); 147 148 // data should contain two floats: … … 162 163 { 163 164 // this should be a float containing the measured voltage 164 is >> measured_voltage;165 data.push_back( measured_voltage);166 Out() << "voltage: " << measured_voltage << endl;165 is >> fMeasuredVoltage; 166 data.push_back(fMeasuredVoltage); 167 Out() << "voltage: " << fMeasuredVoltage << endl; 167 168 } 168 169 else if (fLineCounter >= 3) 169 170 { 170 171 // this should be a float containing the measured voltage 171 is >> measured_current;172 data.push_back( measured_current);173 Out() << "current: " << measured_current << endl;172 is >> fMeasuredCurrent; 173 data.push_back(fMeasuredCurrent); 174 Out() << "current: " << fMeasuredCurrent << endl; 174 175 fLineCounter = 0; 175 fSendRequest = true; 176 } 177 178 if (measured_voltage > 1.0) 176 } 177 178 // read the buffer empty ... 179 // FIXME: I surely misunderstand that damn fBuffer thing. 180 // I thought it should be emtpy by now... 181 string buffer; 182 while (getline(is,buffer, '\n')) 183 { 184 buffer = Tools::Trim(buffer); 185 if (buffer.empty()) continue; 186 } 187 188 189 if (fMeasuredVoltage > 1.0) 179 190 { 180 191 fState = State::kVoltage_On; … … 206 217 fState = State::kConnected; 207 218 Start_async_read_until(); 208 PostStatusRequest();219 RequestStatus(); 209 220 210 221 fLineCounter = 0; … … 216 227 ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 217 228 fIsVerbose(true), 218 f CheckStatusTimer(ioservice),219 f Dump(true)229 fDump(true), 230 fCheckStatusTimer(ioservice) 220 231 { 221 232 SetLogStream(&imp); 222 233 fState = State::kDisconnected; 234 fMeasuredVoltage=-1; 235 fMeasuredCurrent=-1; 223 236 } 224 237 … … 335 348 336 349 if ( fAgilent.IsConnected() ) 337 return f Weather.GetState();350 return fAgilent.GetState(); 338 351 else 339 352 return State::kDisconnected; … … 381 394 } 382 395 383 int Identify()384 {385 fAgilent.Identify();386 return T::GetCurrentState();387 }388 396 389 397 public: … … 437 445 ("set output on or off" 438 446 "|[state][boolean]: output setting (1;0 or 'on';'off')"); 439 440 T::AddEvent("IDENTIFY", State::kConnected)441 (bind(&StateMachineAgilent::Identify, this))442 ("Request Agilent ID");443 447 444 448 fAgilent.StartConnect();
Note:
See TracChangeset
for help on using the changeset viewer.