use serde::{Deserialize, Serialize};
use std::fmt;
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum TpsMetric {
metric_mura,
metric_andon,
metric_lead_time,
metric_takt_time,
metric_value_stream,
}
impl TpsMetric {
pub fn id(&self) -> &'static str {
match self {
Self::metric_mura => "metric-mura",
Self::metric_andon => "metric-andon",
Self::metric_lead_time => "metric-lead-time",
Self::metric_takt_time => "metric-takt-time",
Self::metric_value_stream => "metric-value-stream",
}
}
pub fn label(&self) -> &'static str {
match self {
Self::metric_mura => "Mura (Unevenness)",
Self::metric_andon => "Andon",
Self::metric_lead_time => "Lead Time",
Self::metric_takt_time => "Takt Time",
Self::metric_value_stream => "Value Stream",
}
}
pub fn tps_principle(&self) -> &'static str {
match self {
Self::metric_mura => "Heijunka",
Self::metric_andon => "Jidoka",
Self::metric_lead_time => "Just-In-Time",
Self::metric_takt_time => "Just-In-Time",
Self::metric_value_stream => "Muda Elimination",
}
}
pub fn target_threshold(&self) -> f64 {
match self {
Self::metric_mura => 0.1,
Self::metric_andon => 0.95,
Self::metric_lead_time => 30.0,
Self::metric_takt_time => 5.0,
Self::metric_value_stream => 0.8,
}
}
pub fn module(&self) -> &'static str {
match self {
Self::metric_mura => "mura",
Self::metric_andon => "andon",
Self::metric_lead_time => "lead_time",
Self::metric_takt_time => "takt_time",
Self::metric_value_stream => "value_stream",
}
}
pub fn all() -> &'static [Self] {
&[
Self::metric_mura,
Self::metric_andon,
Self::metric_lead_time,
Self::metric_takt_time,
Self::metric_value_stream,
]
}
}
impl fmt::Display for TpsMetric {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.label())
}
}