use super::std_msgs::Header;
crate::ros_message! {
pub struct KeyValue("diagnostic_msgs/msg/KeyValue") {
pub key: String,
pub value: String,
}
}
crate::ros_message! {
pub struct DiagnosticStatus("diagnostic_msgs/msg/DiagnosticStatus") {
pub level: u8 [BYTE],
pub name: String,
pub message: String,
pub hardware_id: String,
pub values: Vec<KeyValue>,
}
}
crate::ros_message! {
pub struct DiagnosticArray("diagnostic_msgs/msg/DiagnosticArray") {
pub header: Header,
pub status: Vec<DiagnosticStatus>,
}
}
impl KeyValue {
pub fn new(key: &str, value: impl std::fmt::Display) -> Self {
Self {
key: key.to_owned(),
value: value.to_string(),
}
}
}
impl DiagnosticStatus {
pub const OK: u8 = 0;
pub const WARN: u8 = 1;
pub const ERROR: u8 = 2;
pub const STALE: u8 = 3;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::ros::Message;
#[test]
fn hashes_match_jazzy() {
assert_eq!(
KeyValue::type_hash(),
"RIHS01_d68081eaa540288c5440753baecef0c4e16e81a5f78ad68902ded5100413bb42"
);
assert_eq!(
DiagnosticStatus::type_hash(),
"RIHS01_b0e3e692ea2d54a8af2f4ef1930e81556a2db55216b771f8a7d2724ed47bf0e4"
);
assert_eq!(
DiagnosticArray::type_hash(),
"RIHS01_5a8a36efb05fb25070fa0fb3810290c0e6cd4862b54a8fb975a1ee8dc55a333e"
);
}
}