1#[derive(Debug)]
6#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
7pub struct Model17 {
8 pub nam: Option<String>,
12 pub rte: u32,
16 pub bits: u16,
20 pub pty: Pty,
24 pub dup: Option<Dup>,
28 pub flw: Option<Flw>,
32 pub typ: Option<Typ>,
36 pub pcol: Option<Pcol>,
40}
41#[allow(missing_docs)]
42impl Model17 {
43 pub const NAM: crate::Point<Self, Option<String>> = crate::Point::new(0, 4, true);
44 pub const RTE: crate::Point<Self, u32> = crate::Point::new(4, 2, true);
45 pub const BITS: crate::Point<Self, u16> = crate::Point::new(6, 1, true);
46 pub const PTY: crate::Point<Self, Pty> = crate::Point::new(7, 1, true);
47 pub const DUP: crate::Point<Self, Option<Dup>> = crate::Point::new(8, 1, true);
48 pub const FLW: crate::Point<Self, Option<Flw>> = crate::Point::new(9, 1, true);
49 pub const TYP: crate::Point<Self, Option<Typ>> = crate::Point::new(10, 1, false);
50 pub const PCOL: crate::Point<Self, Option<Pcol>> = crate::Point::new(11, 1, false);
51}
52impl crate::Group for Model17 {
53 const LEN: u16 = 12;
54}
55impl Model17 {
56 fn parse_group(data: &[u16]) -> Result<(&[u16], Self), crate::DecodeError> {
57 let nested_data = data
58 .get(usize::from(<Self as crate::Group>::LEN)..)
59 .unwrap_or(&[]);
60 Ok((
61 nested_data,
62 Self {
63 nam: Self::NAM.from_data(data)?,
64 rte: Self::RTE.from_data(data)?,
65 bits: Self::BITS.from_data(data)?,
66 pty: Self::PTY.from_data(data)?,
67 dup: Self::DUP.from_data(data)?,
68 flw: Self::FLW.from_data(data)?,
69 typ: Self::TYP.from_data(data)?,
70 pcol: Self::PCOL.from_data(data)?,
71 },
72 ))
73 }
74}
75#[derive(Copy, Clone, Debug, Eq, PartialEq)]
79#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
80pub enum Pty {
81 #[allow(missing_docs)]
82 None,
83 #[allow(missing_docs)]
84 Odd,
85 #[allow(missing_docs)]
86 Even,
87 Invalid(u16),
89}
90impl crate::EnumValue for Pty {
91 type Repr = u16;
92 const INVALID: Self::Repr = 65535;
93 fn from_repr(value: Self::Repr) -> Self {
94 match value {
95 0 => Self::None,
96 1 => Self::Odd,
97 2 => Self::Even,
98 value => Self::Invalid(value),
99 }
100 }
101 fn to_repr(self) -> Self::Repr {
102 match self {
103 Self::None => 0,
104 Self::Odd => 1,
105 Self::Even => 2,
106 Self::Invalid(value) => value,
107 }
108 }
109}
110impl crate::FixedSize for Pty {
111 const SIZE: u16 = 1u16;
112 const INVALID: Self = Self::Invalid(65535);
113 fn is_invalid(&self) -> bool {
114 matches!(self, Self::Invalid(_))
115 }
116}
117#[derive(Copy, Clone, Debug, Eq, PartialEq)]
121#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
122pub enum Dup {
123 #[allow(missing_docs)]
124 Full,
125 #[allow(missing_docs)]
126 Half,
127 Invalid(u16),
129}
130impl crate::EnumValue for Dup {
131 type Repr = u16;
132 const INVALID: Self::Repr = 65535;
133 fn from_repr(value: Self::Repr) -> Self {
134 match value {
135 0 => Self::Full,
136 1 => Self::Half,
137 value => Self::Invalid(value),
138 }
139 }
140 fn to_repr(self) -> Self::Repr {
141 match self {
142 Self::Full => 0,
143 Self::Half => 1,
144 Self::Invalid(value) => value,
145 }
146 }
147}
148impl crate::FixedSize for Dup {
149 const SIZE: u16 = 1u16;
150 const INVALID: Self = Self::Invalid(65535);
151 fn is_invalid(&self) -> bool {
152 matches!(self, Self::Invalid(_))
153 }
154}
155#[derive(Copy, Clone, Debug, Eq, PartialEq)]
159#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
160pub enum Flw {
161 #[allow(missing_docs)]
162 None,
163 #[allow(missing_docs)]
164 Hw,
165 #[allow(missing_docs)]
166 Xonxoff,
167 Invalid(u16),
169}
170impl crate::EnumValue for Flw {
171 type Repr = u16;
172 const INVALID: Self::Repr = 65535;
173 fn from_repr(value: Self::Repr) -> Self {
174 match value {
175 0 => Self::None,
176 1 => Self::Hw,
177 2 => Self::Xonxoff,
178 value => Self::Invalid(value),
179 }
180 }
181 fn to_repr(self) -> Self::Repr {
182 match self {
183 Self::None => 0,
184 Self::Hw => 1,
185 Self::Xonxoff => 2,
186 Self::Invalid(value) => value,
187 }
188 }
189}
190impl crate::FixedSize for Flw {
191 const SIZE: u16 = 1u16;
192 const INVALID: Self = Self::Invalid(65535);
193 fn is_invalid(&self) -> bool {
194 matches!(self, Self::Invalid(_))
195 }
196}
197#[derive(Copy, Clone, Debug, Eq, PartialEq)]
201#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
202pub enum Typ {
203 #[allow(missing_docs)]
204 Unknown,
205 #[allow(missing_docs)]
206 Rs232,
207 #[allow(missing_docs)]
208 Rs485,
209 Invalid(u16),
211}
212impl crate::EnumValue for Typ {
213 type Repr = u16;
214 const INVALID: Self::Repr = 65535;
215 fn from_repr(value: Self::Repr) -> Self {
216 match value {
217 0 => Self::Unknown,
218 1 => Self::Rs232,
219 2 => Self::Rs485,
220 value => Self::Invalid(value),
221 }
222 }
223 fn to_repr(self) -> Self::Repr {
224 match self {
225 Self::Unknown => 0,
226 Self::Rs232 => 1,
227 Self::Rs485 => 2,
228 Self::Invalid(value) => value,
229 }
230 }
231}
232impl crate::FixedSize for Typ {
233 const SIZE: u16 = 1u16;
234 const INVALID: Self = Self::Invalid(65535);
235 fn is_invalid(&self) -> bool {
236 matches!(self, Self::Invalid(_))
237 }
238}
239#[derive(Copy, Clone, Debug, Eq, PartialEq)]
243#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
244pub enum Pcol {
245 #[allow(missing_docs)]
246 Unknown,
247 #[allow(missing_docs)]
248 Modbus,
249 #[allow(missing_docs)]
250 Vendor,
251 Invalid(u16),
253}
254impl crate::EnumValue for Pcol {
255 type Repr = u16;
256 const INVALID: Self::Repr = 65535;
257 fn from_repr(value: Self::Repr) -> Self {
258 match value {
259 0 => Self::Unknown,
260 1 => Self::Modbus,
261 2 => Self::Vendor,
262 value => Self::Invalid(value),
263 }
264 }
265 fn to_repr(self) -> Self::Repr {
266 match self {
267 Self::Unknown => 0,
268 Self::Modbus => 1,
269 Self::Vendor => 2,
270 Self::Invalid(value) => value,
271 }
272 }
273}
274impl crate::FixedSize for Pcol {
275 const SIZE: u16 = 1u16;
276 const INVALID: Self = Self::Invalid(65535);
277 fn is_invalid(&self) -> bool {
278 matches!(self, Self::Invalid(_))
279 }
280}
281impl crate::Model for Model17 {
282 const ID: u16 = 17;
283 fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
284 models.m17
285 }
286 fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
287 let (_, model) = Self::parse_group(data)?;
288 Ok(model)
289 }
290}