source: trunk/MagicSoft/Cosy/devdrv/dkc.h@ 9391

Last change on this file since 9391 was 9132, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.9 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 BYTE_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<<16));
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<<16));
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 ReqPos1();
87 void ReqPos2();
88 void ReqVel();
89 void ReqVelRes();
90 void ReqPosRes();
91 void ReqVelMax();
92 void SetAcceleration(LWORD_t acc);
93 void SetDeceleration(LWORD_t dec);
94 void SetVelocity(LWORD_t vel);
95 void SetVelocityRel(Double_t vel);
96 void SetRpmMode(BYTE_t mode=TRUE);
97 void SetRpmVelocity(LWORDS_t cvel);
98 void SetPDO1On(BYTE_t flag=TRUE);
99
100 void StartVelSync();
101 void StartPosSync();
102
103 void StartRelPos(LWORDS_t pos);
104 void StartAbsPos(LWORDS_t pos);
105 void StartAbsPosRev(Double_t pos);
106
107 void StartNode();
108
109 bool IsArmed() const { return fArmed; }
110 void Arm();
111 void Disarm();
112
113 int IsPositioning() const { return fPosActive; }
114 BYTE_t GetStatus() const { return fStatus; }
115 BYTE_t GetStatusPdo3() const { return fStatusPdo3; }
116
117 LWORDS_t GetPdoPos1() const { return fPdoPos1; }
118 LWORDS_t GetPdoPos2() const { return fPdoPos2; }
119
120 LWORDS_t GetVel() const { return fVel; }
121 LWORD_t GetVelMax() const { return fVelMax; } // Velocity units (would be 100 for %)
122 Double_t GetVelMaxRev() const { return (Double_t)fVelMax/fVelRes; } // Velocity units (would be 100 for %)
123 LWORD_t GetVelRes() const { return fVelRes; } // Velocity units (would be 100 for %)
124 LWORD_t GetPosRes() const { return fPosRes; } // Velocity units (would be 100 for %)
125
126 bool IsOperative() const { return fStatusPdo3==0xef; }
127
128 void HandleError();
129
130 Double_t GetMjdPos1() const { return fPdoTime1.GetMjd(); }
131 Double_t GetMjdPos2() const { return fPdoTime2.GetMjd(); }
132
133 bool HasChangedPos1() const { return fHasChangedPos1; }
134 bool HasChangedPos2() const { return fHasChangedPos2; }
135
136 void ResetHasChangedPos1() { fHasChangedPos1 = false; }
137 void ResetHasChangedPos2() { fHasChangedPos2 = false; }
138
139 TString GetStatusDKC() const { return GetStatus(fStatusDKC); }
140
141 void SetReport(MLog *log) { fReport = log; }
142 void SetDisplay(TGLabel *label) { fLabel = label; }
143
144 void DisplayVal();
145
146 ClassDef(Dkc, 0)
147};
148
149#endif
Note: See TracBrowser for help on using the repository browser.