source: trunk/MagicSoft/Cosy/devdrv/macs.h@ 1728

Last change on this file since 1728 was 1727, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 3.0 KB
Line 
1#ifndef MACS_H
2#define MACS_H
3
4#include "nodedrv.h"
5#include "base/timer.h"
6
7class Macs : public NodeDrv
8{
9private:
10 BYTE_t fMacId;
11
12 LWORD_t fSoftVersion;
13
14 LWORD_t fVelRes;
15 LWORDS_t fVel;
16
17 LWORDS_t fPos;
18 Timer fPosTime;
19
20 LWORD_t fRes; // Encoder resolution
21
22 LWORDS_t fPdoPos;
23 Timer fPdoTime;
24
25 BYTE_t fPosActive;
26 BYTE_t fRpmActive;
27 BYTE_t fInControl;
28 BYTE_t fStatus;
29
30 LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
31 {
32 return (LWORD_t)(b0<<24 | b1<<16 | b2<<8 | b3);
33 }
34
35 void Init();
36 void StopDevice();
37
38 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, timeval_t *tv);
39 void HandleSDOOK(WORD_t idx, BYTE_t subidx, timeval_t *tv);
40 //void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
41
42 void HandlePDO1(BYTE_t *data, timeval_t *tv);
43 void HandlePDO2(BYTE_t *data, timeval_t *tv);
44 //void HandleNodeguard(timeval_t *tv);
45
46 void SendNodeguard();
47
48 void CheckConnection();
49
50public:
51 enum
52 {
53 kNoSync = BIT(0),
54 kPosSync = BIT(1),
55 kVelSync = BIT(2)
56 };
57 enum
58 {
59 kNotMoving = BIT(0), // motor not moving
60 kPosActive = BIT(1), // positioning active
61 kRpmActive = BIT(2), // RPM mode switched on
62 // BIT(3-5) unsused
63 kOutOfControl = BIT(6), // motor uncontrolled
64 kAxisReset = BIT(7) // axis resetted (after errclr, motor stop, motor on)
65 };
66
67 Macs(const BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
68 virtual ~Macs();
69
70 void SendMsg(BYTE_t data[6]);
71 void SendMsg(BYTE_t d0=0, BYTE_t d1=0, BYTE_t d2=0,
72 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
73
74 void ReqPos();
75 void ReqVel();
76 //void ReqAxEnd();
77 void ReqVelRes();
78 void ReqRes();
79 void SetHome(LWORDS_t pos=0, WORD_t maxtime=25);
80 void SetAcceleration(LWORD_t acc);
81 void SetDeceleration(LWORD_t dec);
82 void SetVelocity(LWORD_t vel);
83 void SetNoWait(BYTE_t flag=TRUE);
84 void SetRpmMode(BYTE_t mode=TRUE);
85 void SetRpmVelocity(LWORDS_t cvel);
86 void SetPDO1On(BYTE_t flag=TRUE);
87 void SetPosEndswitch(LWORDS_t val);
88 void SetNegEndswitch(LWORDS_t val);
89
90 void EnableEndswitches(bool neg=true, bool pos=true);
91
92 void StartVelSync();
93 void StartPosSync();
94
95 void StartRelPos(LWORDS_t pos);
96 void StartAbsPos(LWORDS_t pos);
97
98 void StopMotor();
99
100 int IsPositioning() const { return fPosActive; }
101 BYTE_t GetStatus() const { return fStatus; }
102
103 double GetTime();
104 double GetMjd();
105
106 double GetPdoTime();
107 double GetPdoMjd();
108
109 LWORDS_t GetPdoPos() const { return fPdoPos; }
110
111 LWORDS_t GetPos() const { return fPos; }
112 LWORDS_t GetVel() const { return fVel; }
113 LWORD_t GetVelRes() const { return fVelRes; } // Velocity units (would be 100 for %)
114 LWORD_t GetRes() const { return fRes; } // Encoder resolution
115
116 void StartHostGuarding();
117 void StopHostGuarding();
118
119 void HandleError();
120
121 ClassDef(Macs, 0)
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.