Index: /trunk/Cosy/devdrv/dkc.cc
===================================================================
--- /trunk/Cosy/devdrv/dkc.cc	(revision 10028)
+++ /trunk/Cosy/devdrv/dkc.cc	(revision 10029)
@@ -30,34 +30,34 @@
     {
     case 0: return "offline";
-    case 0xa000:
-    case 0xa001:
-    case 0xa002:
-    case 0xa003: return MString::Format("Communication phase %d", stat&0xf);
-    case 0xa010: return "Drive HALT";
-    case 0xa012: return "Control and power section ready for operation";
-    case 0xa013: return "Ready for power on";
-    case 0xa100: return "Drive in Torque mode";
-    case 0xa101: return "Drive in Velocity mode";
-    case 0xa102: return "Position control mode with encoder 1";
-    case 0xa103: return "Position control mode with encoder 2";
-    case 0xa104: return "Position control mode with encoder 1, lagless";
-    case 0xa105: return "Position control mode with encoder 2, lagless";
-    case 0xa106: return "Drive controlled interpolated positioning with encoder 1";
-    case 0xa107: return "Drive controlled interpolated positioning with encoder 2";
-    case 0xa108: return "Drive controlled interpolated positioning with encoder 1, lagless";
-    case 0xa109: return "Drive controlled interpolated positioning with encoder 2, lagless";
+    case 0xa000: case 0xa0000:
+    case 0xa001: case 0xa0001:
+    case 0xa002: case 0xa0002:
+    case 0xa003: case 0xa0003: return MString::Format("Communication phase %d", stat&0xf);
+    case 0xa010: case 0xa0010: return "Drive HALT";
+    case 0xa012: case 0xa0012: return "Control and power section ready for operation";
+    case 0xa013: case 0xa0013: return "Ready for power on";
+    case 0xa100: case 0xa0100: return "Drive in Torque mode";
+    case 0xa101: case 0xa0101: return "Drive in Velocity mode";
+    case 0xa102: case 0xa0102: return "Position control mode with encoder 1";
+    case 0xa103: case 0xa0103: return "Position control mode with encoder 2";
+    case 0xa104: case 0xa0104: return "Position control mode with encoder 1, lagless";
+    case 0xa105: case 0xa0105: return "Position control mode with encoder 2, lagless";
+    case 0xa106: case 0xa0106: return "Drive controlled interpolated positioning with encoder 1";
+    case 0xa107: case 0xa0107: return "Drive controlled interpolated positioning with encoder 2";
+    case 0xa108: case 0xa0108: return "Drive controlled interpolated positioning with encoder 1, lagless";
+    case 0xa109: case 0xa0109: return "Drive controlled interpolated positioning with encoder 2, lagless";
     //case 0xa146: return "Drive controlled interpolated relative positioning with encoder 1";
     //case 0xa147: return "Drive controlled interpolated relative positioning with encoder 2";
     //case 0xa148: return "Drive controlled interpolated relative positioning lagless with encoder 1";
     //case 0xa149: return "Drive controlled interpolated relative positioning lagless with encoder 2";
-    case 0xa150: return "Drive controlled positioning with encoder 1";
-    case 0xa151: return "Drive controlled positioning with encoder 1, lagless";
-    case 0xa152: return "Drive controlled positioning with encoder 2";
-    case 0xa153: return "Drive controlled positioning with encoder 2, lagless";
-    case 0xa208: return "Jog mode positive";
-    case 0xa218: return "Jog mode negative";
-    case 0xa400: return "Automatic drive check and adjustment";
-    case 0xa401: return "Drive decelerating to standstill";
-    case 0xa800: return "Unknown operation mode";
+    case 0xa150: case 0xa0150: return "Drive controlled positioning with encoder 1";
+    case 0xa151: case 0xa0151: return "Drive controlled positioning with encoder 1, lagless";
+    case 0xa152: case 0xa0152: return "Drive controlled positioning with encoder 2";
+    case 0xa153: case 0xa0153: return "Drive controlled positioning with encoder 2, lagless";
+    case 0xa208:               return "Jog mode positive";
+    case 0xa218:               return "Jog mode negative";
+    case 0xa400: case 0xa4000: return "Automatic drive check and adjustment";
+    case 0xa401: case 0xa4001: return "Drive decelerating to standstill";
+    case 0xa800: case 0xa0800: return "Unknown operation mode";
     case 0xc217: return "Motor encoder reading error";
     case 0xc218: return "Shaft encoder reading error";
@@ -65,10 +65,10 @@
     case 0xc221: return "Shaft encoder initialization error";
     case 0xc300: return "Command: set absolute measure";
-    case 0xc400: return "Switching to parameter mode";
-    case 0xc401: return "Drive active, switching mode not allowed";
-    case 0xc500: return "Error reset";
-    case 0xc600: return "Drive controlled homi*ng procedure ";
+    case 0xc400: case 0xc0400: return "Switching to parameter mode";
+    case 0xc401: case 0xc0401: return "Drive active, switching mode not allowed";
+    case 0xc500: case 0xc0500: return "Error reset";
+    case 0xc600: case 0xc0600: return "Drive controlled homing procedure";
     case 0xe225: return "Motor overload";
-    case 0xe249: return "Positioning command velocity exceeds limit bipolar";
+    case 0xe249: case 0xe2049: return "Positioning command velocity exceeds limit bipolar";
     case 0xe250: return "Drive overtemp warning";
     case 0xe251: return "Motor overtemp warning";
@@ -76,4 +76,5 @@
     case 0xe257: return "Continous current limit active";
     case 0xe259: return "Command velocity limit active";
+                 case 0xe8260: return "Torque limit active";
     case 0xe264: return "Target position out of numerical range";
     case 0xe829: return "Positive position limit exceeded";
@@ -84,14 +85,17 @@
     case 0xe843: return "Positive end-switch activated";
     case 0xe844: return "Negative end-switch activated";
-    case 0xf218: return "Amplifier overtemp shutdown";
-    case 0xf219: return "Motor overtemp shutdown";
+    case 0xf218: case 0xf2018: return "Amplifier overtemp shutdown";
+    case 0xf219: case 0xf2019: return "Motor overtemp shutdown";
     case 0xf220: return "Bleeder overload shutdown";
-    case 0xf221: return "Motor temperature surveillance defective";
+    case 0xf221: case 0xf2021: return "Motor temperature surveillance defective";
+                 case 0xf2022: return "Unit temperature surveillance defective";
     case 0xf224: return "Maximum breaking time exceeded";
-    case 0xf228: return "Excessive control deviation";
+                 case 0xf2025: return "Drive not ready for power on";
+    case 0xf228: case 0xf2028: return "Excessive control deviation";
     case 0xf250: return "Overflow of target position preset memory";
     case 0xf269: return "Error during release of the motor holding brake";
     case 0xf276: return "Absolute encoder out of allowed window";
-    case 0xf409: return "Bus error on Profibus interface";
+                 case 0xf2174: return "Lost reference of motor encoder";
+    case 0xf409: case 0xf4009: return "Bus error on Profibus interface";
     case 0xf434: return "Emergency-Stop";
     case 0xf629: return "Positive position limit exceeded";
@@ -100,6 +104,9 @@
     case 0xf643: return "Positive end-switch activated";
     case 0xf644: return "Negative end-switch activated";
-    case 0xf870: return "24V DC error";
-    case 0xf878: return "Velocity loop error";
+                 case 0xf8069: return "15V DC error";
+    case 0xf870: case 0xf8070: return "24V DC error";
+    case 0xf878: case 0xf8078: return "Velocity loop error";
+                 case 0xf8079: return "Velocity limit exceeded";
+                 case 0xf2026: return "Undervoltage in power section";
     }
     return "unknown";
@@ -108,6 +115,6 @@
 TString Dkc::GetStatus(LWORD_t val) const
 {
-    const Int_t errnum = val&0xffff;
-    const Int_t errinf = val>>16;
+    const Int_t errnum = val&0xff;
+    const Int_t errinf = val>>8;
 
     if (errnum!=0xff)
@@ -120,13 +127,13 @@
     TString str;
 
-    const Int_t type = errinf&0xf000;
+    const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
     switch (type)
     {
-    case 0xf000: str += "ERROR";   break;
-    case 0xe000: str += "WARNING"; break;
-    case 0xa000: str += "Status";  break;
-    case 0xc000: 
-    case 0xd000: str += "Message"; break;
-    default:     str += "Unknown"; break;
+    case 0xf: str += "ERROR";   break;
+    case 0xe: str += "WARNING"; break;
+    case 0xa: str += "Status";  break;
+    case 0xc:
+    case 0xd: str += "Message"; break;
+    default:  str += "Unknown"; break;
     }
 
@@ -135,5 +142,5 @@
     str += "): ";
     str += EvalStatusDKC(errinf);
-    str += (type==0xf000 || type==0xe000 ? "!" : ".");
+    str += (type==0xf || type==0xe ? "!" : ".");
 
     return str;
@@ -142,6 +149,6 @@
 Bool_t Dkc::PrintStatus(LWORD_t val) const
 {
-    const Int_t errnum = val&0xffff;
-    const Int_t errinf = val>>16;
+    const Int_t errnum = val&0xff;
+    const Int_t errinf = val>>8;
 
     if (errnum!=0xff)
@@ -151,5 +158,6 @@
 
     // errinf==0: DKC offline. This is a fatal error
-    return errinf==0 ? kFALSE : (errinf&0xf000)!=0xf000;
+    const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
+    return errinf==0 ? kFALSE : (type&0xf)!=0xf;
 }
 
@@ -356,5 +364,4 @@
     Arm();
 #endif
-
     gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl;
     RequestSDO(0x1000);
@@ -529,26 +536,33 @@
     }
 
-    if (fStatusPdo3!=data[0])
-    {
-        gLog << inf << MTime(-1) << ": " << GetNodeName() << " - PDO1 = ";
-        const Bool_t ready = data[0]&0x01;
-        const Bool_t fuse  = data[0]&0x02;
-        const Bool_t emcy  = data[0]&0x04;
-        const Bool_t vltg  = data[0]&0x08;
-        const Bool_t mode  = data[0]&0x10;
-        const Bool_t rf    = data[0]&0x20;
-        const Bool_t brake = data[0]&0x40;
-        const Bool_t power = data[0]&0x80;
-        if (ready) gLog << "DKC-Ready ";
-        if (fuse)  gLog << "FuseOk ";
-        if (emcy)  gLog << "EmcyOk ";
-        if (vltg)  gLog << "OvervoltOk ";
-        if (mode)  gLog << "SwitchToManualMode ";
-        if (rf)    gLog << "RF ";
-        if (brake) gLog << "BrakeOpen ";
-        if (power) gLog << "PowerOn ";
+    const LWORD_t stat = data[0] | (data[1]<<8);
+    if (fStatusPdo3!=stat)
+    {
+        gLog << inf << MTime(-1) << ": " << GetNodeName() << " - PDO2(0x" << hex << (int)stat << dec << ") = ";
+        const Bool_t ready  = stat&0x001;
+        const Bool_t fuse   = stat&0x002;
+        const Bool_t emcy   = stat&0x004;
+        const Bool_t vltg   = stat&0x008;
+        const Bool_t mode   = stat&0x010;
+        const Bool_t rf     = stat&0x020;
+        const Bool_t brake  = stat&0x040;
+        const Bool_t power  = stat&0x080;
+        const Bool_t alarm  = stat&0x100;  // UPS Alarm      (FACT only)
+        const Bool_t batt   = stat&0x200;  // UPS on battery (FACT only)
+        const Bool_t charge = stat&0x400;  // UPS charging   (FACT only)
+        if (ready)  gLog << "DKC-Ready ";
+        if (fuse)   gLog << "FuseOk ";
+        if (emcy)   gLog << "EmcyOk ";
+        if (vltg)   gLog << "OvervoltOk ";
+        if (mode)   gLog << "SwitchToManualMode ";
+        if (rf)     gLog << "RF ";
+        if (brake)  gLog << "BrakeOpen ";
+        if (power)  gLog << "PowerOn ";
+        if (alarm)  gLog << "UPS-PowerLoss ";
+        if (batt)   gLog << "UPS-OnBattery ";
+        if (charge) gLog << "UPS-Charging ";
         gLog << endl;
 
-        fStatusPdo3 = data[0];
+        fStatusPdo3 = stat;
     }
 }
@@ -570,5 +584,6 @@
 
     // Check if the DKC changed its status message
-    if (errnum==0xff && (errinf&0xf000)<=0xe000)
+    const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
+    if (errnum==0xff && (type&0xf)<=0xe)
     {
         CheckErrorDKC(errnum, errinf);
Index: /trunk/Cosy/devdrv/dkc.h
===================================================================
--- /trunk/Cosy/devdrv/dkc.h	(revision 10028)
+++ /trunk/Cosy/devdrv/dkc.h	(revision 10029)
@@ -33,5 +33,5 @@
     BYTE_t   fStatus;
     LWORD_t  fStatusDKC;
-    BYTE_t   fStatusPdo3;
+    WORD_t   fStatusPdo3;
 
     bool fHasChangedPos1;  //!
@@ -52,5 +52,5 @@
     Bool_t  EvalStatus(UInt_t errnum, UInt_t errinf) const
     {
-        return PrintStatus(errnum|(errinf<<16));
+        return PrintStatus(errnum|(errinf<<8));
     }
     TString GetStatus(LWORD_t val) const;
@@ -58,5 +58,5 @@
     void CheckErrorDKC(UInt_t errnum, UInt_t errinf)
     {
-        CheckErrorDKC(errnum|(errinf<<16));
+        CheckErrorDKC(errnum|(errinf<<8));
     }
 
@@ -107,6 +107,6 @@
 
     int IsPositioning() const { return fPosActive; }
-    BYTE_t GetStatus() const { return fStatus; }
-    BYTE_t GetStatusPdo3() const { return fStatusPdo3; }
+    BYTE_t  GetStatus() const { return fStatus; }
+    LWORD_t GetStatusPdo3() const { return fStatusPdo3; }
 
     LWORDS_t GetPdoPos1() const { return fPdoPos1; }
@@ -119,5 +119,5 @@
     LWORD_t  GetPosRes() const { return fPosRes; } // Velocity units (would be 100 for %)
 
-    bool IsOperative() const { return fStatusPdo3==0xef; }
+    bool IsOperative() const { return (fStatusPdo3&0xff)==0xef; }
     bool IsRpmActive() const { return fRpmActive; }
 
