Skip to main content

nominal_api/conjure/objects/scout/compute/api/
frequency_bucket.rs

1/// A single bucket in a bucketed frequency domain plot.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct FrequencyBucket {
14    #[serde(rename = "frequencyStart")]
15    #[derive_with(with = conjure_object::private::DoubleWrapper)]
16    frequency_start: f64,
17    #[serde(rename = "frequencyEnd")]
18    #[derive_with(with = conjure_object::private::DoubleWrapper)]
19    frequency_end: f64,
20    #[serde(rename = "frequencyCenter")]
21    #[derive_with(with = conjure_object::private::DoubleWrapper)]
22    frequency_center: f64,
23    #[serde(rename = "minAmplitude")]
24    #[derive_with(with = conjure_object::private::DoubleWrapper)]
25    min_amplitude: f64,
26    #[serde(rename = "maxAmplitude")]
27    #[derive_with(with = conjure_object::private::DoubleWrapper)]
28    max_amplitude: f64,
29    #[serde(rename = "meanAmplitude")]
30    #[derive_with(with = conjure_object::private::DoubleWrapper)]
31    mean_amplitude: f64,
32    #[serde(rename = "count")]
33    count: conjure_object::SafeLong,
34    #[builder(custom(type = super::FrequencyPoint, convert = Box::new))]
35    #[serde(rename = "firstPoint")]
36    first_point: Box<super::FrequencyPoint>,
37    #[builder(
38        default,
39        custom(
40            type = impl
41            Into<Option<super::FrequencyPoint>>,
42            convert = |v|v.into().map(Box::new)
43        )
44    )]
45    #[serde(rename = "lastPoint", skip_serializing_if = "Option::is_none", default)]
46    last_point: Option<Box<super::FrequencyPoint>>,
47}
48impl FrequencyBucket {
49    /// The start frequency of this bucket (inclusive).
50    #[inline]
51    pub fn frequency_start(&self) -> f64 {
52        self.frequency_start
53    }
54    /// The end frequency of this bucket (exclusive).
55    #[inline]
56    pub fn frequency_end(&self) -> f64 {
57        self.frequency_end
58    }
59    /// The center frequency of this bucket.
60    #[inline]
61    pub fn frequency_center(&self) -> f64 {
62        self.frequency_center
63    }
64    /// The minimum amplitude value in this bucket.
65    #[inline]
66    pub fn min_amplitude(&self) -> f64 {
67        self.min_amplitude
68    }
69    /// The maximum amplitude value in this bucket.
70    #[inline]
71    pub fn max_amplitude(&self) -> f64 {
72        self.max_amplitude
73    }
74    /// The mean amplitude value in this bucket.
75    #[inline]
76    pub fn mean_amplitude(&self) -> f64 {
77        self.mean_amplitude
78    }
79    /// The number of original frequency points that were aggregated into this bucket.
80    #[inline]
81    pub fn count(&self) -> conjure_object::SafeLong {
82        self.count
83    }
84    /// The first point (lowest frequency) in this bucket.
85    #[inline]
86    pub fn first_point(&self) -> &super::FrequencyPoint {
87        &*self.first_point
88    }
89    /// The last point (highest frequency) in this bucket. Will be empty if the bucket only has a single point.
90    #[inline]
91    pub fn last_point(&self) -> Option<&super::FrequencyPoint> {
92        self.last_point.as_ref().map(|o| &**o)
93    }
94}