- Timestamp:
- 08/12/13 17:36:32 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r16887 r17004 78 78 79 79 public: 80 virtual void UpdateSource( )80 virtual void UpdateSource(const string & = "", bool = false) 81 81 { 82 82 } … … 756 756 } 757 757 758 void UpdateSource() 759 { 760 const vector<char> empty(6*sizeof(double)+31, 0); 761 fDimSource.setQuality(0); 762 fDimSource.Update(empty); 758 void UpdateSource(const string &name="", bool tracking=false) 759 { 760 vector<char> dat(6*sizeof(double)+31, 0); 761 strncpy(dat.data()+6*sizeof(double), name.c_str(), 30); 762 763 fDimSource.setQuality(tracking); 764 fDimSource.Update(dat); 763 765 } 764 766 … … 853 855 } 854 856 855 int SendCommand(const string &str , bool upd=true)857 int SendCommand(const string &str) 856 858 { 857 859 // This happens if fLastCommand should be send, … … 868 870 T::Message("Sending: "+str); 869 871 870 if (upd)871 fDrive.UpdateSource();872 873 872 return T::GetCurrentState(); 874 873 } 875 874 875 int TrackCelest(const string &cmd, const string &source) 876 { 877 SendCommand(cmd); 878 879 fDrive.UpdateSource(source, true); 880 881 return T::GetCurrentState(); 882 } 883 876 884 int Park() 877 885 { 878 SendCommand("PREPS Park", false); 886 SendCommand("PREPS Park"); 887 fDrive.UpdateSource("Park"); 879 888 880 889 // FIXME: Go to locked state only when park position properly reached … … 882 891 } 883 892 893 int SendStop() 894 { 895 SendCommand("STOP!"); 896 fDrive.UpdateSource(); 897 898 return T::GetCurrentState(); 899 } 900 884 901 int Resume() 885 902 { … … 892 909 893 910 T::Info("Resume: "+fLastCommand); 894 return SendCommand(fLastCommand , false);911 return SendCommand(fLastCommand); 895 912 } 896 913 … … 916 933 fDrive.UpdateSource(dim); 917 934 } 935 else 936 fDrive.UpdateSource("", false); 937 918 938 919 939 command += AngleToStr(dat[0]) + ' ' + AngleToStr(dat[1]); 920 return SendCommand(command , type==kPoint);940 return SendCommand(command); 921 941 } 922 942 … … 944 964 string command = "RADEC "; 945 965 command += AngleToStr(srcra) + ' ' + AngleToStr(srcdec); 946 return SendCommand(command , false);966 return SendCommand(command); 947 967 } 948 968 … … 967 987 string command = "RADEC "; 968 988 command += AngleToStr(nra) + ' ' + AngleToStr(ndec); 969 return SendCommand(command , false);989 return SendCommand(command); 970 990 } 971 991 … … 1107 1127 src.erase(src.find_first_of(' '), 1); 1108 1128 1109 SendCommand("TPOIN "+src+" "+to_string(mag) , false);;1129 SendCommand("TPOIN "+src+" "+to_string(mag));; 1110 1130 1111 1131 return T::GetCurrentState(); … … 1119 1139 const uint32_t *led = evt.Ptr<uint32_t>(); 1120 1140 1121 ostringstream cmd; 1122 cmd << "LEDS " << led[0] << " " << led[1]; 1123 return SendCommand(cmd.str(), false); 1141 return SendCommand("LEDS "+to_string(led[0])+" "+to_string(led[1])); 1124 1142 } 1125 1143 … … 1397 1415 1398 1416 T::AddEvent("MOON", State::kArmed, State::kTracking, State::kOnTrack) 1399 (bind(&StateMachineDrive:: SendCommand, this, "MOON 0 0", true))1417 (bind(&StateMachineDrive::TrackCelest, this, "MOON 0 0", "Moon")) 1400 1418 ("Start tracking the moon"); 1401 1419 T::AddEvent("VENUS", State::kArmed, State::kTracking, State::kOnTrack) 1402 (bind(&StateMachineDrive:: SendCommand, this, "CELEST 2 0 0", true))1420 (bind(&StateMachineDrive::TrackCelest, this, "CELEST 2 0 0", "Venus")) 1403 1421 ("Start tracking Venus"); 1404 1422 T::AddEvent("MARS", State::kArmed, State::kTracking, State::kOnTrack) 1405 (bind(&StateMachineDrive:: SendCommand, this, "CELEST 4 0 0", true))1423 (bind(&StateMachineDrive::TrackCelest, this, "CELEST 4 0 0", "Mars")) 1406 1424 ("Start tracking Mars"); 1407 1425 T::AddEvent("JUPITER", State::kArmed, State::kTracking, State::kOnTrack) 1408 (bind(&StateMachineDrive:: SendCommand, this, "CELEST 5 0 0", true))1426 (bind(&StateMachineDrive::TrackCelest, this, "CELEST 5 0 0", "Jupiter")) 1409 1427 ("Start tracking Jupiter"); 1410 1428 T::AddEvent("SATURN", State::kArmed, State::kTracking, State::kOnTrack) 1411 (bind(&StateMachineDrive:: SendCommand, this, "CELEST 6 0 0", true))1429 (bind(&StateMachineDrive::TrackCelest, this, "CELEST 6 0 0", "Saturn")) 1412 1430 ("Start tracking Saturn"); 1413 1431 … … 1417 1435 1418 1436 T::AddEvent("TAKE_TPOINT") 1419 (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0" , false))1437 (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0")) 1420 1438 ("Take a TPoint"); 1421 1439 … … 1433 1451 1434 1452 T::AddEvent("LEDS_OFF") 1435 (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0" , false))1453 (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0")) 1436 1454 ("Switch off TPoint LEDs"); 1437 1455 1438 1456 T::AddEvent("STOP") 1439 (bind(&StateMachineDrive::Send Command, this, "STOP!", true))1457 (bind(&StateMachineDrive::SendStop, this)) 1440 1458 ("Stop any kind of movement."); 1441 1459
Note:
See TracChangeset
for help on using the changeset viewer.