Files
pamhagen-sysctrl/PamhagenSysCtrl/Helpers/T1Error.cs
T

145 lines
8.8 KiB
C#

namespace PamhagenSysCtrl.Helpers {
public enum T1Error {
UNKNOWN_ERROR = -1,
NO_ERROR = 0,
SYSTEM_POWER_ON = 10,
SYSTEM_POWER_OFF = 11,
RAM_CHECK_ERROR = 20,
PROGRAM_BCC_ERROR = 21,
BATTERY_VOLTAGE_DROP = 22,
EEPROM_BCC_ERROR = 23,
EEPROM_WARNING = 26,
SYSTEM_RAM_CHECK_ERROR = 30,
SYSTEM_ROM_BCC_ERROR = 31,
PERIPHERAL_LSI_ERROR = 32,
CLOCK_CALENDAR_CHECK_ERROR = 33,
ILLEGAL_SYSTEM_INTERRUPT = 34,
WD_TIMER_ERROR = 35,
IO_BUS_ERROR = 40,
IO_MISMATCH = 41,
IO_NO_ANSWER = 42,
IO_PARITY_ERROR = 43,
ILLEGAL_IO_REGISTER = 46,
COMMUNICATION_BUSY = 51,
FORMAT_ERROR = 52,
SCAN_TIME_OVER = 64,
NO_END_IRET_ERROR = 80,
PAIR_INSTRUCTION_ERROR = 81,
OPERAND_ERROR = 82,
INVALID_PROGRAM = 83,
NO_SUBROUTINE_ENTRY = 86,
NO_RET_ERROR = 87,
SUBROUTINE_NESTING_ERROR = 88,
LOOP_NESTING_ERROR = 89,
INVALID_FUNCTION_INSTRUCTION = 98,
PASSWORD_PROTECT = 106,
ILLEGAL_INSTRUCTION = 110,
REGISTER_ADDRESS_ERROR = 111,
BOUNDARY_ERROR = 112,
MEMORY_FULL = 113,
MODE_MISMATCH = 114,
REGISTER_ADDRESS_SIZE_ERROR = 115,
DUPLICATE_ENTRY_NR = 121,
}
public static class T1ErrorExtension {
public static bool IsError(this T1Error error) {
return error switch {
T1Error.NO_ERROR => false,
T1Error.SYSTEM_POWER_ON => false,
T1Error.SYSTEM_POWER_OFF => false,
_ => true,
};
}
public static string GetName(this T1Error error) {
return error switch {
T1Error.UNKNOWN_ERROR => "Unknown error",
T1Error.NO_ERROR => "No error",
T1Error.SYSTEM_POWER_ON => "System power on",
T1Error.SYSTEM_POWER_OFF => "System power off",
T1Error.RAM_CHECK_ERROR => "RAM check error",
T1Error.PROGRAM_BCC_ERROR => "Program BCC error",
T1Error.BATTERY_VOLTAGE_DROP => "Battery voltage drop",
T1Error.EEPROM_BCC_ERROR => "EEPROM BCC error",
T1Error.EEPROM_WARNING => "EEPROM warning",
T1Error.SYSTEM_RAM_CHECK_ERROR => "System RAM check error",
T1Error.SYSTEM_ROM_BCC_ERROR => "System ROM BCC error",
T1Error.PERIPHERAL_LSI_ERROR => "Peripheral LSI error",
T1Error.CLOCK_CALENDAR_CHECK_ERROR => "Clock-calendar check error",
T1Error.ILLEGAL_SYSTEM_INTERRUPT => "Illegal system interrupt",
T1Error.WD_TIMER_ERROR => "WD timer error",
T1Error.IO_BUS_ERROR => "I/O bus error",
T1Error.IO_MISMATCH => "I/O mismatch",
T1Error.IO_NO_ANSWER => "I/O no answer",
T1Error.IO_PARITY_ERROR => "I/O parity error",
T1Error.ILLEGAL_IO_REGISTER => "Illegal I/O register",
T1Error.COMMUNICATION_BUSY => "Communication busy",
T1Error.FORMAT_ERROR => "Format error",
T1Error.SCAN_TIME_OVER => "Scan time over",
T1Error.NO_END_IRET_ERROR => "No END/IRET error",
T1Error.PAIR_INSTRUCTION_ERROR => "Pair instruction error",
T1Error.OPERAND_ERROR => "Operand error",
T1Error.INVALID_PROGRAM => "Invalid program",
T1Error.NO_SUBROUTINE_ENTRY => "No subroutine entry",
T1Error.NO_RET_ERROR => "No RET error",
T1Error.SUBROUTINE_NESTING_ERROR => "Subroutine nesting error",
T1Error.LOOP_NESTING_ERROR => "Loop nesting error",
T1Error.INVALID_FUNCTION_INSTRUCTION => "Invalid function instruction",
T1Error.PASSWORD_PROTECT => "Password protect",
T1Error.ILLEGAL_INSTRUCTION => "Illegal instruction",
T1Error.REGISTER_ADDRESS_ERROR => "Register address error",
T1Error.BOUNDARY_ERROR => "Boundary error",
T1Error.MEMORY_FULL => "Memory full",
T1Error.MODE_MISMATCH => "Mode mismatch",
T1Error.REGISTER_ADDRESS_SIZE_ERROR => "Register address/size error",
T1Error.DUPLICATE_ENTRY_NR => "Duplicate entry No.",
_ => error.ToString(),
};
}
public static string? GetDescription(this T1Error error) {
return error switch {
T1Error.NO_ERROR => "No error recorded",
T1Error.SYSTEM_POWER_ON => "Power on (no error)",
T1Error.SYSTEM_POWER_OFF => "Power off (no error)",
T1Error.RAM_CHECK_ERROR => "RAM read/write error has been detected",
T1Error.PROGRAM_BCC_ERROR => "Program BCC (memory check code) error has been detected",
T1Error.BATTERY_VOLTAGE_DROP => "Data invalidity of RAM (back-up area) has been detected",
T1Error.EEPROM_BCC_ERROR => "BCC error of built-in EEPROM has been detected",
T1Error.EEPROM_WARNING => "EEPROM write operation has exceeded 100,000 times",
T1Error.SYSTEM_RAM_CHECK_ERROR => "System RAM read/write error has been detected",
T1Error.SYSTEM_ROM_BCC_ERROR => "BCC error of system ROM has been detected",
T1Error.PERIPHERAL_LSI_ERROR => "CPU hardware error has been detected",
T1Error.CLOCK_CALENDAR_CHECK_ERROR => "Invalid clock-calendar data has been detected",
T1Error.ILLEGAL_SYSTEM_INTERRUPT => "Unregistered interrupt has occurred",
T1Error.WD_TIMER_ERROR => "Watchdog timer error has occurred",
T1Error.IO_BUS_ERROR => "I/O bus error has been detected",
T1Error.IO_MISMATCH => "Registered I/O allocation table and actual I/O configuration are not identical",
T1Error.IO_NO_ANSWER => "No response from I/O module has been received",
T1Error.IO_PARITY_ERROR => "I/O bus parity error has been detected",
T1Error.ILLEGAL_IO_REGISTER => "Excess I/O register allocation has been detected",
T1Error.COMMUNICATION_BUSY => "The T1/T1S is busy in processing for other peripheral communications",
T1Error.FORMAT_ERROR => "Received request is invalid (detected by the T1/T1S)",
T1Error.SCAN_TIME_OVER => "Scan time has exceeded 200 ms",
T1Error.NO_END_IRET_ERROR => "END or IRET instruction has not been programmed",
T1Error.PAIR_INSTRUCTION_ERROR => "Illegal combination of pair instructions has been programmed",
T1Error.OPERAND_ERROR => "Illegal operand has been detected",
T1Error.INVALID_PROGRAM => "Program abnormality has been detected",
T1Error.NO_SUBROUTINE_ENTRY => "Subroutine corresponding to CALL instruction has not been programmed",
T1Error.NO_RET_ERROR => "RET (subroutine return) instruction has not been in a subroutine",
T1Error.SUBROUTINE_NESTING_ERROR => "CALL instruction has been programmed in a subroutine (subroutine nesting)",
T1Error.LOOP_NESTING_ERROR => "Nesting of FOR-NEXT loop has been programmed",
T1Error.INVALID_FUNCTION_INSTRUCTION => "Function instruction which is not supported by T1/T1S has been programmed",
T1Error.PASSWORD_PROTECT => "Requested operation is protected by password",
T1Error.ILLEGAL_INSTRUCTION => "Illegal instruction has been detected",
T1Error.REGISTER_ADDRESS_ERROR => "Excess register address range has been programmed",
T1Error.BOUNDARY_ERROR => "Illegal register address is designated by index modification",
T1Error.MEMORY_FULL => "Program memory is insufficient for the requested command",
T1Error.MODE_MISMATCH => "Received command is invalid in the current T1/T1S operation mode",
T1Error.REGISTER_ADDRESS_SIZE_ERROR => "Specified register range exceeds the limit",
T1Error.DUPLICATE_ENTRY_NR => "Multiple subroutines which has same subroutine number have been programmed",
_ => null,
};
}
}
}