package org.wcs.constant.enums.etag;

import lombok.Getter;

/**
 * 电子标签灯（按钮）颜色
 */
@Getter
public enum LedColorEnum {

    RED(0, "红色"),
    GREEN(1, "绿色"),
    ORANGE(2, "橙色"),
    BLUE(3, "蓝色"),
    PINK(4, "粉色"),
    CYAN(5, "青色");

    private final Integer code;
    private final String desc;

    LedColorEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public static LedColorEnum getByCode(Integer code) {
        for (LedColorEnum value : LedColorEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取灯颜色对应的二进制字符串 ---- 仅适用于单色灯，需要和其他字符串拼接使用
     * @param ledColor 灯颜色
     * @return 二进制字符串
     */
    public static  String getLightColorBitString(LedColorEnum ledColor) {
        return switch (ledColor) {
            case RED -> "000";
            case GREEN -> "001";
            case ORANGE -> "010";
            case BLUE -> "011";
            case PINK -> "100";
            case CYAN -> "101";
        };

    }


}
