Changeset 12309 for trunk/FACT++


Ignore:
Timestamp:
10/28/11 05:36:07 (13 years ago)
Author:
tbretz
Message:
First woring and tested version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/drivectrl.cc

    r12252 r12309  
    5555    struct DimTPoint
    5656    {
    57         double fNominalAlt;
    58         double fNominalAz;
    59 
    60         double fCurrentAlt;
    61         double fCurrentAz;
    62 
    63         double fDevZd;
    64         double fDevAz;
    65 
    6657        double fRa;
    6758        double fDec;
    6859
     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 
    6972        double fCenterX;
    7073        double fCenterY;
     
    7578        double fStarMag;
    7679
    77         double fBrightness;
    7880        double fRealMag;
    79 
    80         uint16_t fNumLeds;
    81         uint16_t fNumRings;
    82         uint16_t fNumStars;
    83         uint16_t fNumCorrelated;
    8481
    8582    } __attribute__((__packed__));
     
    131128    }
    132129
    133     virtual void UpdateTPoint(const Time &, const Drive::DimTPoint &)
     130    virtual void UpdateTPoint(const Time &, const Drive::DimTPoint &, const string &)
    134131    {
    135132    }
     
    260257            const Time t2 = ReadTime(stream);
    261258
     259            char type;
     260            stream >> type;
     261            if (type != 'T')
     262                return;
     263
    262264            double az1, alt1, az2, alt2, ra, dec, dzd, daz;
    263265            stream >> az1 >> alt1 >> az2 >> alt2 >> ra >> dec >> dzd >> daz;
     
    281283            Drive::DimTPoint tpoint;
    282284
    283             tpoint.fNominalAz  = az1;
    284             tpoint.fNominalAlt = alt1;
    285             tpoint.fCurrentAz  = az2;
    286             tpoint.fCurrentAlt = alt2;
    287             tpoint.fDevAz      = daz;
    288             tpoint.fDevZd      = dzd;
    289285            tpoint.fRa         = ra;
    290286            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;
    291299
    292300            tpoint.fCenterX    = cx;
     
    298306            tpoint.fStarMag    = smag;
    299307
    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);
    310311
    311312            return;
     
    383384                ra, dec, ha,
    384385                zd1, az1,
    385                 zd_err, az_err
     386                zd_err/3600, az_err/3600
    386387            }};
    387388            UpdateTracking(Time(mjd), track);
     
    533534    DimDescribedService fDimPointing;
    534535    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;
    542537
    543538    virtual void UpdatePointing(const Time &t,
    544539                                const array<double, 2> &arr)
    545540    {
    546         Update(fDimPointing, t, arr);
     541        fDimPointing.setData(arr);
     542        fDimPointing.Update(t);
    547543    }
    548544
     
    550546                                const array<double, 7> &arr)
    551547    {
    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);
    553561    }
    554562
     
    556564    ConnectionDimDrive(ba::io_service& ioservice, MessageImp &imp) :
    557565        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
    560596    {
    561597    }
     
    746782        // State names
    747783        AddStateName(kStateDisconnected, "Disconnected",
    748                      "");
     784                     "No connection to cosy");
    749785
    750786        AddStateName(kStateConnected, "Connected",
    751                      "");
     787                     "Cosy connected, drive stopped");
    752788
    753789        AddStateName(kStateArmed, "Armed",
    754                      "");
     790                     "Cosy armed, drive stopped");
    755791
    756792        AddStateName(kStateMoving, "Moving",
    757                      "");
     793                     "Telescope moving");
    758794
    759795        AddStateName(kStateTracking, "Tracking",
    760                      "");
     796                     "Telescope tracking");
    761797
    762798        // kStateIdle
     
    787823        T::AddEvent("MOVE_TO", "D:2", kStateArmed)  // ->ZDAZ
    788824            (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");
    792828
    793829        T::AddEvent("TRACK", "D:2", kStateArmed)   // ->RADEC/GRB
    794830            (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");
    798834
    799835        T::AddEvent("MOON", kStateArmed)
    800836            (bind(&StateMachineDrive::SendCommand, this, "MOON 0 0"))
    801             ("");
     837            ("Start tracking the moon");
    802838        T::AddEvent("VENUS", kStateArmed)
    803839            (bind(&StateMachineDrive::SendCommand, this, "CELEST 2 0 0"))
    804             ("");
     840            ("Start tracking Venus");
    805841        T::AddEvent("MARS", kStateArmed)
    806842            (bind(&StateMachineDrive::SendCommand, this, "CELEST 4 0 0"))
    807             ("");
     843            ("Start tracking Mars");
    808844        T::AddEvent("JUPITER", kStateArmed)
    809845            (bind(&StateMachineDrive::SendCommand, this, "CELEST 5 0 0"))
    810             ("");
     846            ("Start tracking Jupiter");
    811847        T::AddEvent("SATURN", kStateArmed)
    812848            (bind(&StateMachineDrive::SendCommand, this, "CELEST 6 0 0"))
    813             ("");
    814 
    815         T::AddEvent("TPOINT")
     849            ("Start tracking Saturn");
     850
     851        T::AddEvent("TAKE_TPOINT")
    816852            (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0"))
    817             ("");
     853            ("Take a TPoint");
    818854
    819855        T::AddEvent("SET_LED_BRIGHTNESS", "I:2")
    820856            (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");
    822860
    823861        T::AddEvent("LEDS_OFF")
    824862            (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0"))
    825             ("");
     863            ("Switch off TPoint LEDs");
    826864
    827865        T::AddEvent("STOP")
    828866            (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//            ("");
    834872
    835873
     
    872910#include "Main.h"
    873911
    874 /*
    875 void RunThread(StateMachineImp *io_service)
    876 {
    877     // This is necessary so that the StateMachien Thread can signal the
    878     // Readline to exit
    879     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() loop
    896     // Start io_service.run to only use the commandHandler command detaching
    897     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 */
    906912
    907913template<class T, class S, class R>
    908914int RunShell(Configuration &conf)
    909915{
    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);
    958917}
    959918
     
    964923        ("no-dim,d",  po_switch(),    "Disable dim services")
    965924        ("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.")
    967926        ;
    968927
     
    996955void PrintHelp()
    997956{
     957//    Main::PrintHelp<StateMachineFTM<StateMachine, ConnectionFTM>>();
     958
    998959    /* Additional help text which is printed after the configuration
    999960     options goes here */
Note: See TracChangeset for help on using the changeset viewer.