1 | #ifndef MACS_H
|
---|
2 | #define MACS_H
|
---|
3 |
|
---|
4 | #include <TObject.h>
|
---|
5 |
|
---|
6 | #include "nodedrv.h"
|
---|
7 | #include "base/timer.h"
|
---|
8 |
|
---|
9 | class Macs : public NodeDrv, public TObject
|
---|
10 | {
|
---|
11 | private:
|
---|
12 | BYTE_t fMacId;
|
---|
13 |
|
---|
14 | LWORD_t fVelRes;
|
---|
15 | LWORDS_t fVel;
|
---|
16 |
|
---|
17 | LWORDS_t fPos;
|
---|
18 | Timer fPosTime;
|
---|
19 |
|
---|
20 | LWORDS_t fPdoPos;
|
---|
21 | Timer fPdoTime;
|
---|
22 |
|
---|
23 | BYTE_t fPosActive;
|
---|
24 | BYTE_t fRpmActive;
|
---|
25 |
|
---|
26 | TTimer *fTimeout;
|
---|
27 | Bool_t fTimerOn;
|
---|
28 | LWORD_t fTimeoutTime;
|
---|
29 |
|
---|
30 | LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
|
---|
31 | {
|
---|
32 | return (LWORD_t)(b0<<24 | b1<<16 | b2<<8 | b3);
|
---|
33 | }
|
---|
34 |
|
---|
35 | Bool_t HandleTimer(TTimer *t);
|
---|
36 |
|
---|
37 | public:
|
---|
38 | Macs(BYTE_t nodeid, MLog &out=gLog);
|
---|
39 | virtual ~Macs();
|
---|
40 |
|
---|
41 | void InitDevice(Network *);
|
---|
42 |
|
---|
43 | void StartDevice();
|
---|
44 | void StopDevice();
|
---|
45 |
|
---|
46 | void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
|
---|
47 | void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
|
---|
48 | void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
|
---|
49 |
|
---|
50 | void HandlePDO1(BYTE_t *data, struct timeval *tv);
|
---|
51 | void HandlePDO2(BYTE_t *data, struct timeval *tv);
|
---|
52 |
|
---|
53 | void SendMsg(BYTE_t data[6]);
|
---|
54 | void SendMsg(BYTE_t d0=0, BYTE_t d1=0, BYTE_t d2=0,
|
---|
55 | BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
|
---|
56 |
|
---|
57 | void ReqPos();
|
---|
58 | void ReqVel();
|
---|
59 | void ReqAxEnd();
|
---|
60 | void ReqVelRes();
|
---|
61 | void SetHome(LWORDS_t pos=0, WORD_t maxtime=25);
|
---|
62 | void SetAcceleration(LWORD_t acc);
|
---|
63 | void SetDeceleration(LWORD_t dec);
|
---|
64 | void SetVelocity(LWORD_t vel);
|
---|
65 | void SetNoWait(BYTE_t flag=TRUE);
|
---|
66 | void SetRpmMode(BYTE_t mode=TRUE);
|
---|
67 | void SetRpmVelocity(LWORDS_t cvel);
|
---|
68 | void SetPDO1On(BYTE_t flag=TRUE);
|
---|
69 | void SetPosEndswitch(LWORDS_t val);
|
---|
70 | void SetNegEndswitch(LWORDS_t val);
|
---|
71 |
|
---|
72 | void EnableEndswitches(bool neg=true, bool pos=true);
|
---|
73 |
|
---|
74 | void StartVelSync();
|
---|
75 | void StartPosSync();
|
---|
76 |
|
---|
77 | void StartRelPos(LWORDS_t pos);
|
---|
78 | void StartAbsPos(LWORDS_t pos);
|
---|
79 |
|
---|
80 | void SetTimeoutTime(LWORD_t ms);
|
---|
81 | void ReqTimeoutTime();
|
---|
82 |
|
---|
83 | void EnableTimeout(bool enable=true, LWORDS_t ms=-1);
|
---|
84 |
|
---|
85 | void StopMotor();
|
---|
86 |
|
---|
87 | int IsPositioning() { return fPosActive; }
|
---|
88 |
|
---|
89 | double GetTime();
|
---|
90 | double GetMjd();
|
---|
91 |
|
---|
92 | double GetPdoTime();
|
---|
93 | double GetPdoMjd();
|
---|
94 |
|
---|
95 | LWORDS_t GetPdoPos() { return fPdoPos; }
|
---|
96 |
|
---|
97 | LWORDS_t GetPos() { return fPos; }
|
---|
98 | LWORDS_t GetVel() { return fVel; }
|
---|
99 | LWORD_t GetVelRes() { return fVelRes; } // Velocity units (would be 100 for %)
|
---|
100 |
|
---|
101 | void HandleError();
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif
|
---|