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

Last change on this file since 851 was 808, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.1 KB
Line 
1#ifndef MACS_H
2#define MACS_H
3
4#include "timer.h"
5#include "nodedrv.h"
6
7class Macs : public NodeDrv
8{
9private:
10 BYTE_t fMacId;
11
12 LWORD_t fVelRes;
13 LWORDS_t fVel;
14
15 LWORDS_t fPos;
16 Timer fPosTime;
17
18 LWORDS_t fPdoPos;
19 Timer fPdoTime;
20
21 BYTE_t fPosActive;
22 BYTE_t fRpmActive;
23
24 LWORD_t string(BYTE_t b0=0, BYTE_t b1=0, BYTE_t b2=0, BYTE_t b3=0)
25 {
26 return (LWORD_t)(b0<<24 | b1<<16 | b2<<8 | b3);
27 }
28
29public:
30 Macs(BYTE_t nodeid, ostream &out=cout);
31 virtual ~Macs();
32
33 void InitDevice(Network *);
34
35 void StartDevice();
36 void StopDevice();
37
38 void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
39 void HandleSDOOK(WORD_t idx, BYTE_t subidx) { NodeDrv::HandleSDOOK(idx, subidx); }
40 void HandleSDOError(LWORD_t data) { NodeDrv::HandleSDOError(data); }
41
42 void HandlePDO1(BYTE_t *data, struct timeval *tv);
43 void HandlePDO2(BYTE_t *data, struct timeval *tv);
44
45 void SendMsg(BYTE_t data[6]);
46 void SendMsg(BYTE_t d0=0, BYTE_t d1=0, BYTE_t d2=0,
47 BYTE_t d3=0, BYTE_t d4=0, BYTE_t d5=0);
48
49 void ReqPos();
50 void ReqVel();
51 void ReqAxEnd();
52 void ReqVelRes();
53 void SetHome(LWORDS_t pos=0);
54 void SetAcceleration(LWORD_t acc);
55 void SetDeceleration(LWORD_t dec);
56 void SetVelocity(LWORD_t vel);
57 void SetNoWait(BYTE_t flag=TRUE);
58 void SetSyncMode();
59 void SetRpmMode(BYTE_t mode=TRUE);
60 void SetRpmVelocity(LWORDS_t cvel);
61 void SetPDO1On(BYTE_t flag=TRUE);
62 void SetPosEndswitch(LWORDS_t val);
63 void SetNegEndswitch(LWORDS_t val);
64
65 void EnableEndswitches(bool neg=true, bool pos=true);
66
67 void StartRelPos(LWORDS_t pos);
68 void StartAbsPos(LWORDS_t pos);
69
70 void StopMotor();
71
72 int IsPositioning() { return fPosActive; }
73
74 double GetTime();
75 double GetMjd();
76
77 double GetPdoTime();
78 double GetPdoMjd();
79
80 LWORDS_t GetPdoPos() { return fPdoPos; }
81
82 LWORDS_t GetPos() { return fPos; }
83 LWORDS_t GetVel() { return fVel; }
84 LWORD_t GetVelRes() { return fVelRes; } // Velocity units (would be 100 for %)
85
86 void HandleError();
87};
88
89#endif
Note: See TracBrowser for help on using the repository browser.