Changeset 14523


Ignore:
Timestamp:
10/24/12 21:56:06 (12 years ago)
Author:
tbretz
Message:
Added command discriptions - otherwise they are not displayed; the interlock arduino needs a GET-request, not a POST-request; the transmitted data needs to be URL-encoded.
File:
1 edited

Legend:

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

    r14522 r14523  
    160160    boost::asio::deadline_timer fKeepAlive;
    161161
    162     void PostRequest(string cmd, const string &args="")
    163     {
    164         cmd += " "+fSite+" HTTP/1.1\r\n"
    165             //"Connection: Keep-Alive\r\n"
    166             ;
    167 
    168         ostringstream msg;
    169         msg << args.length();
    170 
    171         cmd += "Content-Length: ";
    172         cmd += msg.str();
    173         cmd += "\r\n";
    174 
    175         if (args.length()>0)
    176             cmd += "\r\n" + args + "\r\n";
    177 
    178         cmd += "\r\n";
    179 
    180         //cout << "Post: " << cmd << endl;
    181         PostMessage(cmd);
    182     }
    183 
    184162    void HandleRequest(const bs::error_code &error)
    185163    {
     
    260238    void Request()
    261239    {
    262         PostRequest("POST", fNextCommand);
     240        string cmd = "GET " + fSite;
     241
     242        if (!fNextCommand.empty())
     243            cmd += "?" + fNextCommand;
     244
     245        cmd += " HTTP/1.1\r\n";
     246        cmd += "\r\n";
     247
     248        PostMessage(cmd);
     249
    263250        fNextCommand = "";
    264251
     
    393380
    394381        fLastCommand = Time();
    395         fPower.Post(evt.GetBool() ? "cam_on=" : "cam_off=");
     382        fPower.Post(evt.GetBool() ? "cam_on=Camera+ON" : "cam_off=Camera+OFF");
    396383        return T::GetCurrentState();
    397384    }
     
    400387    {
    401388        fLastCommand = Time();
    402         fPower.Post("dt=");
     389        fPower.Post("dt=Drive+ON%2FOFF");
    403390        return T::GetCurrentState();
    404391
     
    463450
    464451        // Verbosity commands
    465         T::AddEvent("SET_VERBOSE", "B")
     452        T::AddEvent("SET_VERBOSE", "B:1")
    466453            (bind(&StateMachinePowerControl::SetVerbosity, this, placeholders::_1))
    467             ("set verbosity state"
     454            ("Set verbosity state"
    468455             "|verbosity[bool]:disable or enable verbosity for interpreted data (yes/no)");
    469456
    470         T::AddEvent("SET_DEBUG_RX", "B")
     457        T::AddEvent("SET_DEBUG_RX", "B:1")
    471458            (bind(&StateMachinePowerControl::SetDebugRx, this, placeholders::_1))
    472             ("set debux-rx state"
     459            ("Set debux-rx state"
    473460             "|debug[bool]:dump received text and parsed text to console (yes/no)");
    474461
    475         T::AddEvent("CAMERA_POWER", "B")
    476             (bind(&StateMachinePowerControl::SetCameraPower, this, placeholders::_1));
     462        T::AddEvent("CAMERA_POWER", "B:1")
     463            (bind(&StateMachinePowerControl::SetCameraPower, this, placeholders::_1))
     464            ("Switch camera power"
     465             "|power[bool]:Switch camera power 'on' or 'off'");
    477466
    478467        T::AddEvent("TOGGLE_DRIVE")
    479             (bind(&StateMachinePowerControl::ToggleDrive, this));
     468            (bind(&StateMachinePowerControl::ToggleDrive, this))
     469            ("Toggle drive power");
    480470
    481471        T::AddEvent("POST", "C")
Note: See TracChangeset for help on using the changeset viewer.