source: trunk/Cosy/devdrv/dkc.h@ 10113

Last change on this file since 10113 was 10029, checked in by tbretz, 14 years ago
Added handling of the IndraDrive error codes.
File size: 3.8 KB
Line 
1#ifndef COSY_Dkc
2#define COSY_Dkc
3
4#ifndef COSY_NodeDrv
5#include "nodedrv.h"
6#endif
7
8#ifndef MARS_MTime
9#include "MTime.h"
10#endif
11
12class TGLabel;
13
14class Dkc : public NodeDrv
15{
16private:
17 BYTE_t fMacId;
18
19 LWORD_t fSoftVersion;
20
21 LWORD_t fPosRes;
22 LWORD_t fVelMax;
23 LWORD_t fVelRes;
24 LWORDS_t fVel;
25
26 LWORDS_t fPdoPos1;
27 LWORDS_t fPdoPos2;
28 MTime fPdoTime1;
29 MTime fPdoTime2;
30
31 BYTE_t fPosActive;
32 BYTE_t fRpmActive;
33 BYTE_t fStatus;
34 LWORD_t fStatusDKC;
35 WORD_t fStatusPdo3;
36
37 bool fHasChangedPos1; //!
38 bool fHasChangedPos2; //!
39
40 bool fArmed;
41
42 MLog *fReport;
43
44 TGLabel *fLabel; //
45 LWORDS_t fUpdPos; // ticks
46
47 void Init();
48 void StopDevice();
49
50 TString EvalStatusDKC(UInt_t stat) const;
51 Bool_t PrintStatus(LWORD_t val) const;
52 Bool_t EvalStatus(UInt_t errnum, UInt_t errinf) const
53 {
54 return PrintStatus(errnum|(errinf<<8));
55 }
56 TString GetStatus(LWORD_t val) const;
57 void CheckErrorDKC(LWORD_t val);
58 void CheckErrorDKC(UInt_t errnum, UInt_t errinf)
59 {
60 CheckErrorDKC(errnum|(errinf<<8));
61 }
62
63
64 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, const timeval_t &tv);
65 void HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, const timeval_t &tv);
66
67 void HandlePDO1(const BYTE_t *data, const timeval_t &tv);
68 void HandlePDO2(const BYTE_t *data, const timeval_t &tv);
69 void HandlePDO3(const BYTE_t *data, const timeval_t &tv);
70
71 void CheckConnection();
72
73public:
74 Dkc(const BYTE_t nodeid, const char *name=NULL);
75 virtual ~Dkc() { }
76
77 static LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
78 {
79 return (LWORD_t)(b0<<24 | b1<<16 | b2<<8 | b3);
80 }
81
82 void SendMsg(BYTE_t data[6]);
83 void SendMsg(BYTE_t d0=0, BYTE_t d1=0, BYTE_t d2=0,
84 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
85
86 void ReqPDOs();
87 void ReqPos1();
88 void ReqPos2();
89 void ReqVel();
90 void ReqVelRes();
91 void ReqPosRes();
92 void ReqVelMax();
93 void SetAcceleration(LWORD_t acc);
94// void SetDeceleration(LWORD_t dec);
95 void SetVelocity(LWORD_t vel);
96 void SetVelocityRel(Double_t vel);
97 void SetRpmMode(BYTE_t mode=TRUE);
98 void SetRpmVelocity(LWORDS_t cvel);
99
100 void StartRelPos(LWORDS_t pos);
101 void StartAbsPos(LWORDS_t pos);
102 void StartAbsPosRev(Double_t pos);
103
104 bool IsArmed() const { return fArmed; }
105 void Arm();
106 void Disarm();
107
108 int IsPositioning() const { return fPosActive; }
109 BYTE_t GetStatus() const { return fStatus; }
110 LWORD_t GetStatusPdo3() const { return fStatusPdo3; }
111
112 LWORDS_t GetPdoPos1() const { return fPdoPos1; }
113 LWORDS_t GetPdoPos2() const { return fPdoPos2; }
114
115 LWORDS_t GetVel() const { return fVel; }
116 LWORD_t GetVelMax() const { return fVelMax; } // Velocity units (would be 100 for %)
117 Double_t GetVelMaxRev() const { return (Double_t)fVelMax/fVelRes; } // Velocity units (would be 100 for %)
118 LWORD_t GetVelRes() const { return fVelRes; } // Velocity units (would be 100 for %)
119 LWORD_t GetPosRes() const { return fPosRes; } // Velocity units (would be 100 for %)
120
121 bool IsOperative() const { return (fStatusPdo3&0xff)==0xef; }
122 bool IsRpmActive() const { return fRpmActive; }
123
124 void HandleError();
125
126 Double_t GetMjdPos1() const { return fPdoTime1.GetMjd(); }
127 Double_t GetMjdPos2() const { return fPdoTime2.GetMjd(); }
128
129 bool HasChangedPos1() const { return fHasChangedPos1; }
130 bool HasChangedPos2() const { return fHasChangedPos2; }
131
132 void ResetHasChangedPos1() { fHasChangedPos1 = false; }
133 void ResetHasChangedPos2() { fHasChangedPos2 = false; }
134
135 TString GetStatusDKC() const { return GetStatus(fStatusDKC); }
136
137 void SetReport(MLog *log) { fReport = log; }
138 void SetDisplay(TGLabel *label) { fLabel = label; }
139
140 void DisplayVal();
141
142 ClassDef(Dkc, 0)
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.