dis_rs/common/sees/
model.rs

1use crate::common::{BodyInfo, Interaction};
2use crate::enumerations::PduType;
3use crate::model::{EntityId, PduBody};
4use crate::sees::builder::SeesBuilder;
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8const BASE_SEES_BODY_LENGTH: u16 = 16;
9const BASE_SYSTEM_DATA_LENGTH: u16 = 8;
10
11/// 5.7.7 Supplemental Emission/Entity State (SEES) PDU
12///
13/// 7.6.6 Supplemental Emission/Entity State (SEES) PDU
14#[derive(Clone, Debug, Default, PartialEq)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub struct SEES {
17    pub originating_entity_id: EntityId,
18    pub infrared_signature_representation_index: u16,
19    pub acoustic_signature_representation_index: u16,
20    pub radar_cross_section_representation_index: u16,
21    pub propulsion_systems: Vec<PropulsionSystemData>,
22    pub vectoring_nozzle_systems: Vec<VectoringNozzleSystemData>,
23}
24
25impl SEES {
26    #[must_use]
27    pub fn builder() -> SeesBuilder {
28        SeesBuilder::new()
29    }
30
31    #[must_use]
32    pub fn into_builder(self) -> SeesBuilder {
33        SeesBuilder::new_from_body(self)
34    }
35
36    #[must_use]
37    pub fn into_pdu_body(self) -> PduBody {
38        PduBody::SupplementalEmissionEntityState(self)
39    }
40}
41
42impl BodyInfo for SEES {
43    fn body_length(&self) -> u16 {
44        BASE_SEES_BODY_LENGTH
45            + (BASE_SYSTEM_DATA_LENGTH * self.propulsion_systems.len() as u16)
46            + (BASE_SYSTEM_DATA_LENGTH * self.vectoring_nozzle_systems.len() as u16)
47    }
48
49    fn body_type(&self) -> PduType {
50        PduType::SupplementalEmissionEntityState
51    }
52}
53
54impl Interaction for SEES {
55    fn originator(&self) -> Option<&EntityId> {
56        Some(&self.originating_entity_id)
57    }
58
59    fn receiver(&self) -> Option<&EntityId> {
60        None
61    }
62}
63
64/// 6.2.68 Propulsion System Data record
65#[derive(Clone, Debug, Default, PartialEq)]
66#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
67pub struct PropulsionSystemData {
68    pub power_setting: f32,
69    pub engine_rpm: f32,
70}
71
72impl PropulsionSystemData {
73    #[must_use]
74    pub fn with_power_setting(mut self, power_setting: f32) -> Self {
75        self.power_setting = power_setting;
76        self
77    }
78
79    #[must_use]
80    pub fn with_engine_rpm(mut self, engine_rpm: f32) -> Self {
81        self.engine_rpm = engine_rpm;
82        self
83    }
84}
85
86/// 6.2.97 Vectoring Nozzle System Data record
87#[derive(Clone, Debug, Default, PartialEq)]
88#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
89pub struct VectoringNozzleSystemData {
90    pub horizontal_deflection_angle: f32,
91    pub vertical_deflection_angle: f32,
92}
93
94impl VectoringNozzleSystemData {
95    #[must_use]
96    pub fn with_horizontal_deflection_angle(mut self, horizontal_deflection_angle: f32) -> Self {
97        self.horizontal_deflection_angle = horizontal_deflection_angle;
98        self
99    }
100
101    #[must_use]
102    pub fn with_vertical_deflection_angle(mut self, vertical_deflection_angle: f32) -> Self {
103        self.vertical_deflection_angle = vertical_deflection_angle;
104        self
105    }
106}