forked from amaurial/mergCanBus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergNodeIdentification.cpp
More file actions
202 lines (185 loc) · 3.87 KB
/
MergNodeIdentification.cpp
File metadata and controls
202 lines (185 loc) · 3.87 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#include "MergNodeIdentification.h"
/** \brief Constructor
*
* Set the internal variables.
*/
MergNodeIdentification::MergNodeIdentification()
{
for (int i=0;i<NAME_SIZE;i++){
nodeName[i]='0';
}
}
/** \brief Destructor
*
*/
MergNodeIdentification::~MergNodeIdentification()
{
//dtor
}
/** \brief Set the node name
*
* \param nn Pointer to the node name.
* \param csize Size of the node name limited by NAME_SIZE.
*
*/
void MergNodeIdentification::setNodeName(char const *nn,int csize)
{
int i=0;
int n=NAME_SIZE;
if (csize<NAME_SIZE){
n=csize;
}
for (i=0;i<NAME_SIZE;i++){
nodeName[i]=0;
}
for (i=0;i<n;i++){
nodeName[i]=nn[i];
}
}
/** \brief Retrieve the node name.
*
* \return Pointer to the node name.
*
*/
const char* MergNodeIdentification::getNodeName()
{
return nodeName;
}
/** \brief Get one of the defined parameters
*
* \param idx Index of the parameter: 0 to 8
* \return Return either of the parameters:
* + Manufacturer Id
* + Max Code Version
* + Min Code Version
* + Module Id
* + Number of Supported Events
* + Number of Supported Event Variables
* + Number of Supported Node Variables
* + Node Flags
* + 0 by default
*/
byte MergNodeIdentification::getParameter(byte idx){
switch (idx){
case 1:
return manufacturerId;
break;
case 2:
return minCodeVersion;
break;
case 3:
return moduleId;
break;
case 4:
return suportedEvents;
break;
case 5:
return suportedEventsVariables;
break;
case 6:
return suportedNodeVariables;
break;
case 7:
return maxCodeVersion;
break;
case 8:
return flags;
break;
}
return 0;
}
/** \brief Set this module as a producer.
*
* \param val True for producer. False not producer.
*/
void MergNodeIdentification::setProducerNode(bool val){
if (val){
bitSet(flags,1);
}else {
bitClear(flags,1);
}
}
/** \brief Indicates if the node is a producer.
* \return True for producer. False not producer.
*
*/
bool MergNodeIdentification::isProducerNode(){
if (bitRead(flags,1)==1){
return true;
} else{
return false;
}
}
/** \brief Set this module as a consumer.
*
* \param val True for consumer. False not consumer.
*/
void MergNodeIdentification::setConsumerNode(bool val){
if (val){
bitSet(flags,0);
}else {
bitClear(flags,0);
}
}
/** \brief Indicates if the node is a consumer.
* \return True for consumer. False not consumer.
*
*/
bool MergNodeIdentification::isConsumerNode(){
if (bitRead(flags,0)==0){
return true;
} else{
return false;
}
}
/** \brief Set this module to SlimMode.
*/
void MergNodeIdentification::setSlimMode(){
bitClear(flags,2);
}
/** \brief Set this module to FlimMode.
*/
void MergNodeIdentification::setFlimMode(){
bitSet(flags,2);
}
/** \brief Indicate if the mode is in SlimMode.
*/
bool MergNodeIdentification::isSlimMode(){
if (bitRead(flags,2)==0){
return true;
} else{
return false;
}
}
/** \brief Indicate if the mode is in FlimMode.
*/
bool MergNodeIdentification::isFlimMode(){
if (bitRead(flags,2)==1){
return true;
} else{
return false;
}
}
/** \brief Indicate if the mode supports boot loading.
* This current version by default does not support boot loading.
*/
void MergNodeIdentification::setSuportBootLoading(bool val){
if (val){
bitSet(flags,3);
}else {
bitClear(flags,3);
}
}
/** \brief Indicate if the mode supports boot loading.
* This current version by default does not support boot loading.
*/
bool MergNodeIdentification::suportBootLoading(){
/*
if (bitRead(flags,3)==1){
return true;
} else{
return false;
}
*/
return false;
}