aws_sdk_iotfleetwise/types/
_can_signal.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Information about a single controller area network (CAN) signal and the messages it receives and transmits.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct CanSignal {
7    /// <p>The ID of the message.</p>
8    pub message_id: i32,
9    /// <p>Whether the byte ordering of a CAN message is big-endian.</p>
10    pub is_big_endian: bool,
11    /// <p>Determines whether the message is signed (<code>true</code>) or not (<code>false</code>). If it's signed, the message can represent both positive and negative numbers. The <code>isSigned</code> parameter only applies to the <code>INTEGER</code> raw signal type, and it doesn't affect the <code>FLOATING_POINT</code> raw signal type.</p>
12    pub is_signed: bool,
13    /// <p>Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).</p>
14    /// <p>This value might be different from the value in a DBC file. For little endian signals, <code>startBit</code> is the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as the <code>startBit</code>.</p>
15    pub start_bit: i32,
16    /// <p>The offset used to calculate the signal value. Combined with factor, the calculation is <code>value = raw_value * factor + offset</code>.</p>
17    pub offset: f64,
18    /// <p>A multiplier used to decode the CAN message.</p>
19    pub factor: f64,
20    /// <p>How many bytes of data are in the message.</p>
21    pub length: i32,
22    /// <p>The name of the signal.</p>
23    pub name: ::std::option::Option<::std::string::String>,
24    /// <p>The value type of the signal. The default value is <code>INTEGER</code>.</p>
25    pub signal_value_type: ::std::option::Option<crate::types::SignalValueType>,
26}
27impl CanSignal {
28    /// <p>The ID of the message.</p>
29    pub fn message_id(&self) -> i32 {
30        self.message_id
31    }
32    /// <p>Whether the byte ordering of a CAN message is big-endian.</p>
33    pub fn is_big_endian(&self) -> bool {
34        self.is_big_endian
35    }
36    /// <p>Determines whether the message is signed (<code>true</code>) or not (<code>false</code>). If it's signed, the message can represent both positive and negative numbers. The <code>isSigned</code> parameter only applies to the <code>INTEGER</code> raw signal type, and it doesn't affect the <code>FLOATING_POINT</code> raw signal type.</p>
37    pub fn is_signed(&self) -> bool {
38        self.is_signed
39    }
40    /// <p>Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).</p>
41    /// <p>This value might be different from the value in a DBC file. For little endian signals, <code>startBit</code> is the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as the <code>startBit</code>.</p>
42    pub fn start_bit(&self) -> i32 {
43        self.start_bit
44    }
45    /// <p>The offset used to calculate the signal value. Combined with factor, the calculation is <code>value = raw_value * factor + offset</code>.</p>
46    pub fn offset(&self) -> f64 {
47        self.offset
48    }
49    /// <p>A multiplier used to decode the CAN message.</p>
50    pub fn factor(&self) -> f64 {
51        self.factor
52    }
53    /// <p>How many bytes of data are in the message.</p>
54    pub fn length(&self) -> i32 {
55        self.length
56    }
57    /// <p>The name of the signal.</p>
58    pub fn name(&self) -> ::std::option::Option<&str> {
59        self.name.as_deref()
60    }
61    /// <p>The value type of the signal. The default value is <code>INTEGER</code>.</p>
62    pub fn signal_value_type(&self) -> ::std::option::Option<&crate::types::SignalValueType> {
63        self.signal_value_type.as_ref()
64    }
65}
66impl CanSignal {
67    /// Creates a new builder-style object to manufacture [`CanSignal`](crate::types::CanSignal).
68    pub fn builder() -> crate::types::builders::CanSignalBuilder {
69        crate::types::builders::CanSignalBuilder::default()
70    }
71}
72
73/// A builder for [`CanSignal`](crate::types::CanSignal).
74#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
75#[non_exhaustive]
76pub struct CanSignalBuilder {
77    pub(crate) message_id: ::std::option::Option<i32>,
78    pub(crate) is_big_endian: ::std::option::Option<bool>,
79    pub(crate) is_signed: ::std::option::Option<bool>,
80    pub(crate) start_bit: ::std::option::Option<i32>,
81    pub(crate) offset: ::std::option::Option<f64>,
82    pub(crate) factor: ::std::option::Option<f64>,
83    pub(crate) length: ::std::option::Option<i32>,
84    pub(crate) name: ::std::option::Option<::std::string::String>,
85    pub(crate) signal_value_type: ::std::option::Option<crate::types::SignalValueType>,
86}
87impl CanSignalBuilder {
88    /// <p>The ID of the message.</p>
89    /// This field is required.
90    pub fn message_id(mut self, input: i32) -> Self {
91        self.message_id = ::std::option::Option::Some(input);
92        self
93    }
94    /// <p>The ID of the message.</p>
95    pub fn set_message_id(mut self, input: ::std::option::Option<i32>) -> Self {
96        self.message_id = input;
97        self
98    }
99    /// <p>The ID of the message.</p>
100    pub fn get_message_id(&self) -> &::std::option::Option<i32> {
101        &self.message_id
102    }
103    /// <p>Whether the byte ordering of a CAN message is big-endian.</p>
104    /// This field is required.
105    pub fn is_big_endian(mut self, input: bool) -> Self {
106        self.is_big_endian = ::std::option::Option::Some(input);
107        self
108    }
109    /// <p>Whether the byte ordering of a CAN message is big-endian.</p>
110    pub fn set_is_big_endian(mut self, input: ::std::option::Option<bool>) -> Self {
111        self.is_big_endian = input;
112        self
113    }
114    /// <p>Whether the byte ordering of a CAN message is big-endian.</p>
115    pub fn get_is_big_endian(&self) -> &::std::option::Option<bool> {
116        &self.is_big_endian
117    }
118    /// <p>Determines whether the message is signed (<code>true</code>) or not (<code>false</code>). If it's signed, the message can represent both positive and negative numbers. The <code>isSigned</code> parameter only applies to the <code>INTEGER</code> raw signal type, and it doesn't affect the <code>FLOATING_POINT</code> raw signal type.</p>
119    /// This field is required.
120    pub fn is_signed(mut self, input: bool) -> Self {
121        self.is_signed = ::std::option::Option::Some(input);
122        self
123    }
124    /// <p>Determines whether the message is signed (<code>true</code>) or not (<code>false</code>). If it's signed, the message can represent both positive and negative numbers. The <code>isSigned</code> parameter only applies to the <code>INTEGER</code> raw signal type, and it doesn't affect the <code>FLOATING_POINT</code> raw signal type.</p>
125    pub fn set_is_signed(mut self, input: ::std::option::Option<bool>) -> Self {
126        self.is_signed = input;
127        self
128    }
129    /// <p>Determines whether the message is signed (<code>true</code>) or not (<code>false</code>). If it's signed, the message can represent both positive and negative numbers. The <code>isSigned</code> parameter only applies to the <code>INTEGER</code> raw signal type, and it doesn't affect the <code>FLOATING_POINT</code> raw signal type.</p>
130    pub fn get_is_signed(&self) -> &::std::option::Option<bool> {
131        &self.is_signed
132    }
133    /// <p>Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).</p>
134    /// <p>This value might be different from the value in a DBC file. For little endian signals, <code>startBit</code> is the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as the <code>startBit</code>.</p>
135    /// This field is required.
136    pub fn start_bit(mut self, input: i32) -> Self {
137        self.start_bit = ::std::option::Option::Some(input);
138        self
139    }
140    /// <p>Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).</p>
141    /// <p>This value might be different from the value in a DBC file. For little endian signals, <code>startBit</code> is the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as the <code>startBit</code>.</p>
142    pub fn set_start_bit(mut self, input: ::std::option::Option<i32>) -> Self {
143        self.start_bit = input;
144        self
145    }
146    /// <p>Indicates the beginning of the CAN signal. This should always be the least significant bit (LSB).</p>
147    /// <p>This value might be different from the value in a DBC file. For little endian signals, <code>startBit</code> is the same value as in the DBC file. For big endian signals in a DBC file, the start bit is the most significant bit (MSB). You will have to calculate the LSB instead and pass it as the <code>startBit</code>.</p>
148    pub fn get_start_bit(&self) -> &::std::option::Option<i32> {
149        &self.start_bit
150    }
151    /// <p>The offset used to calculate the signal value. Combined with factor, the calculation is <code>value = raw_value * factor + offset</code>.</p>
152    /// This field is required.
153    pub fn offset(mut self, input: f64) -> Self {
154        self.offset = ::std::option::Option::Some(input);
155        self
156    }
157    /// <p>The offset used to calculate the signal value. Combined with factor, the calculation is <code>value = raw_value * factor + offset</code>.</p>
158    pub fn set_offset(mut self, input: ::std::option::Option<f64>) -> Self {
159        self.offset = input;
160        self
161    }
162    /// <p>The offset used to calculate the signal value. Combined with factor, the calculation is <code>value = raw_value * factor + offset</code>.</p>
163    pub fn get_offset(&self) -> &::std::option::Option<f64> {
164        &self.offset
165    }
166    /// <p>A multiplier used to decode the CAN message.</p>
167    /// This field is required.
168    pub fn factor(mut self, input: f64) -> Self {
169        self.factor = ::std::option::Option::Some(input);
170        self
171    }
172    /// <p>A multiplier used to decode the CAN message.</p>
173    pub fn set_factor(mut self, input: ::std::option::Option<f64>) -> Self {
174        self.factor = input;
175        self
176    }
177    /// <p>A multiplier used to decode the CAN message.</p>
178    pub fn get_factor(&self) -> &::std::option::Option<f64> {
179        &self.factor
180    }
181    /// <p>How many bytes of data are in the message.</p>
182    /// This field is required.
183    pub fn length(mut self, input: i32) -> Self {
184        self.length = ::std::option::Option::Some(input);
185        self
186    }
187    /// <p>How many bytes of data are in the message.</p>
188    pub fn set_length(mut self, input: ::std::option::Option<i32>) -> Self {
189        self.length = input;
190        self
191    }
192    /// <p>How many bytes of data are in the message.</p>
193    pub fn get_length(&self) -> &::std::option::Option<i32> {
194        &self.length
195    }
196    /// <p>The name of the signal.</p>
197    pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
198        self.name = ::std::option::Option::Some(input.into());
199        self
200    }
201    /// <p>The name of the signal.</p>
202    pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
203        self.name = input;
204        self
205    }
206    /// <p>The name of the signal.</p>
207    pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
208        &self.name
209    }
210    /// <p>The value type of the signal. The default value is <code>INTEGER</code>.</p>
211    pub fn signal_value_type(mut self, input: crate::types::SignalValueType) -> Self {
212        self.signal_value_type = ::std::option::Option::Some(input);
213        self
214    }
215    /// <p>The value type of the signal. The default value is <code>INTEGER</code>.</p>
216    pub fn set_signal_value_type(mut self, input: ::std::option::Option<crate::types::SignalValueType>) -> Self {
217        self.signal_value_type = input;
218        self
219    }
220    /// <p>The value type of the signal. The default value is <code>INTEGER</code>.</p>
221    pub fn get_signal_value_type(&self) -> &::std::option::Option<crate::types::SignalValueType> {
222        &self.signal_value_type
223    }
224    /// Consumes the builder and constructs a [`CanSignal`](crate::types::CanSignal).
225    /// This method will fail if any of the following fields are not set:
226    /// - [`offset`](crate::types::builders::CanSignalBuilder::offset)
227    /// - [`factor`](crate::types::builders::CanSignalBuilder::factor)
228    pub fn build(self) -> ::std::result::Result<crate::types::CanSignal, ::aws_smithy_types::error::operation::BuildError> {
229        ::std::result::Result::Ok(crate::types::CanSignal {
230            message_id: self.message_id.unwrap_or_default(),
231            is_big_endian: self.is_big_endian.unwrap_or_default(),
232            is_signed: self.is_signed.unwrap_or_default(),
233            start_bit: self.start_bit.unwrap_or_default(),
234            offset: self.offset.ok_or_else(|| {
235                ::aws_smithy_types::error::operation::BuildError::missing_field(
236                    "offset",
237                    "offset was not specified but it is required when building CanSignal",
238                )
239            })?,
240            factor: self.factor.ok_or_else(|| {
241                ::aws_smithy_types::error::operation::BuildError::missing_field(
242                    "factor",
243                    "factor was not specified but it is required when building CanSignal",
244                )
245            })?,
246            length: self.length.unwrap_or_default(),
247            name: self.name,
248            signal_value_type: self.signal_value_type,
249        })
250    }
251}