use crate::common::{BodyInfo, Interaction};
use crate::enumerations::PduType;
use crate::model::{EntityId, PduBody};
use crate::sees::builder::SeesBuilder;
use crate::BodyRaw;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
const BASE_SEES_BODY_LENGTH: u16 = 16;
const BASE_SYSTEM_DATA_LENGTH: u16 = 8;
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct SEES {
pub originating_entity_id: EntityId,
pub infrared_signature_representation_index: u16,
pub acoustic_signature_representation_index: u16,
pub radar_cross_section_representation_index: u16,
pub propulsion_systems: Vec<PropulsionSystemData>,
pub vectoring_nozzle_systems: Vec<VectoringNozzleSystemData>,
}
impl BodyRaw for SEES {
type Builder = SeesBuilder;
fn builder() -> Self::Builder {
Self::Builder::new()
}
fn into_builder(self) -> Self::Builder {
Self::Builder::new_from_body(self)
}
fn into_pdu_body(self) -> PduBody {
PduBody::SupplementalEmissionEntityState(self)
}
}
impl BodyInfo for SEES {
fn body_length(&self) -> u16 {
BASE_SEES_BODY_LENGTH
+ (BASE_SYSTEM_DATA_LENGTH * self.propulsion_systems.len() as u16)
+ (BASE_SYSTEM_DATA_LENGTH * self.vectoring_nozzle_systems.len() as u16)
}
fn body_type(&self) -> PduType {
PduType::SupplementalEmissionEntityState
}
}
impl Interaction for SEES {
fn originator(&self) -> Option<&EntityId> {
Some(&self.originating_entity_id)
}
fn receiver(&self) -> Option<&EntityId> {
None
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PropulsionSystemData {
pub power_setting: f32,
pub engine_rpm: f32,
}
impl PropulsionSystemData {
#[must_use]
pub fn with_power_setting(mut self, power_setting: f32) -> Self {
self.power_setting = power_setting;
self
}
#[must_use]
pub fn with_engine_rpm(mut self, engine_rpm: f32) -> Self {
self.engine_rpm = engine_rpm;
self
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct VectoringNozzleSystemData {
pub horizontal_deflection_angle: f32,
pub vertical_deflection_angle: f32,
}
impl VectoringNozzleSystemData {
#[must_use]
pub fn with_horizontal_deflection_angle(mut self, horizontal_deflection_angle: f32) -> Self {
self.horizontal_deflection_angle = horizontal_deflection_angle;
self
}
#[must_use]
pub fn with_vertical_deflection_angle(mut self, vertical_deflection_angle: f32) -> Self {
self.vertical_deflection_angle = vertical_deflection_angle;
self
}
}