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

Last change on this file since 2514 was 1953, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 1.8 KB
Line 
1#ifndef SHAFTENCODER_H
2#define SHAFTENCODER_H
3
4#include "base/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, timeval_t *tv);
29 void HandlePDOType1(BYTE_t *data, timeval_t *tv);
30 void HandlePDOType2(BYTE_t *data, timeval_t *tv);
31
32 void ReqPos();
33
34 void Init();
35 void CheckConnection();
36
37public:
38 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
39
40 void StopDevice();
41
42 void SetDisplay(TGLabel *label) { fLabel = label; }
43
44 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv);
45 /*
46 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) { NodeDrv::HandleSDOOK(idx, subidx, tv); }
47 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
48 */
49 void HandlePDO1(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); }
50 void HandlePDO2(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); }
51
52 LWORDS_t GetPos() { return IsZombieNode() ? 0 : fPos+fTurn*fTicks; } // FIXME? 0?
53 LWORD_t GetPhysRes() { return fTicks; }
54
55 double GetTime();
56 double GetMjd();
57
58 void SetPreset(LWORD_t pre=0);
59
60 void DisplayVal();
61
62 bool PosHasChanged() const { return fPosHasChanged; }
63 void ResetPosHasChanged() { fPosHasChanged = false; }
64
65 ClassDef(ShaftEncoder, 0)
66};
67
68#endif
Note: See TracBrowser for help on using the repository browser.