Index: /trunk/FACT++/src/HeadersAgilent.h
===================================================================
--- /trunk/FACT++/src/HeadersAgilent.h	(revision 14536)
+++ /trunk/FACT++/src/HeadersAgilent.h	(revision 14537)
@@ -9,9 +9,22 @@
         {
             kDisconnected = 1,
-            kConnected    = 2,
-            kVoltage_On   = 3,
-            kVoltage_Off  = 4,
+            kConnected,
+            kVoltageOff,
+            kVoltageLow,
+            kVoltageOn,
+            kVoltageHigh,
         };
     }
+
+    struct Data
+    {
+        float fVoltageSet;
+        float fVoltageMeasured;
+
+        float fCurrentLimit;
+        float fCurrentMeasured;
+
+        Data() : fVoltageSet(-1), fVoltageMeasured(-1), fCurrentLimit(-1), fCurrentMeasured(-1) { }
+    };
 }
 
Index: /trunk/FACT++/src/agilentctrl.cc
===================================================================
--- /trunk/FACT++/src/agilentctrl.cc	(revision 14536)
+++ /trunk/FACT++/src/agilentctrl.cc	(revision 14537)
@@ -3,11 +3,8 @@
 #include "Dim.h"
 #include "Event.h"
-#include "Shell.h"
 #include "StateMachineDim.h"
 #include "Connection.h"
 #include "LocalControl.h"
 #include "Configuration.h"
-#include "Console.h"
-#include "Converter.h"
 
 #include "tools.h"
@@ -17,5 +14,5 @@
 namespace ba    = boost::asio;
 namespace bs    = boost::system;
-namespace bapla = ba::placeholders;
+namespace dummy = ba::placeholders;
 
 using namespace std;
@@ -26,304 +23,291 @@
 class ConnectionAgilent : public Connection
 {
+    bool fIsVerbose;
+    bool fDebugRx;
+
+    uint16_t fInterval;
+
+    boost::asio::deadline_timer fTimeout;
+    boost::asio::deadline_timer fTimeoutPowerCycle;
     boost::asio::streambuf fBuffer;
-    bool fIsVerbose;
-    bool fDump;
-    ofstream fDumpStream;
-    int fState;
-    float fMeasuredVoltage;
-    float fMeasuredCurrent;
-    
+
+    Data fData;
+
+    Time fLastReceived;
+    Time fLastCommand;
 
 protected:
 
-    virtual void UpdateDim(const vector<float> &)
-    {
-    }
-
-    void Dump(const string &str)
-    {
-        if (!fDumpStream.is_open())
-        {
-            fDumpStream.open("socket_dump-agilent.txt", ios::app);
-            if (!fDumpStream)
+    virtual void UpdateDim(const Data &)
+    {
+    }
+
+    void RequestStatus()
+    {
+        if (IsConnected())
+            PostMessage(string("*IDN?\nvolt?\nmeas:volt?\nmeas:curr?\ncurr?\n"));
+
+        fTimeout.expires_from_now(boost::posix_time::seconds(fInterval));
+        fTimeout.async_wait(boost::bind(&ConnectionAgilent::HandleStatusTimer,
+                                        this, dummy::error));
+    }
+
+
+    void HandleStatusTimer(const bs::error_code &error)
+    {
+        // 125: Operation canceled (bs::error_code(125, bs::system_category))
+        if (error && error!=ba::error::basic_errors::operation_aborted)
+        {
+            ostringstream str;
+            str << "Status request timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl;
+            Error(str);
+
+            PostClose(false);
+            return;
+        }
+
+        if (!is_open())
+        {
+            // For example: Here we could schedule a new accept if we
+            // would not want to allow two connections at the same time.
+            PostClose(true);
+            return;
+        }
+
+        // Check whether the deadline has passed. We compare the deadline
+        // against the current time since a new asynchronous operation
+        // may have moved the deadline before this actor had a chance
+        // to run.
+        if (fTimeout.expires_at() > ba::deadline_timer::traits_type::now())
+            return;
+
+        RequestStatus();
+    }
+
+    void HandlePowerCycle(const bs::error_code &error)
+    {
+        // 125: Operation canceled (bs::error_code(125, bs::system_category))
+        if (error && error!=ba::error::basic_errors::operation_aborted)
+        {
+            ostringstream str;
+            str << "Power cycle timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl;
+            Error(str);
+
+            PostClose(false);
+            return;
+        }
+
+        if (!is_open())
+        {
+            // For example: Here we could schedule a new accept if we
+            // would not want to allow two connections at the same time.
+            PostClose(true);
+            return;
+        }
+
+        // Check whether the deadline has passed. We compare the deadline
+        // against the current time since a new asynchronous operation
+        // may have moved the deadline before this actor had a chance
+        // to run.
+        if (fTimeout.expires_at() > ba::deadline_timer::traits_type::now())
+            return;
+
+        SetPower(true);
+    }
+
+private:
+    void StartRead(int line=0)
+    {
+        ba::async_read_until(*this, fBuffer, "\n",
+                             boost::bind(&ConnectionAgilent::HandleReceivedData, this,
+                                         dummy::error, dummy::bytes_transferred, line+1));
+    }
+
+    void HandleReceivedData(const bs::error_code& err, size_t bytes_received, int line)
+    {
+
+        // Do not schedule a new read if the connection failed.
+        if (bytes_received==0 || err)
+        {
+            if (err==ba::error::eof)
+                Warn("Connection closed by remote host (FTM).");
+
+            // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
+            // 125: Operation canceled
+            if (err && err!=ba::error::eof &&                     // Connection closed by remote host
+                err!=ba::error::basic_errors::not_connected &&    // Connection closed by remote host
+                err!=ba::error::basic_errors::operation_aborted)  // Connection closed by us
             {
-                //ostringstream str;
-                //str << "Open file " << name << ": " << strerror(errno) << " (errno=" << errno << ")";
-                //Error(str);
-
+                ostringstream str;
+                str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
+                Error(str);
+            }
+            PostClose(err!=ba::error::basic_errors::operation_aborted);
+            return;
+        }
+
+
+        if (fDebugRx)
+        {
+            Out() << kBold << "Received (" << bytes_received << ", " << fBuffer.size() << " bytes):" << endl;
+            Out() << "-----\n" << string(ba::buffer_cast<const char*>(fBuffer.data()), bytes_received) << "-----\n";
+        }
+
+        istream is(&fBuffer);
+
+        string str;
+        getline(is, str, '\n');
+
+        try
+        {
+            switch (line)
+            {
+            case 1:  Out() << "ID: " << str << endl; break;
+            case 2:  fData.fVoltageSet      = stof(str); break;
+            case 3:  fData.fVoltageMeasured = stof(str); break;
+            case 4:  fData.fCurrentMeasured = stof(str); break;
+            case 5:  fData.fCurrentLimit    = stof(str); break;
+            default:
                 return;
             }
         }
-
-        fDumpStream << str << endl;
-    }
-    
-boost::asio::deadline_timer fCheckStatusTimer;
-boost::asio::deadline_timer fAntiFloddingTimer;
-
-void PostStatusRequest()
-{
-    if (IsConnected())
-    {
-        PostMessage(string("*IDN?\n"));
-        PostMessage(string("meas:volt?\n"));
-        PostMessage(string("meas:curr?\n"));
-    }
-}
-
-
-void RequestStatus()
-{
-    PostStatusRequest();
-
-    fCheckStatusTimer.expires_from_now(boost::posix_time::seconds(60));
-    fCheckStatusTimer.async_wait(boost::bind(&ConnectionAgilent::HandleRequest,
-                                      this, bapla::error));
-}
-
-void HandleRequest(const bs::error_code &error)
-{
-    // 125: Operation canceled (bs::error_code(125, bs::system_category))
-    if (error && error!=ba::error::basic_errors::operation_aborted)
-    {
-        ostringstream str;
-        str << "Write timeout of " << URL() << ": " << error.message() << " (" << error << ")";// << endl;
-        Error(str);
-
-        PostClose(false);
-        return;
-    }
-
-    if (!is_open())
-    {
-        // For example: Here we could schedule a new accept if we
-        // would not want to allow two connections at the same time.
-        PostClose(true);
-        return;
-    }
-
-    // Check whether the deadline has passed. We compare the deadline
-    // against the current time since a new asynchronous operation
-    // may have moved the deadline before this actor had a chance
-    // to run.
-    if (fCheckStatusTimer.expires_at() > ba::deadline_timer::traits_type::now())
-        return;
-
-    RequestStatus();
-}
+        catch (const exception &e)
+        {
+            Error("String conversion failed for '"+str+" ("+e.what()+")");
+            return;
+        }
+
+        if (line==5)
+        {
+            if (fIsVerbose)
+            {
+                Out() << "Voltage: " << fData.fVoltageMeasured << "V/" << fData.fVoltageSet   << "V\n";
+                Out() << "Current: " << fData.fCurrentMeasured << "A/" << fData.fCurrentLimit << "A\n" << endl;
+            }
+
+            UpdateDim(fData);
+
+            fLastReceived = Time();
+
+            line = 0;
+
+        }
+
+        StartRead(line);
+    }
+
+
+    // This is called when a connection was established
+    void ConnectionEstablished()
+    {
+        fBuffer.prepare(1000);
+
+        StartRead();
+        RequestStatus();
+    }
+
+public:
+
+    ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
+        fIsVerbose(true), fDebugRx(false), fTimeout(ioservice), fTimeoutPowerCycle(ioservice)
+    {
+        SetLogStream(&imp);
+    }
+
+    void SetVerbose(bool b)
+    {
+        fIsVerbose = b;
+    }
+
+    void SetDebugRx(bool b)
+    {
+        fDebugRx = b;
+    }
+
+    void SetInterval(uint16_t i)
+    {
+        fInterval = i;
+    }
+
+    bool SetPower(bool on)
+    {
+        if (!IsConnected())
+            return false;
+
+        if (fLastCommand+boost::posix_time::seconds(59)>Time())
+        {
+            Error("Last power command within the last 59 seconds... ignored.");
+            return false;
+        }
+
+        PostMessage("outp "+string(on?"on":"off")+"\n*IDN?\nvolt?\nmeas:volt?\nmeas:curr?\ncurr?\n");
+        fLastCommand = Time();
+
+        // Stop any pending power cycling
+        fTimeoutPowerCycle.cancel();
+
+        return true;
+    }
+
+    void PowerCycle(uint16_t seconds)
+    {
+        if (!SetPower(false))
+            return;
+
+        fTimeoutPowerCycle.expires_from_now(boost::posix_time::seconds(seconds));
+        fTimeoutPowerCycle.async_wait(boost::bind(&ConnectionAgilent::HandlePowerCycle,
+                                                  this, dummy::error));
+    }
+
+    int GetState()
+    {
+        if (!IsConnected())
+            return State::kDisconnected;
+
+        if (fLastReceived+boost::posix_time::seconds(fInterval*2)<Time())
+            return State::kDisconnected;
+
+        if (fData.fCurrentMeasured<0)
+            return State::kConnected;
+
+        if (fData.fVoltageMeasured<0.1)
+            return State::kVoltageOff;
+
+        if (fData.fVoltageMeasured<fData.fVoltageSet-0.1)
+            return State::kVoltageLow;
+
+        if (fData.fVoltageMeasured>fData.fVoltageSet+0.1)
+            return State::kVoltageHigh;
+
+        return State::kVoltageOn;
+    }
+};
+
+// ------------------------------------------------------------------------
+
+#include "DimDescriptionService.h"
+
+class ConnectionDimAgilent : public ConnectionAgilent
+{
 private:
 
-int  fLineCounter;
-
-void Start_async_read_until()
-{
-    // Bind Received Data Handler to the event: "received <enter> character"
-    //   this Handler will try to parse the incoming data
-    ba::async_read_until(*this, fBuffer, "\n",
-                         boost::bind(&ConnectionAgilent::ReceivedStatusHandler, this,
-                                     bapla::error, bapla::bytes_transferred, 0));
-
-    // FIXME: Add timeout here
-}
-
-void ReceivedStatusHandler(const bs::error_code& err, size_t bytes_received, int /*type*/)
-{
-    
-    // Do not schedule a new read if the connection failed.
-    if (bytes_received==0 || err)
-    {
-        if (err==ba::error::eof)
-            Warn("Connection closed by remote host (FTM).");
-
-        // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
-        // 125: Operation canceled
-        if (err && err!=ba::error::eof &&                     // Connection closed by remote host
-            err!=ba::error::basic_errors::not_connected &&    // Connection closed by remote host
-            err!=ba::error::basic_errors::operation_aborted)  // Connection closed by us
-        {
-            ostringstream str;
-            str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
-            Error(str);
-        }
-        PostClose(err!=ba::error::basic_errors::operation_aborted);
-        return;
-    }
-
-    if (fIsVerbose)
-    {
-       Out() << kBold << "Received (" << bytes_received << " bytes):" << endl;
-    }
-    // FIXME: the piece of code below causes a Seg Fault in case 
-    // The Agilent is not listening during program start, then after a while is 
-    // listening and after connection established.
-    // It sends: 1.) a string and 2.) and empty line (just an <Enter> pressed)
-    //
-    // then the agilent_ctrl segfaults ... was able to reproduce it.
-    // gdp just gave me the hint, that Time().GetAdStr() caused the Seg Fault in a way...
-    // Is Time threadsafe?
-    /*
-    if (fDump)
-    {
-        ostringstream msg;
-        msg << "--- " << Time().GetAsStr() << " --- received " << bytes_received << " bytes.";
-        Dump(msg.str());
-    }
-    */
-
-
-    istream is(&fBuffer);
-    fLineCounter++;
-
-    if (fLineCounter == 1)
-    {
-        // this is the Agilent identity string, do nothing
-        string s;
-        getline(is,s, '\n');
-        Out() << "ID string: " << s << endl;
-    }
-    else if (fLineCounter == 2)
-    {
-        // this should be a float containing the measured voltage
-        is >> fMeasuredVoltage;
-        Out() << "voltage: " << fMeasuredVoltage << endl;
-    }
-    else if (fLineCounter >= 3)
-    {
-        // this should be a float containing the measured voltage
-        is >> fMeasuredCurrent;
-        Out() << "current: " << fMeasuredCurrent << endl;
-        fLineCounter = 0;
-
-        // data should contain two floats:
-        //  * measured output voltage in volts
-        //  * measured ouput current in amperes
-        vector<float> data(2);
-        data[0] = fMeasuredVoltage;
-        data[1] = fMeasuredCurrent;
-        UpdateDim(data);
-    }
-   
-    // read the buffer empty ...
-    // FIXME: I surely misunderstand that damn fBuffer thing.
-    // I thought it should be emtpy by now...
-    string buffer;
-    while (getline(is,buffer, '\n'))
-    {
-        buffer = Tools::Trim(buffer);
-        if (buffer.empty()) continue;
-    }
-
-
-    if (fMeasuredVoltage > 1.0)
-    {
-        fState = State::kVoltage_On;
-    }
-    else
-    {
-        fState = State::kVoltage_Off;
-    }
-    Start_async_read_until();
-}
-
-
-// This is called when a connection was established
-void ConnectionEstablished()
-{
-    // DN 07.08.2012: The next line is imho not needed.
-    // But I'm in a train and cannot test it.
-    fState = State::kConnected;
-    Start_async_read_until();
-    RequestStatus();
-    
-    fLineCounter = 0;
-    fBuffer.prepare(1000);
-}
+    DimDescribedService fDim;
+
+    void UpdateDim(const Data &data)
+    {
+        fDim.Update(data);
+    }
 
 public:
-
-ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
-    fIsVerbose(true),
-    fDump(true),
-    fCheckStatusTimer(ioservice),
-    fAntiFloddingTimer(ioservice)
-{
-    SetLogStream(&imp);
-    fState = State::kDisconnected;
-    fMeasuredVoltage=-1;
-    fMeasuredCurrent=-1;
-}
-
-void SetVerbose(bool b)
-{
-    fIsVerbose = b;
-}
-
-void SetDumpStream(bool b)
-{
-    fDump = b;
-}
-
-void SetOutput(bool b)
-{
-    if (b)
-    {
-        // check if the previous 'outp off' is some time ago
-        if (fAntiFloddingTimer.expires_at() < ba::deadline_timer::traits_type::now())
-        {    
-            if (IsConnected()) PostMessage(string("outp on\n"));
-        }
-    }
-    else
-    {
-        if (IsConnected()) PostMessage(string("outp off\n"));
-        // start a Timer, which runs out in 60sec making sure, that the 
-        // camera can't be switched off&on on short time scales.
-        // sending repetetive outp off is possible
-        // sending repetivitve outp on is also posible
-        // switching off immediately after switching on is also possible.
-        fAntiFloddingTimer.expires_from_now(boost::posix_time::seconds(60));
-    }
-    RequestStatus();
-}
-
-int GetState() const
-{
-    // fState is set in ReceivedStatusHandler
-    return fState;
-}
-
-
-};
-
-// ------------------------------------------------------------------------
-
-#include "DimDescriptionService.h"
-
-class ConnectionDimAgilent : public ConnectionAgilent
-{
-private:
-
-DimDescribedService fDim;
-
-void Update(DimDescribedService &svc, vector<float> data) const
-{
-    svc.Update(data);
-}
-
-void UpdateDim(const vector<float> &data)
-{
-    Update(fDim, data);
-}
-
-
-public:
-ConnectionDimAgilent(ba::io_service& ioservice, MessageImp &imp) :
-    ConnectionAgilent(ioservice, imp),
-    fDim("AGILENT_CONTROL/DATA", "F:1;F:1",
-                "|U[V]: output voltage"
-                "|I[A]: output current")
-{
-    // nothing happens here.
-}
+    ConnectionDimAgilent(ba::io_service& ioservice, MessageImp &imp) :
+        ConnectionAgilent(ioservice, imp),
+        fDim("AGILENT_CONTROL/DATA", "F:1;F:1;F:1;F:1",
+             "|U_nom[V]: Nominal output voltage"
+             "|U_mes[V]: Measured output voltage"
+             "|I_mes[A]: Measured current"
+             "|I_max[A]: Current limit")
+    {
+        // nothing happens here.
+    }
 };
 
@@ -334,51 +318,51 @@
 {
 private:
-S fAgilent;
-
-int Disconnect()
-{
-    // Close all connections
-    fAgilent.PostClose(false);
-
-    /*
-     // Now wait until all connection have been closed and
-     // all pending handlers have been processed
-     poll();
-     */
-
-    return T::GetCurrentState();
-}
-
-int Reconnect(const EventImp &evt)
-{
-    // Close all connections to supress the warning in SetEndpoint
-    fAgilent.PostClose(false);
-
-    // Now wait until all connection have been closed and
-    // all pending handlers have been processed
-    poll();
-
-    if (evt.GetBool())
-        fAgilent.SetEndpoint(evt.GetString());
-
-    // Now we can reopen the connection
-    fAgilent.PostClose(true);
-
-    return T::GetCurrentState();
-}
-
-int Execute()
-{
-    // Dispatch (execute) at most one handler from the queue. In contrary
-    // to run_one(), it doesn't wait until a handler is available
-    // which can be dispatched, so poll_one() might return with 0
-    // handlers dispatched. The handlers are always dispatched/executed
-    // synchronously, i.e. within the call to poll_one()
-    poll_one();
-    
-    if ( fAgilent.IsConnected() )
+    S fAgilent;
+
+    int Disconnect()
+    {
+        // Close all connections
+        fAgilent.PostClose(false);
+
+        /*
+         // Now wait until all connection have been closed and
+         // all pending handlers have been processed
+         poll();
+         */
+
+        return T::GetCurrentState();
+    }
+
+    int Reconnect(const EventImp &evt)
+    {
+        // Close all connections to supress the warning in SetEndpoint
+        fAgilent.PostClose(false);
+
+        // Now wait until all connection have been closed and
+        // all pending handlers have been processed
+        poll();
+
+        if (evt.GetBool())
+            fAgilent.SetEndpoint(evt.GetString());
+
+        // Now we can reopen the connection
+        fAgilent.PostClose(true);
+
+        return T::GetCurrentState();
+    }
+
+    int Execute()
+    {
+        // Dispatch (execute) at most one handler from the queue. In contrary
+        // to run_one(), it doesn't wait until a handler is available
+        // which can be dispatched, so poll_one() might return with 0
+        // handlers dispatched. The handlers are always dispatched/executed
+        // synchronously, i.e. within the call to poll_one()
+        poll_one();
+
+        if (!fAgilent.IsConnected())
+            return State::kDisconnected;
+
         return fAgilent.GetState();
-    else
-            return State::kDisconnected;
     }
 
@@ -404,20 +388,36 @@
     }
 
-    int SetDumpStream(const EventImp &evt)
-    {
-        if (!CheckEventSize(evt.GetSize(), "SetDumpStream", 1))
+    int SetDebugRx(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetDebugRx", 1))
             return T::kSM_FatalError;
 
-        fAgilent.SetDumpStream(evt.GetBool());
+        fAgilent.SetDebugRx(evt.GetBool());
 
         return T::GetCurrentState();
     }
 
-    int SetOutput(const EventImp &evt)
-    {
-        if (!CheckEventSize(evt.GetSize(), "SetOutput", 1))
+    int SetPower(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "SetPower", 1))
             return T::kSM_FatalError;
 
-        fAgilent.SetOutput(evt.GetBool());
+        fAgilent.SetPower(evt.GetBool());
+
+        return T::GetCurrentState();
+    }
+
+    int PowerCycle(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "PowerCyle", 2))
+            return T::kSM_FatalError;
+
+        if (evt.GetShort()<60)
+        {
+            T::Warn("Power cycle delays of less than 60s not allowed.");
+            return T::GetCurrentState();
+        }
+
+        fAgilent.PowerCycle(evt.GetShort());
 
         return T::GetCurrentState();
@@ -439,14 +439,16 @@
         // State names
         T::AddStateName(State::kDisconnected, "Disconnected",
-                     "Agilent not connected via ethernet.");
-
+                        "Agilent not connected via ethernet.");
         T::AddStateName(State::kConnected, "Connected",
-                     "Ethernet connection to Agilent established.");
-
-        T::AddStateName(State::kVoltage_On, "Voltage_On",
-                     "The measured output voltage is higher than 1.0V");
-
-        T::AddStateName(State::kVoltage_Off, "Voltage_Off",
-                     "The measured output voltage is lower than 1.0V");
+                        "Ethernet connection to Agilent established, but not data received yet.");
+
+        T::AddStateName(State::kVoltageOff, "VoltageOff",
+                        "The measured output voltage is lower than 0.1V");
+        T::AddStateName(State::kVoltageLow, "VoltageLow",
+                        "The measured output voltage is higher than 0.1V, but lower than the command voltage");
+        T::AddStateName(State::kVoltageOn, "VoltageOn",
+                        "The measured output voltage is higher than 0.1V and comparable to the command voltage");
+        T::AddStateName(State::kVoltageHigh, "VoltageHigh",
+                        "The measured output voltage is higher than the command voltage!");
 
         // Verbosity commands
@@ -456,8 +458,19 @@
              "|verbosity[bool]:disable or enable verbosity for received data (yes/no)");
 
-        T::AddEvent("DUMP_STREAM", "B:1")
-            (bind(&StateMachineAgilent::SetDumpStream, this, placeholders::_1))
-            (""
-             "");
+        T::AddEvent("SET_DEBUG_RX", "B:1")
+            (bind(&StateMachineAgilent::SetVerbosity, this, placeholders::_1))
+            ("set debug state"
+             "|debug[bool]:disable or enable verbosity for received raw data (yes/no)");
+
+        T::AddEvent("SET_POWER", "B:1")
+            (bind(&StateMachineAgilent::SetPower, this, placeholders::_1))
+            ("Enable or disable power output"
+             "|output[bool]:set power output to 'on' or 'off'");
+
+        T::AddEvent("POWER_CYCLE", "S:1")
+            (bind(&StateMachineAgilent::PowerCycle, this, placeholders::_1))
+            ("Power cycle the power output"
+             "|delay[short]:Defines the delay between switching off and on.");
+
 
         // Conenction commands
@@ -471,9 +484,4 @@
              "|[host][string]:new ethernet address in the form <host:port>");
 
-        T::AddEvent("OUTPUT", "B:1")
-            (bind(&StateMachineAgilent::SetOutput, this, placeholders::_1))
-            ("set output on or off"
-             "|[state][boolean]: output setting (1;0 or 'on';'off')");
-
         fAgilent.StartConnect();
     }
@@ -487,4 +495,6 @@
     {
         fAgilent.SetVerbose(!conf.Get<bool>("quiet"));
+        fAgilent.SetDebugRx(conf.Get<bool>("debug-rx"));
+        fAgilent.SetInterval(conf.Get<uint16_t>("interval"));
 
         SetEndpoint(conf.Get<string>("addr"));
@@ -508,8 +518,9 @@
     po::options_description control("agilent_ctrl control options");
     control.add_options()
-        ("no-dim",        po_bool(),  "Disable dim services")
-//        ("addr,a",        var<string>("localhost:8080"),  "network address of Agilent")
-        ("addr,a",        var<string>("10.0.100.220:5025"),  "network address of Agilent")
-        ("quiet,q",       po_bool(true),  "Disable printing contents of all received messages (except dynamic data) in clear text.")
+        ("no-dim",    po_bool(),         "Disable dim services")
+        ("addr,a",    var<string>("10.0.100.220:5025"),  "network address of Agilent")
+        ("debug-rx",  po_bool(false),    "Enable raw debug output wehen receiving data")
+        ("interval",  var<uint16_t>(15), "Interval in seconds in which the Agilent status is requested")
+        ("quiet,q",   po_bool(true),     "Disable printing contents of all received messages (except dynamic data) in clear text.")
         ;
 
@@ -529,12 +540,7 @@
 {
     cout <<
-        "The agilentctrl controls the FACT camera power supply.\n"
-        "The powersupply is made by Agilent, so we call it 'The Agilent'. \n"
-        "Since FACT uses three Agilent Power Supplies with different output voltages\n"
-        "one might still not now which one ist controlled by this Program, so:\n"
+        "The agilentctrl controls the FACT camera power supply.\n\n"
         "\n"
-        "This program controls the 48V Agilent."
-        "\n"
-        "The default is that the program is started with user intercation. "
+        "The default is that the program is started without user intercation. "
         "All actions are supposed to arrive as DimCommands. Using the -c "
         "option, a local shell can be initialized. With h or help a short "
