-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from Northeastern-Electric-Racing/223-metadat…
…a-injector 223 metadata injector
- Loading branch information
Showing
12 changed files
with
389 additions
and
114 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use ::serde::Serialize; | ||
use chrono::{serde::ts_milliseconds, DateTime, TimeDelta, Utc}; | ||
|
||
pub const DATA_SOCKET_KEY: &str = "data"; | ||
|
||
#[derive(Serialize)] | ||
pub struct TimerData { | ||
/// the topic being timed | ||
pub topic: &'static str, | ||
/// the last time the value changed | ||
#[serde(with = "ts_milliseconds")] | ||
pub last_change: DateTime<Utc>, | ||
/// the value at the above time | ||
pub last_value: f32, | ||
} | ||
pub const TIMER_SOCKET_KEY: &str = "timers"; | ||
pub const TIMERS_TOPICS: &[&str] = &[ | ||
"BMS/Status/Balancing", | ||
"BMS/Status/State", | ||
"BMS/Charging/Control", | ||
]; | ||
|
||
#[derive(Serialize, PartialEq, Clone, Debug)] | ||
pub enum Node { | ||
Bms, | ||
Dti, | ||
Mpu, | ||
Charger, | ||
} | ||
|
||
#[derive(Serialize, Clone)] | ||
pub struct FaultData { | ||
/// the node the fault came from | ||
pub node: Node, | ||
/// the word describing the fault | ||
pub name: String, | ||
/// when the fault occured | ||
#[serde(with = "ts_milliseconds")] | ||
pub occured_at: DateTime<Utc>, | ||
/// when the fault was last seen | ||
#[serde(with = "ts_milliseconds")] | ||
pub last_seen: DateTime<Utc>, | ||
/// whether another fault of the same node and name as occured after this fault | ||
pub expired: bool, | ||
} | ||
pub const FAULT_SOCKET_KEY: &str = "faults"; | ||
pub const FAULT_MIN_REG_GAP: TimeDelta = TimeDelta::seconds(8); | ||
|
||
pub const FAULT_BINS: &[&str] = &["DTI/Fault/FaultCode"]; | ||
pub const fn map_dti_flt(index: usize) -> Option<&'static str> { | ||
match index { | ||
0 => None, | ||
1 => Some("Overvoltage"), | ||
2 => None, | ||
3 => Some("DRV"), | ||
4 => Some("ABS_Overcurrent"), | ||
5 => Some("CTLR_Overtemp"), | ||
6 => Some("Motor_Overtemp"), | ||
7 => Some("Sensor_wire"), | ||
8 => Some("Sensor_general"), | ||
9 => Some("CAN_command"), | ||
0x0A => Some("Analog_input"), | ||
_ => None, | ||
} | ||
} |
Oops, something went wrong.