Changeset 12309
- Timestamp:
- 10/28/11 05:36:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/drivectrl.cc
r12252 r12309 55 55 struct DimTPoint 56 56 { 57 double fNominalAlt;58 double fNominalAz;59 60 double fCurrentAlt;61 double fCurrentAz;62 63 double fDevZd;64 double fDevAz;65 66 57 double fRa; 67 58 double fDec; 68 59 60 double fNominalZd; 61 double fNominalAz; 62 63 double fPointingZd; 64 double fPointingAz; 65 66 double fFeedbackZd; 67 double fFeedbackAz; 68 69 uint16_t fNumLeds; 70 uint16_t fNumRings; 71 69 72 double fCenterX; 70 73 double fCenterY; … … 75 78 double fStarMag; 76 79 77 double fBrightness;78 80 double fRealMag; 79 80 uint16_t fNumLeds;81 uint16_t fNumRings;82 uint16_t fNumStars;83 uint16_t fNumCorrelated;84 81 85 82 } __attribute__((__packed__)); … … 131 128 } 132 129 133 virtual void UpdateTPoint(const Time &, const Drive::DimTPoint & )130 virtual void UpdateTPoint(const Time &, const Drive::DimTPoint &, const string &) 134 131 { 135 132 } … … 260 257 const Time t2 = ReadTime(stream); 261 258 259 char type; 260 stream >> type; 261 if (type != 'T') 262 return; 263 262 264 double az1, alt1, az2, alt2, ra, dec, dzd, daz; 263 265 stream >> az1 >> alt1 >> az2 >> alt2 >> ra >> dec >> dzd >> daz; … … 281 283 Drive::DimTPoint tpoint; 282 284 283 tpoint.fNominalAz = az1;284 tpoint.fNominalAlt = alt1;285 tpoint.fCurrentAz = az2;286 tpoint.fCurrentAlt = alt2;287 tpoint.fDevAz = daz;288 tpoint.fDevZd = dzd;289 285 tpoint.fRa = ra; 290 286 tpoint.fDec = dec; 287 288 tpoint.fNominalZd = 90-alt1-dzd; 289 tpoint.fNominalAz = 90-az1 +daz; 290 291 tpoint.fPointingZd = 90-alt1; 292 tpoint.fPointingAz = az1; 293 294 tpoint.fFeedbackZd = 90-alt2; 295 tpoint.fFeedbackAz = az2; 296 297 tpoint.fNumLeds = nled; 298 tpoint.fNumRings = nring; 291 299 292 300 tpoint.fCenterX = cx; … … 298 306 tpoint.fStarMag = smag; 299 307 300 tpoint.fBrightness = bright; 301 302 tpoint.fNumCorrelated = ncor; 303 tpoint.fNumLeds = nled; 304 tpoint.fNumRings = nring; 305 tpoint.fNumStars = nstar; 306 307 tpoint.fRealMag = mag; 308 309 UpdteTPoint(t1, tpoint); 308 tpoint.fRealMag = mag; 309 310 UpdateTPoint(t1, tpoint, name); 310 311 311 312 return; … … 383 384 ra, dec, ha, 384 385 zd1, az1, 385 zd_err , az_err386 zd_err/3600, az_err/3600 386 387 }}; 387 388 UpdateTracking(Time(mjd), track); … … 533 534 DimDescribedService fDimPointing; 534 535 DimDescribedService fDimTracking; 535 536 template<size_t N> 537 void Update(DimDescribedService &svc, const Time &t, const array<double, N> &arr) const 538 { 539 svc.setData(arr); 540 svc.Update(t); 541 } 536 DimDescribedService fDimTPoint; 542 537 543 538 virtual void UpdatePointing(const Time &t, 544 539 const array<double, 2> &arr) 545 540 { 546 Update(fDimPointing, t, arr); 541 fDimPointing.setData(arr); 542 fDimPointing.Update(t); 547 543 } 548 544 … … 550 546 const array<double, 7> &arr) 551 547 { 552 Update(fDimTracking, t, arr); 548 fDimTracking.setData(arr); 549 fDimTracking.Update(t); 550 } 551 virtual void UpdateTPoint(const Time &t, 552 const Drive::DimTPoint &data, 553 const string &name) 554 { 555 vector<char> dim(sizeof(data)+name.length()+1); 556 memcpy(dim.data(), &data, sizeof(data)); 557 memcpy(dim.data()+sizeof(data), name.c_str(), name.length()+1); 558 559 fDimTPoint.setData(dim); 560 fDimTPoint.Update(t); 553 561 } 554 562 … … 556 564 ConnectionDimDrive(ba::io_service& ioservice, MessageImp &imp) : 557 565 ConnectionDrive(ioservice, imp), 558 fDimPointing("FTM_CONTROL/POINTING_POSITION", "D:2", ""), 559 fDimTracking("FTM_CONTROL/TRACKING_POSITION", "D:7", "") 566 fDimPointing("DRIVE_CONTROL/POINTING_POSITION", "D:1;D:1", 567 "|Zd[deg]:Zenith distance (encoder readout)" 568 "|Az[deg]:Azimuth angle (encoder readout)"), 569 fDimTracking("DRIVE_CONTROL/TRACKING_POSITION", "D:1;D:1;D:1;D:1;D:1;D:1;D:1", 570 "|Ra[h]:Command right ascension" 571 "|Dec[deg]:Command declination" 572 "|Ha[h]:Corresponding hour angle" 573 "|Zd[deg]:Nominal zenith distance" 574 "|Az[deg]:Nominal azimuth angle" 575 "|dZd[deg]:Control deviation Zd" 576 "|dAz[deg]:Control deviation Az"), 577 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", 578 "|Ra[h]:Command right ascension" 579 "|Dec[deg]:Command declination" 580 "|Zd_nom[deg]:Nominal zenith distance" 581 "|Az_nom[deg]:Nominal azimuth angle" 582 "|Zd_cur[deg]:Current zenith distance (calculated from image)" 583 "|Az_cur[deg]:Current azimuth angle (calculated from image)" 584 "|Zd_enc[deg]:Feedback zenith axis (from encoder)" 585 "|Az_enc[deg]:Feedback azimuth angle (from encoder)" 586 "|N_leds[cnt]:Number of detected LEDs" 587 "|N_rings[cnt]:Number of rings used to calculate the camera center" 588 "|Xc[pix]:X position of center in CCD camera frame" 589 "|Yc[pix]:Y position of center in CCD camera frame" 590 "|Ic[au]:Average intensity (LED intensity weighted with their frequency of occurance in the calculation)" 591 "|Xs[pix]:X position of start in CCD camera frame" 592 "|Ys[pix]:Y position of star in CCD camera frame" 593 "|Ms[mag]:Artifical magnitude of star (calculated form image))" 594 "|Mc[mag]:Catalog magnitude of star") 595 560 596 { 561 597 } … … 746 782 // State names 747 783 AddStateName(kStateDisconnected, "Disconnected", 748 " ");784 "No connection to cosy"); 749 785 750 786 AddStateName(kStateConnected, "Connected", 751 " ");787 "Cosy connected, drive stopped"); 752 788 753 789 AddStateName(kStateArmed, "Armed", 754 " ");790 "Cosy armed, drive stopped"); 755 791 756 792 AddStateName(kStateMoving, "Moving", 757 " ");793 "Telescope moving"); 758 794 759 795 AddStateName(kStateTracking, "Tracking", 760 " ");796 "Telescope tracking"); 761 797 762 798 // kStateIdle … … 787 823 T::AddEvent("MOVE_TO", "D:2", kStateArmed) // ->ZDAZ 788 824 (bind(&StateMachineDrive::SendCoordinates, this, placeholders::_1, kPoint)) 789 (" "790 "| zd[deg]:"791 "| az[deg]:");825 ("Move the telescope to the given local coordinates" 826 "|Zd[deg]:Zenith distance" 827 "|Az[deg]:Azimuth"); 792 828 793 829 T::AddEvent("TRACK", "D:2", kStateArmed) // ->RADEC/GRB 794 830 (bind(&StateMachineDrive::SendCoordinates, this, placeholders::_1, kTrackSlow)) 795 (" "796 "| ra[h]:"797 "| dec[deg]:");831 ("Move the telescope to the given sky coordinates and start tracking them" 832 "|Ra[h]:Right ascension" 833 "|Dec[deg]:Declination"); 798 834 799 835 T::AddEvent("MOON", kStateArmed) 800 836 (bind(&StateMachineDrive::SendCommand, this, "MOON 0 0")) 801 (" ");837 ("Start tracking the moon"); 802 838 T::AddEvent("VENUS", kStateArmed) 803 839 (bind(&StateMachineDrive::SendCommand, this, "CELEST 2 0 0")) 804 (" ");840 ("Start tracking Venus"); 805 841 T::AddEvent("MARS", kStateArmed) 806 842 (bind(&StateMachineDrive::SendCommand, this, "CELEST 4 0 0")) 807 (" ");843 ("Start tracking Mars"); 808 844 T::AddEvent("JUPITER", kStateArmed) 809 845 (bind(&StateMachineDrive::SendCommand, this, "CELEST 5 0 0")) 810 (" ");846 ("Start tracking Jupiter"); 811 847 T::AddEvent("SATURN", kStateArmed) 812 848 (bind(&StateMachineDrive::SendCommand, this, "CELEST 6 0 0")) 813 (" ");814 815 T::AddEvent("T POINT")849 ("Start tracking Saturn"); 850 851 T::AddEvent("TAKE_TPOINT") 816 852 (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0")) 817 (" ");853 ("Take a TPoint"); 818 854 819 855 T::AddEvent("SET_LED_BRIGHTNESS", "I:2") 820 856 (bind(&StateMachineDrive::SetLedBrightness, this, placeholders::_1)) 821 (""); 857 ("Set the LED brightness of the top and bottom leds" 858 "|top[au]:Allowed range 0-32767 for top LEDs" 859 "|bot[au]:Allowed range 0-32767 for bottom LEDs"); 822 860 823 861 T::AddEvent("LEDS_OFF") 824 862 (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0")) 825 (" ");863 ("Switch off TPoint LEDs"); 826 864 827 865 T::AddEvent("STOP") 828 866 (bind(&StateMachineDrive::SendCommand, this, "STOP!")) 829 (" ");830 831 T::AddEvent("ARM", kStateConnected)832 (bind(&StateMachineDrive::SendCommand, this, "ARM lock"))833 ("");867 ("Stop any kind of movement."); 868 869 // T::AddEvent("ARM", kStateConnected) 870 // (bind(&StateMachineDrive::SendCommand, this, "ARM lock")) 871 // (""); 834 872 835 873 … … 872 910 #include "Main.h" 873 911 874 /*875 void RunThread(StateMachineImp *io_service)876 {877 // This is necessary so that the StateMachien Thread can signal the878 // Readline to exit879 io_service->Run();880 Readline::Stop();881 }882 */883 /*884 template<class S, class T>885 int RunDim(Configuration &conf)886 {887 WindowLog wout;888 889 ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);890 891 if (conf.Has("log"))892 if (!wout.OpenLogFile(conf.Get<string>("log")))893 wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;894 895 // Start io_service.Run to use the StateMachineImp::Run() loop896 // Start io_service.run to only use the commandHandler command detaching897 StateMachineDrive<S, T> io_service(wout);898 if (!io_service.EvalConfiguration(conf))899 return -1;900 901 io_service.Run();902 903 return 0;904 }905 */906 912 907 913 template<class T, class S, class R> 908 914 int RunShell(Configuration &conf) 909 915 { 910 return Main<T, StateMachineDrive<S, R>>(conf); 911 /* 912 static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1); 913 914 WindowLog &win = shell.GetStreamIn(); 915 WindowLog &wout = shell.GetStreamOut(); 916 917 if (conf.Has("log")) 918 if (!wout.OpenLogFile(conf.Get<string>("log"))) 919 win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl; 920 921 StateMachineDrive<S, R> io_service(wout); 922 if (!io_service.EvalConfiguration(conf)) 923 return -1; 924 925 shell.SetReceiver(io_service); 926 927 boost::thread t(bind(RunThread, &io_service)); 928 // boost::thread t(bind(&StateMachineDrive<S>::Run, &io_service)); 929 930 if (conf.Has("cmd")) 931 { 932 const vector<string> v = conf.Get<vector<string>>("cmd"); 933 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 934 shell.ProcessLine(*it); 935 } 936 937 if (conf.Has("exec")) 938 { 939 const vector<string> v = conf.Get<vector<string>>("exec"); 940 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 941 shell.Execute(*it); 942 } 943 944 if (conf.Get<bool>("quit")) 945 shell.Stop(); 946 947 shell.Run(); // Run the shell 948 io_service.Stop(); // Signal Loop-thread to stop 949 // io_service.Close(); // Obsolete, done by the destructor 950 951 // Wait until the StateMachine has finished its thread 952 // before returning and destroying the dim objects which might 953 // still be in use. 954 t.join(); 955 956 return 0; 957 */ 916 return Main::execute<T, StateMachineDrive<S, R>>(conf); 958 917 } 959 918 … … 964 923 ("no-dim,d", po_switch(), "Disable dim services") 965 924 ("addr,a", var<string>("localhost:7404"), "Network address of FTM") 966 ("quiet,q", po_bool( ), "Disable printing contents of all received messages (except dynamic data) in clear text.")925 ("quiet,q", po_bool(true), "Disable printing contents of all received messages (except dynamic data) in clear text.") 967 926 ; 968 927 … … 996 955 void PrintHelp() 997 956 { 957 // Main::PrintHelp<StateMachineFTM<StateMachine, ConnectionFTM>>(); 958 998 959 /* Additional help text which is printed after the configuration 999 960 options goes here */
Note:
See TracChangeset
for help on using the changeset viewer.