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

Last change on this file since 12596 was 12587, checked in by tbretz, 13 years ago
Added sending the command to set the FACT Led voltages
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 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 void SetLedVoltage(LWORDS_t cvel);
100
101 void StartRelPos(LWORDS_t pos);
102 void StartAbsPos(LWORDS_t pos);
103 void StartAbsPosRev(Double_t pos);
104
105 bool IsArmed() const { return fArmed; }
106 void Arm();
107 void Disarm();
108
109 int IsPositioning() const { return fPosActive; }
110 BYTE_t GetStatus() const { return fStatus; }
111 LWORD_t GetStatusPdo3() const { return fStatusPdo3; }
112
113 LWORDS_t GetPdoPos1() const { return fPdoPos1; }
114 LWORDS_t GetPdoPos2() const { return fPdoPos2; }
115
116 LWORDS_t GetVel() const { return fVel; }
117 LWORD_t GetVelMax() const { return fVelMax; } // Velocity units (would be 100 for %)
118 Double_t GetVelMaxRev() const { return (Double_t)fVelMax/fVelRes; } // Velocity units (would be 100 for %)
119 LWORD_t GetVelRes() const { return fVelRes; } // Velocity units (would be 100 for %)
120 LWORD_t GetPosRes() const { return fPosRes; } // Velocity units (would be 100 for %)
121
122 bool IsOperative() const { return (fStatusPdo3&0xff)==0xef; }
123 bool IsRpmActive() const { return fRpmActive; }
124
125 void HandleError();
126
127 Double_t GetMjdPos1() const { return fPdoTime1.GetMjd(); }
128 Double_t GetMjdPos2() const { return fPdoTime2.GetMjd(); }
129
130 bool HasChangedPos1() const { return fHasChangedPos1; }
131 bool HasChangedPos2() const { return fHasChangedPos2; }
132
133 void ResetHasChangedPos1() { fHasChangedPos1 = false; }
134 void ResetHasChangedPos2() { fHasChangedPos2 = false; }
135
136 TString GetStatusDKC() const { return GetStatus(fStatusDKC); }
137
138 void SetReport(MLog *log) { fReport = log; }
139 void SetDisplay(TGLabel *label) { fLabel = label; }
140
141 void DisplayVal();
142
143 ClassDef(Dkc, 0)
144};
145
146#endif
Note: See TracBrowser for help on using the repository browser.