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

Last change on this file since 7217 was 4104, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 2.2 KB
Line 
1#ifndef COSY_ShafTEncoder
2#define COSY_ShafTEncoder
3
4#ifndef COSY_NodeDrv
5#include "nodedrv.h"
6#endif
7
8#ifndef MARS_MTime
9#include "MTime.h"
10#endif
11
12class Macs;
13class TGLabel;
14
15class ShaftEncoder : public NodeDrv
16{
17private:
18 LWORDS_t fPos; // ticks
19 WORDS_t fVel; // ticks per 5ms
20 WORDS_t fAcc; // ticks per 25ms^2
21 WORDS_t fTurn; // Number of turn
22 LWORD_t fTicks; // Number of ticks per turn
23 WORD_t fTurns; // Number of possible turns
24
25 TGLabel *fLabel; //
26 LWORDS_t fUpdPos; // ticks
27
28 bool fPosHasChanged; //!
29
30 MTime fTime;
31 MLog *fReport;
32
33 Macs *fMotor;
34 Int_t fOffset;
35
36 void HandlePDOType0(BYTE_t *data, timeval_t *tv);
37 void HandlePDOType1(BYTE_t *data, timeval_t *tv);
38 void HandlePDOType2(BYTE_t *data, timeval_t *tv);
39
40 void ReqPos();
41
42 void Init();
43 void CheckConnection();
44 // void CheckTwin(Int_t diff) const;
45
46public:
47 ShaftEncoder(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
48
49 void StopDevice();
50
51 void SetDisplay(TGLabel *label) { fLabel = label; }
52 void SetMotor(Macs *m) { fMotor = m; }
53 //void SetTwin(ShaftEncoder *se) { fTwin = se; }
54
55 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv);
56 void HandleSDOOK(WORD_t idx, BYTE_t subidx, LWORD_t data, timeval_t *tv);
57 /*
58 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv) { NodeDrv::HandleSDOOK(idx, subidx, tv); }
59 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
60 */
61 void HandlePDO1(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); }
62 void HandlePDO2(BYTE_t *data, timeval_t *tv) { HandlePDOType2(data, tv); }
63
64 LWORDS_t GetPos() const { return IsZombieNode() ? 0 : fPos+fTurn*fTicks; } // FIXME? 0?
65 LWORD_t GetPhysRes() const { return fTicks; }
66 Int_t GetOffset() const { return fOffset; }
67 void SetOffset(Int_t off) { fOffset = off; }
68
69 double GetMjd();
70
71 void SetPreset(LWORD_t pre=0);
72
73 void DisplayVal();
74
75 bool PosHasChanged() const { return fPosHasChanged; }
76 void ResetPosHasChanged() { fPosHasChanged = false; }
77
78 void SetReport(MLog *log) { fReport = log; }
79
80 ClassDef(ShaftEncoder, 0)
81};
82
83#endif
Note: See TracBrowser for help on using the repository browser.