Index: trunk/FACT++/src/magicweather.cc
===================================================================
--- trunk/FACT++/src/magicweather.cc	(revision 13209)
+++ trunk/FACT++/src/magicweather.cc	(revision 13210)
@@ -49,9 +49,10 @@
 class ConnectionWeather : public Connection
 {
-    int      fState;
     uint16_t fInterval;
 
     bool fIsVerbose;
 
+    string fSite;
+
     virtual void UpdateWeather(const Time &, const DimWeather &)
     {
@@ -63,4 +64,5 @@
 
     Time fLastReport;
+    Time fLastReception;
 
     void HandleRead(const boost::system::error_code& err, size_t bytes_received)
@@ -86,4 +88,6 @@
         }
 
+        fLastReception = Time();
+
         const string str(fArray.data(), bytes_received);
         memset(fArray.data(), 0, fArray.size());
@@ -180,8 +184,12 @@
 
             ostringstream msg;
-            msg << tm << "[" << data.fStatus << "]: T="
-                << data.fTemp << "°C H=" << data.fHum << "% P="
-                << data.fPress << "hPa Td=" << data.fDew << "°C V="
-                << data.fWind << "km/h dir=" << data.fDir << "deg";
+            msg << tm.GetAsStr("%H:%M:%S") << "[" << data.fStatus << "]:"
+                << " T="    << data.fTemp  << "°C"
+                << " H="    << data.fHum   << "%"
+                << " P="    << data.fPress << "hPa"
+                << " Td="   << data.fDew   << "°C"
+                << " V="    << data.fWind  << "km/h"
+                << " Vmax=" << data.fGusts << "km/h"
+                << " dir="  << data.fDir   << "°";
             Message(msg);
 
@@ -208,7 +216,6 @@
     void PostRequest()
     {
-        const string dir = "/site/weather/weather_data.txt";
         const string cmd =
-            "GET "+dir+" HTTP/1.1\r\n"
+            "GET "+fSite+" HTTP/1.1\r\n"
             "Accept: */*\r\n"
             "Content-Type: application/octet-stream\r\n"
@@ -228,5 +235,5 @@
         PostRequest();
 
-        fKeepAlive.expires_from_now(boost::posix_time::seconds(fInterval));
+        fKeepAlive.expires_from_now(boost::posix_time::seconds(fInterval/2));
         fKeepAlive.async_wait(boost::bind(&ConnectionWeather::HandleRequest,
                                           this, dummy::error));
@@ -279,5 +286,5 @@
 public:
     ConnectionWeather(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()),
-        fState(-1), fIsVerbose(true), fKeepAlive(ioservice)
+        fIsVerbose(true), fKeepAlive(ioservice)
     {
         SetLogStream(&imp);
@@ -287,4 +294,5 @@
     {
         fIsVerbose = b;
+        Connection::SetVerbose(b);
     }
 
@@ -294,11 +302,17 @@
     }
 
+    void SetSite(const string &site)
+    {
+        fSite = site;
+    }
+
     int GetState() const
     {
-        if (!IsConnected())
-            return 1;
-        if (IsConnected() && fState<0)
+        if (fLastReport+boost::posix_time::seconds(fInterval*2)>Time())
+            return 3;
+        if (fLastReception+boost::posix_time::seconds(fInterval*2)>Time())
             return 2;
-        return fState+3;
+        return 1;
+
     }
 };
@@ -361,5 +375,5 @@
         kStateDisconnected = 1,
         kStateConnected,
-        kStateOk,
+        kStateReceiving,
     };
 
@@ -384,15 +398,9 @@
         return T::GetCurrentState();
     }
-
+/*
     int Disconnect()
     {
         // Close all connections
         fWeather.PostClose(false);
-
-        /*
-         // Now wait until all connection have been closed and
-         // all pending handlers have been processed
-         poll();
-         */
 
         return T::GetCurrentState();
@@ -416,5 +424,5 @@
         return T::GetCurrentState();
     }
-
+*/
     int Execute()
     {
@@ -444,11 +452,11 @@
         // State names
         AddStateName(kStateDisconnected, "Disconnected",
-                     "No connection to cosy");
+                     "No connection with web-server recently");
 
         AddStateName(kStateConnected, "Connected",
-                     "Cosy connected, drive stopped");
-
-        AddStateName(kStateOk, "Ok",
-                     "Drive system not ready for movement");
+                     "Connection to webserver can be established, but received data is not recent");
+
+        AddStateName(kStateReceiving, "Valid",
+                     "Connection to webserver can be established, receint data received");
 
         // Verbosity commands
@@ -457,15 +465,15 @@
             ("set verbosity state"
              "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
-
+/*
         // Conenction commands
-        AddEvent("DISCONNECT", kStateConnected)
+        AddEvent("DISCONNECT")
             (bind(&StateMachineDrive::Disconnect, this))
             ("disconnect from ethernet");
 
-        AddEvent("RECONNECT", "O", kStateDisconnected, kStateConnected)
+        AddEvent("RECONNECT", "O")
             (bind(&StateMachineDrive::Reconnect, this, placeholders::_1))
             ("(Re)connect ethernet connection to FTM, a new address can be given"
              "|[host][string]:new ethernet address in the form <host:port>");
-
+*/
         fWeather.StartConnect();
     }
@@ -478,9 +486,11 @@
     int EvalOptions(Configuration &conf)
     {
-        SetEndpoint(conf.Get<string>("addr"));
-
         fWeather.SetVerbose(!conf.Get<bool>("quiet"));
         fWeather.SetInterval(conf.Get<uint16_t>("interval"));
         fWeather.SetDebugTx(conf.Get<bool>("debug-tx"));
+        fWeather.SetSite(conf.Get<string>("url"));
+
+        SetEndpoint(conf.Get<string>("addr"));
+
 
         return -1;
@@ -505,6 +515,7 @@
         ("no-dim,d",  po_switch(),    "Disable dim services")
         ("addr,a",  var<string>("www.magic.iac.es:80"),  "Network address of Cosy")
+        ("url,u",  var<string>("/site/weather/weather_data.txt"),  "File name and path to load")
         ("quiet,q", po_bool(true),  "Disable printing contents of all received messages (except dynamic data) in clear text.")
-        ("interval,i", var<uint16_t>(25), "Interval between two server requests in seconds")
+        ("interval,i", var<uint16_t>(30), "Interval between two updates on the server in seconds")
         ("debug-tx", po_bool(), "Enable debugging of ethernet transmission.")
         ;
