Skip to main content

sunspec/models/
model64001.rs

1//! Veris Status and Configuration
2/// Veris Status and Configuration
3#[derive(Debug)]
4#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
5pub struct Model64001 {
6    /// Command Code
7    pub cmd: Option<u16>,
8    /// Hardware Revision
9    pub hw_rev: Option<u16>,
10    /// RS FW Revision
11    pub rsfw_rev: Option<u16>,
12    /// OS FW Revision
13    pub osfw_rev: Option<u16>,
14    /// Product Revision
15    pub prod_rev: Option<String>,
16    /// Boot Count
17    pub boots: Option<u16>,
18    /// DIP Switches
19    pub switch: Option<Switch>,
20    /// Num Detected Sensors
21    pub sensors: Option<u16>,
22    /// Num Communicating Sensors
23    pub talking: Option<u16>,
24    /// System Status
25    pub status: Option<Status>,
26    /// System Configuration
27    pub config: Option<Config>,
28    /// LED Blink Threshold
29    pub le_dblink: Option<u16>,
30    /// LED On Threshold
31    pub le_don: Option<u16>,
32    #[allow(missing_docs)]
33    pub reserved: Option<u16>,
34    /// Location String
35    pub loc: Option<String>,
36    /// Sensor 1 Unit ID
37    pub s1id: Option<u16>,
38    /// Sensor 1 Address
39    pub s1_addr: Option<u16>,
40    /// Sensor 1 OS Version
41    pub s1os_ver: Option<u16>,
42    /// Sensor 1 Product Version
43    pub s1_ver: Option<String>,
44    /// Sensor 1 Serial Num
45    pub s1_serial: Option<String>,
46    /// Sensor 2 Unit ID
47    pub s2id: Option<u16>,
48    /// Sensor 2 Address
49    pub s2_addr: Option<u16>,
50    /// Sensor 2 OS Version
51    pub s2os_ver: Option<u16>,
52    /// Sensor 2 Product Version
53    pub s2_ver: Option<String>,
54    /// Sensor 2 Serial Num
55    pub s2_serial: Option<String>,
56    /// Sensor 3 Unit ID
57    pub s3id: Option<u16>,
58    /// Sensor 3 Address
59    pub s3_addr: Option<u16>,
60    /// Sensor 3 OS Version
61    pub s3os_ver: Option<u16>,
62    /// Sensor 3 Product Version
63    pub s3_ver: Option<String>,
64    /// Sensor 3 Serial Num
65    pub s3_serial: Option<String>,
66    /// Sensor 4 Unit ID
67    pub s4id: Option<u16>,
68    /// Sensor 4 Address
69    pub s4_addr: Option<u16>,
70    /// Sensor 4 OS Version
71    pub s4os_ver: Option<u16>,
72    /// Sensor 4 Product Version
73    pub s4_ver: Option<String>,
74    /// Sensor 4 Serial Num
75    pub s4_serial: Option<String>,
76}
77#[allow(missing_docs)]
78impl Model64001 {
79    pub const CMD: crate::Point<Self, Option<u16>> = crate::Point::new(0, 1, true);
80    pub const HW_REV: crate::Point<Self, Option<u16>> = crate::Point::new(1, 1, false);
81    pub const RSFW_REV: crate::Point<Self, Option<u16>> = crate::Point::new(2, 1, false);
82    pub const OSFW_REV: crate::Point<Self, Option<u16>> = crate::Point::new(3, 1, false);
83    pub const PROD_REV: crate::Point<Self, Option<String>> = crate::Point::new(4, 2, false);
84    pub const BOOTS: crate::Point<Self, Option<u16>> = crate::Point::new(6, 1, false);
85    pub const SWITCH: crate::Point<Self, Option<Switch>> = crate::Point::new(7, 1, false);
86    pub const SENSORS: crate::Point<Self, Option<u16>> = crate::Point::new(8, 1, false);
87    pub const TALKING: crate::Point<Self, Option<u16>> = crate::Point::new(9, 1, false);
88    pub const STATUS: crate::Point<Self, Option<Status>> = crate::Point::new(10, 1, false);
89    pub const CONFIG: crate::Point<Self, Option<Config>> = crate::Point::new(11, 1, false);
90    pub const LE_DBLINK: crate::Point<Self, Option<u16>> = crate::Point::new(12, 1, false);
91    pub const LE_DON: crate::Point<Self, Option<u16>> = crate::Point::new(13, 1, false);
92    pub const RESERVED: crate::Point<Self, Option<u16>> = crate::Point::new(14, 1, false);
93    pub const LOC: crate::Point<Self, Option<String>> = crate::Point::new(15, 16, false);
94    pub const S1ID: crate::Point<Self, Option<u16>> = crate::Point::new(31, 1, false);
95    pub const S1_ADDR: crate::Point<Self, Option<u16>> = crate::Point::new(32, 1, false);
96    pub const S1OS_VER: crate::Point<Self, Option<u16>> = crate::Point::new(33, 1, false);
97    pub const S1_VER: crate::Point<Self, Option<String>> = crate::Point::new(34, 2, false);
98    pub const S1_SERIAL: crate::Point<Self, Option<String>> = crate::Point::new(36, 5, false);
99    pub const S2ID: crate::Point<Self, Option<u16>> = crate::Point::new(41, 1, false);
100    pub const S2_ADDR: crate::Point<Self, Option<u16>> = crate::Point::new(42, 1, false);
101    pub const S2OS_VER: crate::Point<Self, Option<u16>> = crate::Point::new(43, 1, false);
102    pub const S2_VER: crate::Point<Self, Option<String>> = crate::Point::new(44, 2, false);
103    pub const S2_SERIAL: crate::Point<Self, Option<String>> = crate::Point::new(46, 5, false);
104    pub const S3ID: crate::Point<Self, Option<u16>> = crate::Point::new(51, 1, false);
105    pub const S3_ADDR: crate::Point<Self, Option<u16>> = crate::Point::new(52, 1, false);
106    pub const S3OS_VER: crate::Point<Self, Option<u16>> = crate::Point::new(53, 1, false);
107    pub const S3_VER: crate::Point<Self, Option<String>> = crate::Point::new(54, 2, false);
108    pub const S3_SERIAL: crate::Point<Self, Option<String>> = crate::Point::new(56, 5, false);
109    pub const S4ID: crate::Point<Self, Option<u16>> = crate::Point::new(61, 1, false);
110    pub const S4_ADDR: crate::Point<Self, Option<u16>> = crate::Point::new(62, 1, false);
111    pub const S4OS_VER: crate::Point<Self, Option<u16>> = crate::Point::new(63, 1, false);
112    pub const S4_VER: crate::Point<Self, Option<String>> = crate::Point::new(64, 2, false);
113    pub const S4_SERIAL: crate::Point<Self, Option<String>> = crate::Point::new(66, 5, false);
114}
115impl crate::Group for Model64001 {
116    const LEN: u16 = 71;
117}
118impl Model64001 {
119    fn parse_group(data: &[u16]) -> Result<(&[u16], Self), crate::DecodeError> {
120        let nested_data = data
121            .get(usize::from(<Self as crate::Group>::LEN)..)
122            .unwrap_or(&[]);
123        Ok((
124            nested_data,
125            Self {
126                cmd: Self::CMD.from_data(data)?,
127                hw_rev: Self::HW_REV.from_data(data)?,
128                rsfw_rev: Self::RSFW_REV.from_data(data)?,
129                osfw_rev: Self::OSFW_REV.from_data(data)?,
130                prod_rev: Self::PROD_REV.from_data(data)?,
131                boots: Self::BOOTS.from_data(data)?,
132                switch: Self::SWITCH.from_data(data)?,
133                sensors: Self::SENSORS.from_data(data)?,
134                talking: Self::TALKING.from_data(data)?,
135                status: Self::STATUS.from_data(data)?,
136                config: Self::CONFIG.from_data(data)?,
137                le_dblink: Self::LE_DBLINK.from_data(data)?,
138                le_don: Self::LE_DON.from_data(data)?,
139                reserved: Self::RESERVED.from_data(data)?,
140                loc: Self::LOC.from_data(data)?,
141                s1id: Self::S1ID.from_data(data)?,
142                s1_addr: Self::S1_ADDR.from_data(data)?,
143                s1os_ver: Self::S1OS_VER.from_data(data)?,
144                s1_ver: Self::S1_VER.from_data(data)?,
145                s1_serial: Self::S1_SERIAL.from_data(data)?,
146                s2id: Self::S2ID.from_data(data)?,
147                s2_addr: Self::S2_ADDR.from_data(data)?,
148                s2os_ver: Self::S2OS_VER.from_data(data)?,
149                s2_ver: Self::S2_VER.from_data(data)?,
150                s2_serial: Self::S2_SERIAL.from_data(data)?,
151                s3id: Self::S3ID.from_data(data)?,
152                s3_addr: Self::S3_ADDR.from_data(data)?,
153                s3os_ver: Self::S3OS_VER.from_data(data)?,
154                s3_ver: Self::S3_VER.from_data(data)?,
155                s3_serial: Self::S3_SERIAL.from_data(data)?,
156                s4id: Self::S4ID.from_data(data)?,
157                s4_addr: Self::S4_ADDR.from_data(data)?,
158                s4os_ver: Self::S4OS_VER.from_data(data)?,
159                s4_ver: Self::S4_VER.from_data(data)?,
160                s4_serial: Self::S4_SERIAL.from_data(data)?,
161            },
162        ))
163    }
164}
165bitflags::bitflags! {
166    #[doc = " DIP Switches"] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
167    #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))] pub
168    struct Switch : u16 {}
169}
170impl crate::Value for Switch {
171    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
172        let value = u16::decode(data)?;
173        Ok(Self::from_bits_retain(value))
174    }
175    fn encode(self) -> Box<[u16]> {
176        self.bits().encode()
177    }
178}
179impl crate::FixedSize for Switch {
180    const SIZE: u16 = 1u16;
181    const INVALID: Self = Self::from_bits_retain(65535u16);
182    fn is_invalid(&self) -> bool {
183        self.bits() == 65535u16
184    }
185}
186bitflags::bitflags! {
187    #[doc = " System Status"] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
188    #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))] pub
189    struct Status : u16 {}
190}
191impl crate::Value for Status {
192    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
193        let value = u16::decode(data)?;
194        Ok(Self::from_bits_retain(value))
195    }
196    fn encode(self) -> Box<[u16]> {
197        self.bits().encode()
198    }
199}
200impl crate::FixedSize for Status {
201    const SIZE: u16 = 1u16;
202    const INVALID: Self = Self::from_bits_retain(65535u16);
203    fn is_invalid(&self) -> bool {
204        self.bits() == 65535u16
205    }
206}
207bitflags::bitflags! {
208    #[doc = " System Configuration"] #[derive(Copy, Clone, Debug, Eq, PartialEq)]
209    #[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))] pub
210    struct Config : u16 {}
211}
212impl crate::Value for Config {
213    fn decode(data: &[u16]) -> Result<Self, crate::DecodeError> {
214        let value = u16::decode(data)?;
215        Ok(Self::from_bits_retain(value))
216    }
217    fn encode(self) -> Box<[u16]> {
218        self.bits().encode()
219    }
220}
221impl crate::FixedSize for Config {
222    const SIZE: u16 = 1u16;
223    const INVALID: Self = Self::from_bits_retain(65535u16);
224    fn is_invalid(&self) -> bool {
225        self.bits() == 65535u16
226    }
227}
228impl crate::Model for Model64001 {
229    const ID: u16 = 64001;
230    fn addr(models: &crate::Models) -> crate::ModelAddr<Self> {
231        models.m64001
232    }
233    fn parse(data: &[u16]) -> Result<Self, crate::ParseError<Self>> {
234        let (_, model) = Self::parse_group(data)?;
235        Ok(model)
236    }
237}