nyx_space/od/ground_station/
doppler_config.rs1use crate::od::msr::IntegrationRef;
20use der::{Decode, Encode, Reader};
21use hifitime::{Duration, Unit};
22use serde::{Deserialize, Serialize};
23
24#[cfg(feature = "python")]
25use pyo3::prelude::*;
26
27#[cfg_attr(feature = "python", pyclass(from_py_object, get_all, set_all))]
28#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
29pub struct DopplerConfig {
30 pub integration_time: Duration,
32 #[serde(default)]
33 pub integration_ref: IntegrationRef,
35}
36
37impl Default for DopplerConfig {
38 fn default() -> Self {
39 Self {
40 integration_time: 1 * Unit::Second,
41 integration_ref: IntegrationRef::End,
42 }
43 }
44}
45
46impl<'a> Decode<'a> for DopplerConfig {
47 fn decode<R: Reader<'a>>(decoder: &mut R) -> der::Result<Self> {
48 let integration_time_ns = decoder.decode()?;
49 let integration_time = Duration::from_total_nanoseconds(integration_time_ns);
50 let integration_ref = decoder.decode()?;
51
52 Ok(DopplerConfig {
53 integration_time,
54 integration_ref,
55 })
56 }
57}
58
59impl Encode for DopplerConfig {
60 fn encoded_len(&self) -> der::Result<der::Length> {
61 self.integration_time.total_nanoseconds().encoded_len()?
62 + self.integration_ref.encoded_len()?
63 }
64
65 fn encode(&self, encoder: &mut impl der::Writer) -> der::Result<()> {
66 let integration_time_ns = self.integration_time.total_nanoseconds();
67 integration_time_ns.encode(encoder)?;
68 self.integration_ref.encode(encoder)?;
69
70 Ok(())
71 }
72}
73
74#[cfg_attr(feature = "python", pymethods)]
75impl DopplerConfig {
76 fn __str__(&self) -> String {
77 format!("{self:?}")
78 }
79
80 fn __repr__(&self) -> String {
81 format!("{self:?} @ {self:p}")
82 }
83
84 fn __eq__(&self, other: &Self) -> bool {
85 self == other
86 }
87}