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

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