#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChangerError {
#[error("hopper is empty - requires refill")]
HopperEmpty = 1,
#[error("hopper jam - remove hopper shelf and clear jam")]
HopperJam = 2,
#[error("hopper fraud detected - alert security")]
HopperFraud = 3,
#[error("hopper fault - service callout required")]
HopperFault = 4,
#[error("coin acceptor jam - remove coin acceptor and clear jam")]
CoinAcceptorJam = 101,
#[error("coin acceptor fraud attempt - alert security")]
CoinAcceptorFraudAttempt = 102,
#[error("coin acceptor fault - service callout required")]
CoinAcceptorFault = 103,
#[error("coin acceptor to manifold opto fault - check connector")]
CoinAcceptorToManifoldOptoFault = 104,
#[error("cashbox is full - empty cashbox")]
CashboxFull = 251,
#[error("cashbox is missing - insert cashbox")]
CashboxMissing = 252,
#[error("other changer error")]
Other = 255,
}
impl From<ChangerError> for u8 {
fn from(error: ChangerError) -> Self {
error as Self
}
}
impl From<u8> for ChangerError {
fn from(value: u8) -> Self {
match value {
1 => Self::HopperEmpty,
2 => Self::HopperJam,
3 => Self::HopperFraud,
4 => Self::HopperFault,
101 => Self::CoinAcceptorJam,
102 => Self::CoinAcceptorFraudAttempt,
103 => Self::CoinAcceptorFault,
104 => Self::CoinAcceptorToManifoldOptoFault,
251 => Self::CashboxFull,
252 => Self::CashboxMissing,
_ => Self::Other,
}
}
}