FACT++  1.0
template<class T , class S >
StateMachineDrive< T, S >::StateMachineDrive ( ostream &  out = cout)
inline

Definition at line 2681 of file drivectrl.cc.

References StateMachineDrive< T, S >::Disconnect(), StateMachineDrive< T, S >::HandleTPoint(), StateMachineDrive< T, S >::HandleWeatherData(), Drive::State::kAllowedRangeExceeded, Drive::State::kArmed, Drive::State::kAvailable, Drive::State::kBlocked, State::kConnected, State::kDisconnected, kEJupiter, kEMars, kEMoon, kESaturn, kEVenus, Drive::State::kInitialized, Drive::State::kInvalidCoordinates, Drive::State::kLocked, BIAS::State::kLocked, Drive::State::kMoving, Drive::State::kOnTrack, Drive::State::kParking, Drive::State::kPositioningFailed, Drive::State::kStopping, Drive::State::kTracking, Drive::State::kUnavailable, StateMachineDrive< T, S >::MoveTo(), StateMachineDrive< T, S >::Orbit(), StateMachineDrive< T, S >::Park(), StateMachineDrive< T, S >::Print(), StateMachineDrive< T, S >::Reconnect(), StateMachineDrive< T, S >::ReloadSources(), StateMachineDrive< T, S >::RequestSdo(), StateMachineDrive< T, S >::ResetError(), StateMachineDrive< T, S >::Screenshot(), StateMachineDrive< T, S >::SendSdo(), StateMachineDrive< T, S >::SetLedBrightness(), StateMachineDrive< T, S >::SetLedsOff(), StateMachineDrive< T, S >::SetVerbosity(), StateMachineDrive< T, S >::StopMovement(), StateMachineDrive< T, S >::TPoint(), StateMachineDrive< T, S >::Track(), StateMachineDrive< T, S >::TrackCelest(), StateMachineDrive< T, S >::TrackOn(), StateMachineDrive< T, S >::TrackOrbit(), StateMachineDrive< T, S >::TrackSource(), StateMachineDrive< T, S >::TrackWobble(), StateMachineDrive< T, S >::Unlock(), and StateMachineDrive< T, S >::Wobble().

2681  :
2682  StateMachineAsio<T>(out, "DRIVE_CONTROL"), fDrive(*this, *this),
2683  fTrackingLoop(*this), fSunRise(Time().GetNextSunRise()), fDevBuffer(5)
2684  {
2685 
2686  T::Subscribe("MAGIC_WEATHER/DATA")
2687  (bind(&StateMachineDrive::HandleWeatherData, this, placeholders::_1));
2688 
2689  T::Subscribe("TPOINT/DATA")
2690  (bind(&StateMachineDrive::HandleTPoint, this, placeholders::_1));
2691 
2692  // State names
2693  T::AddStateName(State::kDisconnected, "Disconnected",
2694  "No connection to SPS");
2695  T::AddStateName(State::kConnected, "Connected",
2696  "Connection to SPS, no information received yet");
2697 
2698  T::AddStateName(State::kLocked, "Locked",
2699  "Drive system is locked (will not accept commands)");
2700 
2701  T::AddStateName(State::kUnavailable, "Unavailable",
2702  "Connected to SPS, no connection to at least one IndraDrives");
2703  T::AddStateName(State::kAvailable, "Available",
2704  "Connected to SPS and to IndraDrives, but at least one drive not in RF");
2705  T::AddStateName(State::kBlocked, "Blocked",
2706  "Drive system is blocked by manual operation or a pressed emergeny button");
2707  T::AddStateName(State::kArmed, "Armed",
2708  "Connected to SPS and IndraDrives in RF, but not yet initialized");
2709  T::AddStateName(State::kInitialized, "Initialized",
2710  "Connected to SPS and IndraDrives in RF and initialized");
2711 
2712  T::AddStateName(State::kStopping, "Stopping",
2713  "Stop command sent, waiting for telescope to be still");
2714  T::AddStateName(State::kParking, "Parking",
2715  "Telescope in parking operation, waiting for telescope to be still");
2716  T::AddStateName(State::kMoving, "Moving",
2717  "Telescope moving");
2718  T::AddStateName(State::kTracking, "Tracking",
2719  "Telescope in tracking mode");
2720  T::AddStateName(State::kOnTrack, "OnTrack",
2721  "Telescope tracking stable");
2722 
2723  T::AddStateName(State::kPositioningFailed, "PositioningFailed",
2724  "Target position was not reached within ten steps");
2725  T::AddStateName(State::kAllowedRangeExceeded, "OutOfRange",
2726  "Telecope went out of range during tracking");
2727  T::AddStateName(State::kInvalidCoordinates, "InvalidCoordinates",
2728  "Tracking coordinates out of range");
2729 
2730 
2731  T::AddEvent("REQUEST_SDO", "S:3", State::kArmed)
2732  (bind(&StateMachineDrive::RequestSdo, this, placeholders::_1))
2733  ("Request an SDO from the drive"
2734  "|node[uint32]:Node identifier (1:az, 3:zd)"
2735  "|index[uint32]:SDO index"
2736  "|subindex[uint32]:SDO subindex");
2737 
2738  T::AddEvent("SET_SDO", "S:3;X:1", State::kArmed)
2739  (bind(&StateMachineDrive::SendSdo, this, placeholders::_1))
2740  ("Request an SDO from the drive"
2741  "|node[uint32]:Node identifier (1:az, 3:zd)"
2742  "|index[uint32]:SDO index"
2743  "|subindex[uint32]:SDO subindex"
2744  "|value[uint64]:Value");
2745 
2746  // Drive Commands
2747  T::AddEvent("MOVE_TO", "D:2", State::kInitialized) // ->ZDAZ
2748  (bind(&StateMachineDrive::MoveTo, this, placeholders::_1))
2749  ("Move the telescope to the given local sky coordinates"
2750  "|Zd[deg]:Zenith distance"
2751  "|Az[deg]:Azimuth");
2752 
2753  T::AddEvent("TRACK", "D:2", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2754  (bind(&StateMachineDrive::Track, this, placeholders::_1))
2755  ("Move the telescope to the given sky coordinates and start tracking them"
2756  "|Ra[h]:Right ascension"
2757  "|Dec[deg]:Declination");
2758 
2759  T::AddEvent("WOBBLE", "D:4", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2760  (bind(&StateMachineDrive::Wobble, this, placeholders::_1))
2761  ("Move the telescope to the given wobble position around the given sky coordinates and start tracking them"
2762  "|Ra[h]:Right ascension"
2763  "|Dec[deg]:Declination"
2764  "|Offset[deg]:Wobble offset"
2765  "|Angle[deg]:Wobble angle");
2766 
2767  T::AddEvent("ORBIT", "D:5", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2768  (bind(&StateMachineDrive::Orbit, this, placeholders::_1))
2769  ("Move the telescope in a circle around the source"
2770  "|Ra[h]:Right ascension"
2771  "|Dec[deg]:Declination"
2772  "|Offset[deg]:Wobble offset"
2773  "|Angle[deg]:Starting angle"
2774  "|Period[min]:Time for one orbit");
2775 
2776  T::AddEvent("TRACK_SOURCE", "D:2;C", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2777  (bind(&StateMachineDrive::TrackSource, this, placeholders::_1))
2778  ("Move the telescope to the given wobble position around the given source and start tracking"
2779  "|Offset[deg]:Wobble offset"
2780  "|Angle[deg]:Wobble angle"
2781  "|Name[string]:Source name");
2782 
2783  T::AddEvent("TRACK_WOBBLE", "S:1;C", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2784  (bind(&StateMachineDrive::TrackWobble, this, placeholders::_1))
2785  ("Move the telescope to the given wobble position around the given source and start tracking"
2786  "|Id:Wobble angle id (1 or 2)"
2787  "|Name[string]:Source name");
2788 
2789  T::AddEvent("TRACK_ORBIT", "D:2;C", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2790  (bind(&StateMachineDrive::TrackOrbit, this, placeholders::_1))
2791  ("Move the telescope in a circle around the source"
2792  "|Angle[deg]:Starting angle"
2793  "|Period[min]:Time for one orbit"
2794  "|Name[string]:Source name");
2795 
2796  T::AddEvent("TRACK_ON", "C", State::kInitialized, State::kTracking, State::kOnTrack) // ->RADEC/GRB
2797  (bind(&StateMachineDrive::TrackOn, this, placeholders::_1))
2798  ("Move the telescope to the given position and start tracking"
2799  "|Name[string]:Source name");
2800 
2802  (bind(&StateMachineDrive::TrackCelest, this, kEMoon))
2803  ("Start tracking the moon");
2804  T::AddEvent("VENUS", State::kInitialized, State::kTracking, State::kOnTrack)
2805  (bind(&StateMachineDrive::TrackCelest, this, kEVenus))
2806  ("Start tracking Venus");
2808  (bind(&StateMachineDrive::TrackCelest, this, kEMars))
2809  ("Start tracking Mars");
2810  T::AddEvent("JUPITER", State::kInitialized, State::kTracking, State::kOnTrack)
2812  ("Start tracking Jupiter");
2813  T::AddEvent("SATURN", State::kInitialized, State::kTracking, State::kOnTrack)
2815  ("Start tracking Saturn");
2816 
2817  // FIXME: What to do in error state?
2819  (bind(&StateMachineDrive::Park, this))
2820  ("Park the telescope");
2821 
2823  (bind(&StateMachineDrive::StopMovement, this))
2824  ("Stop any kind of movement.");
2825 
2827  (bind(&StateMachineDrive::ResetError, this))
2828  ("Acknoledge an internal error (PositioningFailed, AllowedRangeExceeded)");
2829 
2830  T::AddEvent("TPOINT", State::kOnTrack)
2831  (bind(&StateMachineDrive::TPoint, this))
2832  ("Take a TPoint");
2833 
2834  T::AddEvent("SCREENSHOT", "B:1;C")
2835  (bind(&StateMachineDrive::Screenshot, this, placeholders::_1))
2836  ("Take a screenshot"
2837  "|color[bool]:False if just the gray image should be saved."
2838  "|name[string]:Filename");
2839 
2840  T::AddEvent("SET_LED_BRIGHTNESS", "I:2")
2841  (bind(&StateMachineDrive::SetLedBrightness, this, placeholders::_1))
2842  ("Set the LED brightness of the top and bottom leds"
2843  "|top[au]:Allowed range 0-32767 for top LEDs"
2844  "|bot[au]:Allowed range 0-32767 for bottom LEDs");
2845 
2846  T::AddEvent("LEDS_OFF")
2847  (bind(&StateMachineDrive::SetLedsOff, this))
2848  ("Switch off TPoint LEDs");
2849 
2850  T::AddEvent("UNLOCK", Drive::State::kLocked)
2851  (bind(&StateMachineDrive::Unlock, this))
2852  ("Unlock locked state.");
2853 
2854  // Verbosity commands
2855  T::AddEvent("SET_VERBOSITY", "S:1")
2856  (bind(&StateMachineDrive::SetVerbosity, this, placeholders::_1))
2857  ("Set verbosity state"
2858  "|verbosity[uint16]:disable or enable verbosity for received data (yes/no), except dynamic data");
2859 
2860  // Conenction commands
2861  T::AddEvent("DISCONNECT", State::kConnected)
2862  (bind(&StateMachineDrive::Disconnect, this))
2863  ("disconnect from ethernet");
2864 
2865  T::AddEvent("RECONNECT", "O", State::kDisconnected, State::kConnected)
2866  (bind(&StateMachineDrive::Reconnect, this, placeholders::_1))
2867  ("(Re)connect Ethernet connection to SPS, a new address can be given"
2868  "|[host][string]:new ethernet address in the form <host:port>");
2869 
2870 
2871  T::AddEvent("PRINT")
2872  (bind(&StateMachineDrive::Print, this))
2873  ("Print source list.");
2874 
2876  (bind(&StateMachineDrive::ReloadSources, this))
2877  ("Reload sources from database after database has changed..");
2878 
2879 
2880  //fDrive.SetUpdateStatus(std::bind(&StateMachineDrive::UpdateStatus, this, placeholders::_1, placeholders::_2));
2881  fDrive.StartConnect();
2882  }
vector< double > fDevBuffer
Definition: drivectrl.cc:1591
int TrackOn(const EventImp &evt)
Definition: cosyctrl.cc:1082
int TrackOrbit(const EventImp &evt)
Definition: drivectrl.cc:2170
int RequestSdo(const EventImp &evt)
Definition: drivectrl.cc:1822
ba::deadline_timer fTrackingLoop
Definition: drivectrl.cc:1566
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
int Reconnect(const EventImp &evt)
Definition: cosyctrl.cc:1202
int TrackSource(const EventImp &evt)
Definition: drivectrl.cc:2133
int HandleTPoint(const EventImp &evt)
Definition: drivectrl.cc:1630
int Orbit(const EventImp &evt)
Definition: drivectrl.cc:2026
int SendSdo(const EventImp &evt)
Definition: drivectrl.cc:1849
int HandleWeatherData(const EventImp &evt)
Definition: drivectrl.cc:1612
int Screenshot(const EventImp &evt)
Definition: drivectrl.cc:2220
int SetLedBrightness(const EventImp &evt)
Definition: cosyctrl.cc:1119
int TrackWobble(const EventImp &evt)
Definition: cosyctrl.cc:1008
int MoveTo(const EventImp &evt)
Definition: drivectrl.cc:1918
int SetVerbosity(const EventImp &evt)
Definition: cosyctrl.cc:1130
int Wobble(const EventImp &evt)
Definition: cosyctrl.cc:978
int Track(const EventImp &evt)
Definition: cosyctrl.cc:1065
int TrackCelest(const string &cmd, const string &source)
Definition: cosyctrl.cc:861

+ Here is the call graph for this function: