Changeset 13911
- Timestamp:
- 05/26/12 14:18:58 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r13767 r13911 22 22 #endif 23 23 24 #include "HeadersDrive.h" 25 24 26 namespace ba = boost::asio; 25 27 namespace bs = boost::system; … … 27 29 28 30 using namespace std; 29 30 // ------------------------------------------------------------------------ 31 32 namespace Drive 33 { 34 struct DimPointing 35 { 36 } __attribute__((__packed__)); 37 38 struct DimTracking 39 { 40 } __attribute__((__packed__)); 41 42 struct DimStarguider 43 { 44 double fMissZd; 45 double fMissAz; 46 47 double fNominalZd; 48 double fNominalAz; 49 50 double fCenterX; 51 double fCenterY; 52 53 double fBrightness; 54 55 uint16_t fNumCorrelated; 56 uint16_t fNumLeds; 57 uint16_t fNumRings; 58 uint16_t fNumStars; 59 60 } __attribute__((__packed__)); 61 62 struct DimTPoint 63 { 64 double fRa; 65 double fDec; 66 67 double fNominalZd; 68 double fNominalAz; 69 70 double fPointingZd; 71 double fPointingAz; 72 73 double fFeedbackZd; 74 double fFeedbackAz; 75 76 uint16_t fNumLeds; 77 uint16_t fNumRings; 78 79 double fCenterX; 80 double fCenterY; 81 double fCenterMag; 82 83 double fStarX; 84 double fStarY; 85 double fStarMag; 86 87 double fRealMag; 88 89 } __attribute__((__packed__)); 90 }; 91 92 31 using namespace Drive; 93 32 94 33 // ------------------------------------------------------------------------ … … 135 74 } 136 75 137 virtual void UpdateStarguider(const Time &, const D rive::DimStarguider &)138 { 139 } 140 141 virtual void UpdateTPoint(const Time &, const D rive::DimTPoint &, const string &)76 virtual void UpdateStarguider(const Time &, const DimStarguider &) 77 { 78 } 79 80 virtual void UpdateTPoint(const Time &, const DimTPoint &, const string &) 142 81 { 143 82 } … … 252 191 return; 253 192 254 D rive::DimStarguider data;193 DimStarguider data; 255 194 256 195 data.fMissZd = misszd; … … 308 247 return; 309 248 310 D rive::DimTPoint tpoint;249 DimTPoint tpoint; 311 250 312 251 tpoint.fRa = ra; … … 594 533 }; 595 534 596 const uint16_t Connection Drive::kMaxAddr = 0xfff;535 const uint16_t ConnectionkMaxAddr = 0xfff; 597 536 598 537 // ------------------------------------------------------------------------ … … 627 566 } 628 567 629 void UpdateTPoint(const Time &t, const D rive::DimTPoint &data,568 void UpdateTPoint(const Time &t, const DimTPoint &data, 630 569 const string &name) 631 570 { … … 708 647 class StateMachineDrive : public T, public ba::io_service, public ba::io_service::work 709 648 { 710 int Wrap(boost::function<void()> f)711 {712 f();713 return T::GetCurrentState();714 }715 716 boost::function<int(const EventImp &)> Wrapper(boost::function<void()> func)717 {718 return bind(&StateMachineDrive::Wrap, this, func);719 }720 721 649 private: 722 650 S fDrive; 723 724 enum states_t725 {726 kStateDisconnected = 1,727 kStateConnected,728 kStateNotReady,729 kStateReady,730 kStateArmed,731 kStateMoving,732 kStateTracking,733 };734 651 735 652 string fDatabase; … … 1014 931 fDrive(*this, *this) 1015 932 { 1016 // ba::io_service::work is a kind of keep_alive for the loop.1017 // It prevents the io_service to go to stopped state, which1018 // would prevent any consecutive calls to run()1019 // or poll() to do nothing. reset() could also revoke to the1020 // previous state but this might introduce some overhead of1021 // deletion and creation of threads and more.1022 1023 933 // State names 1024 AddStateName(kStateDisconnected, "Disconnected",934 T::AddStateName(State::kDisconnected, "Disconnected", 1025 935 "No connection to cosy"); 1026 936 1027 AddStateName(kStateConnected, "Connected",937 T::AddStateName(State::kConnected, "Connected", 1028 938 "Cosy connected, drive stopped"); 1029 939 1030 AddStateName(kStateNotReady, "NotReady",940 T::AddStateName(State::kNotReady, "NotReady", 1031 941 "Drive system not ready for movement"); 1032 942 1033 AddStateName(kStateReady, "Ready",943 T::AddStateName(State::kReady, "Ready", 1034 944 "Drive system ready for movement"); 1035 945 1036 AddStateName(kStateArmed, "Armed",946 T::AddStateName(State::kArmed, "Armed", 1037 947 "Cosy armed, drive stopped"); 1038 948 1039 AddStateName(kStateMoving, "Moving",949 T::AddStateName(State::kMoving, "Moving", 1040 950 "Telescope moving"); 1041 951 1042 AddStateName(kStateTracking, "Tracking",952 T::AddStateName(State::kTracking, "Tracking", 1043 953 "Telescope tracking"); 1044 954 1045 // kStateIdle1046 // kStateArmed1047 // kStateMoving1048 // kStateTracking955 // State::kIdle 956 // State::kArmed 957 // State::kMoving 958 // State::kTracking 1049 959 1050 960 // Init … … 1068 978 1069 979 // Drive Commands 1070 T::AddEvent("MOVE_TO", "D:2", kStateArmed) // ->ZDAZ980 T::AddEvent("MOVE_TO", "D:2", State::kArmed) // ->ZDAZ 1071 981 (bind(&StateMachineDrive::SendCoordinates, this, placeholders::_1, kPoint)) 1072 982 ("Move the telescope to the given local coordinates" … … 1074 984 "|Az[deg]:Azimuth"); 1075 985 1076 T::AddEvent("TRACK", "D:2", kStateArmed) // ->RADEC/GRB986 T::AddEvent("TRACK", "D:2", State::kArmed) // ->RADEC/GRB 1077 987 (bind(&StateMachineDrive::SendCoordinates, this, placeholders::_1, kTrackSlow)) 1078 988 ("Move the telescope to the given sky coordinates and start tracking them" … … 1080 990 "|Dec[deg]:Declination"); 1081 991 1082 T::AddEvent("WOBBLE", "D:4", kStateArmed) // ->RADEC/GRB992 T::AddEvent("WOBBLE", "D:4", State::kArmed) // ->RADEC/GRB 1083 993 (bind(&StateMachineDrive::Wobble, this, placeholders::_1)) 1084 994 ("Move the telescope to the given wobble position around the given sky coordinates and start tracking them" … … 1088 998 "|Angle[deg]:Wobble angle"); 1089 999 1090 T::AddEvent("TRACK_SOURCE", "D:2;C", kStateArmed) // ->RADEC/GRB1000 T::AddEvent("TRACK_SOURCE", "D:2;C", State::kArmed) // ->RADEC/GRB 1091 1001 (bind(&StateMachineDrive::Track, this, placeholders::_1)) 1092 1002 ("Move the telescope to the given wobble position around the given source and start tracking" … … 1095 1005 "|Name[string]:Source name"); 1096 1006 1097 T::AddEvent("MOON", kStateArmed)1007 T::AddEvent("MOON", State::kArmed) 1098 1008 (bind(&StateMachineDrive::SendCommand, this, "MOON 0 0", true)) 1099 1009 ("Start tracking the moon"); 1100 T::AddEvent("VENUS", kStateArmed)1010 T::AddEvent("VENUS", State::kArmed) 1101 1011 (bind(&StateMachineDrive::SendCommand, this, "CELEST 2 0 0", true)) 1102 1012 ("Start tracking Venus"); 1103 T::AddEvent("MARS", kStateArmed)1013 T::AddEvent("MARS", State::kArmed) 1104 1014 (bind(&StateMachineDrive::SendCommand, this, "CELEST 4 0 0", true)) 1105 1015 ("Start tracking Mars"); 1106 T::AddEvent("JUPITER", kStateArmed)1016 T::AddEvent("JUPITER", State::kArmed) 1107 1017 (bind(&StateMachineDrive::SendCommand, this, "CELEST 5 0 0", true)) 1108 1018 ("Start tracking Jupiter"); 1109 T::AddEvent("SATURN", kStateArmed)1019 T::AddEvent("SATURN", State::kArmed) 1110 1020 (bind(&StateMachineDrive::SendCommand, this, "CELEST 6 0 0", true)) 1111 1021 ("Start tracking Saturn"); … … 1129 1039 ("Stop any kind of movement."); 1130 1040 1131 // T::AddEvent("ARM", kStateConnected)1132 // (bind(&StateMachine Drive::SendCommand, this, "ARM lock"))1041 // T::AddEvent("ARM", State::kConnected) 1042 // (bind(&StateMachineSendCommand, this, "ARM lock")) 1133 1043 // (""); 1134 1044 … … 1141 1051 1142 1052 // Conenction commands 1143 AddEvent("DISCONNECT", kStateConnected, kStateArmed)1053 T::AddEvent("DISCONNECT", State::kConnected, State::kArmed) 1144 1054 (bind(&StateMachineDrive::Disconnect, this)) 1145 1055 ("disconnect from ethernet"); 1146 1056 1147 AddEvent("RECONNECT", "O", kStateDisconnected, kStateConnected, kStateArmed)1057 T::AddEvent("RECONNECT", "O", State::kDisconnected, State::kConnected, State::kArmed) 1148 1058 (bind(&StateMachineDrive::Reconnect, this, placeholders::_1)) 1149 1059 ("(Re)connect ethernet connection to FTM, a new address can be given"
Note:
See TracChangeset
for help on using the changeset viewer.