Changeset 17004 for trunk


Ignore:
Timestamp:
08/12/13 17:36:32 (11 years ago)
Author:
tbretz
Message:
Changed the way the source position is updated. When a poitning command is issued, I send now QoS=1 and (if available) the pointing position, e.g. 'Park'. If a celestial object is tracked, I send the name plus QoS=1 with Ra/Dec=0.
File:
1 edited

Legend:

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

    r16887 r17004  
    7878
    7979public:
    80     virtual void UpdateSource()
     80    virtual void UpdateSource(const string & = "", bool = false)
    8181    {
    8282    }
     
    756756    }
    757757
    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);
    763765    }
    764766
     
    853855    }
    854856
    855     int SendCommand(const string &str, bool upd=true)
     857    int SendCommand(const string &str)
    856858    {
    857859        // This happens if fLastCommand should be send,
     
    868870        T::Message("Sending: "+str);
    869871
    870         if (upd)
    871             fDrive.UpdateSource();
    872 
    873872        return T::GetCurrentState();
    874873    }
    875874
     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
    876884    int Park()
    877885    {
    878         SendCommand("PREPS Park", false);
     886        SendCommand("PREPS Park");
     887        fDrive.UpdateSource("Park");
    879888
    880889        // FIXME: Go to locked state only when park position properly reached
     
    882891    }
    883892
     893    int SendStop()
     894    {
     895        SendCommand("STOP!");
     896        fDrive.UpdateSource();
     897
     898        return T::GetCurrentState();
     899    }
     900
    884901    int Resume()
    885902    {
     
    892909       
    893910        T::Info("Resume: "+fLastCommand);
    894         return SendCommand(fLastCommand, false);
     911        return SendCommand(fLastCommand);
    895912    }
    896913
     
    916933            fDrive.UpdateSource(dim);
    917934        }
     935        else
     936            fDrive.UpdateSource("", false);
     937
    918938
    919939        command += AngleToStr(dat[0]) + ' ' + AngleToStr(dat[1]);
    920         return SendCommand(command, type==kPoint);
     940        return SendCommand(command);
    921941    }
    922942
     
    944964            string command = "RADEC ";
    945965            command += AngleToStr(srcra) + ' ' + AngleToStr(srcdec);
    946             return SendCommand(command, false);
     966            return SendCommand(command);
    947967        }
    948968
     
    967987        string command = "RADEC ";
    968988        command += AngleToStr(nra) + ' ' + AngleToStr(ndec);
    969         return SendCommand(command, false);
     989        return SendCommand(command);
    970990    }
    971991
     
    11071127            src.erase(src.find_first_of(' '), 1);
    11081128
    1109         SendCommand("TPOIN "+src+" "+to_string(mag), false);;
     1129        SendCommand("TPOIN "+src+" "+to_string(mag));;
    11101130
    11111131        return T::GetCurrentState();
     
    11191139        const uint32_t *led = evt.Ptr<uint32_t>();
    11201140
    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]));
    11241142    }
    11251143
     
    13971415
    13981416        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"))
    14001418            ("Start tracking the moon");
    14011419        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"))
    14031421            ("Start tracking Venus");
    14041422        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"))
    14061424            ("Start tracking Mars");
    14071425        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"))
    14091427            ("Start tracking Jupiter");
    14101428        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"))
    14121430            ("Start tracking Saturn");
    14131431
     
    14171435
    14181436        T::AddEvent("TAKE_TPOINT")
    1419             (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0", false))
     1437            (bind(&StateMachineDrive::SendCommand, this, "TPOIN FACT 0"))
    14201438            ("Take a TPoint");
    14211439
     
    14331451
    14341452        T::AddEvent("LEDS_OFF")
    1435             (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0", false))
     1453            (bind(&StateMachineDrive::SendCommand, this, "LEDS 0 0"))
    14361454            ("Switch off TPoint LEDs");
    14371455
    14381456        T::AddEvent("STOP")
    1439             (bind(&StateMachineDrive::SendCommand, this, "STOP!", true))
     1457            (bind(&StateMachineDrive::SendStop, this))
    14401458            ("Stop any kind of movement.");
    14411459
Note: See TracChangeset for help on using the changeset viewer.