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

Last change on this file since 2615 was 2615, checked in by tbretz, 21 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 "MTime.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 MTime fPosTime;
19
20 LWORD_t fRes; // Encoder resolution
21
22 LWORDS_t fPdoPos;
23 MTime 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, LWORD_t data, 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 void StartNode();
104
105 int IsPositioning() const { return fPosActive; }
106 BYTE_t GetStatus() const { return fStatus; }
107
108 LWORDS_t GetPdoPos() const { return fPdoPos; }
109
110 LWORDS_t GetPos() const { return fPos; }
111 LWORDS_t GetVel() const { return fVel; }
112 LWORD_t GetVelRes() const { return fVelRes; } // Velocity units (would be 100 for %)
113 LWORD_t GetRes() const { return fRes; } // Encoder resolution
114
115 void StartHostGuarding();
116 void StopHostGuarding();
117
118 void HandleError();
119
120 ClassDef(Macs, 0)
121};
122
123#endif
Note: See TracBrowser for help on using the repository browser.