pub const SAMPLE_A2L: &str = include_str!("../data/powertrain.a2l");
pub const SAMPLE_DBC: &str = include_str!("../data/powertrain.dbc");
#[must_use]
pub fn tables() -> Vec<(&'static str, Vec<(f64, f64)>)> {
vec![
(
"boost_curve_tab",
vec![
(0.0, 0.0),
(1000.0, 45.0),
(2000.0, 78.0),
(3000.0, 105.0),
(4000.0, 128.0),
(5000.0, 142.0),
(6000.0, 150.0),
],
),
(
"gear_vtab",
vec![(0.0, 0.0), (1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0)],
),
(
"gear_pos_tab",
vec![(0.0, 0.0), (10.0, 1.0), (25.0, 2.0), (45.0, 3.0)],
),
(
"ratio_vtab",
vec![(1.0, 0.0), (2.0, 1.0), (3.0, 2.0), (4.0, 3.0)],
),
]
}
#[must_use]
pub fn seed_memory() -> Vec<(u32, Vec<u8>)> {
vec![
(0x72_01_00, vec![0x00, 0x90, 0x01]),
(0x72_01_04, vec![0x00, 0xC8, 0x00]),
(0x72_01_08, vec![0x00, 0x80, 0x0C]),
(0x72_01_0C, vec![0x00, 0x00, 0x00]),
(0x72_01_10, vec![0x00, 0x01]),
(0x70_01_00, vec![0x00, 0x41]),
(
0x72_10_00,
vec![
0x00, 0xE8, 0x03, 0xE8, 0x03, 0xE8, 0x03, 0xE8, 0x03, 0xE8, 0x03, 0xE8, 0x03, 0xE8,
0x03, 0xE8, 0x03,
],
),
(
0x72_20_00,
vec![0x00, 0x2C, 0x01, 0x2C, 0x01, 0x2C, 0x01, 0x2C, 0x01],
),
(0x72_30_00, vec![0x00, 0xD0, 0x07, 0xD0, 0x07, 0xD0, 0x07]),
(0x32_00_01, vec![0x00, 0x04]), (0x32_01_00, vec![0x64]), (0x32_02_00, vec![0xC8, 0x00]), (0x73_01_00, vec![0x00, 0xA8, 0x61]),
(0x73_01_04, vec![0x00, 0x20, 0x03]),
(0x73_01_08, vec![0x00, 0x78, 0x00]),
(0x73_01_0C, vec![0x00, 0xF4, 0x01]),
(0x73_01_10, vec![0x00, 0x02]),
(
0x73_20_00,
vec![0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0xA0, 0x00],
),
(0x33_00_01, vec![0x10, 0x27]), (0x33_01_00, vec![0x64, 0x00]), ]
}
#[must_use]
pub fn element_counts() -> Vec<(&'static str, &'static str, usize)> {
vec![
("engine", "boost_curve", 8),
("engine", "inj_map", 4),
("engine", "knock_table", 3),
("transmission", "shift_map", 4),
]
}
pub fn complete(project: &mut crate::CalibrationProject) -> Result<(), crate::CalError> {
for (name, points) in tables() {
project.register_table(name, points)?;
}
for (module, name, elements) in element_counts() {
project.declare_elements(module, name, elements)?;
}
Ok(())
}
pub fn sample_project() -> Result<crate::CalibrationProject, crate::CalError> {
let mut project = crate::CalibrationProject::from_a2l(SAMPLE_A2L)?;
complete(&mut project)?;
project.attach_dbc(dbc_parse::Dbc::parse(SAMPLE_DBC)?)?;
Ok(project)
}