Changeset 14324 for trunk/FACT++/src
- Timestamp:
- 08/07/12 22:22:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/agilentctrl.cc
r14317 r14324 60 60 61 61 boost::asio::deadline_timer fCheckStatusTimer; 62 boost::asio::deadline_timer fAntiFloddingTimer; 62 63 63 64 void PostStatusRequest() … … 111 112 112 113 int fLineCounter; 114 115 void Start_async_read_until() 116 { 117 // Bind Received Data Handler to the event: "received <enter> character" 118 // this Handler will try to parse the incoming data 119 ba::async_read_until(*this, fBuffer, "\n", 120 boost::bind(&ConnectionAgilent::ReceivedStatusHandler, this, 121 bapla::error, bapla::bytes_transferred, 0)); 122 123 // FIXME: Add timeout here 124 } 113 125 114 126 void ReceivedStatusHandler(const bs::error_code& err, size_t bytes_received, int /*type*/) … … 136 148 137 149 if (fIsVerbose) 150 { 138 151 Out() << kBold << "Received (" << bytes_received << " bytes):" << endl; 152 } 153 // FIXME: the piece of code below causes a Seg Fault in case 154 // The Agilent is not listening during program start, then after a while is 155 // listening and after connection established. 156 // It sends: 1.) a string and 2.) and empty line (just an <Enter> pressed) 157 // 158 // then the agilent_ctrl segfaults ... was able to reproduce it. 159 // gdp just gave me the hint, that Time().GetAdStr() caused the Seg Fault in a way... 160 // Is Time threadsafe? 139 161 /* 140 162 if (fDump) … … 144 166 Dump(msg.str()); 145 167 } 146 */ 168 */ 169 170 147 171 istream is(&fBuffer); 148 // data should contain two floats:149 // * measured output voltage in volts150 // * measured ouput current in amperes151 vector<float> data;152 153 172 fLineCounter++; 154 173 … … 157 176 // this is the Agilent identity string, do nothing 158 177 string s; 159 is >> s;178 getline(s,buffer, '\n'); 160 179 Out() << "ID string: " << s << endl; 161 180 } … … 164 183 // this should be a float containing the measured voltage 165 184 is >> fMeasuredVoltage; 166 data.push_back(fMeasuredVoltage);167 185 Out() << "voltage: " << fMeasuredVoltage << endl; 168 186 } … … 171 189 // this should be a float containing the measured voltage 172 190 is >> fMeasuredCurrent; 173 data.push_back(fMeasuredCurrent);174 191 Out() << "current: " << fMeasuredCurrent << endl; 175 192 fLineCounter = 0; 193 194 // data should contain two floats: 195 // * measured output voltage in volts 196 // * measured ouput current in amperes 197 vector<float> data(2); 198 data[0] = fMeasuredVoltage; 199 data[1] = fMeasuredCurrent; 200 UpdateDim(data); 176 201 } 177 202 … … 195 220 fState = State::kVoltage_Off; 196 221 } 197 198 UpdateDim(data);199 200 222 Start_async_read_until(); 201 223 } 202 224 203 void Start_async_read_until()204 {205 // Bind Received Data Handler to the event: "received <enter> character"206 // this Handler will try to parse the incoming data207 ba::async_read_until(*this, fBuffer, "\n",208 boost::bind(&ConnectionAgilent::ReceivedStatusHandler, this,209 bapla::error, bapla::bytes_transferred, 0));210 211 // FIXME: Add timeout here212 }213 225 214 226 // This is called when a connection was established 215 227 void ConnectionEstablished() 216 228 { 229 // DN 07.08.2012: The next line is imho not needed. 230 // But I'm in a train and cannot test it. 217 231 fState = State::kConnected; 218 232 Start_async_read_until(); … … 228 242 fIsVerbose(true), 229 243 fDump(true), 230 fCheckStatusTimer(ioservice) 244 fCheckStatusTimer(ioservice), 245 fAntiFloddingTimer(ioservice) 231 246 { 232 247 SetLogStream(&imp); … … 250 265 if (b) 251 266 { 252 PostMessage(string("outp on\n")); 267 // check if the previous 'outp off' is some time ago 268 if (fAntiFloddingTimer.expires_at() > ba::deadline_timer::traits_type::now()) 269 { 270 PostMessage(string("outp on\n")); 271 } 253 272 } 254 273 else 255 274 { 256 275 PostMessage(string("outp off\n")); 257 } 258 RequestStatus(); 276 // start a Timer, which runs out in 60sec making sure, that the 277 // camera can't be switched off&on on short time scales. 278 // sending repetetive outp off is possible 279 // sending repetivitve outp on is also posible 280 // switching off immediately after switching on is also possible. 281 fAntiFloddingTimer.expires_from_now(boost::posix_time::seconds(60)); 282 } 283 RequestStatus(); 259 284 } 260 285 261 286 int GetState() const 262 287 { 288 // fState is set in ReceivedStatusHandler 263 289 return fState; 264 290 } … … 500 526 { 501 527 cout << 502 "The ftmctrl controls the FSC (FACT Slow Control) board.\n" 528 "The agilentctrl controls the FACT camera power supply.\n" 529 "The powersupply is made by Agilent, so we call it 'The Agilent'. \n" 530 "Since FACT uses three Agilent Power Supplies with different output voltages\n" 531 "one might still not now which one ist controlled by this Program, so:\n" 503 532 "\n" 504 "The default is that the program is started without user intercation. " 533 "This program controls the 48V Agilent." 534 "\n" 535 "The default is that the program is started with user intercation. " 505 536 "All actions are supposed to arrive as DimCommands. Using the -c " 506 537 "option, a local shell can be initialized. With h or help a short " 507 538 "help message about the usuage can be brought to the screen.\n" 508 539 "\n" 509 "Usage: fscctrl [-c type] [OPTIONS]\n"510 " or: fscctrl [OPTIONS]\n";540 "Usage: agilentctrl [-c type] [OPTIONS]\n" 541 " or: agilentctrl [OPTIONS]\n"; 511 542 cout << endl; 512 543 } … … 515 546 { 516 547 Main::PrintHelp<StateMachineAgilent<StateMachine, ConnectionAgilent>>(); 517 518 /* Additional help text which is printed after the configuration519 options goes here */520 521 /*522 cout << "bla bla bla" << endl << endl;523 cout << endl;524 cout << "Environment:" << endl;525 cout << "environment" << endl;526 cout << endl;527 cout << "Examples:" << endl;528 cout << "test exam" << endl;529 cout << endl;530 cout << "Files:" << endl;531 cout << "files" << endl;532 cout << endl;533 */534 548 } 535 549
Note:
See TracChangeset
for help on using the changeset viewer.