package ru.upos;

/**
 * Команды для выполения на терминале UPOS 1.0
 */
public enum UposCommand {

    Response((byte)0x00),
    GetReady((byte)0x50),
    Transaction((byte)0x6D),
    MasterCall((byte)0xA0),
    RunScreen((byte)0xC0);

    private final byte commandId;

    UposCommand(byte commandId) {
        this.commandId = commandId;
    }

    public byte getCommandId() {
        return commandId;
    }

    public static UposCommand getCommand(byte commandId) throws Exception {
        for (UposCommand command : UposCommand.values()) {
            if (commandId == command.getCommandId()) {
                return command;
            }
        }
        throw new Exception(String.format("Unallowable command: %02X", commandId));
    }
}
