2023-01-24 13:13:39 +01:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
2023-01-25 16:08:13 +01:00
|
|
|
use std::fs;
|
2023-01-24 13:13:39 +01:00
|
|
|
|
2023-01-31 19:23:00 +01:00
|
|
|
#[derive(Deserialize, Debug, Default)]
|
2023-01-24 13:13:39 +01:00
|
|
|
pub struct Shot {
|
|
|
|
pub filename: Option<String>,
|
|
|
|
pub json: Option<String>,
|
|
|
|
pub title: String,
|
|
|
|
pub cutoff: Option<f64>,
|
|
|
|
pub disable: Option<bool>,
|
|
|
|
}
|
|
|
|
|
2023-01-31 19:23:00 +01:00
|
|
|
#[derive(Deserialize, Debug, Default)]
|
2023-01-24 13:13:39 +01:00
|
|
|
pub struct Chart {
|
|
|
|
pub title: String,
|
|
|
|
pub shots: Vec<u64>,
|
|
|
|
|
|
|
|
pub max_time: u64,
|
|
|
|
pub max_weight: u64,
|
|
|
|
pub max_flow: u64,
|
|
|
|
}
|
|
|
|
|
2023-01-31 19:23:00 +01:00
|
|
|
#[derive(Deserialize, Debug, Default)]
|
2023-01-24 13:13:39 +01:00
|
|
|
pub struct Config {
|
|
|
|
pub shots: HashMap<String, Shot>,
|
|
|
|
pub charts: HashMap<String, Chart>,
|
|
|
|
|
|
|
|
pub shot_dir: String,
|
|
|
|
pub brew_dir: String,
|
2023-01-24 17:26:55 +01:00
|
|
|
pub data_dir: String,
|
2023-01-24 13:13:39 +01:00
|
|
|
pub output_dir: String,
|
|
|
|
pub main_json: String,
|
|
|
|
|
|
|
|
pub width: u32,
|
|
|
|
pub height: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const WGHT_SHEET: usize = 0;
|
|
|
|
pub const FLOW_SHEET: usize = 1;
|
|
|
|
|
|
|
|
pub const TIME_COL: usize = 0;
|
|
|
|
pub const WGHT_COL: usize = 5;
|
|
|
|
pub const FLOW_COL: usize = 2;
|
|
|
|
|
|
|
|
pub struct Data {
|
|
|
|
pub weight: Vec<(f64, f64)>,
|
|
|
|
pub flowrate: Vec<(f64, f64)>,
|
|
|
|
}
|
2023-01-25 16:08:13 +01:00
|
|
|
|
|
|
|
impl Config {
|
|
|
|
pub fn from_file(path: &str) -> Self {
|
|
|
|
let config_file = fs::read_to_string(&path).expect("Can't read config.toml");
|
|
|
|
toml::from_str(&config_file).expect("Can't deserialize config.toml")
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_default() -> Self {
|
|
|
|
Self::from_file("config.toml")
|
|
|
|
}
|
|
|
|
}
|