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

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