1 | #ifndef MACS_H
|
---|
2 | #define MACS_H
|
---|
3 |
|
---|
4 | #include "timer.h"
|
---|
5 | #include "nodedrv.h"
|
---|
6 |
|
---|
7 | class Macs : public NodeDrv
|
---|
8 | {
|
---|
9 | private:
|
---|
10 | BYTE_t fMacId;
|
---|
11 |
|
---|
12 | LWORD_t fVelRes;
|
---|
13 | LWORDS_t fVel;
|
---|
14 |
|
---|
15 | LWORDS_t fPos;
|
---|
16 | Timer fPosTime;
|
---|
17 |
|
---|
18 | LWORDS_t fPdoPos;
|
---|
19 | Timer fPdoTime;
|
---|
20 |
|
---|
21 | BYTE_t fPosActive;
|
---|
22 | BYTE_t fRpmActive;
|
---|
23 |
|
---|
24 | int fError; // Indicater for error state
|
---|
25 |
|
---|
26 | LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
|
---|
27 | {
|
---|
28 | return (LWORD_t)(b0<<24 | b1<<16 | b2<<8 | b3);
|
---|
29 | }
|
---|
30 |
|
---|
31 | public:
|
---|
32 | Macs(BYTE_t nodeid, ostream &out=cout);
|
---|
33 | virtual ~Macs();
|
---|
34 |
|
---|
35 | void InitDevice(Network *);
|
---|
36 |
|
---|
37 | void StartDevice();
|
---|
38 | void StopDevice();
|
---|
39 |
|
---|
40 | void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
|
---|
41 | void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
|
---|
42 | void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
|
---|
43 |
|
---|
44 | void HandlePDO1(BYTE_t *data, struct timeval *tv);
|
---|
45 | void HandlePDO2(BYTE_t *data, struct timeval *tv);
|
---|
46 |
|
---|
47 | void SendMsg(BYTE_t data[6]);
|
---|
48 | void SendMsg(BYTE_t d0=0, BYTE_t d1=0, BYTE_t d2=0,
|
---|
49 | BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
|
---|
50 |
|
---|
51 | void ReqPos();
|
---|
52 | void ReqVel();
|
---|
53 | void ReqAxEnd();
|
---|
54 | void ReqVelRes();
|
---|
55 | void SetHome(LWORDS_t pos=0);
|
---|
56 | void SetAcceleration(LWORD_t acc);
|
---|
57 | void SetDeceleration(LWORD_t dec);
|
---|
58 | void SetVelocity(LWORD_t vel);
|
---|
59 | void SetNoWait(BYTE_t flag=TRUE);
|
---|
60 | void SetRpmMode(BYTE_t mode=TRUE);
|
---|
61 | void SetRpmVelocity(LWORDS_t cvel);
|
---|
62 | void SetPDO1On(BYTE_t flag=TRUE);
|
---|
63 |
|
---|
64 | void StartRelPos(LWORDS_t pos);
|
---|
65 | void StartAbsPos(LWORDS_t pos);
|
---|
66 |
|
---|
67 | void StopMotor();
|
---|
68 |
|
---|
69 | int IsPositioning() { return fPosActive; }
|
---|
70 |
|
---|
71 | double GetTime();
|
---|
72 | double GetMjd();
|
---|
73 |
|
---|
74 | double GetPdoTime();
|
---|
75 | double GetPdoMjd();
|
---|
76 |
|
---|
77 | LWORDS_t GetPdoPos() { return fPdoPos; }
|
---|
78 |
|
---|
79 | LWORDS_t GetPos() { return fPos; }
|
---|
80 | LWORDS_t GetVel() { return fVel; }
|
---|
81 | LWORD_t GetVelRes() { return fVelRes; }
|
---|
82 |
|
---|
83 | int HasError() { return fError; }
|
---|
84 | };
|
---|
85 |
|
---|
86 | #endif
|
---|