package com.jwk.spring.boot.constant;

import com.serotonin.modbus4j.code.DataType;

/**
 * 包装DataType
 *
 * @author JWK
 * @version 1.0
 * @date 2022/12/12 22:45
 * {@link com.serotonin.modbus4j.code.DataType}
 */
public enum DATA_TYPE_WRAPPER {
    BINARY(DataType.BINARY),
    TWO_BYTE_INT_UNSIGNED(DataType.TWO_BYTE_INT_UNSIGNED),
    TWO_BYTE_INT_SIGNED(DataType.TWO_BYTE_INT_SIGNED),
    TWO_BYTE_INT_UNSIGNED_SWAPPED(DataType.TWO_BYTE_INT_UNSIGNED_SWAPPED),
    TWO_BYTE_INT_SIGNED_SWAPPED(DataType.TWO_BYTE_INT_SIGNED_SWAPPED),
    FOUR_BYTE_INT_UNSIGNED(DataType.FOUR_BYTE_INT_UNSIGNED),
    FOUR_BYTE_INT_SIGNED(DataType.FOUR_BYTE_INT_SIGNED),
    FOUR_BYTE_INT_UNSIGNED_SWAPPED(DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED),
    FOUR_BYTE_INT_SIGNED_SWAPPED(DataType.FOUR_BYTE_INT_SIGNED_SWAPPED),
    FOUR_BYTE_INT_UNSIGNED_SWAPPED_SWAPPED(DataType.FOUR_BYTE_INT_UNSIGNED_SWAPPED_SWAPPED),
    FOUR_BYTE_INT_SIGNED_SWAPPED_SWAPPED(DataType.FOUR_BYTE_INT_SIGNED_SWAPPED_SWAPPED),
    FOUR_BYTE_FLOAT(DataType.FOUR_BYTE_FLOAT),
    FOUR_BYTE_FLOAT_SWAPPED(DataType.FOUR_BYTE_FLOAT_SWAPPED),
    FOUR_BYTE_FLOAT_SWAPPED_INVERTED(DataType.FOUR_BYTE_FLOAT_SWAPPED_INVERTED),
    EIGHT_BYTE_INT_UNSIGNED(DataType.EIGHT_BYTE_INT_UNSIGNED),
    EIGHT_BYTE_INT_SIGNED(DataType.EIGHT_BYTE_INT_SIGNED),
    EIGHT_BYTE_INT_UNSIGNED_SWAPPED(DataType.EIGHT_BYTE_INT_UNSIGNED_SWAPPED),
    EIGHT_BYTE_INT_SIGNED_SWAPPED(DataType.EIGHT_BYTE_INT_SIGNED_SWAPPED),
    EIGHT_BYTE_FLOAT(DataType.EIGHT_BYTE_FLOAT),
    EIGHT_BYTE_FLOAT_SWAPPED(DataType.EIGHT_BYTE_FLOAT_SWAPPED),
    TWO_BYTE_BCD(DataType.TWO_BYTE_BCD),
    FOUR_BYTE_BCD(DataType.FOUR_BYTE_BCD),
    FOUR_BYTE_BCD_SWAPPED(DataType.FOUR_BYTE_BCD_SWAPPED),
    CHAR(DataType.CHAR),
    VARCHAR(DataType.VARCHAR),
    FOUR_BYTE_MOD_10K(DataType.FOUR_BYTE_MOD_10K),
    SIX_BYTE_MOD_10K(DataType.SIX_BYTE_MOD_10K),
    EIGHT_BYTE_MOD_10K(DataType.EIGHT_BYTE_MOD_10K),
    FOUR_BYTE_MOD_10K_SWAPPED(DataType.FOUR_BYTE_MOD_10K_SWAPPED),
    SIX_BYTE_MOD_10K_SWAPPED(DataType.SIX_BYTE_MOD_10K_SWAPPED),
    EIGHT_BYTE_MOD_10K_SWAPPED(DataType.EIGHT_BYTE_MOD_10K_SWAPPED),
    ONE_BYTE_INT_UNSIGNED_LOWER(DataType.ONE_BYTE_INT_UNSIGNED_LOWER),
    ONE_BYTE_INT_UNSIGNED_UPPER(DataType.ONE_BYTE_INT_UNSIGNED_UPPER);
    private int value;

    DATA_TYPE_WRAPPER(int value) {
        this.value = value;
    }

    public static int getRegisterCount(int id) {
        return DataType.getRegisterCount(id);
    }

    public static Class<?> getJavaType(int id) {
        return DataType.getJavaType(id);
    }


    public int getValue() {
        return value;
    }

}

