Changeset 18125 for trunk/FACT++
- Timestamp:
- 02/13/15 09:24:07 (10 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/HeadersLid.h
r16837 r18125 17 17 kClosed, 18 18 kOpen, 19 kMoving 19 kMoving, 20 kLocked 20 21 }; 21 22 }; -
trunk/FACT++/src/lidctrl.cc
r17916 r18125 473 473 S fLid; 474 474 Time fLastCommand; 475 Time fSunRise; 475 476 476 477 uint16_t fTimeToMove; … … 535 536 }*/ 536 537 538 int Unlock() 539 { 540 return fLid.GetState(); 541 } 542 537 543 int Execute() 538 544 { 539 545 const int rc = fLid.GetState(); 540 541 if (T::GetCurrentState()==Lid::State::kMoving && 546 const int state = T::GetCurrentState(); 547 548 if (state==Lid::State::kMoving && 542 549 (rc==Lid::State::kConnected || rc==Lid::State::kDisconnected) && 543 550 fLastCommand+boost::posix_time::seconds(fTimeToMove+fLid.GetInterval()) > Time()) … … 546 553 } 547 554 548 return rc==Lid::State::kConnected ? T::GetCurrentState() : rc; 555 const Time now; 556 if (now>fSunRise) 557 { 558 if (state!=Lid::State::kClosed && state!=Lid::State::kLocked && state>Lid::State::kDisconnected) 559 { 560 T::Error("Lidctrl not in 'Closed' at end of nautical twilight!"); 561 Close(); 562 } 563 564 fSunRise = now.GetNextSunRise(-6); 565 566 ostringstream msg; 567 msg << "During next sun-rise nautical twilight will end at " << fSunRise; 568 T::Info(msg); 569 570 return Lid::State::kLocked; 571 } 572 573 return rc==Lid::State::kConnected ? state : rc; 549 574 } 550 575 … … 552 577 public: 553 578 StateMachineLidControl(ostream &out=cout) : 554 StateMachineAsio<T>(out, "LID_CONTROL"), fLid(*this, *this) 579 StateMachineAsio<T>(out, "LID_CONTROL"), fLid(*this, *this), 580 fSunRise(Time().GetNextSunRise(-6)) 555 581 { 556 582 // State names … … 584 610 T::AddStateName(Lid::State::kMoving, "Moving", 585 611 "Lids are supposed to move, waiting for next status"); 612 613 T::AddStateName(Lid::State::kLocked, "Locked", 614 "Locked, no commands accepted except UNLOCK."); 586 615 587 616 … … 600 629 ("Close the lids"); 601 630 602 T::AddEvent("POST", "C") 631 T::AddEvent("POST", "C")(Lid::State::kUnidentified)(Lid::State::kInconsistent)(Lid::State::kUnknown)(Lid::State::kOvercurrent)(Lid::State::kPowerProblem)(Lid::State::kOpen)(Lid::State::kClosed)(Lid::State::kMoving) 603 632 (bind(&StateMachineLidControl::Post, this, placeholders::_1)) 604 633 ("set verbosity state" 605 634 "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data"); 635 636 T::AddEvent("UNLOCK", Lid::State::kLocked) 637 (bind(&StateMachineLidControl::Unlock, this)) 638 ("Unlock if in locked state."); 606 639 } 607 640
Note:
See TracChangeset
for help on using the changeset viewer.