Line | |
---|
1 | #ifndef SHAFTENCODER_H
|
---|
2 | #define SHAFTENCODER_H
|
---|
3 |
|
---|
4 | #include "timer.h"
|
---|
5 | #include "nodedrv.h"
|
---|
6 |
|
---|
7 | #include <pthread.h>
|
---|
8 |
|
---|
9 | class TGLabel;
|
---|
10 |
|
---|
11 | class ShaftEncoder : public NodeDrv
|
---|
12 | {
|
---|
13 | private:
|
---|
14 | LWORDS_t fPos; // ticks
|
---|
15 | WORDS_t fVel; // ticks per 5ms
|
---|
16 | WORDS_t fAcc; // ticks per 25ms^2
|
---|
17 | WORDS_t fTurn; // Number of turn
|
---|
18 | LWORD_t fTicks; // Number of ticks per turn
|
---|
19 | WORD_t fTurns; // Number of possible turns
|
---|
20 |
|
---|
21 | TGLabel **fLabel;
|
---|
22 |
|
---|
23 | Timer fTime;
|
---|
24 |
|
---|
25 | pthread_t fThread;
|
---|
26 |
|
---|
27 | static void *MapUpdateThread(void *se);
|
---|
28 | void UpdateThread();
|
---|
29 |
|
---|
30 | void HandlePDOType0(BYTE_t *data);
|
---|
31 | void HandlePDOType1(BYTE_t *data);
|
---|
32 | void HandlePDOType2(BYTE_t *data, struct timeval *tv);
|
---|
33 |
|
---|
34 | void ReqPos();
|
---|
35 |
|
---|
36 | public:
|
---|
37 | ShaftEncoder(BYTE_t nodeid, ostream &out=cout);
|
---|
38 | virtual ~ShaftEncoder();
|
---|
39 |
|
---|
40 | void InitDevice(Network *);
|
---|
41 |
|
---|
42 | void StartDevice();
|
---|
43 | void StopDevice();
|
---|
44 |
|
---|
45 | void SetDisplay(TGLabel **label) { fLabel = label; }
|
---|
46 |
|
---|
47 | void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
|
---|
48 | void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
|
---|
49 | void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
|
---|
50 |
|
---|
51 | void HandlePDO1(BYTE_t *data, struct timeval *tv) { HandlePDOType2(data, tv); }
|
---|
52 | void HandlePDO2(BYTE_t *data, struct timeval *tv) { HandlePDOType2(data, tv); }
|
---|
53 |
|
---|
54 | LWORDS_t GetPos() { return fPos+fTurn*fTicks; }
|
---|
55 |
|
---|
56 | double GetTime();
|
---|
57 | double GetMjd();
|
---|
58 |
|
---|
59 | void SetPreset(LWORD_t pre=0);
|
---|
60 | };
|
---|
61 |
|
---|
62 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.