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

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