1pub type Model2 = Aggregator;
4#[derive(Debug)]
8#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
9pub struct Aggregator {
10 pub aid: u16,
14 pub n: u16,
18 pub un: u16,
22 pub st: St,
26 pub st_vnd: Option<u16>,
30 pub evt: Evt,
34 pub evt_vnd: Option<EvtVnd>,
38 pub ctl: Option<Ctl>,
42 pub ctl_vnd: Option<u32>,
46 pub ctl_vl: Option<u32>,
50}
51#[allow(missing_docs)]
52impl Aggregator {
53 pub const AID: crate::Point<Self, u16> = crate::Point::new(0, 1, false);
54 pub const N: crate::Point<Self, u16> = crate::Point::new(1, 1, false);
55 pub const UN: crate::Point<Self, u16> = crate::Point::new(2, 1, false);
56 pub const ST: crate::Point<Self, St> = crate::Point::new(3, 1, false);
57 pub const ST_VND: crate::Point<Self, Option<u16>> = crate::Point::new(4, 1, false);
58 pub const EVT: crate::Point<Self, Evt> = crate::Point::new(5, 2, false);
59 pub const EVT_VND: crate::Point<Self, Option<EvtVnd>> = crate::Point::new(7, 2, false);
60 pub const CTL: crate::Point<Self, Option<Ctl>> = crate::Point::new(9, 1, false);
61 pub const CTL_VND: crate::Point<Self, Option<u32>> = crate::Point::new(10, 2, false);
62 pub const CTL_VL: crate::Point<Self, Option<u32>> = crate::Point::new(12, 2, false);
63}
64impl crate::Group for Aggregator {
65 const LEN: u16 = 14;
66}
67impl Aggregator {
68 fn parse_group(data: &[u16]) -> Result<(&[u16], Self), crate::DecodeError> {
69 let nested_data = data
70 .get(usize::from(<Self as crate::Group>::LEN)..)
71 .unwrap_or(&[]);
72 Ok((
73 nested_data,
74 Self {
75 aid: Self::AID.from_data(data)?,
76 n: Self::N.from_data(data)?,
77 un: Self::UN.from_data(data)?,
78 st: Self::ST.from_data(data)?,
79 st_vnd: Self::ST_VND.from_data(data)?,
80 evt: Self::EVT.from_data(data)?,
81 evt_vnd: Self::EVT_VND.from_data(data)?,
82 ctl: Self::CTL.from_data(data)?,
83 ctl_vnd: Self::CTL_VND.from_data(data)?,
84 ctl_vl: Self::CTL_VL.from_data(data)?,
85 },
86 ))
87 }
88}
89#[derive(Copy, Clone, Debug, Eq, PartialEq)]
93#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
94pub enum St {
95 #[allow(missing_docs)]
96 Off,
97 #[allow(missing_docs)]
98 On,
99 #[allow(missing_docs)]
100 Full,
101 #[allow(missing_docs)]
102 Fault,
103 Invalid(u16),
105}
106impl crate::EnumValue for St {
107 type Repr = u16;
108 const INVALID: Self::Repr = 65535;
109 fn from_repr(value: Self::Repr) -> Self {
110 match value {
111 1 => Self::Off,
112 2 => Self::On,
113 3 => Self::Full,
114 4 => Self::Fault,
115 value => Self::Invalid(value),
116 }
117 }
118 fn to_repr(self) -> Self::Repr {
119 match self {
120 Self::Off => 1,
121 Self::On => 2,
122 Self::Full => 3,
123 Self::Fault => 4,
124 Self::Invalid(value) => value,
125 }
126 }
127}
128impl crate::FixedSize for St {
129 const SIZE: u16 = 1u16;
130 const INVALID: Self = Self::Invalid(65535);
131 fn is_invalid(&self) -> bool {
132 matches!(self, Self::Invalid(_))
133 }
134}
135bitflags::bitflags! {
136 #[doc = " Event Code"] #[doc = " "] #[doc = " Bitmask event code"] #[derive(Copy,
137 Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde",
138 derive(::serde::Serialize, ::serde::Deserialize))] pub struct Evt : u32 {
139 #[allow(missing_docs)] const GroundFault = 1; #[allow(missing_docs)] const
140 InputOverVoltage = 2; #[allow(missing_docs)] const Reserved2 = 4;
141 #[allow(missing_docs)] const DcDisconnect = 8; #[allow(missing_docs)] const Reserved4
142 = 16; #[allow(missing_docs)] const Reserved5 = 32; #[allow(missing_docs)] const
143 ManualShutdown = 64; #[allow(missing_docs)] const OverTemperature = 128;
144 #[allow(missing_docs)] const Reserved8 = 256; #[allow(missing_docs)] const Reserved9
145 = 512; #[allow(missing_docs)] const Reserved10 = 1024; #[allow(missing_docs)] const
146 Reserved11 = 2048; #[allow(missing_docs)] const BlownFuse = 4096;
147 #[allow(missing_docs)] const UnderTemperature = 8192; #[allow(missing_docs)] const
148 MemoryLoss = 16384; #[allow(missing_docs)] const ArcDetection = 32768;
149 #[allow(missing_docs)] const TheftDetection = 65536; #[allow(missing_docs)] const
150 OutputOverCurrent = 131072; #[allow(missing_docs)] const OutputOverVoltage = 262144;
151 #[allow(missing_docs)] const OutputUnderVoltage = 524288; #[allow(missing_docs)]
152 const TestFailed = 1048576; }
153}
154impl crate::Value for Evt {
155 fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
156 let value = u32::decode(data)?;
157 Ok(Self::from_bits_retain(value))
158 }
159 fn encode(self) -> Box<[u16]> {
160 self.bits().encode()
161 }
162}
163impl crate::FixedSize for Evt {
164 const SIZE: u16 = 2u16;
165 const INVALID: Self = Self::from_bits_retain(4294967295u32);
166 fn is_invalid(&self) -> bool {
167 self.bits() == 4294967295u32
168 }
169}
170bitflags::bitflags! {
171 #[doc = " Vendor Event Code"] #[doc = " "] #[doc = " Vendor specific event code"]
172 #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde",
173 derive(::serde::Serialize, ::serde::Deserialize))] pub struct EvtVnd : u32 {}
174}
175impl crate::Value for EvtVnd {
176 fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
177 let value = u32::decode(data)?;
178 Ok(Self::from_bits_retain(value))
179 }
180 fn encode(self) -> Box<[u16]> {
181 self.bits().encode()
182 }
183}
184impl crate::FixedSize for EvtVnd {
185 const SIZE: u16 = 2u16;
186 const INVALID: Self = Self::from_bits_retain(4294967295u32);
187 fn is_invalid(&self) -> bool {
188 self.bits() == 4294967295u32
189 }
190}
191#[derive(Copy, Clone, Debug, Eq, PartialEq)]
195#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
196pub enum Ctl {
197 #[allow(missing_docs)]
198 None,
199 #[allow(missing_docs)]
200 Automatic,
201 #[allow(missing_docs)]
202 ForceOff,
203 #[allow(missing_docs)]
204 Test,
205 #[allow(missing_docs)]
206 Throttle,
207 Invalid(u16),
209}
210impl crate::EnumValue for Ctl {
211 type Repr = u16;
212 const INVALID: Self::Repr = 65535;
213 fn from_repr(value: Self::Repr) -> Self {
214 match value {
215 0 => Self::None,
216 1 => Self::Automatic,
217 2 => Self::ForceOff,
218 3 => Self::Test,
219 4 => Self::Throttle,
220 value => Self::Invalid(value),
221 }
222 }
223 fn to_repr(self) -> Self::Repr {
224 match self {
225 Self::None => 0,
226 Self::Automatic => 1,
227 Self::ForceOff => 2,
228 Self::Test => 3,
229 Self::Throttle => 4,
230 Self::Invalid(value) => value,
231 }
232 }
233}
234impl crate::FixedSize for Ctl {
235 const SIZE: u16 = 1u16;
236 const INVALID: Self = Self::Invalid(65535);
237 fn is_invalid(&self) -> bool {
238 matches!(self, Self::Invalid(_))
239 }
240}
241impl crate::Model for Aggregator {
242 const ID: u16 = 2;
243 fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
244 models.m2
245 }
246 fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
247 let (_, model) = Self::parse_group(data)?;
248 Ok(model)
249 }
250}