Changeset 14316


Ignore:
Timestamp:
08/06/12 22:16:25 (12 years ago)
Author:
neise
Message:
step by step ... going to test it
File:
1 edited

Legend:

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

    r14315 r14316  
    3131    ofstream fDumpStream;
    3232    int fState;
     33    float fMeasuredVoltage;
     34    float fMeasuredCurrent;
    3335   
    3436
     
    7274
    7375        fCheckStatusTimer.expires_from_now(boost::posix_time::seconds(60));
    74         fCheckStatusTimer.async_wait(boost::bind(&ConnectionWeather::HandleRequest,
     76        fCheckStatusTimer.async_wait(boost::bind(&ConnectionAgilent::HandleRequest,
    7577                                          this, bapla::error));
    7678    }
     
    101103        // may have moved the deadline before this actor had a chance
    102104        // to run.
    103         if (fKeepAlive.expires_at() > ba::deadline_timer::traits_type::now())
     105        if (fCheckStatusTimer.expires_at() > ba::deadline_timer::traits_type::now())
    104106            return;
    105107
     
    112114    void ReceivedStatusHandler(const bs::error_code& err, size_t bytes_received, int /*type*/)
    113115    {
    114         float measured_voltage;
    115         float measured_current;
    116116       
    117117        // Do not schedule a new read if the connection failed.
     
    137137        if (fIsVerbose)
    138138           Out() << kBold << "Received (" << bytes_received << " bytes):" << endl;
     139        /*
    139140        if (fDump)
    140141        {
     
    143144            Dump(msg.str());
    144145        }
    145 
     146*/
    146147        istream is(&fBuffer);
    147148        // data should contain two floats:
     
    162163        {
    163164            // this should be a float containing the measured voltage
    164             is >> measured_voltage;
    165             data.push_back(measured_voltage);
    166             Out() << "voltage: " << measured_voltage << endl;
     165            is >> fMeasuredVoltage;
     166            data.push_back(fMeasuredVoltage);
     167            Out() << "voltage: " << fMeasuredVoltage << endl;
    167168        }
    168169        else if (fLineCounter >= 3)
    169170        {
    170171            // this should be a float containing the measured voltage
    171             is >> measured_current;
    172             data.push_back(measured_current);
    173             Out() << "current: " << measured_current << endl;
     172            is >> fMeasuredCurrent;
     173            data.push_back(fMeasuredCurrent);
     174            Out() << "current: " << fMeasuredCurrent << endl;
    174175            fLineCounter = 0;
    175             fSendRequest = true;
    176         }
    177        
    178         if (measured_voltage > 1.0)
     176        }
     177       
     178        // read the buffer empty ...
     179        // FIXME: I surely misunderstand that damn fBuffer thing.
     180        // I thought it should be emtpy by now...
     181        string buffer;
     182        while (getline(is,buffer, '\n'))
     183        {
     184            buffer = Tools::Trim(buffer);
     185            if (buffer.empty()) continue;
     186        }
     187
     188
     189        if (fMeasuredVoltage > 1.0)
    179190        {
    180191            fState = State::kVoltage_On;
     
    206217        fState = State::kConnected;
    207218        Start_async_read_until();
    208         PostStatusRequest();
     219        RequestStatus();
    209220       
    210221        fLineCounter = 0;
     
    216227    ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
    217228        fIsVerbose(true),
    218         fCheckStatusTimer(ioservice),
    219         fDump(true)
     229        fDump(true),
     230        fCheckStatusTimer(ioservice)
    220231    {
    221232        SetLogStream(&imp);
    222233        fState = State::kDisconnected;
     234        fMeasuredVoltage=-1;
     235        fMeasuredCurrent=-1;
    223236    }
    224237
     
    335348       
    336349        if ( fAgilent.IsConnected() )
    337             return fWeather.GetState();
     350            return fAgilent.GetState();
    338351        else
    339352            return State::kDisconnected;
     
    381394    }
    382395
    383     int Identify()
    384     {
    385         fAgilent.Identify();
    386         return T::GetCurrentState();
    387     }
    388396
    389397public:
     
    437445            ("set output on or off"
    438446             "|[state][boolean]: output setting (1;0 or 'on';'off')");
    439 
    440         T::AddEvent("IDENTIFY", State::kConnected)
    441             (bind(&StateMachineAgilent::Identify, this))
    442             ("Request Agilent ID");
    443447
    444448        fAgilent.StartConnect();
Note: See TracChangeset for help on using the changeset viewer.