Changeset 12770
- Timestamp:
- 01/26/12 10:05:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r12649 r12770 136 136 } 137 137 138 public: 139 virtual void UpdateSource() 140 { 141 } 142 virtual void UpdateSource(const array<double, 6> &) 143 { 144 } 138 145 139 146 protected: … … 587 594 { 588 595 private: 589 590 596 DimDescribedService fDimPointing; 591 597 DimDescribedService fDimTracking; 598 DimDescribedService fDimSource; 592 599 DimDescribedService fDimTPoint; 593 600 DimDescribedService fDimStatus; 594 601 595 virtual void UpdatePointing(const Time &t, 596 const array<double, 2> &arr) 602 void UpdatePointing(const Time &t, const array<double, 2> &arr) 597 603 { 598 604 fDimPointing.setData(arr); … … 600 606 } 601 607 602 virtual void UpdateTracking(const Time &t, 603 const array<double, 7> &arr) 608 void UpdateTracking(const Time &t,const array<double, 7> &arr) 604 609 { 605 610 fDimTracking.setData(arr); 606 611 fDimTracking.Update(t); 607 612 } 608 virtual void UpdateStatus(const Time &t, 609 613 614 void UpdateStatus(const Time &t, const array<uint8_t, 3> &arr) 610 615 { 611 616 fDimStatus.setData(arr); 612 617 fDimStatus.Update(t); 613 618 } 614 virtual void UpdateTPoint(const Time &t, 615 616 619 620 void UpdateTPoint(const Time &t, const Drive::DimTPoint &data, 621 const string &name) 617 622 { 618 623 vector<char> dim(sizeof(data)+name.length()+1); … … 630 635 "|Zd[deg]:Zenith distance (encoder readout)" 631 636 "|Az[deg]:Azimuth angle (encoder readout)"), 632 fDimTracking("DRIVE_CONTROL/TRACKING_POSITION", "D:1;D:1;D:1;D:1;D:1;D:1;D:1 ",637 fDimTracking("DRIVE_CONTROL/TRACKING_POSITION", "D:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1", 633 638 "|Ra[h]:Command right ascension" 634 639 "|Dec[deg]:Command declination" … … 638 643 "|dZd[deg]:Control deviation Zd" 639 644 "|dAz[deg]:Control deviation Az"), 645 fDimSource("DRIVE_CONTROL/SOURCE_POSITION", "D:1;D:1;D:1;D:1;D:1;D:1", 646 "|Ra_cmd[h]:Command right ascension" 647 "|Dec_cmd[deg]:Command declination" 648 "|Ra_src[h]:Source right ascension" 649 "|Dec_src[deg]:Source declination" 650 "|Offfset[deg]:Wobble offset" 651 "|Angle[deg]:Wobble angle"), 640 652 fDimTPoint("DRIVE_CONTROL/TPOINT", "D:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1;S:1;D:1;D:1;D:1;D:1;D:1;D:1;D:1;C", 641 653 "|Ra[h]:Command right ascension" … … 661 673 } 662 674 675 void UpdateSource() 676 { 677 const array<double, 6> arr = {{ 0, 0, 0, 0, 0, 0 }}; 678 fDimSource.setQuality(0); 679 fDimSource.Update(arr); 680 } 681 682 void UpdateSource(const array<double, 6> &arr) 683 { 684 fDimSource.setQuality(1); 685 fDimSource.Update(arr); 686 } 687 663 688 // A B [C] [D] E [F] G H [I] J K [L] M N O P Q R [S] T U V W [X] Y Z 664 689 }; … … 739 764 } 740 765 741 int SendCommand(const string &str )766 int SendCommand(const string &str, bool upd=true) 742 767 { 743 768 fDrive.PostMessage(str); 744 769 T::Message("Sending: "+str); 770 771 if (upd) 772 fDrive.UpdateSource(); 773 745 774 return T::GetCurrentState(); 746 775 } … … 762 791 } 763 792 793 if (type!=kPoint) 794 { 795 const array<double, 6> dim = {{ dat[0], dat[1], dat[0], dat[1], 0, 0 }}; 796 fDrive.UpdateSource(dim); 797 } 798 764 799 command += AngleToStr(dat[0]) + ' ' + AngleToStr(dat[1]); 765 766 return SendCommand(command); 800 return SendCommand(command, type==kPoint); 801 } 802 803 int Wobble(const EventImp &evt) 804 { 805 if (!CheckEventSize(evt.GetSize(), "Wobble", 32)) 806 return T::kSM_FatalError; 807 808 const double *dat = evt.Ptr<double>(); 809 810 const double ra = dat[0]*M_PI/12; 811 const double dec = dat[1]*M_PI/180; 812 const double off = dat[2]*M_PI/180; 813 const double dir = dat[3]*M_PI/180; 814 815 const double cosdir = cos(dir); 816 const double sindir = sin(dir); 817 const double cosoff = cos(off); 818 const double sinoff = sin(off); 819 const double cosdec = cos(dec); 820 const double sindec = sin(dec); 821 822 if (off==0) 823 { 824 const array<double, 6> dim = {{ ra, dec, ra, dec, 0, 0 }}; 825 fDrive.UpdateSource(dim); 826 827 string command = "RADEC "; 828 command += AngleToStr(dat[0]) + ' ' + AngleToStr(dat[1]); 829 return SendCommand(command, false); 830 } 831 832 const double costheta = cosdec*cosoff + sindec*sinoff*cosdir; 833 if (costheta >= 1) 834 { 835 T::Error("cos(Zd) > 1"); 836 return T::GetCurrentState(); 837 } 838 839 const double sintheta = sqrt(1 - costheta*costheta); 840 841 const double cosdeltara = (cosoff - cosdec*costheta)/(sindec*sintheta); 842 const double sindeltara = sindir*sinoff/sintheta; 843 844 const double ndec = acos(costheta)*180/M_PI; 845 const double nra = (atan2(sindeltara, cosdeltara) + ra)*12/M_PI; 846 847 const array<double, 6> dim = {{ ra, dec, nra, ndec, off, dir }}; 848 fDrive.UpdateSource(dim); 849 850 string command = "RADEC "; 851 command += AngleToStr(nra) + ' ' + AngleToStr(ndec); 852 return SendCommand(command, false); 767 853 } 768 854 … … 776 862 ostringstream cmd; 777 863 cmd << "LEDS " << led[0] << " " << led[1]; 778 return SendCommand(cmd.str() );864 return SendCommand(cmd.str(), false); 779 865 } 780 866 … … 906 992 "|Dec[deg]:Declination"); 907 993 994 T::AddEvent("WOBBLE", "D:4", kStateArmed) // ->RADEC/GRB 995 (bind(&StateMachineDrive::Wobble, this, placeholders::_1)) 996 ("Move the telescope to the given wobble position around the given sky coordinates and start tracking them" 997 "|Ra[h]:Right ascension" 998 "|Dec[deg]:Declination" 999 "|Offset[deg]:Wobble offset" 1000 "|Angle[deg]:Wobble angle"); 1001 908 1002 T::AddEvent("MOON", kStateArmed) 909 (bind(&StateMachineDrive::SendCommand, this, "MOON 0 0" ))1003 (bind(&StateMachineDrive::SendCommand, this, "MOON 0 0", true)) 910 1004 ("Start tracking the moon"); 911 1005 T::AddEvent("VENUS", kStateArmed) 912 (bind(&StateMachineDrive::SendCommand, this, "CELEST 2 0 0" ))1006 (bind(&StateMachineDrive::SendCommand, this, "CELEST 2 0 0", true)) 913 1007 ("Start tracking Venus"); 914 1008 T::AddEvent("MARS", kStateArmed) 915 (bind(&StateMachineDrive::SendCommand, this, "CELEST 4 0 0" ))1009 (bind(&StateMachineDrive::SendCommand, this, "CELEST 4 0 0", true)) 916 1010 ("Start tracking Mars"); 917 1011 T::AddEvent("JUPITER", kStateArmed) 918 (bind(&StateMachineDrive::SendCommand, this, "CELEST 5 0 0" ))1012 (bind(&StateMachineDrive::SendCommand, this, "CELEST 5 0 0", true)) 919 1013 ("Start tracking Jupiter"); 920 1014 T::AddEvent("SATURN", kStateArmed) 921 (bind(&StateMachineDrive::SendCommand, this, "CELEST 6 0 0" ))1015 (bind(&StateMachineDrive::SendCommand, this, "CELEST 6 0 0", true)) 922 1016 ("Start tracking Saturn"); 923 1017 924 1018 T::AddEvent("TAKE_TPOINT") 925 (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0" ))1019 (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0", true)) 926 1020 ("Take a TPoint"); 927 1021 … … 933 1027 934 1028 T::AddEvent("LEDS_OFF") 935 (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0" ))1029 (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0", false)) 936 1030 ("Switch off TPoint LEDs"); 937 1031 938 1032 T::AddEvent("STOP") 939 (bind(&StateMachineDrive::SendCommand, this, "STOP!" ))1033 (bind(&StateMachineDrive::SendCommand, this, "STOP!", true)) 940 1034 ("Stop any kind of movement."); 941 1035
Note:
See TracChangeset
for help on using the changeset viewer.