package com.dcs.equipment.domain;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static com.dcs.equipment.constants.ModbusConstants.*;

/**
 * @author: wangpx
 * @date: 2025-03-14 15:35
 */
public class ModbusTcpEnum {
    // 数据类型与最大长度的映射
    public static final Map<String, Integer> DATA_TYPE_LENGTH_MAP;
    public static final Map<String, Integer> DATA_ADDRESS_LENGTH_MAP;

    static {
        Map<String, Integer> map = new HashMap<>();
        map.put(COIL_DATA_TYPE, COIL_MAX_LENGTH);
        map.put(INT_DATA_TYPE, INT_MAX_LENGTH);
        map.put(FLOAT_DATA_TYPE, FLOAT_MAX_LENGTH);
        DATA_TYPE_LENGTH_MAP = Collections.unmodifiableMap(map);
    }

    static {
        Map<String, Integer> map = new HashMap<>();
        map.put(COIL_DATA_TYPE, COIL_ADDRESS_LENGTH);
        map.put(INT_DATA_TYPE, INT_ADDRESS_LENGTH);
        map.put(FLOAT_DATA_TYPE, FLOAT_ADDRESS_LENGTH);
        DATA_ADDRESS_LENGTH_MAP = Collections.unmodifiableMap(map);
    }

    private ModbusTcpEnum() { /* 防止实例化 */ }
}
