1#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, converting_high_level_callback_receiver::ConvertingHighLevelCallbackReceiver,
17 converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
18 low_level_traits::LowLevelRead,
19};
20#[allow(unused_imports)]
21use futures_core::Stream;
22#[allow(unused_imports)]
23use tokio_stream::StreamExt;
24pub enum ThermalImagingBrickletFunction {
25 GetHighContrastImageLowLevel,
26 GetTemperatureImageLowLevel,
27 GetStatistics,
28 SetResolution,
29 GetResolution,
30 SetSpotmeterConfig,
31 GetSpotmeterConfig,
32 SetHighContrastConfig,
33 GetHighContrastConfig,
34 SetImageTransferConfig,
35 GetImageTransferConfig,
36 SetFluxLinearParameters,
37 GetFluxLinearParameters,
38 SetFfcShutterMode,
39 GetFfcShutterMode,
40 RunFfcNormalization,
41 GetSpitfpErrorCount,
42 SetBootloaderMode,
43 GetBootloaderMode,
44 SetWriteFirmwarePointer,
45 WriteFirmware,
46 SetStatusLedConfig,
47 GetStatusLedConfig,
48 GetChipTemperature,
49 Reset,
50 WriteUid,
51 ReadUid,
52 GetIdentity,
53 CallbackHighContrastImageLowLevel,
54 CallbackTemperatureImageLowLevel,
55}
56impl From<ThermalImagingBrickletFunction> for u8 {
57 fn from(fun: ThermalImagingBrickletFunction) -> Self {
58 match fun {
59 ThermalImagingBrickletFunction::GetHighContrastImageLowLevel => 1,
60 ThermalImagingBrickletFunction::GetTemperatureImageLowLevel => 2,
61 ThermalImagingBrickletFunction::GetStatistics => 3,
62 ThermalImagingBrickletFunction::SetResolution => 4,
63 ThermalImagingBrickletFunction::GetResolution => 5,
64 ThermalImagingBrickletFunction::SetSpotmeterConfig => 6,
65 ThermalImagingBrickletFunction::GetSpotmeterConfig => 7,
66 ThermalImagingBrickletFunction::SetHighContrastConfig => 8,
67 ThermalImagingBrickletFunction::GetHighContrastConfig => 9,
68 ThermalImagingBrickletFunction::SetImageTransferConfig => 10,
69 ThermalImagingBrickletFunction::GetImageTransferConfig => 11,
70 ThermalImagingBrickletFunction::SetFluxLinearParameters => 14,
71 ThermalImagingBrickletFunction::GetFluxLinearParameters => 15,
72 ThermalImagingBrickletFunction::SetFfcShutterMode => 16,
73 ThermalImagingBrickletFunction::GetFfcShutterMode => 17,
74 ThermalImagingBrickletFunction::RunFfcNormalization => 18,
75 ThermalImagingBrickletFunction::GetSpitfpErrorCount => 234,
76 ThermalImagingBrickletFunction::SetBootloaderMode => 235,
77 ThermalImagingBrickletFunction::GetBootloaderMode => 236,
78 ThermalImagingBrickletFunction::SetWriteFirmwarePointer => 237,
79 ThermalImagingBrickletFunction::WriteFirmware => 238,
80 ThermalImagingBrickletFunction::SetStatusLedConfig => 239,
81 ThermalImagingBrickletFunction::GetStatusLedConfig => 240,
82 ThermalImagingBrickletFunction::GetChipTemperature => 242,
83 ThermalImagingBrickletFunction::Reset => 243,
84 ThermalImagingBrickletFunction::WriteUid => 248,
85 ThermalImagingBrickletFunction::ReadUid => 249,
86 ThermalImagingBrickletFunction::GetIdentity => 255,
87 ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel => 12,
88 ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel => 13,
89 }
90 }
91}
92pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN: u8 = 0;
93pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN: u8 = 1;
94pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_NEVER_COMMANDED: u8 = 0;
95pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IMMINENT: u8 = 1;
96pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IN_PROGRESS: u8 = 2;
97pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_COMPLETE: u8 = 3;
98pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE: u8 = 0;
99pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_TEMPERATURE_IMAGE: u8 = 1;
100pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE: u8 = 2;
101pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_TEMPERATURE_IMAGE: u8 = 3;
102pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_MANUAL: u8 = 0;
103pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_AUTO: u8 = 1;
104pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_EXTERNAL: u8 = 2;
105pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_INACTIVE: u8 = 0;
106pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_HIGH: u8 = 1;
107pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_LOW: u8 = 2;
108pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
109pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
110pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
111pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
112pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
113pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
114pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
115pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
116pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
117pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
118pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
119pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
120pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
121pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
122pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
123
124#[derive(Clone, Copy)]
125pub struct HighContrastImageLowLevel {
126 pub image_chunk_offset: u16,
127 pub image_chunk_data: [u8; 62],
128}
129impl FromByteSlice for HighContrastImageLowLevel {
130 fn bytes_expected() -> usize {
131 64
132 }
133 fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevel {
134 HighContrastImageLowLevel {
135 image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
136 image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
137 }
138 }
139}
140impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevel {
141 fn ll_message_length(&self) -> usize {
142 4800
143 }
144
145 fn ll_message_chunk_offset(&self) -> usize {
146 self.image_chunk_offset as usize
147 }
148
149 fn ll_message_chunk_data(&self) -> &[u8] {
150 &self.image_chunk_data
151 }
152
153 fn get_result(&self) -> HighContrastImageResult {
154 HighContrastImageResult {}
155 }
156}
157
158#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
159pub struct TemperatureImageLowLevel {
160 pub image_chunk_offset: u16,
161 pub image_chunk_data: [u16; 31],
162}
163impl FromByteSlice for TemperatureImageLowLevel {
164 fn bytes_expected() -> usize {
165 64
166 }
167 fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevel {
168 TemperatureImageLowLevel {
169 image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
170 image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
171 }
172 }
173}
174impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevel {
175 fn ll_message_length(&self) -> usize {
176 4800
177 }
178
179 fn ll_message_chunk_offset(&self) -> usize {
180 self.image_chunk_offset as usize
181 }
182
183 fn ll_message_chunk_data(&self) -> &[u16] {
184 &self.image_chunk_data
185 }
186
187 fn get_result(&self) -> TemperatureImageResult {
188 TemperatureImageResult {}
189 }
190}
191
192#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
193pub struct Statistics {
194 pub spotmeter_statistics: [u16; 4],
195 pub temperatures: [u16; 4],
196 pub resolution: u8,
197 pub ffc_status: u8,
198 pub temperature_warning: [bool; 2],
199}
200impl FromByteSlice for Statistics {
201 fn bytes_expected() -> usize {
202 19
203 }
204 fn from_le_byte_slice(bytes: &[u8]) -> Statistics {
205 Statistics {
206 spotmeter_statistics: <[u16; 4]>::from_le_byte_slice(&bytes[0..8]),
207 temperatures: <[u16; 4]>::from_le_byte_slice(&bytes[8..16]),
208 resolution: <u8>::from_le_byte_slice(&bytes[16..17]),
209 ffc_status: <u8>::from_le_byte_slice(&bytes[17..18]),
210 temperature_warning: <[bool; 2]>::from_le_byte_slice(&bytes[18..19]),
211 }
212 }
213}
214
215#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
216pub struct HighContrastConfig {
217 pub region_of_interest: [u8; 4],
218 pub dampening_factor: u16,
219 pub clip_limit: [u16; 2],
220 pub empty_counts: u16,
221}
222impl FromByteSlice for HighContrastConfig {
223 fn bytes_expected() -> usize {
224 12
225 }
226 fn from_le_byte_slice(bytes: &[u8]) -> HighContrastConfig {
227 HighContrastConfig {
228 region_of_interest: <[u8; 4]>::from_le_byte_slice(&bytes[0..4]),
229 dampening_factor: <u16>::from_le_byte_slice(&bytes[4..6]),
230 clip_limit: <[u16; 2]>::from_le_byte_slice(&bytes[6..10]),
231 empty_counts: <u16>::from_le_byte_slice(&bytes[10..12]),
232 }
233 }
234}
235
236#[derive(Clone, Copy)]
237pub struct HighContrastImageLowLevelEvent {
238 pub image_chunk_offset: u16,
239 pub image_chunk_data: [u8; 62],
240}
241impl FromByteSlice for HighContrastImageLowLevelEvent {
242 fn bytes_expected() -> usize {
243 64
244 }
245 fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevelEvent {
246 HighContrastImageLowLevelEvent {
247 image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
248 image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
249 }
250 }
251}
252impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevelEvent {
253 fn ll_message_length(&self) -> usize {
254 4800
255 }
256
257 fn ll_message_chunk_offset(&self) -> usize {
258 self.image_chunk_offset as usize
259 }
260
261 fn ll_message_chunk_data(&self) -> &[u8] {
262 &self.image_chunk_data
263 }
264
265 fn get_result(&self) -> HighContrastImageResult {
266 HighContrastImageResult {}
267 }
268}
269
270#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
271pub struct TemperatureImageLowLevelEvent {
272 pub image_chunk_offset: u16,
273 pub image_chunk_data: [u16; 31],
274}
275impl FromByteSlice for TemperatureImageLowLevelEvent {
276 fn bytes_expected() -> usize {
277 64
278 }
279 fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevelEvent {
280 TemperatureImageLowLevelEvent {
281 image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
282 image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
283 }
284 }
285}
286impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevelEvent {
287 fn ll_message_length(&self) -> usize {
288 4800
289 }
290
291 fn ll_message_chunk_offset(&self) -> usize {
292 self.image_chunk_offset as usize
293 }
294
295 fn ll_message_chunk_data(&self) -> &[u16] {
296 &self.image_chunk_data
297 }
298
299 fn get_result(&self) -> TemperatureImageResult {
300 TemperatureImageResult {}
301 }
302}
303
304#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
305pub struct FluxLinearParameters {
306 pub scene_emissivity: u16,
307 pub temperature_background: u16,
308 pub tau_window: u16,
309 pub temperatur_window: u16,
310 pub tau_atmosphere: u16,
311 pub temperature_atmosphere: u16,
312 pub reflection_window: u16,
313 pub temperature_reflection: u16,
314}
315impl FromByteSlice for FluxLinearParameters {
316 fn bytes_expected() -> usize {
317 16
318 }
319 fn from_le_byte_slice(bytes: &[u8]) -> FluxLinearParameters {
320 FluxLinearParameters {
321 scene_emissivity: <u16>::from_le_byte_slice(&bytes[0..2]),
322 temperature_background: <u16>::from_le_byte_slice(&bytes[2..4]),
323 tau_window: <u16>::from_le_byte_slice(&bytes[4..6]),
324 temperatur_window: <u16>::from_le_byte_slice(&bytes[6..8]),
325 tau_atmosphere: <u16>::from_le_byte_slice(&bytes[8..10]),
326 temperature_atmosphere: <u16>::from_le_byte_slice(&bytes[10..12]),
327 reflection_window: <u16>::from_le_byte_slice(&bytes[12..14]),
328 temperature_reflection: <u16>::from_le_byte_slice(&bytes[14..16]),
329 }
330 }
331}
332
333#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
334pub struct FfcShutterMode {
335 pub shutter_mode: u8,
336 pub temp_lockout_state: u8,
337 pub video_freeze_during_ffc: bool,
338 pub ffc_desired: bool,
339 pub elapsed_time_since_last_ffc: u32,
340 pub desired_ffc_period: u32,
341 pub explicit_cmd_to_open: bool,
342 pub desired_ffc_temp_delta: u16,
343 pub imminent_delay: u16,
344}
345impl FromByteSlice for FfcShutterMode {
346 fn bytes_expected() -> usize {
347 17
348 }
349 fn from_le_byte_slice(bytes: &[u8]) -> FfcShutterMode {
350 FfcShutterMode {
351 shutter_mode: <u8>::from_le_byte_slice(&bytes[0..1]),
352 temp_lockout_state: <u8>::from_le_byte_slice(&bytes[1..2]),
353 video_freeze_during_ffc: <bool>::from_le_byte_slice(&bytes[2..3]),
354 ffc_desired: <bool>::from_le_byte_slice(&bytes[3..4]),
355 elapsed_time_since_last_ffc: <u32>::from_le_byte_slice(&bytes[4..8]),
356 desired_ffc_period: <u32>::from_le_byte_slice(&bytes[8..12]),
357 explicit_cmd_to_open: <bool>::from_le_byte_slice(&bytes[12..13]),
358 desired_ffc_temp_delta: <u16>::from_le_byte_slice(&bytes[13..15]),
359 imminent_delay: <u16>::from_le_byte_slice(&bytes[15..17]),
360 }
361 }
362}
363
364#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
365pub struct SpitfpErrorCount {
366 pub error_count_ack_checksum: u32,
367 pub error_count_message_checksum: u32,
368 pub error_count_frame: u32,
369 pub error_count_overflow: u32,
370}
371impl FromByteSlice for SpitfpErrorCount {
372 fn bytes_expected() -> usize {
373 16
374 }
375 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
376 SpitfpErrorCount {
377 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
378 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
379 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
380 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
381 }
382 }
383}
384
385#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
386pub struct Identity {
387 pub uid: String,
388 pub connected_uid: String,
389 pub position: char,
390 pub hardware_version: [u8; 3],
391 pub firmware_version: [u8; 3],
392 pub device_identifier: u16,
393}
394impl FromByteSlice for Identity {
395 fn bytes_expected() -> usize {
396 25
397 }
398 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
399 Identity {
400 uid: <String>::from_le_byte_slice(&bytes[0..8]),
401 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
402 position: <char>::from_le_byte_slice(&bytes[16..17]),
403 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
404 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
405 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
406 }
407 }
408}
409
410#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
411pub struct HighContrastImageResult {}
412
413#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
414pub struct TemperatureImageResult {}
415
416#[derive(Clone)]
418pub struct ThermalImagingBricklet {
419 device: Device,
420}
421impl ThermalImagingBricklet {
422 pub const DEVICE_IDENTIFIER: u16 = 278;
423 pub const DEVICE_DISPLAY_NAME: &'static str = "Thermal Imaging Bricklet";
424 pub fn new(uid: Uid, connection: AsyncIpConnection) -> ThermalImagingBricklet {
426 let mut result = ThermalImagingBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
427 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel) as usize] =
428 ResponseExpectedFlag::AlwaysTrue;
429 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel) as usize] =
430 ResponseExpectedFlag::AlwaysTrue;
431 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatistics) as usize] =
432 ResponseExpectedFlag::AlwaysTrue;
433 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetResolution) as usize] = ResponseExpectedFlag::False;
434 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetResolution) as usize] =
435 ResponseExpectedFlag::AlwaysTrue;
436 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig) as usize] =
437 ResponseExpectedFlag::False;
438 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig) as usize] =
439 ResponseExpectedFlag::AlwaysTrue;
440 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig) as usize] =
441 ResponseExpectedFlag::False;
442 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig) as usize] =
443 ResponseExpectedFlag::AlwaysTrue;
444 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig) as usize] =
445 ResponseExpectedFlag::True;
446 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig) as usize] =
447 ResponseExpectedFlag::AlwaysTrue;
448 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters) as usize] =
449 ResponseExpectedFlag::False;
450 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters) as usize] =
451 ResponseExpectedFlag::AlwaysTrue;
452 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode) as usize] = ResponseExpectedFlag::False;
453 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode) as usize] =
454 ResponseExpectedFlag::AlwaysTrue;
455 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::RunFfcNormalization) as usize] =
456 ResponseExpectedFlag::False;
457 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount) as usize] =
458 ResponseExpectedFlag::AlwaysTrue;
459 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetBootloaderMode) as usize] =
460 ResponseExpectedFlag::AlwaysTrue;
461 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetBootloaderMode) as usize] =
462 ResponseExpectedFlag::AlwaysTrue;
463 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer) as usize] =
464 ResponseExpectedFlag::False;
465 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteFirmware) as usize] =
466 ResponseExpectedFlag::AlwaysTrue;
467 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig) as usize] =
468 ResponseExpectedFlag::False;
469 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig) as usize] =
470 ResponseExpectedFlag::AlwaysTrue;
471 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetChipTemperature) as usize] =
472 ResponseExpectedFlag::AlwaysTrue;
473 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
474 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
475 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
476 result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
477 result
478 }
479
480 pub fn get_response_expected(&mut self, fun: ThermalImagingBrickletFunction) -> Result<bool, GetResponseExpectedError> {
495 self.device.get_response_expected(u8::from(fun))
496 }
497
498 pub fn set_response_expected(
507 &mut self,
508 fun: ThermalImagingBrickletFunction,
509 response_expected: bool,
510 ) -> Result<(), SetResponseExpectedError> {
511 self.device.set_response_expected(u8::from(fun), response_expected)
512 }
513
514 pub fn set_response_expected_all(&mut self, response_expected: bool) {
516 self.device.set_response_expected_all(response_expected)
517 }
518
519 pub fn get_api_version(&self) -> [u8; 3] {
522 self.device.api_version
523 }
524
525 pub async fn get_high_contrast_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = HighContrastImageLowLevelEvent> {
527 self.device
528 .get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel))
529 .await
530 .map(|p| HighContrastImageLowLevelEvent::from_le_byte_slice(p.body()))
531 }
532
533 pub async fn get_temperature_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = TemperatureImageLowLevelEvent> {
535 self.device
536 .get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel))
537 .await
538 .map(|p| TemperatureImageLowLevelEvent::from_le_byte_slice(p.body()))
539 }
540
541 pub async fn get_high_contrast_image_low_level(&mut self) -> Result<HighContrastImageLowLevel, TinkerforgeError> {
558 let payload = [0; 0];
559
560 #[allow(unused_variables)]
561 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel), &payload).await?;
562 Ok(HighContrastImageLowLevel::from_le_byte_slice(result.body()))
563 }
564
565 pub async fn get_temperature_image_low_level(&mut self) -> Result<TemperatureImageLowLevel, TinkerforgeError> {
579 let payload = [0; 0];
580
581 #[allow(unused_variables)]
582 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel), &payload).await?;
583 Ok(TemperatureImageLowLevel::from_le_byte_slice(result.body()))
584 }
585
586 pub async fn get_statistics(&mut self) -> Result<Statistics, TinkerforgeError> {
625 let payload = [0; 0];
626
627 #[allow(unused_variables)]
628 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatistics), &payload).await?;
629 Ok(Statistics::from_le_byte_slice(result.body()))
630 }
631
632 pub async fn set_resolution(&mut self, resolution: u8) -> Result<(), TinkerforgeError> {
644 let mut payload = [0; 1];
645 resolution.write_to_slice(&mut payload[0..1]);
646
647 #[allow(unused_variables)]
648 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetResolution), &payload).await?;
649 Ok(())
650 }
651
652 pub async fn get_resolution(&mut self) -> Result<u8, TinkerforgeError> {
658 let payload = [0; 0];
659
660 #[allow(unused_variables)]
661 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetResolution), &payload).await?;
662 Ok(u8::from_le_byte_slice(result.body()))
663 }
664
665 pub async fn set_spotmeter_config(&mut self, region_of_interest: &[u8; 4]) -> Result<(), TinkerforgeError> {
674 let mut payload = [0; 4];
675 region_of_interest.write_to_slice(&mut payload[0..4]);
676
677 #[allow(unused_variables)]
678 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig), &payload).await?;
679 Ok(())
680 }
681
682 pub async fn get_spotmeter_config(&mut self) -> Result<Box<[u8; 4]>, TinkerforgeError> {
684 let payload = [0; 0];
685
686 #[allow(unused_variables)]
687 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig), &payload).await?;
688 Ok(Box::<[u8; 4]>::from_le_byte_slice(result.body()))
689 }
690
691 pub async fn set_high_contrast_config(
730 &mut self,
731 region_of_interest: &[u8; 4],
732 dampening_factor: u16,
733 clip_limit: &[u16; 2],
734 empty_counts: u16,
735 ) -> Result<(), TinkerforgeError> {
736 let mut payload = [0; 12];
737 region_of_interest.write_to_slice(&mut payload[0..4]);
738 dampening_factor.write_to_slice(&mut payload[4..6]);
739 clip_limit.write_to_slice(&mut payload[6..10]);
740 empty_counts.write_to_slice(&mut payload[10..12]);
741
742 #[allow(unused_variables)]
743 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig), &payload).await?;
744 Ok(())
745 }
746
747 pub async fn get_high_contrast_config(&mut self) -> Result<HighContrastConfig, TinkerforgeError> {
749 let payload = [0; 0];
750
751 #[allow(unused_variables)]
752 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig), &payload).await?;
753 Ok(HighContrastConfig::from_le_byte_slice(result.body()))
754 }
755
756 pub async fn set_image_transfer_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
773 let mut payload = [0; 1];
774 config.write_to_slice(&mut payload[0..1]);
775
776 #[allow(unused_variables)]
777 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig), &payload).await?;
778 Ok(())
779 }
780
781 pub async fn get_image_transfer_config(&mut self) -> Result<u8, TinkerforgeError> {
789 let payload = [0; 0];
790
791 #[allow(unused_variables)]
792 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig), &payload).await?;
793 Ok(u8::from_le_byte_slice(result.body()))
794 }
795
796 pub async fn set_flux_linear_parameters(
803 &mut self,
804 scene_emissivity: u16,
805 temperature_background: u16,
806 tau_window: u16,
807 temperatur_window: u16,
808 tau_atmosphere: u16,
809 temperature_atmosphere: u16,
810 reflection_window: u16,
811 temperature_reflection: u16,
812 ) -> Result<(), TinkerforgeError> {
813 let mut payload = [0; 16];
814 scene_emissivity.write_to_slice(&mut payload[0..2]);
815 temperature_background.write_to_slice(&mut payload[2..4]);
816 tau_window.write_to_slice(&mut payload[4..6]);
817 temperatur_window.write_to_slice(&mut payload[6..8]);
818 tau_atmosphere.write_to_slice(&mut payload[8..10]);
819 temperature_atmosphere.write_to_slice(&mut payload[10..12]);
820 reflection_window.write_to_slice(&mut payload[12..14]);
821 temperature_reflection.write_to_slice(&mut payload[14..16]);
822
823 #[allow(unused_variables)]
824 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters), &payload).await?;
825 Ok(())
826 }
827
828 pub async fn get_flux_linear_parameters(&mut self) -> Result<FluxLinearParameters, TinkerforgeError> {
833 let payload = [0; 0];
834
835 #[allow(unused_variables)]
836 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters), &payload).await?;
837 Ok(FluxLinearParameters::from_le_byte_slice(result.body()))
838 }
839
840 pub async fn set_ffc_shutter_mode(
855 &mut self,
856 shutter_mode: u8,
857 temp_lockout_state: u8,
858 video_freeze_during_ffc: bool,
859 ffc_desired: bool,
860 elapsed_time_since_last_ffc: u32,
861 desired_ffc_period: u32,
862 explicit_cmd_to_open: bool,
863 desired_ffc_temp_delta: u16,
864 imminent_delay: u16,
865 ) -> Result<(), TinkerforgeError> {
866 let mut payload = [0; 17];
867 shutter_mode.write_to_slice(&mut payload[0..1]);
868 temp_lockout_state.write_to_slice(&mut payload[1..2]);
869 video_freeze_during_ffc.write_to_slice(&mut payload[2..3]);
870 ffc_desired.write_to_slice(&mut payload[3..4]);
871 elapsed_time_since_last_ffc.write_to_slice(&mut payload[4..8]);
872 desired_ffc_period.write_to_slice(&mut payload[8..12]);
873 explicit_cmd_to_open.write_to_slice(&mut payload[12..13]);
874 desired_ffc_temp_delta.write_to_slice(&mut payload[13..15]);
875 imminent_delay.write_to_slice(&mut payload[15..17]);
876
877 #[allow(unused_variables)]
878 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode), &payload).await?;
879 Ok(())
880 }
881
882 pub async fn get_ffc_shutter_mode(&mut self) -> Result<FfcShutterMode, TinkerforgeError> {
897 let payload = [0; 0];
898
899 #[allow(unused_variables)]
900 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode), &payload).await?;
901 Ok(FfcShutterMode::from_le_byte_slice(result.body()))
902 }
903
904 pub async fn run_ffc_normalization(&mut self) -> Result<(), TinkerforgeError> {
911 let payload = [0; 0];
912
913 #[allow(unused_variables)]
914 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::RunFfcNormalization), &payload).await?;
915 Ok(())
916 }
917
918 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
930 let payload = [0; 0];
931
932 #[allow(unused_variables)]
933 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount), &payload).await?;
934 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
935 }
936
937 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
960 let mut payload = [0; 1];
961 mode.write_to_slice(&mut payload[0..1]);
962
963 #[allow(unused_variables)]
964 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::SetBootloaderMode), &payload).await?;
965 Ok(u8::from_le_byte_slice(result.body()))
966 }
967
968 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
977 let payload = [0; 0];
978
979 #[allow(unused_variables)]
980 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetBootloaderMode), &payload).await?;
981 Ok(u8::from_le_byte_slice(result.body()))
982 }
983
984 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
991 let mut payload = [0; 4];
992 pointer.write_to_slice(&mut payload[0..4]);
993
994 #[allow(unused_variables)]
995 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
996 Ok(())
997 }
998
999 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
1008 let mut payload = [0; 64];
1009 data.write_to_slice(&mut payload[0..64]);
1010
1011 #[allow(unused_variables)]
1012 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::WriteFirmware), &payload).await?;
1013 Ok(u8::from_le_byte_slice(result.body()))
1014 }
1015
1016 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
1030 let mut payload = [0; 1];
1031 config.write_to_slice(&mut payload[0..1]);
1032
1033 #[allow(unused_variables)]
1034 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig), &payload).await?;
1035 Ok(())
1036 }
1037
1038 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
1046 let payload = [0; 0];
1047
1048 #[allow(unused_variables)]
1049 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig), &payload).await?;
1050 Ok(u8::from_le_byte_slice(result.body()))
1051 }
1052
1053 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
1060 let payload = [0; 0];
1061
1062 #[allow(unused_variables)]
1063 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetChipTemperature), &payload).await?;
1064 Ok(i16::from_le_byte_slice(result.body()))
1065 }
1066
1067 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
1074 let payload = [0; 0];
1075
1076 #[allow(unused_variables)]
1077 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::Reset), &payload).await?;
1078 Ok(())
1079 }
1080
1081 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
1087 let mut payload = [0; 4];
1088 uid.write_to_slice(&mut payload[0..4]);
1089
1090 #[allow(unused_variables)]
1091 let result = self.device.set(u8::from(ThermalImagingBrickletFunction::WriteUid), &payload).await?;
1092 Ok(())
1093 }
1094
1095 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
1098 let payload = [0; 0];
1099
1100 #[allow(unused_variables)]
1101 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::ReadUid), &payload).await?;
1102 Ok(u32::from_le_byte_slice(result.body()))
1103 }
1104
1105 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
1116 let payload = [0; 0];
1117
1118 #[allow(unused_variables)]
1119 let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetIdentity), &payload).await?;
1120 Ok(Identity::from_le_byte_slice(result.body()))
1121 }
1122}