Index: /trunk/MagicSoft/Cosy/Changelog
===================================================================
--- /trunk/MagicSoft/Cosy/Changelog	(revision 925)
+++ /trunk/MagicSoft/Cosy/Changelog	(revision 926)
@@ -1,3 +1,32 @@
                                                                   -*-*- END -*-*-
+
+ 2001/09/10 - Thomas Bretz:
+ 
+   * base/timer.[h,cc]:
+     - added dome comments
+     
+   * candrv/canopen.[cc,h]:
+     - added boolean in SendSDO to suppress occurance in SDO list
+     
+   * candrv/nodedrv.[h,cc]:
+     - added Names for Node
+     - added boolean in SendSDO to suppress occurance in SDO list
+     
+   * devdrv/macs.[h,cc]:
+     - changed GetId() to GetNodeName() in logging output
+     - made timeout timer periodic again
+     - added timeout for Mac response (added SDOOK)
+     - added Name for Node
+     
+   * devdrv/shaftencoder.[h,cc]:
+     - changed GetId() to GetNodeName() in logging output
+     - added Name for Node
+     
+   * main/MCosy.[h,cc]:
+     - renamed fAlt1 to fZd1
+     - renamed fAlt2 to fZd2
+
+
+     
  2001/09/07 - Thomas Bretz:
  
Index: /trunk/MagicSoft/Cosy/ToDo
===================================================================
--- /trunk/MagicSoft/Cosy/ToDo	(revision 925)
+++ /trunk/MagicSoft/Cosy/ToDo	(revision 926)
@@ -21,3 +21,10 @@
   
   - Devide MTTalk into NetworkInit and MCalcTrackingError/Offset-Class
+  
+  - Add possibility to check for timeout when WaitForSDO returns
+    (switching on Guarding!)
+    
+  - If an Error state is set, the first call to Track/Positioning only
+    results in Error Handling. The second one gives the requested
+    action
 
Index: /trunk/MagicSoft/Cosy/base/timer.cc
===================================================================
--- /trunk/MagicSoft/Cosy/base/timer.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/base/timer.cc	(revision 926)
@@ -75,5 +75,5 @@
 }
 
-double Timer::Now()
+double Timer::Now() //[s]
 {
     struct timeval tv;
@@ -97,5 +97,5 @@
 }
 
-Timer::operator double()
+Timer::operator double() //[s]
 {
     return fMs+fSecs;
Index: /trunk/MagicSoft/Cosy/base/timer.h
===================================================================
--- /trunk/MagicSoft/Cosy/base/timer.h	(revision 925)
+++ /trunk/MagicSoft/Cosy/base/timer.h	(revision 926)
@@ -31,5 +31,5 @@
 
     int GetSecs() { return fSecs; }
-    double Now();
+    double Now(); //[s]
     double CalcMjd();
 
@@ -42,5 +42,5 @@
     void Print();
 
-    operator double();
+    operator double(); //[s]
 };
 
Index: /trunk/MagicSoft/Cosy/candrv/canopen.cc
===================================================================
--- /trunk/MagicSoft/Cosy/candrv/canopen.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/candrv/canopen.cc	(revision 926)
@@ -184,7 +184,8 @@
 }
   
-void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, BYTE_t val)
-{
-    fSdoList.Add(node, idx, subidx);
+void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
+{
+    if (store)
+        fSdoList.Add(node, idx, subidx);
 
     SendCanFrame(CobId(node, kSDO_TX), kSDO_RX1,
@@ -192,7 +193,8 @@
 }
 
-void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, WORD_t val)
-{
-    fSdoList.Add(node, idx, subidx);
+void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
+{
+    if (store)
+        fSdoList.Add(node, idx, subidx);
 
     SendCanFrame(CobId(node, kSDO_TX), kSDO_RX2,
@@ -201,7 +203,8 @@
 }
 
-void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, LWORD_t val)
-{
-    fSdoList.Add(node, idx, subidx);
+void CanOpen::SendSDO(BYTE_t node, WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
+{
+    if (store)
+        fSdoList.Add(node, idx, subidx);
 
     SendCanFrame(CobId(node, kSDO_TX), kSDO_RX4,
Index: /trunk/MagicSoft/Cosy/candrv/nodedrv.cc
===================================================================
--- /trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/candrv/nodedrv.cc	(revision 926)
@@ -7,5 +7,5 @@
 #include "MLogManip.h"
 
-NodeDrv::NodeDrv(BYTE_t nodeid, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
+NodeDrv::NodeDrv(BYTE_t nodeid, const char *name, MLog &out) : Log(out), fNetwork(NULL), fId(32), fError(0)
 {
     if (nodeid>31)
@@ -16,4 +16,20 @@
 
     fId = nodeid;
+
+    if (name)
+    {
+        fName = new char[strlen(name)+1];
+        strcpy(fName, name);
+    }
+    else
+    {
+        fName = new char[9];
+        sprintf(fName, "Node#%d", nodeid);
+    }
+}
+
+NodeDrv::~NodeDrv()
+{
+    delete fName;
 }
 
@@ -80,35 +96,35 @@
 }
 
-void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val)
+void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store)
 {
-    fNetwork->SendSDO(fId, idx, subidx, val);
+    fNetwork->SendSDO(fId, idx, subidx, val, store);
 }
 
-void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val)
+void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store)
 {
-    fNetwork->SendSDO(fId, idx, subidx, val);
+    fNetwork->SendSDO(fId, idx, subidx, val, store);
 }
 
-void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val)
+void NodeDrv::SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store)
 {
-    fNetwork->SendSDO(fId, idx, subidx, val);
+    fNetwork->SendSDO(fId, idx, subidx, val, store);
 }
 
 void NodeDrv::SendSDO(WORD_t idx, BYTE_t val)
 {
-    fNetwork->SendSDO(fId, idx, val);
+    fNetwork->SendSDO(fId, idx, val, true);
 }
 
 void NodeDrv::SendSDO(WORD_t idx, WORD_t val)
 {
-    fNetwork->SendSDO(fId, idx, val);
+    fNetwork->SendSDO(fId, idx, val, true);
 }
 
 void NodeDrv::SendSDO(WORD_t idx, LWORD_t val)
 {
-    fNetwork->SendSDO(fId, idx, val);
+    fNetwork->SendSDO(fId, idx, val, true);
 }
 
-void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx=0)
+void NodeDrv::RequestSDO(WORD_t idx, BYTE_t subidx)
 {
     fNetwork->RequestSDO(fId, idx, subidx);
Index: /trunk/MagicSoft/Cosy/candrv/nodedrv.h
===================================================================
--- /trunk/MagicSoft/Cosy/candrv/nodedrv.h	(revision 925)
+++ /trunk/MagicSoft/Cosy/candrv/nodedrv.h	(revision 926)
@@ -13,4 +13,6 @@
     BYTE_t   fId;
 
+    char *fName;
+
     int fError;
 
@@ -21,8 +23,10 @@
 
 public:
-    NodeDrv(BYTE_t nodeid, MLog &out=gLog);
+    NodeDrv(BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
+    virtual ~NodeDrv();
 
-    BYTE_t   GetId()      { return fId; }
-    Network *GetNetwork() { return fNetwork; }
+    BYTE_t   GetId() const       { return fId;   }
+    char    *GetNodeName() const { return fName; }
+    Network *GetNetwork()        { return fNetwork; }
 
     virtual void InitDevice(Network *net);
@@ -47,7 +51,7 @@
                   BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
 
-    void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val);
-    void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val);
-    void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val);
+    void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);
+    void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);
+    void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store=true);
 
     void SendSDO(WORD_t idx, BYTE_t val);
Index: /trunk/MagicSoft/Cosy/devdrv/macs.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/devdrv/macs.cc	(revision 926)
@@ -6,7 +6,8 @@
 #include "timer.h"
 #include "network.h"
-
-Macs::Macs(BYTE_t nodeid, MLog &out)
-    : NodeDrv(nodeid, out), fMacId(2*nodeid+1),
+#include "MLogManip.h"
+
+Macs::Macs(const BYTE_t nodeid, const char *name, MLog &out)
+    : NodeDrv(nodeid, name, out), fMacId(2*nodeid+1),
     fPos(0), fPosTime(0.0), fPdoPos(0), fPdoTime(0.0),
     fPosActive(0), fRpmActive(0)
@@ -26,9 +27,9 @@
     {
     case 0x100a:
-        lout << "- Mac using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
+        lout << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
         return;
 
     case 0x2002:
-        cout << "Actual velocity: " << dec << val << endl;
+        cout << GetNodeName() << ": Actual velocity: " << dec << val << endl;
         fVel = val;
         return;
@@ -38,8 +39,8 @@
         {
         case 1:
-            cout << "Timeout timer is " << (val?"en":"dis") << "abled." << endl;
+            cout << GetNodeName() << ": Timeout timer is " << (val?"en":"dis") << "abled." << endl;
             return;
         case 2:
-            cout << "Actual timeout time: " << dec << val << "ms" << endl;
+            cout << GetNodeName() << ": Actual timeout time: " << dec << val << "ms" << endl;
             return;
         }
@@ -89,5 +90,5 @@
 
     case 0x6002:
-        lout << "- Velocity resolution Node#" << (int)GetId() << ": " << dec << val << " ticks/min" << endl;
+        lout << "- Velocity resolution " << GetNodeName() << ": " << dec << val << " ticks/min" << endl;
         fVelRes = val;
         return;
@@ -97,45 +98,18 @@
 }
 
-void Macs::SetTimeoutTime(LWORD_t ms)
-{
-    fTimeoutTime = ms/2;
-
-    SendSDO(0x4000, 2, ms);
-    WaitForSdo(0x4000, 2);
-}
-
-void Macs::ReqTimeoutTime()
-{
-    RequestSDO(0x4000, 2);
-    WaitForSdo(0x4000, 2);
-}
-
-void Macs::EnableTimeout(bool enable, LWORDS_t ms)
-{
-    if (!enable)
-    {
-        SendSDO(0x4000, 1, string('o', 'f', 'f'));
-        WaitForSdo(0x4000, 1);
-
-        cout << "--> Turn Off. " << endl;
-        fTimerOn = kFALSE;
-    }
-    else
-    {
-        if (ms>0)
-            SetTimeoutTime(ms);
-
-        cout << "--> Turn On." << endl;
-        fTimerOn = kTRUE;
-        fTimeout->Start(fTimeoutTime, kTRUE);
-
-        SendSDO(0x4000, 1, string('o', 'n'));
-        WaitForSdo(0x4000, 1);
-    }
-}
+void Macs::HandleSDOOK(WORD_t idx, BYTE_t subidx)
+{
+    if (idx==0x4000 && subidx==0 && fTimerOn)
+    {
+        ResetTimeout();
+        return;
+    }
+    NodeDrv::HandleSDOOK(idx, subidx);
+}
+
 
 void Macs::ReqVelRes()
 {
-    lout << "- Requesting velocity resolution (velres, 0x6002) of " << (int)GetId() << endl;
+    lout << "- Requesting velocity resolution (velres, 0x6002) of " << GetNodeName() << endl;
     RequestSDO(0x6002);
     WaitForSdo(0x6002);
@@ -144,5 +118,5 @@
 void Macs::SetPDO1On(BYTE_t flag)
 {
-    lout << "- " << (flag?"Enable":"Disable") << " PDO1 of #" << (int)GetId() << endl;
+    lout << "- " << (flag?"Enable":"Disable") << " PDO1 of " << GetNodeName() << endl;
     SendSDO(0x1800, 1, (LWORD_t)(flag?0:1)<<31); 
     WaitForSdo(0x1800, 1);           
@@ -171,5 +145,5 @@
     EnableTimeout(kFALSE);
 
-    lout << "- Requesting Mac Software Version of " << (int)GetId() << endl;
+    lout << "- Requesting Mac Software Version of " << GetNodeName() << endl;
     RequestSDO(0x100a);
     WaitForSdo(0x100a);
@@ -179,5 +153,5 @@
     ReqVelRes(); // Init fVelRes
 
-    lout << "- Motor on of " << (int)GetId() << endl;
+    lout << "- Motor on of " << GetNodeName() << endl;
     SendSDO(0x3000, string('o', 'n'));
     WaitForSdo(0x3000);
@@ -219,5 +193,5 @@
     SetPDO1On(FALSE);
 
-    lout << "- Motor off of " << (int)GetId() << endl;
+    lout << "- Motor off of " << GetNodeName() << endl;
     SendSDO(0x3000, string('o', 'f', 'f'));
     WaitForSdo(0x3000);
@@ -232,5 +206,5 @@
 void Macs::ReqPos()
 {
-    lout << "- Requesting Position of #" << (int)GetId() << endl;
+    lout << "- Requesting Position of " << GetNodeName() << endl;
     RequestSDO(0x6004);
     WaitForSdo(0x6004);
@@ -239,5 +213,5 @@
 void Macs::ReqVel()
 {
-    lout << "- Requesting Velocity of #" << (int)GetId() << endl;
+    lout << "- Requesting Velocity of " << GetNodeName() << endl;
     RequestSDO(0x2002);
     WaitForSdo(0x2002);
@@ -246,5 +220,5 @@
 void Macs::SetHome(LWORDS_t pos, WORD_t maxtime)
 {
-    lout << "- Driving #" << (int)GetId() << " to home position, Offset=" << dec << pos << endl;
+    lout << "- Driving " << GetNodeName() << " to home position, Offset=" << dec << pos << endl;
     SendSDO(0x6003, 2, (LWORD_t)pos);       // home
     WaitForSdo(0x6003, 2);
@@ -254,5 +228,5 @@
     SendSDO(0x3001, string('h','o','m','e'));       // home
     WaitForSdo(0x3001, 0, maxtime*1000);
-    lout << "- Home position of #" << (int)GetId() << " reached. " << endl;
+    lout << "- Home position of " << GetNodeName() << " reached. " << endl;
 
     SendSDO(0x6003, 0, string('s','e','t'));       // home
@@ -305,5 +279,5 @@
 void Macs::SetNoWait(BYTE_t flag)
 {
-    lout << "- Setting NOWAIT " << (flag?"ON":"OFF") << " #" << (int)GetId() << endl;
+    lout << "- Setting NOWAIT " << (flag?"ON ":"OFF ") << GetNodeName() << endl;
     SendSDO(0x3008, flag ? string('o', 'n') : string('o', 'f', 'f'));
     WaitForSdo(0x3008);
@@ -316,5 +290,5 @@
     // or by a positioning command (POSA, ...)
     //
-    lout << "- Setting Vel Sync Mode #" << (int)GetId() << endl;
+    lout << "- Setting Vel Sync Mode of " << GetNodeName() << endl;
     SendSDO(0x3007, 0, string('s', 'y', 'n', 'c'));
     WaitForSdo(0x3007, 0);
@@ -327,5 +301,5 @@
     // or by a positioning command (POSA, ...)
     //
-    lout << "- Setting Pos Sync Mode #" << (int)GetId() << endl;
+    lout << "- Setting Pos Sync Mode of " << GetNodeName() << endl;
     SendSDO(0x3007, 1, string('s', 'y', 'n', 'c'));
     WaitForSdo(0x3007, 1);
@@ -372,5 +346,5 @@
     if (!errnum)
     {
-        cout << "Mac #" << (int)GetId() << " reports Error occursion." << endl;
+        cout << "Mac " << GetNodeName() << " reports Error occursion." << endl;
         SetError(-1);
         return;
@@ -382,9 +356,9 @@
     //
     if (GetError()>0)
-        cout << "Mac #" << (int)GetId() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
+        cout << "Mac " << GetNodeName() << " WARNING! Error #" << GetError() << " unhandled by software." << endl;
 
     SetError(errnum);
 
-    cout << "Mac #" << (int)GetId() << " reports: ";
+    cout << "Mac " << GetNodeName() << " reports: ";
     switch (errnum)
     {
@@ -429,4 +403,8 @@
         return;
 
+    case 100:
+        cout << "Connection timed out." << endl;
+        return;
+
     default:
         cout << "Error Nr. " << errnum << ", " << errinf << endl;
@@ -456,5 +434,5 @@
     // we can go on working 'as usual' Eg. Initialize a Display Update
     //
-    cout << "Mac #" << (int)GetId() << " Handling Error #" << GetError() << endl;
+    cout << "Mac " << GetNodeName() << " Handling Error #" << GetError() << endl;
     switch (GetError())
     {
@@ -463,10 +441,15 @@
     case   9: // zero idx
     case  84: // ON TIME
-    case 100: // timeout
         // Stop program?
         return;
 
-    case 11: // software endswitch
-    case 25: // hardware endswitch
+    case 11:  // software endswitch
+    case 25:  // hardware endswitch
+    case 100: // timeout (movement has been stopped, so we can go on)
+        DelError();
+        return;
+
+    case 101:
+        lout << "Warning: " << GetNodeName() << " didn't respond in timeout window - try again." << endl;
         DelError();
         return;
@@ -513,4 +496,38 @@
     SendSDO(0x2000, 3, (LWORD_t)(neg|(pos<<1)));
     WaitForSdo(0x2000, 3);
+}
+
+void Macs::ReqTimeoutTime()
+{
+    RequestSDO(0x4000, 2);
+    WaitForSdo(0x4000, 2);
+}
+
+void Macs::EnableTimeout(bool enable, LWORDS_t ms)
+{
+    if (!enable)
+    {
+        SendSDO(0x4000, 1, string('o', 'f', 'f'));
+        WaitForSdo(0x4000, 1);
+
+        fTimeout->Stop(); //kTRUE);
+
+        fTimerOn = kFALSE;
+    }
+    else
+    {
+        if (ms>0)
+            SetTimeoutTime(ms);
+
+        ResetTimeout();
+
+        fTimerOn = kTRUE;
+        fTimeout->Start(fGuardTime, kFALSE); //kTRUE);
+
+        SendSDO(0x4000, 1, string('o', 'n'));
+        WaitForSdo(0x4000, 1);
+    }
+    lout << "- Timeout timer of " << GetNodeName() << " turned "
+        << (enable?"on.":"off.") << endl;
 }
 
@@ -542,8 +559,39 @@
        time.
        */
-    SendSDO(0x4000);
-    WaitForSdo(0x4000, 0, kDontWait);
-    if (fTimerOn)
-        fTimeout->Start(fTimeoutTime, kTRUE);
+
+    //
+    //  FIXME! Use NMT!
+    //
+    SendSDO(0x4000, 0, (LWORD_t)0, false);
+
+    Timer time;
+    if (time.Now() > fTimeoutTime)
+    {
+        lout << ddev(MLog::eGui);
+        lout << "Warning: " << GetNodeName() << " didn't respond in timeout window." << endl;
+        lout << edev(MLog::eGui);
+        SetError(101);
+    }
+
+
+    //WaitForSdo(0x4000, 0, kDontWait);
+    //    if (fTimerOn)
+    //        fTimeout->Start(fGuardTime, kTRUE);
+
     return kTRUE;
 }
+
+void Macs::ResetTimeout()
+{
+    Timer time;
+    fTimeoutTime = time.Now() + 2.*fGuardTime/1000.; //[usec]
+}
+
+void Macs::SetTimeoutTime(LWORD_t ms)
+{
+    fGuardTime = ms/2; // FIXME: Is '/2' the best choose?
+
+    SendSDO(0x4000, 2, ms);
+    WaitForSdo(0x4000, 2);
+}
+
Index: /trunk/MagicSoft/Cosy/devdrv/macs.h
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 925)
+++ /trunk/MagicSoft/Cosy/devdrv/macs.h	(revision 926)
@@ -26,5 +26,6 @@
     TTimer  *fTimeout;
     Bool_t   fTimerOn;
-    LWORD_t  fTimeoutTime;
+    LWORD_t  fGuardTime;
+    double   fTimeoutTime;
 
     LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
@@ -33,8 +34,9 @@
     }
 
+    void ResetTimeout();
     Bool_t HandleTimer(TTimer *t);
 
 public:
-    Macs(BYTE_t nodeid, MLog &out=gLog);
+    Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     virtual ~Macs();
 
@@ -45,5 +47,5 @@
 
     void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
-    void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
+    void HandleSDOOK(WORD_t idx, BYTE_t subidx);
     void HandleSDOError(LWORD_t data)           { NodeDrv::HandleSDOError(data); }
 
Index: /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc	(revision 926)
@@ -13,5 +13,6 @@
 #include <sys/resource.h>  // PRIO_PROCESS
 
-ShaftEncoder::ShaftEncoder(BYTE_t nodeid, MLog &out) : NodeDrv(nodeid, out), fLabel(NULL), fPosHasChanged(false)
+ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name, MLog &out)
+    : NodeDrv(nodeid, name, out), fLabel(NULL), fPosHasChanged(false)
 {
 }
@@ -195,5 +196,5 @@
     // Requesting and checking (FIXME) type of encoder
     //
-    lout << "- Requesting Hardware Type (SDO 0x1000) of " << (int)GetId() << endl;
+    lout << "- Requesting Hardware Type (SDO 0x1000) of " << GetNodeName() << endl;
     RequestSDO(0x1000);
     WaitForSdo(0x1000);
@@ -202,5 +203,5 @@
     // Read physical ticks per revolution
     //
-    lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << (int)GetId() << endl;
+    lout << "- Requesting physical ticks/revolution (SDO 0x6501) of " << GetNodeName() << endl;
     RequestSDO(0x6501);
     WaitForSdo(0x6501);
@@ -209,5 +210,5 @@
     // Read number of possible ticks per revolution
     //
-    lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << (int)GetId() << endl;
+    lout << "- Requesting possible ticks/revolution (SDO 0x6502) of " << GetNodeName() << endl;
     RequestSDO(0x6502);
     WaitForSdo(0x6502);
@@ -216,5 +217,5 @@
     // Set logic ticks/revolution = physical ticks/revolution => scale factor = 1
     //
-    lout << "- Configuring SDO 0x6001 of " << (int)GetId() << endl;
+    lout << "- Configuring SDO 0x6001 of " << GetNodeName() << endl;
     SendSDO(0x6001, fTicks);
     WaitForSdo(0x6001);
@@ -223,5 +224,5 @@
     // Set maximum number of ticks (ticks * turns)
     //
-    lout << "- Configuring SDO 0x6002 of " << (int)GetId() << endl;
+    lout << "- Configuring SDO 0x6002 of " << GetNodeName() << endl;
     SendSDO(0x6002, (LWORD_t)(fTicks*fTurns));
     WaitForSdo(0x6002);
@@ -230,5 +231,5 @@
     // Configure PDOs
     //
-    lout << "- Configuring SDO 0x1802 of " << (int)GetId() << endl;
+    lout << "- Configuring SDO 0x1802 of " << GetNodeName() << endl;
     SendSDO(0x1802, 1, (LWORD_t)0x281);
     WaitForSdo(0x1802, 1);
@@ -237,5 +238,5 @@
     // Delete preset Value
     //
-    lout << "- Configuring SDO 0x6003 of " << (int)GetId() << endl;
+    lout << "- Configuring SDO 0x6003 of " << GetNodeName() << endl;
     SendSDO(0x6003, (LWORD_t)0xffffffff);
     WaitForSdo(0x6003);
@@ -244,5 +245,5 @@
     // Request Parameter
     //
-    lout << "- Requesting SDO 0x6000 of " << (int)GetId() << endl;
+    lout << "- Requesting SDO 0x6000 of " << GetNodeName() << endl;
     RequestSDO(0x6000);
     WaitForSdo(0x6000);
@@ -250,5 +251,5 @@
     ReqPos();
 
-    lout << "- Start Node " << (int)GetId() << endl;
+    lout << "- Start Node " << GetNodeName() << endl;
     SendNMT(kNMT_START);
 }
@@ -259,5 +260,5 @@
     // Request Position
     //
-    lout << "- Requesting Position of #" << (int)GetId() << endl;
+    lout << "- Requesting Position of " << GetNodeName() << endl;
     RequestSDO(0x6004);
     WaitForSdo(0x6004);
@@ -269,5 +270,5 @@
     fTurn = pre/16384;
 
-    lout << " - Setting Preset #" << (int)GetId() << endl;
+    lout << " - Setting Preset " << GetNodeName() << endl;
     SendSDO(0x6003, (LWORD_t)fPos);
     WaitForSdo(0x6003);
@@ -276,5 +277,5 @@
 void ShaftEncoder::StopDevice()
 {
-    lout << "- Start Node " << (int)GetId() << endl;
+    lout << "- Start Node " << GetNodeName() << endl;
     SendNMT(kNMT_STOP);
 }
Index: /trunk/MagicSoft/Cosy/devdrv/shaftencoder.h
===================================================================
--- /trunk/MagicSoft/Cosy/devdrv/shaftencoder.h	(revision 925)
+++ /trunk/MagicSoft/Cosy/devdrv/shaftencoder.h	(revision 926)
@@ -33,5 +33,5 @@
 
 public:
-    ShaftEncoder(BYTE_t nodeid, MLog &out=gLog);
+    ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
     virtual ~ShaftEncoder();
 
Index: /trunk/MagicSoft/Cosy/gui/MGCosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/gui/MGCosy.cc	(revision 926)
@@ -437,4 +437,5 @@
 
     // TGMainFrame::CloseWindow();
+    cout << "Closing window - waiting until all nodes are stopped." << endl;
     fQueue->PostMsg(WM_QUIT, 0, 0);
     // gApplication->Terminate(0);
Index: /trunk/MagicSoft/Cosy/main/MCosy.cc
===================================================================
--- /trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 925)
+++ /trunk/MagicSoft/Cosy/main/MCosy.cc	(revision 926)
@@ -125,6 +125,6 @@
 ZdAz MCosy::GetSePos()
 {
-    const int p0 = fAlt1->GetPos();
-    const int p1 = fAlt2->GetPos();
+    const int p0 = fZd1->GetPos();
+    const int p1 = fZd2->GetPos();
     const int p2 = fAz->GetPos();
 
@@ -362,5 +362,8 @@
     else
         if (fabs(vt->Az()) > 0.9*vraz)
+        {
+            lout << "Warning: Azimuth speed limit exceeded. Limiting speed to 90% max." << endl;
             vt->Az(0.9*vraz*sgn(vt->Az()));
+        }
 
     if (sgn(vt->Zd()) != sgn(vcalc.Zd()) &&
@@ -369,5 +372,8 @@
     else
         if (fabs(vt->Zd()) > 0.9*vrzd)
+        {
+            lout << "Warning: Altitude speed limit exceeded. Limiting speed to 90% max." << endl;
             vt->Zd(0.9*vrzd*sgn(vt->Zd()));
+        }
 }
 
@@ -568,6 +574,6 @@
     case WM_PRESET:
         cout << "WM_Preset: start." << endl;
-        fAlt1->SetPreset();
-        fAlt2->SetPreset();
+        fZd1->SetPreset();
+        fZd2->SetPreset();
         fAz->SetPreset();
         cout << "WM_Preset: done. (return 0xaffe)" << endl;
@@ -588,6 +594,6 @@
             cout << "Got  Zd: " << sepos.Zd() << " Az: " << sepos.Az() << endl;
 
-            fAlt1->SetPreset(za.Zd());
-            fAlt2->SetPreset(-za.Zd());
+            fZd1->SetPreset(za.Zd());
+            fZd2->SetPreset(-za.Zd());
             fAz->SetPreset(za.Az());
 
@@ -759,6 +765,6 @@
             do
             {
-                phca1 = fAlt1->PosHasChanged();
-                phca2 = fAlt2->PosHasChanged();
+                phca1 = fZd1->PosHasChanged();
+                phca2 = fZd2->PosHasChanged();
                 phcaz = fAz->PosHasChanged();
                 usleep(1);
@@ -786,5 +792,5 @@
             // FIXME: I cannot take the avarage
             //
-            time.Zd((fAlt1->GetMjd()+fAlt2->GetMjd())/2.0);
+            time.Zd((fZd1->GetMjd()+fZd2->GetMjd())/2.0);
             time.Az(fAz->GetMjd());
 
@@ -823,6 +829,6 @@
     // Update Gui, foremer MTGui.
     //
-    fAlt1->DisplayVal();
-    fAlt2->DisplayVal();
+    fZd1->DisplayVal();
+    fZd2->DisplayVal();
     fAz->DisplayVal();
 
@@ -874,10 +880,11 @@
     // Create Nodes
     //
-    fMac1=new Macs(1, lout);
-    fMac2=new Macs(2, lout);
-    fMac3=new Macs(3, lout);
-    fAlt1=new ShaftEncoder(4, lout);
-    fAlt2=new ShaftEncoder(5, lout);
-    fAz  =new ShaftEncoder(6, lout);
+    fMac1=new Macs(1, "Mac.1/Az",      lout);
+    fMac2=new Macs(2, "Mac.2/Zd",      lout);
+    fMac3=new Macs(3, "Mac.3/Az-Sync", lout);
+
+    fZd1=new ShaftEncoder(4, "SE.4/Zd1", lout);
+    fZd2=new ShaftEncoder(5, "SE.5/Zd2", lout);
+    fAz =new ShaftEncoder(6, "SE.6/Az",  lout);
 
     //
@@ -887,6 +894,6 @@
     SetNode(fMac2);
     SetNode(fMac3);
-    SetNode(fAlt1);
-    SetNode(fAlt2);
+    SetNode(fZd1);
+    SetNode(fZd2);
     SetNode(fAz);
 
@@ -899,6 +906,6 @@
 
     fAz->SetDisplay(fWin->GetLabel1());
-    fAlt1->SetDisplay(fWin->GetLabel2());
-    fAlt2->SetDisplay(fWin->GetLabel3());
+    fZd1->SetDisplay(fWin->GetLabel2());
+    fZd2->SetDisplay(fWin->GetLabel3());
 
     lout.SetOutputGui(fWin->GetLog(), kTRUE);
@@ -930,6 +937,6 @@
 
     delete fAz;
-    delete fAlt2;
-    delete fAlt1;
+    delete fZd2;
+    delete fZd1;
     delete fMac1;
     delete fMac2;
Index: /trunk/MagicSoft/Cosy/main/MCosy.h
===================================================================
--- /trunk/MagicSoft/Cosy/main/MCosy.h	(revision 925)
+++ /trunk/MagicSoft/Cosy/main/MCosy.h	(revision 926)
@@ -50,6 +50,6 @@
 
 private:
-    ShaftEncoder *fAlt1;
-    ShaftEncoder *fAlt2;
+    ShaftEncoder *fZd1;
+    ShaftEncoder *fZd2;
     ShaftEncoder *fAz;
 
