source: trunk/MagicSoft/Cosy/devdrv/shaftencoder.h@ 1018

Last change on this file since 1018 was 926, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 1.7 KB
Line 
1#ifndef SHAFTENCODER_H
2#define SHAFTENCODER_H
3
4#include "timer.h"
5#include "nodedrv.h"
6
7class TGLabel;
8
9class ShaftEncoder : public NodeDrv
10{
11private:
12 LWORDS_t fPos; // ticks
13 WORDS_t fVel; // ticks per 5ms
14 WORDS_t fAcc; // ticks per 25ms^2
15 WORDS_t fTurn; // Number of turn
16 LWORD_t fTicks; // Number of ticks per turn
17 WORD_t fTurns; // Number of possible turns
18
19 TGLabel **fLabel;
20 LWORDS_t fUpdPos; // ticks
21 WORDS_t fUpdVel; // ticks per 5ms
22 WORDS_t fUpdAcc; // ticks per 25ms^2
23
24 bool fPosHasChanged;
25
26 Timer fTime;
27
28 void HandlePDOType0(BYTE_t *data, struct timeval *tv);
29 void HandlePDOType1(BYTE_t *data, struct timeval *tv);
30 void HandlePDOType2(BYTE_t *data, struct timeval *tv);
31
32 void ReqPos();
33
34public:
35 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
36 virtual ~ShaftEncoder();
37
38 void InitDevice(Network *);
39
40 void StartDevice();
41 void StopDevice();
42
43 void SetDisplay(TGLabel **label) { fLabel = label; }
44
45 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
46 void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
47 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
48
49 void HandlePDO1(BYTE_t *data, struct timeval *tv) { HandlePDOType2(data, tv); }
50 void HandlePDO2(BYTE_t *data, struct timeval *tv) { HandlePDOType2(data, tv); }
51
52 LWORDS_t GetPos() { return fPos+fTurn*fTicks; }
53
54 double GetTime();
55 double GetMjd();
56
57 void SetPreset(LWORD_t pre=0);
58
59 void DisplayVal();
60
61 bool PosHasChanged() const { return fPosHasChanged; }
62 void ResetPosHasChanged() { fPosHasChanged = false; }
63};
64
65#endif
Note: See TracBrowser for help on using the repository browser.