1 | #ifndef NODEDRV_H
|
---|
2 | #define NODEDRV_H
|
---|
3 |
|
---|
4 | #include "log.h"
|
---|
5 | #include "gendef.h"
|
---|
6 |
|
---|
7 | class Network;
|
---|
8 |
|
---|
9 | class NodeDrv : public Log
|
---|
10 | {
|
---|
11 | private:
|
---|
12 | Network *fNetwork;
|
---|
13 | BYTE_t fId;
|
---|
14 |
|
---|
15 | public:
|
---|
16 | NodeDrv(BYTE_t nodeid, ostream &out=cout);
|
---|
17 |
|
---|
18 | BYTE_t GetId() { return fId; }
|
---|
19 | Network *GetNetwork() { return fNetwork; }
|
---|
20 |
|
---|
21 | virtual void InitDevice(Network *net);
|
---|
22 | virtual void StopDevice() = 0;
|
---|
23 |
|
---|
24 | virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
|
---|
25 | virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx);
|
---|
26 | virtual void HandleSDOError(LWORD_t data);
|
---|
27 |
|
---|
28 | virtual void HandlePDO1(BYTE_t *data, struct timeval *tv) {};
|
---|
29 | virtual void HandlePDO2(BYTE_t *data, struct timeval *tv) {};
|
---|
30 | virtual void HandlePDO3(BYTE_t *data, struct timeval *tv) {};
|
---|
31 | virtual void HandlePDO4(BYTE_t *data, struct timeval *tv) {};
|
---|
32 |
|
---|
33 | void SendPDO1(BYTE_t data[8]);
|
---|
34 | void SendPDO2(BYTE_t data[8]);
|
---|
35 | void SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
|
---|
36 | BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
|
---|
37 | void SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
|
---|
38 | BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
|
---|
39 |
|
---|
40 | void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val);
|
---|
41 | void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val);
|
---|
42 | void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val);
|
---|
43 |
|
---|
44 | void SendSDO(WORD_t idx, BYTE_t val);
|
---|
45 | void SendSDO(WORD_t idx, WORD_t val);
|
---|
46 | void SendSDO(WORD_t idx, LWORD_t val=0);
|
---|
47 |
|
---|
48 | void SendNMT(BYTE_t cmd);
|
---|
49 |
|
---|
50 | void RequestSDO(WORD_t idx, BYTE_t subidx=0);
|
---|
51 |
|
---|
52 | void WaitForNextPdo1();
|
---|
53 | void WaitForNextPdo2();
|
---|
54 | void WaitForNextPdo3();
|
---|
55 | void WaitForNextPdo4();
|
---|
56 |
|
---|
57 | void WaitForSdos();
|
---|
58 | void WaitForSdo(WORD_t idx, BYTE_t subidx=0);
|
---|
59 |
|
---|
60 | void EnableCanMsg(BYTE_t fcode);
|
---|
61 | };
|
---|
62 |
|
---|
63 | #endif
|
---|