pub const MENU_ALARM_SEVR: &[&str] = &["NO_ALARM", "MINOR", "MAJOR", "INVALID"];
pub const MENU_SIMM: &[&str] = &["NO", "YES", "RAW"];
pub const MENU_SCAN: &[&str] = &[
"Passive",
"Event",
"I/O Intr",
"10 second",
"5 second",
"2 second",
"1 second",
".5 second",
".2 second",
".1 second",
];
pub const MENU_OMSL: &[&str] = &["supervisory", "closed_loop"];
pub const MENU_IVOA: &[&str] = &[
"Continue normally",
"Don't drive outputs",
"Set output to IVOV",
];
pub const MENU_CONVERT: &[&str] = &[
"NO CONVERSION",
"SLOPE",
"LINEAR",
"typeKdegF",
"typeKdegC",
"typeJdegF",
"typeJdegC",
"typeEdegF(ixe only)",
"typeEdegC(ixe only)",
"typeTdegF",
"typeTdegC",
"typeRdegF",
"typeRdegC",
"typeSdegF",
"typeSdegC",
];
pub const MENU_YES_NO: &[&str] = &["NO", "YES"];
pub const MENU_POST: &[&str] = &["On Change", "Always"];
pub const MENU_PRIORITY: &[&str] = &["LOW", "MEDIUM", "HIGH"];
pub const MENU_FTYPE: &[&str] = &[
"STRING", "CHAR", "UCHAR", "SHORT", "USHORT", "LONG", "ULONG", "INT64", "UINT64", "FLOAT",
"DOUBLE", "ENUM",
];
pub fn shared_menu_choices(field: &str) -> Option<&'static [&'static str]> {
match field {
"HHSV" | "HSV" | "LSV" | "LLSV" | "ZSV" | "OSV" | "COSV" | "UNSV" | "BRSV" | "ZRSV"
| "ONSV" | "TWSV" | "THSV" | "FRSV" | "FVSV" | "SXSV" | "SVSV" | "EISV" | "NISV"
| "TESV" | "ELSV" | "TVSV" | "TTSV" | "FTSV" | "FFSV" | "SIMS" => Some(MENU_ALARM_SEVR),
"OLDSIMM" => Some(MENU_SIMM),
"SSCN" => Some(MENU_SCAN),
"OMSL" => Some(MENU_OMSL),
"IVOA" => Some(MENU_IVOA),
"LINR" => Some(MENU_CONVERT),
"PBUF" => Some(MENU_YES_NO),
"FTVL" => Some(MENU_FTYPE),
"PRIO" => Some(MENU_PRIORITY),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn alarm_severity_order_matches_dbd() {
assert_eq!(MENU_ALARM_SEVR[0], "NO_ALARM");
assert_eq!(MENU_ALARM_SEVR[2], "MAJOR");
assert_eq!(shared_menu_choices("HHSV"), Some(MENU_ALARM_SEVR));
assert_eq!(shared_menu_choices("COSV"), Some(MENU_ALARM_SEVR));
assert_eq!(shared_menu_choices("SIMS"), Some(MENU_ALARM_SEVR));
}
#[test]
fn simm_includes_raw_third_choice() {
assert_eq!(MENU_SIMM, &["NO", "YES", "RAW"]);
assert_eq!(shared_menu_choices("OLDSIMM"), Some(MENU_SIMM));
assert_eq!(shared_menu_choices("SIMM"), None);
}
#[test]
fn shared_names_map_to_their_menu() {
assert_eq!(shared_menu_choices("OMSL"), Some(MENU_OMSL));
assert_eq!(shared_menu_choices("IVOA"), Some(MENU_IVOA));
assert_eq!(shared_menu_choices("LINR"), Some(MENU_CONVERT));
assert_eq!(shared_menu_choices("SSCN"), Some(MENU_SCAN));
assert_eq!(shared_menu_choices("FTVL"), Some(MENU_FTYPE));
assert_eq!(shared_menu_choices("PRIO"), Some(MENU_PRIORITY));
assert_eq!(shared_menu_choices("PBUF"), Some(MENU_YES_NO));
}
#[test]
fn record_varying_menu_names_are_not_shared() {
assert_eq!(shared_menu_choices("SIMM"), None);
assert_eq!(shared_menu_choices("MPST"), None);
assert_eq!(shared_menu_choices("APST"), None);
}
#[test]
fn non_menu_name_is_none() {
assert_eq!(shared_menu_choices("VAL"), None);
assert_eq!(shared_menu_choices("DESC"), None);
assert_eq!(shared_menu_choices("OSV"), Some(MENU_ALARM_SEVR));
}
}