Skip to content

Commit bfe0234

Browse files
authored
Clock profile (#107)
* impl std::fmt::Display * rename h-maser Signed-off-by: Guillaume W. Bres <guillaume.bressaix@gmail.com>
1 parent d244eea commit bfe0234

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/user.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ impl std::fmt::Display for UserProfile {
9090
}
9191
}
9292

93-
#[allow(non_camel_case_types)]
9493
#[derive(Default, Debug, Clone, Copy, PartialEq)]
9594
pub enum ClockProfile {
9695
/// [ClockProfile::Quartz] low quality clock,
@@ -106,9 +105,9 @@ pub enum ClockProfile {
106105
/// at the same level of a GNSS constellation.
107106
Atomic,
108107

109-
/// [ClockProfile::H_MASER] (Hydrogen Maser) ultra high quality clock,
108+
/// [ClockProfile::HydrogenMaser] ultra high quality clock,
110109
/// better than a GNSS constellation.
111-
H_MASER,
110+
HydrogenMaser,
112111
}
113112

114113
impl std::str::FromStr for ClockProfile {
@@ -118,22 +117,33 @@ impl std::str::FromStr for ClockProfile {
118117
let trimmed = s.trim();
119118
match trimmed {
120119
"quartz" => Ok(Self::Quartz),
121-
"maser" | "h-maser" => Ok(Self::H_MASER),
120+
"maser" | "h-maser" => Ok(Self::HydrogenMaser),
122121
"oscillator" | "ocxo" => Ok(Self::Oscillator),
123122
"atomic" | "rb" | "rubidium" => Ok(Self::Atomic),
124123
_ => Err(Error::InvalidClockProfile),
125124
}
126125
}
127126
}
128127

128+
impl std::fmt::Display for ClockProfile {
129+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
130+
match self {
131+
Self::Quartz => write!(f, "quartz"),
132+
Self::Oscillator => write!(f, "oscillator"),
133+
Self::Atomic => write!(f, "atomic"),
134+
Self::HydrogenMaser => write!(f, "hydrogen maser"),
135+
}
136+
}
137+
}
138+
129139
impl ClockProfile {
130140
/// Returns bias PSD for this [ClockProfile].
131141
pub(crate) const fn bias_psd(&self) -> f64 {
132142
match self {
133143
Self::Quartz => 0.5 * 2.0E-19,
134144
Self::Oscillator => 0.5 * 2.0E-20,
135145
Self::Atomic => 0.5 * 2.0E-21,
136-
Self::H_MASER => 0.5 * 2.0E-22,
146+
Self::HydrogenMaser => 0.5 * 2.0E-22,
137147
}
138148
}
139149

@@ -143,7 +153,7 @@ impl ClockProfile {
143153
Self::Quartz => 2.0 * PI * PI * 2.0E-20,
144154
Self::Oscillator => 2.0 * PI * PI * 2.0E-23,
145155
Self::Atomic => 2.0 * PI * PI * 2.0E-24,
146-
Self::H_MASER => 2.0 * PI * PI * 2.0E-25,
156+
Self::HydrogenMaser => 2.0 * PI * PI * 2.0E-25,
147157
}
148158
}
149159
}

0 commit comments

Comments
 (0)