-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathOLCB_Link.h
More file actions
61 lines (44 loc) · 2.31 KB
/
OLCB_Link.h
File metadata and controls
61 lines (44 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __OLCB_LINK_H__
#define __OLCB_LINK_H__
#include <stdint.h>
#include "Arduino.h"
#include "can.h"
#include "OLCB_Event.h"
#include "OLCB_Virtual_Node.h"
#include "OLCB_Datagram.h"
#include "OLCB_Stream.h"
#include "OLCB_NodeID.h"
#include "OLCB_Buffer.h"
#include "float16.h"
class OLCB_Virtual_Node;
/* An abstract base class representing a physical link to the outside world */
//Must be subclassed for each physical layer available, currently only CAN
class OLCB_Link
{
public:
OLCB_Link() : _handlers(0) {}
virtual bool initialize(void) {return false;} //called once, returns true if init succeeded.
virtual void update(void); //called repeatedly
virtual void addVNode(OLCB_Virtual_Node *vnode);
virtual void removeVNode(OLCB_Virtual_Node *vnode);
virtual bool sendMessage(OLCB_Buffer *msg) {return false;}
virtual bool sendVerifiedNID(OLCB_NodeID *nid) {return false;}
virtual bool sendVerifyNID(OLCB_NodeID *src, OLCB_NodeID *request) {return false;}
virtual bool sendVerifyNID(OLCB_NodeID *src) {return false;} //global version
virtual bool sendIdent(OLCB_NodeID* source) {return false;}
virtual bool sendPCER(OLCB_NodeID* source, OLCB_Event *event) {return true;}
virtual uint8_t sendDatagramFragment(OLCB_Datagram *datagram, uint8_t start) {return 0;}
virtual bool ackDatagram(OLCB_NodeID *source, OLCB_NodeID *dest) {return true;}
virtual bool nakDatagram(OLCB_NodeID *source, OLCB_NodeID *dest, int reason) {return true;}
virtual bool sendStream(OLCB_NodeID* source, OLCB_Stream *stream) {return true;}
//Not sure that this is how streams should work at all!
//TODO!!
virtual bool sendConsumerIdentified(OLCB_NodeID* source, OLCB_Event *event) {return false;}
virtual bool sendLearnEvent(OLCB_NodeID* source, OLCB_Event *event) {return false;}
virtual bool sendProducerIdentified(OLCB_NodeID* source, OLCB_Event *event, uint8_t active=EVENT_STATE_UNKNOWN) {return false;}
virtual bool sendTractionControlSpeed(OLCB_NodeID* source, OLCB_NodeID* dest, _float16_shape_type speed) {return false;}
virtual bool sendTractionControlFX(OLCB_NodeID* source, OLCB_NodeID* dest, uint32_t address, uint16_t value) {return false;}
protected:
OLCB_Virtual_Node* _handlers;
};
#endif //__OLCB_LINK_H__