1use open_protocol_codec_proc_macro::{OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage};
2
3#[derive(Debug, Eq, PartialEq, Default, OpenProtocolEncode, OpenProtocolDecode)]
4pub enum RotationDirection {
5 #[default]
6 #[open_protocol_value(number=1)]
7 ClockWise,
8 #[open_protocol_value(number=2)]
9 CounterClockWise,
10}
11
12#[derive(Debug, Eq, PartialEq, Default, OpenProtocolEncode, OpenProtocolDecode)]
13pub enum RelayStatus {
14 #[default]
15 #[open_protocol_value(number=0)]
16 Inactive,
17 #[open_protocol_value(number=1)]
18 Active,
19}
20
21#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
22#[open_protocol_message(MID = 0010, revision = 1)]
23pub struct MID0010rev1 {
24}
25
26#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
27#[open_protocol_message(MID = 0011, revision = 1)]
28pub struct MID0011rev1 {
29 #[open_protocol_field(length = 3)]
31 pub number_of_parameter_sets: u16,
32
33 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 3)]
35 pub parameter_set_ids: Vec<u16>,
36}
37
38#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
39#[open_protocol_message(MID = 0011, revision = 2)]
40pub struct MID0011rev2 {
41 #[open_protocol_field(length = 3)]
43 pub number_of_parameter_sets: u16,
44
45 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 3)]
47 pub parameter_set_ids: Vec<u16>,
48
49 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 2)]
51 pub cycles: Vec<u8>,
52}
53
54#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
55#[open_protocol_message(MID = 0011, revision = 3)]
56pub struct MID0011rev3 {
57 #[open_protocol_field(length = 3)]
59 pub number_of_parameter_sets: u16,
60
61 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 3)]
63 pub parameter_set_ids: Vec<u16>,
64
65 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 2)]
67 pub cycles: Vec<u8>,
68
69 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 4)]
71 pub types: Vec<String>,
72}
73
74#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
75#[open_protocol_message(MID = 0011, revision = 4)]
76pub struct MID0011rev4 {
77 #[open_protocol_field(length = 3)]
79 pub number_of_parameter_sets: u16,
80
81 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 3)]
83 pub parameter_set_ids: Vec<u16>,
84
85 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 2)]
87 pub cycles: Vec<u8>,
88
89 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 4)]
91 pub types: Vec<String>,
92
93 #[open_protocol_field(list, amount = "number_of_parameter_sets", length = 19)]
95 pub date_of_last_change: Vec<String>,
96}
97
98#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
99#[open_protocol_message(MID = 0012, revision = 1)]
100pub struct MID0012rev1 {
101
102 #[open_protocol_field(length = 3)]
104 pub parameter_set_id: u16,
105}
106
107#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
108#[open_protocol_message(MID = 0013, revision = 1)]
109pub struct MID0013rev1 {
110 #[open_protocol_field(number = 1, length = 3)]
112 pub parameter_set_id: u16,
113
114 #[open_protocol_field(number = 2, length = 25)]
116 pub parameter_set_name: String,
117
118 #[open_protocol_field(number = 3, length = 1)]
120 pub rotation_direction: RotationDirection,
121
122 #[open_protocol_field(number = 4, length = 2)]
124 pub batch_size: u8,
125
126 #[open_protocol_field(number = 5, length = 6)]
128 pub torque_min: u32,
129
130 #[open_protocol_field(number = 6, length = 6)]
132 pub torque_max: u32,
133
134 #[open_protocol_field(number = 7, length = 6)]
136 pub final_torque_target: u32,
137
138 #[open_protocol_field(number = 8, length = 5)]
140 pub angle_min: u16,
141
142 #[open_protocol_field(number = 9, length = 5)]
144 pub angle_max: u16,
145
146 #[open_protocol_field(number = 10, length = 5)]
148 pub final_angle_target: u16,
149}
150
151#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
152#[open_protocol_message(MID = 0013, revision = 2)]
153pub struct MID0013rev2 {
154 #[open_protocol_field(number = 1, length = 3)]
156 pub parameter_set_id: u16,
157
158 #[open_protocol_field(number = 2, length = 25)]
160 pub parameter_set_name: String,
161
162 #[open_protocol_field(number = 3, length = 1)]
164 pub rotation_direction: RotationDirection,
165
166 #[open_protocol_field(number = 4, length = 2)]
168 pub batch_size: u8,
169
170 #[open_protocol_field(number = 5, length = 6)]
172 pub torque_min: u32,
173
174 #[open_protocol_field(number = 6, length = 6)]
176 pub torque_max: u32,
177
178 #[open_protocol_field(number = 7, length = 6)]
180 pub final_torque_target: u32,
181
182 #[open_protocol_field(number = 8, length = 5)]
184 pub angle_min: u16,
185
186 #[open_protocol_field(number = 9, length = 5)]
188 pub angle_max: u16,
189
190 #[open_protocol_field(number = 10, length = 5)]
192 pub final_angle_target: u16,
193
194 #[open_protocol_field(number = 11, length = 6)]
196 pub first_target: u32,
197
198 #[open_protocol_field(number = 12, length = 6)]
200 pub start_final_angle: u32,
201}
202
203#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
204#[open_protocol_message(MID = 0014, revision = 1)]
205pub struct MID0014rev1 {
206}
207
208#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
209#[open_protocol_message(MID = 0015, revision = 1)]
210pub struct MID0015rev1 {
211 #[open_protocol_field(number = 1, length = 3)]
213 pub parameter_set_id: u16,
214
215 #[open_protocol_field(number = 2, length = 19)]
217 pub date_of_last_change: String,
218}
219
220#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
221#[open_protocol_message(MID = 0015, revision = 2)]
222pub struct MID0015rev2 {
223 #[open_protocol_field(number = 1, length = 3)]
225 pub parameter_set_id: u16,
226
227 #[open_protocol_field(number = 2, length = 25)]
229 pub parameter_set_name: String,
230
231 #[open_protocol_field(number = 3, length = 19)]
233 pub date_of_last_change: String,
234
235 #[open_protocol_field(number = 4, length = 1)]
237 pub rotation_direction: u8,
238
239 #[open_protocol_field(number = 5, length = 2)]
241 pub batch_size: u8,
242
243 #[open_protocol_field(number = 6, length = 6)]
245 pub torque_min: u32,
246
247 #[open_protocol_field(number = 7, length = 6)]
249 pub torque_max: u32,
250
251 #[open_protocol_field(number = 8, length = 6)]
253 pub final_torque_target: u32,
254
255 #[open_protocol_field(number = 9, length = 5)]
257 pub angle_min: u16,
258
259 #[open_protocol_field(number = 10, length = 5)]
261 pub angle_max: u16,
262
263 #[open_protocol_field(number = 11, length = 5)]
265 pub final_angle_target: u16,
266
267 #[open_protocol_field(number = 12, length = 6)]
269 pub first_torque_target: u32,
270
271 #[open_protocol_field(number = 13, length = 6)]
273 pub start_final_angle: u32,
274}
275
276#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
277#[open_protocol_message(MID = 0016, revision = 1)]
278pub struct MID0016rev1 {
279}
280
281#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
282#[open_protocol_message(MID = 0017, revision = 1)]
283pub struct MID0017rev1 {
284}
285
286#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
287#[open_protocol_message(MID = 0018, revision = 1)]
288pub struct MID0018rev1 {
289 #[open_protocol_field(number = 1, length = 3)]
291 pub parameter_set_id: u16,
292}
293
294#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
295#[open_protocol_message(MID = 0019, revision = 1)]
296pub struct MID0019rev1 {
297 #[open_protocol_field(number = 1, length = 3)]
299 pub parameter_set_id: u16,
300
301 #[open_protocol_field(number = 2, length = 2)]
303 pub batch_size: u8,
304}
305
306#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
307#[open_protocol_message(MID = 0019, revision = 2)]
308pub struct MID0019rev2 {
309 #[open_protocol_field(number = 1, length = 3)]
311 pub parameter_set_id: u16,
312
313 #[open_protocol_field(number = 2, length = 4)]
315 pub batch_size: u16,
316}
317
318#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
319#[open_protocol_message(MID = 0020, revision = 1)]
320pub struct MID0020rev1 {
321
322 #[open_protocol_field(number = 1, length = 3)]
324 pub parameter_set_id: u16,
325}
326
327#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
328#[open_protocol_message(MID = 0021, revision = 1)]
329pub struct MID0021rev1 {
330}
331
332#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
333#[open_protocol_message(MID = 0022, revision = 1)]
334pub struct MID0022rev1 {
335
336 #[open_protocol_field(number = 1, length = 1)]
338 pub relay_status: RelayStatus,
339}
340
341#[derive(Debug, Default, Eq, PartialEq, OpenProtocolEncode, OpenProtocolDecode, OpenProtocolMessage)]
342#[open_protocol_message(MID = 2506, revision = 1)]
343pub struct MID2506rev1 {
344
345 #[open_protocol_field(number = 1, length = 4)]
347 pub program_id: u32,
348
349 #[open_protocol_field(number = 2, length = 3)]
351 pub node_type: u16,
352}
353
354#[cfg(test)]
355mod tests {
356 use open_protocol_codec::{decode, encode};
357 use super::*;
358
359 #[test]
360 fn encode_0010() {
361 let message = MID0010rev1 {};
362
363 let result = encode::encode(&message);
364
365 assert_eq!(result, Ok("".to_string()));
366 }
367
368 #[test]
369 fn encode_0012() {
370 let message = MID0012rev1 { parameter_set_id: 12 };
371
372 let result = encode::encode(&message);
373
374 assert_eq!(result, Ok("012".to_string()));
375 }
376
377 #[test]
378 fn encode_0011rev1() {
379 let message = MID0011rev1 {
380 number_of_parameter_sets: 5,
381 parameter_set_ids: vec![1, 2, 3, 10, 20],
382 };
383
384 let result = encode::encode(&message);
385
386 assert_eq!(result, Ok("005001002003010020".to_string()));
387 }
388
389 #[test]
390 fn decode_0011rev1() {
391 let message = "005001002003010020";
392
393 let result = decode::decode(message.as_bytes());
394
395 assert_eq!(result, Ok(MID0011rev1 {
396 number_of_parameter_sets: 5,
397 parameter_set_ids: vec![1, 2, 3, 10, 20],
398 }));
399 }
400}