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
//! Public traits exposed by the codec engine. They decouple generated
//! PGN structures from the serialization/deserialization logic and provide
//! a uniform API to upper layers.
use cratePgnValue;
use crate;
//==================================================================================PGN_DATA
/// Implemented by every generated PGN struct.
/// Acts as a bridge between static descriptors and the interpretation engine.
//==================================================================================FIELD_ACCESS
/// Trait that lets the engine access PGN fields by their `'static str` identifier
/// without knowing the concrete type. Implementations are code-generated.
///
/// # Regular fields vs repeating fields
///
/// NMEA 2000 PGNs may contain:
/// - **Regular fields** accessible through `field()` and `field_mut()`
/// - **Repeating field sets**, groups repeated N times and accessed through
/// `repetitive_field()` / `repetitive_field_mut()`
///
/// ## Example: PGN 129029 (GNSS Position Data)
///
/// Contains regular fields (date, time, latitude, …) and a repeating group of
/// reference stations (`reference_station_id`, `age_of_dgnss_corrections`).
///
/// ```rust, ignore
/// let mut pgn = Pgn129029::new();
///
/// // Regular field access
/// pgn.field_mut("Date", PgnValue::U16(19000));
///
/// // Define the number of reference stations
/// pgn.set_repetitive_count("reference_station_types", 2);
///
/// // Repeating field access (station 0)
/// pgn.repetitive_field_mut("reference_station_types", 0, "ReferenceStationId", PgnValue::U16(101));
/// pgn.repetitive_field_mut("reference_station_types", 0, "AgeOfDgnssCorrections", PgnValue::F32(5.2));
///
/// // Repeating field access (station 1)
/// pgn.repetitive_field_mut("reference_station_types", 1, "ReferenceStationId", PgnValue::U16(202));
/// pgn.repetitive_field_mut("reference_station_types", 1, "AgeOfDgnssCorrections", PgnValue::F32(3.7));
/// ```