Index: /trunk/MagicSoft/Cosy/.cosyrc_magic1
===================================================================
--- /trunk/MagicSoft/Cosy/.cosyrc_magic1	(revision 9443)
+++ /trunk/MagicSoft/Cosy/.cosyrc_magic1	(revision 9443)
@@ -0,0 +1,60 @@
+#
+# .cosyrc
+#
+
+Telescope: 1
+
+# Software endswitch
+Az_Min[deg]:  -95.0
+Zd_Min[deg]:  -70.0
+Az_Max[deg]:  305.0
+Zd_Max[deg]:  100.0
+
+TPointLeds.File: leds_magic1.txt
+TPointLeds.RadiusMin: 225.24
+TPointLeds.RadiusMax: 235.24
+TPointLeds.ArcsecPerPixel: 31.36
+#TPointLeds.MinNumberLeds: 5
+#TPointLeds.BoxSize: 19
+#TPointLeds.CleaningLevel: 3.0
+
+FindStar.SizeBox: 50
+#FindStar.CleaningLevel: 3.0
+
+StarguiderLeds.File: stargleds_magic1.txt
+StarguiderLeds.RadiusMin: 152
+StarguiderLeds.RadiusMax: 154
+#StarguiderLeds.ArcsecPerPixel: 48.9
+StarguiderLeds.MinNumberLeds: 3
+#StarguiderLeds.BoxSize: 19
+#StarguiderLeds.CleaningLevel: 3.0
+
+Starguider.Width:        225
+Starguider.Height:       280
+Starguider.X:            540
+Starguider.Y:            292
+
+# Default offset between the camera center and the corresponding point
+# on the sky. This value is just to make the starguider work. It has 
+# once to be adjusted as good as possible... but NEVER EVER change
+# these values again! (Except you change the alignment of the ccd optics)
+
+# Index Error from pointing model is +0.89 pix
+Starguider.SkyOffsetX:   335
+# Index Error from pointing model is -0.32 pix
+Starguider.SkyOffsetY:   13.5
+
+Leds.Radius: 2000
+
+Starguider.RotationAngle: -0.2
+Starguider.CleaningLevel: 3.0
+
+DefaultCameraChannel: 0
+#IpAddressSPS: sps
+#IpAddressCentralControl: 161.72.130.2
+#PortCentralControlRX: 7414
+#PortCentralControlTX: 7314
+#IpAddressPowerSwitch: powerswitch5
+PointingModel: bending_magic1.txt
+
+FilePredefinedPositions: prepos_magic1.txt
Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 9442)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 9443)
@@ -1,3 +1,29 @@
                                                                   -*-*- END -*-*-
+
+ 2009/05/11 Thomas Bretz (La Palma)
+
+   * cosy.cc:
+     - made compatible with newer MARS version
+     - added a connection check to the sps
+     - made ports settable by rc-file
+
+   * telesto.cc:
+     - made compatible with newer MARS version
+
+   * devdrv/dkc.[h,cc]:
+     - disarm when network is shut down
+     - changed acces to armed
+     - set default status to 0xff
+     - added IsRpmActive
+
+   * main/MTracking.cc:
+     - leave tracking loop when sps stopped tracking (e.g. 
+       disarmed)
+
+   * tcpip/MTcpIpIO.cc:
+     - set debug level to get proper outout when MTcpIpO
+       creates a socket
+
+
 
  2009/05/09 Thomas Bretz (La Palma)
Index: /trunk/MagicSoft/Cosy/bending_magic1.txt
===================================================================
--- /trunk/MagicSoft/Cosy/bending_magic1.txt	(revision 9443)
+++ /trunk/MagicSoft/Cosy/bending_magic1.txt	(revision 9443)
@@ -0,0 +1,28 @@
+MAGIC1 07.03.2009 12:46:43.754
+S   00   000000   000000  0000000
+     IA     0   0.069443427
+     IE     0   0.15558091
+   FLOP             0             0
+     AN -0.0057273968   0.011700174
+     AW  0.0023167714   0.018291312
+   NPAE  -0.050462697   0.086324615
+     CA   0.049020051    0.10099605
+     TF             0             0
+     TX             0             0
+   ECES  -0.039580933    0.12121139
+   ACES  -0.017410399   0.021734225
+   ECEC  -0.065435713    0.11617262
+   ACEC  -0.013713802   0.026423559
+    NRX             0             0
+    NRY             0             0
+    CRX             0             0
+    CRY             0             0
+ MAGIC1  -0.045781639   0.015587386
+ MAGIC2             0             0
+     PX             0             0
+     PY             0             0
+     DX             0             0
+     DY             0             0
+END
+
+# From tpoints between 0808 and 0901
Index: /trunk/MagicSoft/Cosy/cosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/cosy.cc	(revision 9442)
+++ /trunk/MagicSoft/Cosy/cosy.cc	(revision 9443)
@@ -115,5 +115,5 @@
     // Evaluate arguments
     //
-    MArgs arg(argc, argv, kTRUE);
+    MArgs arg(argc, argv);
     gLog.Setup(arg);
 
@@ -131,6 +131,4 @@
     const Bool_t  kDebugMem     = arg.HasOnlyAndRemove("--debug-mem");
     const Bool_t  kDebugThreads = arg.HasOnlyAndRemove("--debug-threads");
-    const Int_t   ceco_tx       = arg.GetIntAndRemove("--cc-tx=", 7314);//7304);
-    const Int_t   ceco_rx       = arg.GetIntAndRemove("--cc-rx=", 7414);//7404);
     const TString kConfig       = arg.GetStringAndRemove("--config=", ".cosyrc"); // ceco
     Int_t  kDebugEnv = arg.HasOnlyAndRemove("--debug-env") ? 1 : 0;
@@ -160,5 +158,7 @@
     const Int_t   channel     = env.GetValue("DefaultCameraChannel", 0);
     const TString sps         = env.GetValue("IpAddressSPS", "sps");
-    const TString ceco        = env.GetValue("IpAddressCentralControl", "161.72.130.60");
+    const TString ceco        = env.GetValue("IpAddressCentralControl", "161.72.130.2");
+    const Int_t   ceco_rx     = env.GetValue("PortCentralControlRX", 7404);
+    const Int_t   ceco_tx     = env.GetValue("PortCentralControlTX", 7304);
     const TString powerswitch = env.GetValue("IpAddressPowerSwitch", "");
     const Int_t   telescope   = env.GetValue("Telescope", 1);
@@ -214,4 +214,11 @@
     if (kDebugMem)
         TObject::SetObjectStat(kTRUE);
+
+    // Check if a connection can be established
+    const Int_t save = gDebug;
+    gDebug = 1;
+    TSocket test(sps, 5357);
+    gDebug = save;
+    test.Close();
 
     //
Index: /trunk/MagicSoft/Cosy/devdrv/dkc.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/dkc.cc	(revision 9442)
+++ /trunk/MagicSoft/Cosy/devdrv/dkc.cc	(revision 9443)
@@ -15,10 +15,10 @@
 using namespace std;
 
-#define EXPERT
+//#define EXPERT
 
 Dkc::Dkc(const BYTE_t nodeid, const char *name)
     : NodeDrv(nodeid, name), fMacId(2*nodeid+1),
     fPdoPos1(0), fPdoPos2(0), fPosActive(0), fRpmActive(0),
-    fStatus(0), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false),
+    fStatus(0xff), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false),
     fReport(NULL),fLabel(NULL),fUpdPos(0)
 {
@@ -367,6 +367,6 @@
     // FIXME: This isn't called if the initialization isn't done completely!
     //
-
     SetRpmMode(FALSE);
+    Disarm();
 }
 
@@ -515,9 +515,7 @@
 void Dkc::HandlePDO3(const BYTE_t *data, const timeval_t &tv)
 {
-    fArmed = data[2]&0x01;
-
     if (fStatus!=data[3])
     {
-                  // data[3]&0x01; // motor not moving
+        fArmed     = data[3]&0x01; // armed status
         fPosActive = data[3]&0x02; // positioning active
         fRpmActive = data[3]&0x04; // RPM mode switched on
Index: /trunk/MagicSoft/Cosy/devdrv/dkc.h
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/dkc.h	(revision 9442)
+++ /trunk/MagicSoft/Cosy/devdrv/dkc.h	(revision 9443)
@@ -120,4 +120,5 @@
 
     bool IsOperative() const { return fStatusPdo3==0xef; }
+    bool IsRpmActive() const { return fRpmActive; }
 
     void HandleError();
Index: /trunk/MagicSoft/Cosy/leds_magic1.txt
===================================================================
--- /trunk/MagicSoft/Cosy/leds_magic1.txt	(revision 9443)
+++ /trunk/MagicSoft/Cosy/leds_magic1.txt	(revision 9443)
@@ -0,0 +1,10 @@
+433  49 0 0 
+532  74 0 0
+640 164 0 0
+686 296 0 0
+569 535 0 0
+296 554 0 0
+150 299 0 0
+175 201 0 0
+267  97 0 0
+
Index: /trunk/MagicSoft/Cosy/main/MTracking.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9442)
+++ /trunk/MagicSoft/Cosy/main/MTracking.cc	(revision 9443)
@@ -363,4 +363,11 @@
         //
         usleep(1000000); // 1s
+
+        //
+        // If we would do it in the beginnign of the loop it can happen
+        // that we check before we got the feedback through the pdo
+        //
+        if (!fCosy->fMac1->IsRpmActive() || !fCosy->fMac2->IsRpmActive())
+            break;
     }
 
Index: /trunk/MagicSoft/Cosy/prepos_magic1.txt
===================================================================
--- /trunk/MagicSoft/Cosy/prepos_magic1.txt	(revision 9443)
+++ /trunk/MagicSoft/Cosy/prepos_magic1.txt	(revision 9443)
@@ -0,0 +1,5 @@
+98.30000000  -10.10333333 Camera Access
+61.23817667   0           Celestial Pole
+93.90055555  -10.14       Park
+76.31       149.913333333 Roque Lamp
+#4             0           Zenith
Index: /trunk/MagicSoft/Cosy/stargleds_magic1.txt
===================================================================
--- /trunk/MagicSoft/Cosy/stargleds_magic1.txt	(revision 9443)
+++ /trunk/MagicSoft/Cosy/stargleds_magic1.txt	(revision 9443)
@@ -0,0 +1,5 @@
+68     127    0 0
+127    142    0 0
+189    199    0 0 
+217    279    0 0
+144    423    0 0
Index: /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc
===================================================================
--- /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc	(revision 9442)
+++ /trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc	(revision 9443)
@@ -15,5 +15,4 @@
 
 #undef DEBUG
-//#define DEBUG
 
 using namespace std;
@@ -46,5 +45,8 @@
     gLog << all << "- Open send socket to " << addr << ":" << tx << endl;
 
+    const Int_t save = gDebug;
+    gDebug=1;
     fTxSocket = new TSocket(addr, tx);
+    gDebug=save;
     fTxSocket->SetOption(kNoBlock, 1);
 
Index: /trunk/MagicSoft/Cosy/telesto.cc
===================================================================
--- /trunk/MagicSoft/Cosy/telesto.cc	(revision 9442)
+++ /trunk/MagicSoft/Cosy/telesto.cc	(revision 9443)
@@ -92,5 +92,5 @@
     // Evaluate arguments
     //
-    MArgs arg(argc, argv, kTRUE);
+    MArgs arg(argc, argv);
     gLog.Setup(arg);
 
