source: trunk/MagicSoft/Cosy/candrv/nodedrv.h@ 1109

Last change on this file since 1109 was 1109, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 2.4 KB
Line 
1#ifndef NODEDRV_H
2#define NODEDRV_H
3
4#include "log.h"
5
6#ifdef __CINT__
7typedef Byte_t BYTE_t;
8typedef UShort_t WORD_t;
9typedef Short_t WORDS_t;
10typedef UInt_t LWORD_t;
11typedef Int_t LWORDS_t;
12struct timeval;
13#else
14#include "gendef.h"
15#endif
16
17class Network;
18
19class NodeDrv : public Log
20{
21private:
22 Network *fNetwork;
23 BYTE_t fId;
24
25 char *fName;
26
27 int fError;
28
29protected:
30 void SetError(int err) { fError = err; }
31 void DelError() { fError = 0; }
32 int GetError() { return fError; }
33
34public:
35 NodeDrv(BYTE_t nodeid, const char *name=NULL, MLog &out=gLog);
36 virtual ~NodeDrv();
37
38 BYTE_t GetId() const { return fId; }
39 char *GetNodeName() const { return fName; }
40 Network *GetNetwork() { return fNetwork; }
41
42 virtual void InitDevice(Network *net);
43 virtual void StopDevice() = 0;
44
45 bool HasError() { return fError; }
46
47 virtual void HandleSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, struct timeval *tv);
48 virtual void HandleSDOOK(WORD_t idx, BYTE_t subidx);
49 virtual void HandleSDOError(LWORD_t data);
50
51 virtual void HandlePDO1(BYTE_t *data, struct timeval *tv) {};
52 virtual void HandlePDO2(BYTE_t *data, struct timeval *tv) {};
53 virtual void HandlePDO3(BYTE_t *data, struct timeval *tv) {};
54 virtual void HandlePDO4(BYTE_t *data, struct timeval *tv) {};
55
56 void SendPDO1(BYTE_t data[8]);
57 void SendPDO2(BYTE_t data[8]);
58 void SendPDO1(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
59 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
60 void SendPDO2(BYTE_t m0=0, BYTE_t m1=0, BYTE_t m2=0, BYTE_t m3=0,
61 BYTE_t m4=0, BYTE_t m5=0, BYTE_t m6=0, BYTE_t m7=0);
62
63 void SendSDO(WORD_t idx, BYTE_t subidx, BYTE_t val, bool store=true);
64 void SendSDO(WORD_t idx, BYTE_t subidx, WORD_t val, bool store=true);
65 void SendSDO(WORD_t idx, BYTE_t subidx, LWORD_t val, bool store=true);
66
67 void SendSDO(WORD_t idx, BYTE_t val);
68 void SendSDO(WORD_t idx, WORD_t val);
69 void SendSDO(WORD_t idx, LWORD_t val=0);
70
71 void SendNMT(BYTE_t cmd);
72
73 void RequestSDO(WORD_t idx, BYTE_t subidx=0);
74
75 void WaitForNextPdo1();
76 void WaitForNextPdo2();
77 void WaitForNextPdo3();
78 void WaitForNextPdo4();
79
80 // void WaitForSdos();
81 void WaitForSdo(WORD_t idx, BYTE_t subidx=0, WORDS_t timeout=500);
82
83 void EnableCanMsg(BYTE_t fcode);
84
85 ClassDef(NodeDrv, 0)
86};
87
88#endif
Note: See TracBrowser for help on using the repository browser.