from enum import IntEnum


class DeviceChannelID(IntEnum):
    CH01 = 0
    CH02 = 1
    NONE = 2

class DeviceState(IntEnum):
    STATE_NOT_CONNECTED = 0
    STATE_IDLE = 1
    STATE_STIMULATING = 2
    STATE_EMERGENCY = 3
    STATE_PENDING = 4

class EcpError(IntEnum):
    NO_ERROR = 0
    UNKNOWN_FUNCTION_ERR = 1
    INVALID_REQUEST_LENGTH_ERR = 2
    SYSTEM_NOT_IDLE_ERR = 3
    INCORRECT_CHANNEL_ERR = 4
    NO_REPONSE_DEVICE_CONNECTED_ERR = 5
    RATING_IS_NOT_ZERO_ERR = 6
    NO_SUPPLY_PRESSURE_ERR = 7
    NO_POWER_ERR = 8
    INVALID_START_CONFIGURATION = 9
    STOP_NOT_POSSIBLE_ERR = 10
    INVALID_EVENT_ADDRESS_ERR = 11
    MAX_WAVEFORM_DURATION_EXCEEDED_ERR = 12
    INVALID_ADDRESS_ERR = 13
    COULD_NOT_SAVE_TO_EEPROM_ERR = 14
    INVALID_CHANNEL_ID_ERR = 15
    CANNOT_SET_BUILT_EVENT_ERR = 16
    INVALID_RUN_LEVEL_ERR = 17

class EventID(IntEnum):
    EVT_NO_EVENT = 0
    EVT_STATUS_UPDATE = 1
    EVT_START_STIMULATION = 2
    EVT_STOP_STIMULATION = 3
    EVT_STOP_BUTTON01_PRESSED = 4
    EVT_STOP_BUTTON01_RELEASED = 5
    EVT_STOP_BUTTON02_PRESSED = 6
    EVT_STOP_BUTTON02_RELEASED = 7
    EVT_MAX_VAS_SCORED = 8
    EVT_RESPONSE_DISCONNECTED = 9
    EVT_RESPONSE_CONNECTED = 10
    EVT_EMERGENCY_ACTIVATED = 11
    EVT_EMERGENCY_DEACTIVATED = 12
    EVT_WAVEFORMS_COMPLETED = 13
    EVT_TIMELIMIT_EXCEEDED = 14
    EVT_COMM_WATCHDOG_TRIGGERED = 15
    EVT_CUFF01_OUT_OF_COMPLIANCE = 16
    EVT_CUFF02_OUT_OF_COMPLIANCE = 17
    EVT_SUPPLY_PRESSURE_LOW = 18
    EVT_12V_POWER_OFF = 19
    EVT_12V_POWER_ON = 20
    EVT_AIR_LEAK = 21
    EVT_TRIG_IN = 22

class OperatingMode(IntEnum):
    RESPONSE_ENABLED = 0
    RESPONSE_DISABLED = 1

class StopCondition(IntEnum):
    STOPCOND_NO_CONDITION = 0
    STOPCOND_STOP_BUTTON_PRESSED = 1
    STOPCOND_MAXIMAL_VAS_SCORED = 2
    STOPCOND_STIMULATION_COMPLETED = 3
    STOPCOND_MAXIMAL_TIME_EXCEEDED = 4
    STOPCOND_VASMETER_DISCONNECTED = 5
    STOPCOND_EMERGENCY_STOP_ACTIVATED = 6
    STOPCOND_CONTROL_SOFTWARE = 7
    STOPCOND_OUT_OF_COMPLIANCE = 8
    STOPCOND_COMM_WATCHDOG = 9
    STOPCOND_12V_POWER_OFF = 10
    STOPCOND_SUPPLY_PRESSURE_LOW = 11

class StopCriterion(IntEnum):
    STOP_CRITERION_ON_BUTTON_VAS = 0
    STOP_CRITERION_ON_BUTTON_PRESSED = 1
    STOP_CRITERION_ON_BUTTON_RELEASED = 2

class WaveformInstructionType(IntEnum):
    TRIG = 0x00
    INC = 0x01
    DEC = 0x02
    STEP = 0x03
