Index: trunk/FACT++/src/agilentctrl.cc
===================================================================
--- trunk/FACT++/src/agilentctrl.cc	(revision 14313)
+++ trunk/FACT++/src/agilentctrl.cc	(revision 14314)
@@ -31,4 +31,7 @@
     bool fDump;
 
+    int  fLineCounter;
+
+
     ofstream fDumpStream;
 
@@ -38,5 +41,4 @@
     {
     }
-
 
     void Dump(const string &str)
@@ -93,7 +95,40 @@
         }
 
-
         istream is(&fBuffer);
-
+        // data should contain two floats:
+        //  * measured output voltage in volts
+        //  * measured ouput current in amperes
+        vector<float> data;
+
+        fLineCounter++;
+
+        if (fLineCounter == 1)
+        {
+            // this is the Agilent identity string, do nothing
+            string s;
+            is >> s;
+            Out() << "ID string: " << s << endl;
+        }
+        else if (fLineCounter == 2)
+        {
+            // this should be a float containing the measured voltage
+            float f;
+            is >> f;
+            data.push_back(f);
+            Out() << "voltage: " << f << endl;
+        }
+        else if (fLineCounter >= 3)
+        {
+            // this should be a float containing the measured voltage
+            float f;
+            is >> f;
+            data.push_back(f);
+            Out() << "current: " << f << endl;
+            fLineCounter = 0;
+            fSendRequest = true;
+        }
+
+
+//        int status=-1;
 
         string buffer;
@@ -124,8 +159,5 @@
         }
 
-        // vector data should have to elements:
-        //   * the measured voltage
-        //   * the measured current
-        vector<float> data;
+
         UpdateDim(data);
 
@@ -145,9 +177,15 @@
     void ConnectionEstablished()
     {
-        fBuffer.prepare(10000);
+        fLineCounter = 0;
+        fSendRequest = true;
+        fBuffer.prepare(1000);
+        fTime = Time();
         StartRead();
     }
 
 public:
+    Time fTime;
+    bool fSendRequest;
+
     ConnectionAgilent(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
         fIsVerbose(true),
@@ -171,9 +209,9 @@
         if (b)
         {
-            PostMessage("outp on\n");
+            PostMessage(string("outp on\n"));
         }
         else
         {
-            PostMessage("outp off\n");
+            PostMessage(string("outp off\n"));
         }
     }
@@ -181,7 +219,7 @@
     void Identify()
     {
-        PostMessage("*IDN?\n",6);
-        PostMessage("meas:volt?\n",11);
-        PostMessage("meas:curr?\n",11);
+        PostMessage(string("*IDN?\n"));
+        PostMessage(string("meas:volt?\n"));
+        PostMessage(string("meas:curr?\n"));
     }
 };
@@ -212,6 +250,6 @@
         ConnectionAgilent(ioservice, imp),
         fDim("AGILENT_CONTROL/DATA", "F:1;F:1",
-                    "|U[V]: FACT supply voltage"
-                    "|I[A]: current consumed by the FACT camera")
+                    "|U[V]: output voltage"
+                    "|I[A]: output current")
     {
         // nothing happens here.
@@ -267,5 +305,13 @@
         // synchronously, i.e. within the call to poll_one()
         poll_one();
-
+        if (fAgilent.fSendRequest)
+        {
+            if (Time()-fAgilent.fTime > boost::posix_time::seconds(5))
+            {
+                fAgilent.Identify();
+                fAgilent.fTime = Time();
+                fAgilent.fSendRequest = false;
+            }
+        }
         return fAgilent.IsConnected() ? State::kConnected : State::kDisconnected;
     }
@@ -358,10 +404,10 @@
              "|[host][string]:new ethernet address in the form <host:port>");
 
-        T::AddEvent("OUTPUT", "B:1")
+        T::AddEvent("OUTPUT", "B:1", State::kConnected)
             (bind(&StateMachineAgilent::SetOutput, this, placeholders::_1))
             ("set output on or off"
              "|[state][boolean]: output setting (1;0 or 'on';'off')");
 
-        T::AddEvent("IDENTIFY")
+        T::AddEvent("IDENTIFY", State::kConnected)
             (bind(&StateMachineAgilent::Identify, this))
             ("Request Agilent ID");
