source: trunk/Cosy/devdrv/dkc.cc@ 12675

Last change on this file since 12675 was 12587, checked in by tbretz, 13 years ago
Added sending the command to set the FACT Led voltages
File size: 21.8 KB
Line 
1#include "dkc.h"
2
3#include <sys/time.h> // timeval->tv_sec
4
5#include <TGLabel.h>
6
7#include "network.h"
8
9#include "MLogManip.h"
10
11#include "MString.h"
12
13ClassImp(Dkc);
14
15using namespace std;
16
17//#define EXPERT
18
19Dkc::Dkc(const BYTE_t nodeid, const char *name)
20 : NodeDrv(nodeid, name), fMacId(2*nodeid+1),
21 fPdoPos1(0), fPdoPos2(0), fPosActive(0), fRpmActive(0),
22 fStatus(0xff), fStatusDKC(0), fStatusPdo3(0xff), fArmed(false),
23 fReport(NULL),fLabel(NULL),fUpdPos(0)
24{
25}
26
27TString Dkc::EvalStatusDKC(UInt_t stat) const
28{
29 switch (stat)
30 {
31 case 0: return "offline";
32 case 0xa000: case 0xa0000:
33 case 0xa001: case 0xa0001:
34 case 0xa002: case 0xa0002:
35 case 0xa003: case 0xa0003: return MString::Format("Communication phase %d", stat&0xf);
36 case 0xa010: case 0xa0010: return "Drive HALT";
37 case 0xa012: case 0xa0012: return "Control and power section ready for operation";
38 case 0xa013: case 0xa0013: return "Ready for power on";
39 case 0xa100: case 0xa0100: return "Drive in Torque mode";
40 case 0xa101: case 0xa0101: return "Drive in Velocity mode";
41 case 0xa102: case 0xa0102: return "Position control mode with encoder 1";
42 case 0xa103: case 0xa0103: return "Position control mode with encoder 2";
43 case 0xa104: case 0xa0104: return "Position control mode with encoder 1, lagless";
44 case 0xa105: case 0xa0105: return "Position control mode with encoder 2, lagless";
45 case 0xa106: case 0xa0106: return "Drive controlled interpolated positioning with encoder 1";
46 case 0xa107: case 0xa0107: return "Drive controlled interpolated positioning with encoder 2";
47 case 0xa108: case 0xa0108: return "Drive controlled interpolated positioning with encoder 1, lagless";
48 case 0xa109: case 0xa0109: return "Drive controlled interpolated positioning with encoder 2, lagless";
49 //case 0xa146: return "Drive controlled interpolated relative positioning with encoder 1";
50 //case 0xa147: return "Drive controlled interpolated relative positioning with encoder 2";
51 //case 0xa148: return "Drive controlled interpolated relative positioning lagless with encoder 1";
52 //case 0xa149: return "Drive controlled interpolated relative positioning lagless with encoder 2";
53 case 0xa150: case 0xa0150: return "Drive controlled positioning with encoder 1";
54 case 0xa151: case 0xa0151: return "Drive controlled positioning with encoder 1, lagless";
55 case 0xa152: case 0xa0152: return "Drive controlled positioning with encoder 2";
56 case 0xa153: case 0xa0153: return "Drive controlled positioning with encoder 2, lagless";
57 case 0xa208: return "Jog mode positive";
58 case 0xa218: return "Jog mode negative";
59 case 0xa400: case 0xa4000: return "Automatic drive check and adjustment";
60 case 0xa401: case 0xa4001: return "Drive decelerating to standstill";
61 case 0xa800: case 0xa0800: return "Unknown operation mode";
62 case 0xc217: return "Motor encoder reading error";
63 case 0xc218: return "Shaft encoder reading error";
64 case 0xc220: return "Motor encoder initialization error";
65 case 0xc221: return "Shaft encoder initialization error";
66 case 0xc300: return "Command: set absolute measure";
67 case 0xc400: case 0xc0400: return "Switching to parameter mode";
68 case 0xc401: case 0xc0401: return "Drive active, switching mode not allowed";
69 case 0xc500: case 0xc0500: return "Error reset";
70 case 0xc600: case 0xc0600: return "Drive controlled homing procedure";
71 case 0xe225: return "Motor overload";
72 case 0xe249: case 0xe2049: return "Positioning command velocity exceeds limit bipolar";
73 case 0xe250: return "Drive overtemp warning";
74 case 0xe251: return "Motor overtemp warning";
75 case 0xe252: return "Bleeder overtemp warning";
76 case 0xe257: return "Continous current limit active";
77 case 0xe259: return "Command velocity limit active";
78 case 0xe8260: return "Torque limit active";
79 case 0xe264: return "Target position out of numerical range";
80 case 0xe829: case 0xe8029: return "Positive position limit exceeded";
81 case 0xe830: case 0xe8030: return "Negative position limit exceeded";
82 case 0xe831: return "Position limit reached during jog";
83 case 0xe834: return "Emergency-Stop";
84 case 0xe842: return "Both end-switches activated";
85 case 0xe843: return "Positive end-switch activated";
86 case 0xe844: return "Negative end-switch activated";
87 case 0xf218: case 0xf2018: return "Amplifier overtemp shutdown";
88 case 0xf219: case 0xf2019: return "Motor overtemp shutdown";
89 case 0xf220: return "Bleeder overload shutdown";
90 case 0xf221: case 0xf2021: return "Motor temperature surveillance defective";
91 case 0xf2022: return "Unit temperature surveillance defective";
92 case 0xf224: return "Maximum breaking time exceeded";
93 case 0xf2025: return "Drive not ready for power on";
94 case 0xf228: case 0xf2028: return "Excessive control deviation";
95 case 0xf250: return "Overflow of target position preset memory";
96 case 0xf257: return "Command position out of range";
97 case 0xf269: return "Error during release of the motor holding brake";
98 case 0xf276: return "Absolute encoder out of allowed window";
99 case 0xf2174: return "Lost reference of motor encoder";
100 case 0xf409: case 0xf4009: return "Bus error on Profibus interface";
101 case 0xf434: return "Emergency-Stop";
102 case 0xf629: return "Positive position limit exceeded";
103 case 0xf630: return "Negative position limit exceeded";
104 case 0xf634: return "Emergency-Stop";
105 case 0xf643: return "Positive end-switch activated";
106 case 0xf644: return "Negative end-switch activated";
107 case 0xf8069: return "15V DC error";
108 case 0xf870: case 0xf8070: return "24V DC error";
109 case 0xf878: case 0xf8078: return "Velocity loop error";
110 case 0xf8079: return "Velocity limit exceeded";
111 case 0xf2026: return "Undervoltage in power section";
112 }
113 return "unknown";
114}
115
116TString Dkc::GetStatus(LWORD_t val) const
117{
118 const Int_t errnum = val&0xff;
119 const Int_t errinf = val>>8;
120
121 if (errnum!=0xff)
122 return "";
123
124 // DKC offline. This is a fatal error
125 if (errinf==0)
126 return "offline.";
127
128 TString str;
129
130 const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
131 switch (type)
132 {
133 case 0xf: str += "ERROR"; break;
134 case 0xe: str += "WARNING"; break;
135 case 0xa: str += "Status"; break;
136 case 0xc:
137 case 0xd: str += "Message"; break;
138 default: str += "Unknown"; break;
139 }
140
141 str += " (";
142 str += MString::Format("%X", errinf);
143 str += "): ";
144 str += EvalStatusDKC(errinf);
145 str += (type==0xf || type==0xe ? "!" : ".");
146
147 return str;
148}
149
150Bool_t Dkc::PrintStatus(LWORD_t val) const
151{
152 const Int_t errnum = val&0xff;
153 const Int_t errinf = val>>8;
154
155 if (errnum!=0xff)
156 return errnum==0;
157
158 gLog << all << MTime(-1) << ": " << GetNodeName() << " " << GetStatus(val) << endl;
159
160 // errinf==0: DKC offline. This is a fatal error
161 const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
162 return errinf==0 ? kFALSE : (type&0xf)!=0xf;
163}
164
165void Dkc::HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, const timeval_t &tv)
166{
167 // cout << "SdoRx: Idx=0x"<< hex << idx << "/" << (int)subidx;
168 // cout << ", val=0x" << val << endl;
169 switch (idx)
170 {
171 case 0x1000:
172 gLog << inf2 << "- " << GetNodeName() << ": Node is" << (val?" ":" not ") << "armed." << endl;
173 fArmed = val==1;
174 return;
175
176 case 0x1003:
177 // FIXME, see Init
178 gLog << inf2 << "- " << GetNodeName() << ": Error[0]=" << hex << val << dec << endl;
179 CheckErrorDKC(val);
180 return;
181
182 case 0x100a:
183 gLog << inf2 << "- " << GetNodeName() << ": Using Software Version V" << dec << (int)(val>>16) << "." << (int)(val&0xff) << endl;
184 fSoftVersion = val;
185 return;
186
187 case 0x100b:
188 // Do not display, this is used for CheckConnection
189 // lout << "Node ID: " << dec << val << endl;
190 return;
191
192 case 0x2002:
193 gLog << inf2 << GetNodeName() << ": Current velocity: " << dec << val << endl;
194 fVel = val;
195 return;
196
197 case 0x6004:
198 fPdoPos1 = (LWORDS_t)val;
199 fPdoTime1.Set(tv);
200 fHasChangedPos1 = true;
201 return;
202
203 case 0x6005:
204 fPdoPos2 = (LWORDS_t)val;
205 fPdoTime2.Set(tv);
206 fHasChangedPos2 = true;
207 return;
208
209 case 0x6002:
210 gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution = " << dec << val << " (1rpm)" << endl;
211 fVelRes = val;
212 return;
213
214 case 0x6003:
215 gLog << inf2 << "- " << GetNodeName() << ": Maximum velocity = " << dec << val << " (100%)" << endl;
216 fVelMax = val;
217 return;
218
219 case 0x6501:
220 gLog << inf2 << "- " << GetNodeName() << ": Position resolution = " << dec << val << " ticks/revolution" << endl;
221 fPosRes = val;
222 return;
223 }
224
225 NodeDrv::HandleSDO(idx, subidx, val, tv);
226
227 // cout << "Dkc: SDO, idx=0x"<< hex << idx << "/" << (int)subidx;
228 // cout << ", val=0x"<<val<<endl;
229}
230
231void Dkc::HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, const timeval_t &tv)
232{
233 // cout << "Node #" << dec << (int)GetId() << ": Sdo=" << hex << idx << "/" << (int)subidx << " set." << endl;
234
235 // If a real drive operation is requested from the MACS and
236 // the MACS is not correctly initialized the operation is
237 // rejected. (This is expecially harmfull if the NoWait state
238 // is set incorrectly)
239 if (data)
240 SetZombie();
241
242 switch (idx)
243 {
244 case 0x1000:
245 gLog << inf2 << "- " << GetNodeName() << ": State of node set." << endl;
246 return;
247
248 case 0x1001:
249 gLog << inf2 << "- " << GetNodeName() << ": PDOs requested." << endl;
250 return;
251
252 case 0x2002:
253 gLog << inf2 << "- " << GetNodeName() << ": Velocity set." << endl;
254 return;
255
256 case 0x2003:
257 gLog << inf2 << "- " << GetNodeName() << ": Acceleration set." << endl;
258 return;
259
260 case 0x3006:
261 gLog << inf2 << "- " << GetNodeName() << ": RPM mode switched." << endl;
262 return;
263
264 case 0x3007:
265 //gLog << inf2 << "- Velocity set (" << GetNodeName() << ")" << endl;
266 return;
267
268 case 0x4000:
269 HandleNodeguard(tv);
270 return;
271
272 case 0x6000:
273 gLog << inf2 << "- " << GetNodeName() << ": Rotation direction set." << endl;
274 return;
275
276 case 0x6002:
277 gLog << inf2 << "- " << GetNodeName() << ": Velocity resolution set." << endl;
278 return;
279
280 case 0x6004:
281 gLog << inf2 << "- " << GetNodeName() << ": Absolute positioning started." << endl;
282 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
283 return;
284
285 case 0x6005:
286 gLog << inf2 << "- " << GetNodeName() << ": Relative positioning started." << endl;
287 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
288 return;
289 }
290
291 NodeDrv::HandleSDOOK(idx, subidx, data, tv);
292}
293
294void Dkc::ReqVelRes()
295{
296 gLog << inf2 << "- " << GetNodeName() << ": Requesting velocity resolution (velres, 0x6002)." << endl;
297 RequestSDO(0x6002);
298 WaitForSdo(0x6002);
299}
300
301void Dkc::ReqVelMax()
302{
303 gLog << inf2 << "- " << GetNodeName() << ": Requesting maximum velocity (velmax, 0x6003)." << endl;
304 RequestSDO(0x6003);
305 WaitForSdo(0x6003);
306}
307
308void Dkc::ReqPosRes()
309{
310 gLog << inf2 << "- " << GetNodeName() << ": Requesting position resolution (posres, 0x6501)." << endl;
311 RequestSDO(0x6501);
312 WaitForSdo(0x6501);
313}
314
315void Dkc::Arm()
316{
317 gLog << inf2 << "- " << GetNodeName() << ": Arming node." << endl;
318 SendSDO(0x1000, (LWORD_t)1);
319 WaitForSdo(0x1000);
320}
321
322void Dkc::Disarm()
323{
324 gLog << inf2 << "- " << GetNodeName() << ": Disarming Node." << endl;
325 SendSDO(0x1000, (LWORD_t)0);
326 WaitForSdo(0x1000);
327}
328
329void Dkc::CheckConnection()
330{
331 RequestSDO(0x100b);
332 WaitForSdo(0x100b);
333}
334
335void Dkc::Init()
336{
337 //
338 // Request current error status (FIXME: is the first entry in the
339 // error list)
340 //
341 gLog << inf2 << "- " << GetNodeName() << ": Requesting Error[0]." << endl;
342 RequestSDO(0x1003);
343 WaitForSdo(0x1003);
344
345 /*
346 if (HasError())
347 {
348 gLog << err << "Dkc::Init: " << GetNodeName() << " has error --> ZOMBIE!" << endl;
349 SetZombie();
350 }
351 if (IsZombieNode())
352 return;
353 */
354
355 SetRpmMode(FALSE);
356
357 ReqPosRes(); // Init fVelRes
358 ReqVelRes(); // Init fVelRes
359 ReqVelMax(); // Init fVelMax
360
361 // Request to send all PDOs at least once
362 ReqPDOs();
363
364#ifdef EXPERT
365 Arm();
366#endif
367 gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl;
368 RequestSDO(0x1000);
369 WaitForSdo(0x1000);
370}
371
372void Dkc::StopDevice()
373{
374 //
375 // FIXME: This isn't called if the initialization isn't done completely!
376 //
377 SetRpmMode(FALSE);
378 Disarm();
379}
380
381void Dkc::ReqPDOs()
382{
383 gLog << inf2 << "- " << GetNodeName() << ": Requesting all PDOs." << endl;
384
385 SendSDO(0x1001, (LWORD_t)1);
386 WaitForSdo(0x1001);
387}
388
389void Dkc::ReqPos1()
390{
391 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 1." << endl;
392 RequestSDO(0x6004);
393 WaitForSdo(0x6004);
394}
395
396void Dkc::ReqPos2()
397{
398 gLog << inf2 << "- " << GetNodeName() << ": Requesting position feedback 2." << endl;
399 RequestSDO(0x6005);
400 WaitForSdo(0x6005);
401}
402
403void Dkc::ReqVel()
404{
405 gLog << inf2 << "- " << GetNodeName() << ": Requesting Velocity." << endl;
406 RequestSDO(0x2002);
407 WaitForSdo(0x2002);
408}
409
410void Dkc::SetVelocity(LWORD_t vel)
411{
412 gLog << dbg << "- Setting velocity to: " << vel << endl;
413 SendSDO(0x2002, vel); // velocity
414 WaitForSdo(0x2002);
415}
416
417void Dkc::SetVelocityRel(Double_t vel)
418{
419 gLog << dbg << "- Setting velocity to: " << vel*100 << "%" << endl;
420 SendSDO(0x2002, (LWORD_t)(vel*fVelMax+0.5)); // velocity
421 WaitForSdo(0x2002);
422}
423
424void Dkc::SetAcceleration(LWORD_t acc)
425{
426 gLog << dbg << "- Setting acceleration to: " << acc << endl;
427 SendSDO(0x2003, acc); // acceleration
428 WaitForSdo(0x2003);
429}
430
431void Dkc::SetRpmMode(BYTE_t mode)
432{
433 //
434 // SetRpmMode(FALSE) stop the motor, but lets the position control unit on
435 //
436 SendSDO(0x3006, mode ? string('s','t','r','t') : string('s','t','o','p'));
437 WaitForSdo(0x3006);
438}
439
440void Dkc::SetRpmVelocity(LWORDS_t cvel)
441{
442 SendSDO(0x3007, (LWORD_t)cvel);
443 WaitForSdo(0x3007);
444}
445
446void Dkc::SetLedVoltage(LWORDS_t volt)
447{
448 SendSDO(0x4000, (LWORD_t)volt);
449 WaitForSdo(0x4000);
450}
451
452void Dkc::StartRelPos(LWORDS_t pos)
453{
454 if (!fArmed)
455 {
456 gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl;
457 SetZombie();
458 return;
459 }
460
461 gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORDS_t)pos << " ticks." << endl;
462 SendSDO(0x6005, (LWORD_t)pos);
463 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
464}
465
466void Dkc::StartAbsPos(LWORDS_t pos)
467{
468 if (!fArmed)
469 {
470 gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl;
471 SetZombie();
472 return;
473 }
474
475 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << (LWORDS_t)pos << " ticks." << endl;
476 SendSDO(0x6004, (LWORD_t)pos);
477 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
478}
479
480void Dkc::StartAbsPosRev(Double_t pos)
481{
482 if (!fArmed)
483 {
484 gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl;
485 SetZombie();
486 return;
487 }
488
489 const LWORD_t p = (LWORD_t)(pos*fPosRes+.5);
490
491 gLog << dbg << GetNodeName() << ": Starting absolute positioning to " << p << " ticks." << endl;
492 SendSDO(0x6004, p);
493 fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
494}
495
496void Dkc::SendMsg(BYTE_t data[6])
497{
498 GetNetwork()->SendCanFrame(fMacId, 0, 0, data[0], data[1], data[2], data[3], data[4], data[5]);
499}
500
501void Dkc::SendMsg(BYTE_t d0, BYTE_t d1, BYTE_t d2,
502 BYTE_t d3, BYTE_t d4, BYTE_t d5)
503{
504 GetNetwork()->SendCanFrame(fMacId, 0, 0, d0, d1, d2, d3, d4, d5);
505}
506
507void Dkc::HandlePDO1(const BYTE_t *data, const timeval_t &tv)
508{
509 // FIXME!!!! Only 0x4000 should do this to be
510 // CanOpen conform
511 //HandleNodeguard(tv);
512
513 fPdoPos1 = (data[3]<<24) | (data[2]<<16) | (data[1]<<8) | data[0];
514 fPdoTime1.Set(tv);
515 fHasChangedPos1 = true;
516
517 fPdoPos2 = (data[7]<<24) | (data[6]<<16) | (data[5]<<8) | data[4];
518 fPdoTime2.Set(tv);
519 fHasChangedPos2 = true;
520
521 if (fReport)
522 {
523 fReport->Lock("ShaftEncoder::HandlePDOType0");
524 *fReport << "FEEDBACK " << (int)GetId() << " " << fPdoTime1 << " PDO0 " << GetNodeName() << " " << fPdoPos1 << " " << fPdoPos2 << endl;
525 fReport->UnLock("ShaftEncoder::HandlePDOType0");
526 }
527}
528
529void Dkc::HandlePDO3(const BYTE_t *data, const timeval_t &tv)
530{
531 if (fStatus!=data[3])
532 {
533 fArmed = data[3]&0x01; // armed status
534 fPosActive = data[3]&0x02; // positioning active
535 fRpmActive = data[3]&0x04; // RPM mode switched on
536 // data[3]&0x08; // - unused -
537 // data[3]&0x10; // - unused -
538 // data[3]&0x20; // - unused -
539 //fInControl = data[3]&0x40; // motor uncontrolled
540 // data[3]&0x80; // axis resetted (after errclr, motor stop, motor on)
541
542 fStatus = data[3];
543 }
544
545 const LWORD_t stat = data[0] | (data[1]<<8);
546 if (fStatusPdo3!=stat)
547 {
548 gLog << inf << MTime(-1) << ": " << GetNodeName() << " - PDO3(0x" << hex << (int)stat << dec << ") = ";
549 const Bool_t ready = stat&0x001;
550 const Bool_t fuse = stat&0x002;
551 const Bool_t emcy = stat&0x004;
552 const Bool_t vltg = stat&0x008;
553 const Bool_t mode = stat&0x010;
554 const Bool_t rf = stat&0x020;
555 const Bool_t brake = stat&0x040;
556 const Bool_t power = stat&0x080;
557 const Bool_t alarm = stat&0x100; // UPS Alarm (FACT only)
558 const Bool_t batt = stat&0x200; // UPS on battery (FACT only)
559 const Bool_t charge = stat&0x400; // UPS charging (FACT only)
560 if (ready) gLog << "DKC-Ready ";
561 if (fuse) gLog << "FuseOk ";
562 if (emcy) gLog << "EmcyOk ";
563 if (vltg) gLog << "OvervoltOk ";
564 if (mode) gLog << "SwitchToManualMode ";
565 if (rf) gLog << "RF ";
566 if (brake) gLog << "BrakeOpen ";
567 if (power) gLog << "PowerOn ";
568 if (alarm) gLog << "UPS-PowerLoss ";
569 if (batt) gLog << "UPS-OnBattery ";
570 if (charge) gLog << "UPS-Charging ";
571 gLog << endl;
572
573 fStatusPdo3 = stat;
574 }
575}
576
577void Dkc::CheckErrorDKC(LWORD_t val)
578{
579 fStatusDKC = val;
580
581 const Bool_t rc = PrintStatus(val);
582 SetError(rc ? 0 : val);
583 if (!rc)
584 SetZombie();
585}
586
587void Dkc::HandlePDO2(const BYTE_t *data, const timeval_t &tv)
588{
589 LWORDS_t errnum = (data[0]<<24) | (data[1]<<16) | (data[2]<<8) | data[3];
590 LWORDS_t errinf = (data[4]<<24) | (data[5]<<16) | (data[6]<<8) | data[7];
591
592 // Check if the DKC changed its status message
593 const Int_t type = (errinf&0xf0000)==0 ? ((errinf>>12)&0xf) : ((errinf>>16)&0xf);
594 if (errnum==0xff && (type&0xf)<=0xe)
595 {
596 CheckErrorDKC(errnum, errinf);
597 return;
598 }
599
600 // Check if MACS report error occursion.
601 // errnum==0 gives a sudden information that something happened. Now the
602 // microcontroller is running inside its interrupt procedure which
603 // stopped the normal program. The interrupt procedure should try to clear
604 // the error state of the hardware. This should never create a new error!
605 //
606 if (!errnum)
607 {
608 gLog << err << "- " << GetNodeName() << ": reports Error occursion." << endl;
609 gLog << "Dkc::HandlePDO2: " << GetNodeName() << " --> ZOMBIE!" << endl;
610 SetZombie();
611 SetError(-1);
612 return;
613 }
614
615 //
616 // Now the error is handled by the hardware now it is the software part
617 // to react on it. The Error flag now is set to the correct value.
618 //
619 if (GetError()>0)
620 {
621 gLog << warn << GetNodeName() << ": WARNING! Previous error #" << GetError() << " unhandled (not cleared) by software." << endl;
622
623 //
624 // If the error is unhadled and/or not cleared, don't try it again.
625 //
626 if (GetError()==errnum)
627 return;
628 }
629
630 SetError(errnum);
631
632 gLog << err << GetNodeName() << " reports: ";
633 switch (errnum)
634 {
635 case 0xff:
636 EvalStatus(errnum, errinf);
637 return;
638
639 default:
640 gLog << "Error Nr. " << dec << errnum << ", " << errinf << endl;
641 }
642}
643
644// FIXME? Handling of fIsZombie?
645void Dkc::HandleError()
646{
647 //
648 // If there is no error we must not handle anything
649 //
650 if (!HasError())
651 return;
652
653 //
654 // If the program got into the: HandleError state before the hardware
655 // has finished handeling the error we have to wait for the hardware
656 // handeling the error
657 //
658 // FIXME: Timeout???
659 //
660// while (GetError()<0)
661// usleep(1);
662
663 //
664 // After this software and hardware should be in a state so that
665 // we can go on working 'as usual' Eg. Initialize a Display Update
666 //
667 gLog << inf << GetNodeName() << " Handling Error #" << dec << GetError() << endl;
668 switch (GetError())
669 {
670 case 0xff:
671 gLog << err << "DKC error! Go and check what is going on!" << endl;
672 return;
673
674 default:
675 gLog << "- " << GetNodeName() << ": Cannot handle error #" << GetError() << endl;
676
677 }
678}
679
680void Dkc::DisplayVal()
681{
682 const LWORDS_t pos = GetPdoPos2();
683 if (IsZombieNode())
684 {
685 if (fLabel)
686 fLabel->SetText(new TGString(""));
687 fUpdPos = ~pos;
688 return;
689 }
690
691 char text[21]="";
692 if (pos!=fUpdPos && fLabel)
693 {
694 sprintf(text, "%ld", pos);
695 fLabel->SetText(new TGString(text));
696 fUpdPos = pos;
697 }
698}
Note: See TracBrowser for help on using the repository browser.