Skip to content

Commit c88280f

Browse files
committed
add alert classes
1 parent 8ea8e50 commit c88280f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

nexus/db-model/src/alert_class.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ impl_enum_type!(
3030
TestFooBaz => b"test.foo.baz"
3131
TestQuuxBar => b"test.quux.bar"
3232
TestQuuxBarBaz => b"test.quux.bar.baz"
33+
PsuInserted => b"hw.insert.power.power_shelf.psu"
34+
PsuRemoved => b"hw.remove.power.power_shelf.psu"
3335
);
3436

3537
impl AlertClass {
@@ -44,6 +46,8 @@ impl AlertClass {
4446
Self::TestFooBaz => "test.foo.baz",
4547
Self::TestQuuxBar => "test.quux.bar",
4648
Self::TestQuuxBarBaz => "test.quux.bar.baz",
49+
Self::PsuInserted => "hw.insert.power.power_shelf.psu",
50+
Self::PsuRemoved => "hw.remove.power.power_shelf.psu",
4751
}
4852
}
4953

@@ -76,6 +80,12 @@ impl AlertClass {
7680
| Self::TestQuuxBarBaz => {
7781
"This is a test of the emergency alert system"
7882
}
83+
Self::PsuInserted => {
84+
"A power supply unit (PSU) has been inserted into the power shelf"
85+
}
86+
Self::PsuRemoved => {
87+
"A power supply unit (PSU) has been removed from the power shelf"
88+
}
7989
}
8090
}
8191

@@ -84,6 +94,16 @@ impl AlertClass {
8494
<Self as strum::VariantArray>::VARIANTS;
8595
}
8696

97+
impl From<nexus_types::fm::AlertClass> for AlertClass {
98+
fn from(input: nexus_types::fm::AlertClass) -> Self {
99+
use nexus_types::fm::AlertClass as In;
100+
match input {
101+
In::PsuRemoved => Self::PsuRemoved,
102+
In::PsuInserted => Self::PsuInserted,
103+
}
104+
}
105+
}
106+
87107
impl fmt::Display for AlertClass {
88108
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89109
write!(f, "{}", self.as_str())

nexus/types/src/fm/alert.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ impl iddqd::IdOrdItem for AlertRequest {
2525

2626
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
2727
pub enum AlertClass {
28-
// TODO
28+
PsuInserted,
29+
PsuRemoved,
2930
}

0 commit comments

Comments
 (0)