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

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