Changeset 16727 for trunk/FACT++/src
- Timestamp:
- 06/05/13 20:36:57 (11 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/agilentctrl.cc
r14537 r16727 4 4 #include "Event.h" 5 5 #include "StateMachineDim.h" 6 #include "StateMachineAsio.h" 6 7 #include "Connection.h" 7 8 #include "LocalControl.h" … … 315 316 316 317 template <class T, class S> 317 class StateMachineAgilent : public T, public ba::io_service, public ba::io_service::work318 class StateMachineAgilent : public StateMachineAsio<T> 318 319 { 319 320 private: … … 341 342 // Now wait until all connection have been closed and 342 343 // all pending handlers have been processed 343 poll();344 ba::io_service::poll(); 344 345 345 346 if (evt.GetBool()) … … 354 355 int Execute() 355 356 { 356 // Dispatch (execute) at most one handler from the queue. In contrary357 // to run_one(), it doesn't wait until a handler is available358 // which can be dispatched, so poll_one() might return with 0359 // handlers dispatched. The handlers are always dispatched/executed360 // synchronously, i.e. within the call to poll_one()361 poll_one();362 363 if (!fAgilent.IsConnected())364 return State::kDisconnected;365 366 357 return fAgilent.GetState(); 367 358 } … … 427 418 public: 428 419 StateMachineAgilent(ostream &out=cout) : 429 T(out, "AGILENT_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 430 fAgilent(*this, *this) 431 { 432 // ba::io_service::work is a kind of keep_alive for the loop. 433 // It prevents the io_service to go to stopped state, which 434 // would prevent any consecutive calls to run() 435 // or poll() to do nothing. reset() could also revoke to the 436 // previous state but this might introduce some overhead of 437 // deletion and creation of threads and more. 438 420 StateMachineAsio<T>(out, "AGILENT_CONTROL"), fAgilent(*this, *this) 421 { 439 422 // State names 440 423 T::AddStateName(State::kDisconnected, "Disconnected", -
trunk/FACT++/src/lidctrl.cc
r15122 r16727 1 #include <boost/bind.hpp>2 1 #include <boost/array.hpp> 3 2 … … 12 11 #include "Event.h" 13 12 #include "StateMachineDim.h" 13 #include "StateMachineAsio.h" 14 14 #include "Connection.h" 15 15 #include "LocalControl.h" … … 460 460 461 461 template <class T, class S> 462 class StateMachineLidControl : public T, public ba::io_service, public ba::io_service::work462 class StateMachineLidControl : public StateMachineAsio<T> 463 463 { 464 464 private: … … 529 529 int Execute() 530 530 { 531 // Dispatch (execute) at most one handler from the queue. In contrary532 // to run_one(), it doesn't wait until a handler is available533 // which can be dispatched, so poll_one() might return with 0534 // handlers dispatched. The handlers are always dispatched/executed535 // synchronously, i.e. within the call to poll_one()536 poll_one();537 538 531 const int rc = fLid.GetState(); 539 532 … … 551 544 public: 552 545 StateMachineLidControl(ostream &out=cout) : 553 T(out, "LID_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 554 fLid(*this, *this) 555 { 556 // ba::io_service::work is a kind of keep_alive for the loop. 557 // It prevents the io_service to go to stopped state, which 558 // would prevent any consecutive calls to run() 559 // or poll() to do nothing. reset() could also revoke to the 560 // previous state but this might introduce some overhead of 561 // deletion and creation of threads and more. 562 546 StateMachineAsio<T>(out, "LID_CONTROL"), fLid(*this, *this) 547 { 563 548 // State names 564 549 T::AddStateName(Lid::State::kDisconnected, "NoConnection", -
trunk/FACT++/src/magiclidar.cc
r15351 r16727 1 #include <boost/bind.hpp>2 1 #include <boost/array.hpp> 3 4 //#include <string> // std::string5 //#include <algorithm> // std::transform6 //#include <cctype> // std::tolower7 2 8 3 #include "FACT.h" … … 11 6 #include "Shell.h" 12 7 #include "StateMachineDim.h" 8 #include "StateMachineAsio.h" 13 9 #include "Connection.h" 14 10 #include "LocalControl.h" … … 353 349 354 350 template <class T, class S> 355 class StateMachineLidar : public T, public ba::io_service, public ba::io_service::work351 class StateMachineLidar : public StateMachineAsio<T> 356 352 { 357 353 private: … … 407 403 int Execute() 408 404 { 409 // Dispatch (execute) at most one handler from the queue. In contrary410 // to run_one(), it doesn't wait until a handler is available411 // which can be dispatched, so poll_one() might return with 0412 // handlers dispatched. The handlers are always dispatched/executed413 // synchronously, i.e. within the call to poll_one()414 poll_one();415 416 405 return fLidar.GetState(); 417 406 } … … 420 409 public: 421 410 StateMachineLidar(ostream &out=cout) : 422 T(out, "MAGIC_LIDAR"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 423 fLidar(*this, *this) 424 { 425 // ba::io_service::work is a kind of keep_alive for the loop. 426 // It prevents the io_service to go to stopped state, which 427 // would prevent any consecutive calls to run() 428 // or poll() to do nothing. reset() could also revoke to the 429 // previous state but this might introduce some overhead of 430 // deletion and creation of threads and more. 431 411 StateMachineAsio<T>(out, "MAGIC_LIDAR"), fLidar(*this, *this) 412 { 432 413 // State names 433 414 T::AddStateName(State::kDisconnected, "NoConnection", -
trunk/FACT++/src/magicweather.cc
r14978 r16727 1 #include <boost/bind.hpp>2 1 #include <boost/array.hpp> 3 2 … … 11 10 #include "Shell.h" 12 11 #include "StateMachineDim.h" 12 #include "StateMachineAsio.h" 13 13 #include "Connection.h" 14 14 #include "LocalControl.h" … … 195 195 } 196 196 197 b oost::asio::deadline_timer fKeepAlive;197 ba::deadline_timer fKeepAlive; 198 198 199 199 void PostRequest() … … 341 341 342 342 template <class T, class S> 343 class StateMachineWeather : public T, public ba::io_service, public ba::io_service::work343 class StateMachineWeather : public StateMachineAsio<T> 344 344 { 345 345 private: … … 382 382 // Now wait until all connection have been closed and 383 383 // all pending handlers have been processed 384 poll();384 ba::io_service::poll(); 385 385 386 386 if (evt.GetBool()) … … 395 395 int Execute() 396 396 { 397 // Dispatch (execute) at most one handler from the queue. In contrary398 // to run_one(), it doesn't wait until a handler is available399 // which can be dispatched, so poll_one() might return with 0400 // handlers dispatched. The handlers are always dispatched/executed401 // synchronously, i.e. within the call to poll_one()402 poll_one();403 404 397 return fWeather.GetState(); 405 398 } 406 407 399 408 400 public: 409 401 StateMachineWeather(ostream &out=cout) : 410 T(out, "MAGIC_WEATHER"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 411 fWeather(*this, *this) 412 { 413 // ba::io_service::work is a kind of keep_alive for the loop. 414 // It prevents the io_service to go to stopped state, which 415 // would prevent any consecutive calls to run() 416 // or poll() to do nothing. reset() could also revoke to the 417 // previous state but this might introduce some overhead of 418 // deletion and creation of threads and more. 419 402 StateMachineAsio<T>(out, "MAGIC_WEATHER"), fWeather(*this, *this) 403 { 420 404 // State names 421 405 T::AddStateName(State::kDisconnected, "NoConnection", … … 458 442 } 459 443 }; 444 445 460 446 461 447 // ------------------------------------------------------------------------ -
trunk/FACT++/src/pwrctrl.cc
r16054 r16727 1 #include <boost/bind.hpp>2 1 #include <boost/array.hpp> 3 2 … … 10 9 #include "Event.h" 11 10 #include "StateMachineDim.h" 11 #include "StateMachineAsio.h" 12 12 #include "Connection.h" 13 13 #include "LocalControl.h" … … 330 330 331 331 template <class T, class S> 332 class StateMachinePowerControl : public T, public ba::io_service, public ba::io_service::work332 class StateMachinePowerControl : public StateMachineAsio<T> 333 333 { 334 334 private: … … 393 393 int Execute() 394 394 { 395 // Dispatch (execute) at most one handler from the queue. In contrary396 // to run_one(), it doesn't wait until a handler is available397 // which can be dispatched, so poll_one() might return with 0398 // handlers dispatched. The handlers are always dispatched/executed399 // synchronously, i.e. within the call to poll_one()400 poll_one();401 402 395 const int rc = fPower.GetState(); 403 396 … … 411 404 public: 412 405 StateMachinePowerControl(ostream &out=cout) : 413 T(out, "PWR_CONTROL"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 414 fPower(*this, *this) 415 { 416 // ba::io_service::work is a kind of keep_alive for the loop. 417 // It prevents the io_service to go to stopped state, which 418 // would prevent any consecutive calls to run() 419 // or poll() to do nothing. reset() could also revoke to the 420 // previous state but this might introduce some overhead of 421 // deletion and creation of threads and more. 422 406 StateMachineAsio<T>(out, "PWR_CONTROL"), fPower(*this, *this) 407 { 423 408 // State names 424 409 T::AddStateName(Power::State::kDisconnected, "NoConnection", … … 508 493 void SetupConfiguration(Configuration &conf) 509 494 { 510 po::options_description control(" Lidcontrol");495 po::options_description control("Interlock control"); 511 496 control.add_options() 512 497 ("no-dim,d", po_switch(), "Disable dim services") … … 534 519 { 535 520 cout << 536 "The pwrctrl is an interface to the LID controlhardware.\n"521 "The pwrctrl is an interface to the interlock hardware.\n" 537 522 "\n" 538 523 "The default is that the program is started without user intercation. " -
trunk/FACT++/src/tngweather.cc
r14978 r16727 1 #include <boost/bind.hpp>2 1 #include <boost/array.hpp> 3 2 … … 11 10 #include "Shell.h" 12 11 #include "StateMachineDim.h" 12 #include "StateMachineAsio.h" 13 13 #include "Connection.h" 14 14 #include "LocalControl.h" … … 407 407 408 408 template <class T, class S> 409 class StateMachineWeather : public T, public ba::io_service, public ba::io_service::work409 class StateMachineWeather : public StateMachineAsio<T> 410 410 { 411 411 private: … … 461 461 int Execute() 462 462 { 463 // Dispatch (execute) at most one handler from the queue. In contrary464 // to run_one(), it doesn't wait until a handler is available465 // which can be dispatched, so poll_one() might return with 0466 // handlers dispatched. The handlers are always dispatched/executed467 // synchronously, i.e. within the call to poll_one()468 poll_one();469 470 463 return fWeather.GetState(); 471 464 } … … 474 467 public: 475 468 StateMachineWeather(ostream &out=cout) : 476 T(out, "TNG_WEATHER"), ba::io_service::work(static_cast<ba::io_service&>(*this)), 477 fWeather(*this, *this) 478 { 479 // ba::io_service::work is a kind of keep_alive for the loop. 480 // It prevents the io_service to go to stopped state, which 481 // would prevent any consecutive calls to run() 482 // or poll() to do nothing. reset() could also revoke to the 483 // previous state but this might introduce some overhead of 484 // deletion and creation of threads and more. 485 469 StateMachineAsio<T>(out, "TNG_WEATHER"), fWeather(*this, *this) 470 { 486 471 // State names 487 472 T::AddStateName(State::kDisconnected, "NoConnection",
Note:
See TracChangeset
for help on using the changeset viewer.