use chrono::offset::Utc;
use chrono::DateTime;
use indexmap::IndexMap;
use samplic;
use uuid::Uuid;

pub mod interface;

#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct SamplingSettings {
    pub taring: Option<TaringSettings>,
    pub interface: interface::WidgetDescription,
}

#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum TaringMode {
    Disabled,
    BeforeFirstMeasurement,
    BeforeEveryMeasurement,
}

#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct TaringSettings {
    pub mode: TaringMode,
    pub timeout: Option<u32>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Calibration {
    pub points: Vec<CalibrationPoint>,
    pub timestamp: DateTime<Utc>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct CalibrationPoint {
    pub coordinates: (f64, f64),
    pub results: IndexMap<String, f64>,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct SampleCachedInformation {
    pub identifier: String,
    pub uuid: Uuid,
    pub measurement_count: usize,
    pub moment: DateTime<Utc>,
    pub source: samplic::Source,
}
