Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 9431)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 9432)
@@ -1,3 +1,29 @@
                                                                   -*-*- END -*-*-
+
+ 2009/04/22 Thomas Bretz (La Palma)
+
+   * .cosyrc_magic2, prepos_magic2.txt, leds_magic2.txt:
+     - added
+
+   * devdrv/dkc.cc:
+     - added some initialisation in the constructor
+     - added Warning E256
+
+   * devdrv/shaftencoder.cc:
+     - removed fTurn
+     - removed fDirChangedPos
+     - removed inter-connection with macs/dkc
+     - added a sanity check for fLabel
+     - removed obsolete functions
+
+   * tcpip/MCeCoCom.[h,cc]:
+     - added telescope number to reports
+
+   * tcpip/MTcpIpIO.[h,cc]:
+     - reopen send socket if invalid
+     - added some debug output
+     - make the timeout a variable
+
+
 
  2009/04/01 Thomas Bretz
@@ -19,12 +45,12 @@
 
 
- 
+
  2009/01/14 Thomas Bretz
 
    * slalib/dat.c:
      - added leap second
- 
- 
- 
+
+
+
  2008/08/26 Thomas Bretz (La Palma)
 
Index: /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc	(revision 9431)
+++ /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc	(revision 9432)
@@ -133,8 +133,8 @@
 
     const TString msg =
-        MString::Format("%s "
+        MString::Format("%s M%d "
              "%02d %04d %02d %02d %02d %02d %02d %03d "
              "%02d %04d %02d %02d %02d %02d %02d %03d "
-             "%s\n", cmd,
+             "%s\n", cmd, fTelescope,
              fStatus,  y1, mon1, d1, h1, m1, s1, ms1,
              fComStat, y2, mon2, d2, h2, m2, s2, ms2,
Index: /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h	(revision 9431)
+++ /trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h	(revision 9432)
@@ -33,4 +33,6 @@
     int     fCCStatus;    // global status of CC
 
+    Byte_t  fTelescope;
+
     ComStatus_t fComStat; // communication status
 
@@ -49,5 +51,6 @@
 public:
     MCeCoCom(const char *addr, const int tx=7304, const int rx=7404, MLog *out=NULL)
-        : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0), fComStat(kNoCmdReceived),
+        : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0),
+        fTelescope(1), fComStat(kNoCmdReceived),
         fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1),
         fAlarmCounter(0)
@@ -60,4 +63,6 @@
     bool SendRep(const char *cmd, const char *str, bool force);
     void SetStatus(Byte_t s) { fStatus=s; }
+
+    void SetTelescope(Byte_t tel) { fTelescope = tel; }
 
     Float_t GetHumidity() const { return fHumidity; }
Index: /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc	(revision 9431)
+++ /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc	(revision 9432)
@@ -15,4 +15,5 @@
 
 #undef DEBUG
+//#define DEBUG
 
 using namespace std;
@@ -40,6 +41,7 @@
      */
 
-MTcpIpO::MTcpIpO(const char *addr, Int_t tx)
-{
+MTcpIpO::MTcpIpO(const char *addr, Int_t tx) : fPortTx(tx)
+{
+    gLog << inf2 << "- Open send socket to " << addr << ":" << tx << endl;
     fTxSocket = new TSocket(addr, tx);
 }
@@ -147,4 +149,16 @@
 bool MTcpIpO::Send(const char *msg, Int_t len)
 {
+    if (!fTxSocket->IsValid())
+    {
+        const TInetAddress &a = fTxSocket->GetInetAddress();
+        if (!a.IsValid())
+            return false;
+#ifdef DEBUG
+        cout << "- Reopen send socket to " << a.GetHostAddress() << ":" << fPortTx << endl;
+#endif
+        delete fTxSocket;
+        fTxSocket = new TSocket(a.GetHostAddress(), fPortTx);
+    }
+
     return SendFrame(*fTxSocket, msg, len);
 }
@@ -206,5 +220,5 @@
     fConnectionEstablished = kTRUE;
 
-    MTimeout timeout;
+    MTimeout timeout(fTimeout);
 
     // Get connection on port fPortRx and redirected
@@ -228,5 +242,5 @@
             if (timeout.HasTimedOut())
             {
-                gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl;
+                gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out after " << fTimeout << "ms." << endl;
                 return kFALSE;
             }
@@ -285,4 +299,7 @@
             fConnectionEstablished = kFALSE;
 
+#ifdef DEBUG
+        cout << "===> DEL SOCKET" << endl;
+#endif
         delete socket;
     }
@@ -314,4 +331,7 @@
         }
 
+#ifdef DEBUG
+        cout << "===> DEL SERVER" << endl;
+#endif
         delete server;
 
Index: /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h	(revision 9431)
+++ /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h	(revision 9432)
@@ -44,4 +44,6 @@
     TSocket *fTxSocket;
 
+    Int_t fPortTx;
+
 public:
     MTcpIpO(const char *addr, Int_t tx);
