use num_derive::FromPrimitive;
use num_traits::cast::FromPrimitive as _;
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive)]
#[repr(u16)]
pub enum AlStatus {
NoError = 0x0000,
UnspecifiedError = 0x0001,
NoMemory = 0x0002,
InvalidRequestedStateChange = 0x0011,
UnknownRequestedState = 0x0012,
BootstrapNotSupported = 0x0013,
NoValidFirmware = 0x0014,
InvalidMailboxConfig = 0x0015,
InvalidMailboxConfig2 = 0x0016,
InvalidSyncManagerConfiguration = 0x0017,
NoValidInputsAvailable = 0x0018,
NoValidOutputs = 0x0019,
SynchronizationError = 0x001A,
SyncManagerWatchdog = 0x001B,
InvalidSyncManagerTypes = 0x001C,
InvalidOutputConfiguration = 0x001D,
InvalidInputConfiguration = 0x001E,
InvalidWatchdogConfiguration = 0x001F,
SlaveNeedsColdStart = 0x0020,
SlaveNeedsInit = 0x0021,
SlaveNeedsPreOp = 0x0022,
SlaveNeedsSafeOp = 0x0023,
InvalidInputMapping = 0x0024,
InvalidOutputMapping = 0x0025,
InconsistentSettings = 0x0026,
FreerunNotSupported = 0x0027,
SynchronisationNotSupported = 0x0028,
FreerunNeeds3BufferMode = 0x0029,
BackgroundWatchdog = 0x002A,
NovalidInputsAndOutputs = 0x002B,
FatalSyncError = 0x002C,
NoSyncError = 0x002D,
InvalidInputFmmuConfiguration = 0x002E,
InvalidDcSyncConfiguration = 0x0030,
InvalidDcLatchConfiguration = 0x0031,
PllError = 0x0032,
DcSyncIoError = 0x0033,
DcSyncTimeoutError = 0x0034,
DcInvalidSyncCycleTime = 0x0035,
DcInvalidSync0CycleTime = 0x0036,
DcInvalidSync1CycleTime = 0x0037,
MbxAoe = 0x0041,
MbxEoe = 0x0042,
MbxCoe = 0x0043,
MbxFoe = 0x0044,
MbxSoe = 0x0045,
MbcVoe = 0x004F,
EepromNoAccess = 0x0050,
EeepromError = 0x0051,
SlaveRestartedLocally = 0x0060,
DeviceIdValueUpdated = 0x0061,
ApplicationControllerAvailable = 0x00f0,
Unknown = 0xffff,
}
impl From<u16> for AlStatus {
fn from(code: u16) -> Self {
AlStatus::from_u16(code).unwrap_or(AlStatus::Unknown)
}
}