Index: trunk/FACT++/src/dclient5.cc
===================================================================
--- trunk/FACT++/src/dclient5.cc	(revision 10230)
+++ trunk/FACT++/src/dclient5.cc	(revision 10269)
@@ -35,10 +35,7 @@
 
 public:
-    void ConnectImp(const bs::error_code& error,
-                    tcp::resolver::iterator endpoint_iterator)
-    {
-        Connection::ConnectImp(error, endpoint_iterator);
-        if (IsConnected())
-            StartAsyncRead();
+    void ConnectionEstablished()
+    {
+        StartAsyncRead();
     }
 
@@ -78,5 +75,5 @@
     }
 
-    void HandleReceivedData(const bs::error_code& error, size_t bytes_received)
+    void HandleReceivedData(const bs::error_code& error, size_t bytes_received, int type)
     {
         // Do not schedule a new read if the connection failed.
@@ -185,4 +182,5 @@
         kSM_Stopping,
         kSM_Reconnect,
+        kSM_SetUrl,
     };
 
@@ -211,5 +209,5 @@
         c9(*this, *this), fTimers(out)
     {
-        c1.SetEndpoint("localhost", 5000);
+//        c1.SetEndpoint();
         c2.SetEndpoint("localhost", 4001);
         c3.SetEndpoint("ftmboard1.ethz.ch", 5000);
@@ -231,13 +229,13 @@
         c9.SetLogStream(this);
 
-        c1.AsyncConnect(); // This sets the connection to "open"
-        c2.AsyncConnect(); // This sets the connection to "open"
-        c3.AsyncConnect(); // This sets the connection to "open"
-        //c4.AsyncConnect(); // This sets the connection to "open"
-        //c5.AsyncConnect(); // This sets the connection to "open"
-        //c6.AsyncConnect(); // This sets the connection to "open"
-        //c7.AsyncConnect(); // This sets the connection to "open"
-        //c8.AsyncConnect(); // This sets the connection to "open"
-        //c9.AsyncConnect(); // This sets the connection to "open"
+        c1.StartConnect(); // This sets the connection to "open"
+        c2.StartConnect(); // This sets the connection to "open"
+        c3.StartConnect(); // This sets the connection to "open"
+        //c4.StartConnect(); // This sets the connection to "open"
+        //c5.StartConnect(); // This sets the connection to "open"
+        //c6.StartConnect(); // This sets the connection to "open"
+        //c7.StartConnect(); // This sets the connection to "open"
+        //c8.StartConnect(); // This sets the connection to "open"
+        //c9.StartConnect(); // This sets the connection to "open"
 
         AddStateName(kSM_Disconnected,  "Disconnected");
@@ -256,16 +254,48 @@
         AddConfiguration("LED",  kSM_Connected);
 
-        T::AddConfiguration("MYT",  "I:1;C:5;I");
-        T::AddConfiguration("TESTI",            "I");
-        T::AddConfiguration("TESTI:5",          "I:5");
-        T::AddConfiguration("TESTI:5;F:1;D:2",  "I:5;F:1;D:2");
-        T::AddConfiguration("TESTC",            "C");
-        T::AddConfiguration("TESTI:5;C",        "I:5;C");
+        T::AddConfiguration("TESTI",    "I");
+        T::AddConfiguration("TESTI2",   "I:2");
+        T::AddConfiguration("TESTIF",   "I:2;F:2");
+        T::AddConfiguration("TESTIC",   "I:2;C");
+
+        T::AddConfiguration("CMD", "C")
+            ->AssignFunction(boost::bind(&StateMachineFAD::Command, this, _1));
 
         AddTransition(kSM_Reconnect, "RECONNECT");
 
+        AddTransition(kSM_SetUrl, "SETURL", "C");
+
         T::PrintListOfEvents();
     }
 
+    int Command(const EventImp &evt)
+    {
+        string cmd = evt.GetText();
+
+        size_t p0 = cmd.find_first_of(' ');
+        if (p0==string::npos)
+            p0 = cmd.length();
+
+    T::Out() << "\nCommand: '" << cmd.substr(0, p0) << "'" << cmd.substr(p0)<< "'" << endl;
+    /*
+    const Converter c(T::Out(), "B:5;I:2;F;W;O;C", "yes no false 0 1 31 42 11.12 \"test hallo\" ");
+
+     T::Out() << c.GetRc() << endl;
+     T::Out() << c.N() << endl;
+     T::Out() << c.Get<bool>(0) << endl;
+     T::Out() << c.Get<bool>(1) << endl;
+     T::Out() << c.Get<bool>(2) << endl;
+     T::Out() << c.Get<bool>(3) << endl;
+     T::Out() << c.Get<bool>(4) << endl;
+     T::Out() << c.Get<int>(5) << endl;
+     T::Out() << c.Get<int>(6) << endl;
+     T::Out() << c.Get<float>(7) << endl;
+     T::Out() << c.Get<int>(7) << endl;
+     T::Out() << c.Get<string>(8) << endl;
+     T::Out() << c.Get<string>(9) << endl;
+     T::Out() << c.Get<string>(10) << endl;
+     */
+     return T::GetCurrentState();
+    }
     int Start(const EventImp &evt, int i)
     {
@@ -336,4 +366,8 @@
         switch (evt.GetTargetState())
         {
+        case kSM_SetUrl:
+            T::Out() << evt.GetText() << endl;
+            c1.SetEndpoint(evt.GetText());
+            return T::GetCurrentState();
         case kSM_Reconnect:
             // Close all connections
