package com.mvc.iot.onenet.enums;

/**
 * OneNet平台消息类型
 */
public enum OneNetMsgType {
    // 设备状态变化通知（600）
    DEVICE_ONLINE(600, "deviceOnline"),
    DEVICE_OFFLINE(600, "deviceOffline"),

    // 设备管理（601）
    DEVICE_CREATE(601, "deviceCreate"),
    DEVICE_DELETE(601, "deviceDelete"),

    // 设备数据上报（602）
    THING_PROPERTY(602, "thingProperty"),
    THING_EVENT(602, "thingEvent"),
    DATA_POINTS(602, "dataPoints"),

    // 设备响应通知（603）
    THING_SERVICE_REPLY(603, "thingServiceReply"),
    NB_COMMAND_CACHE_REPLY(603, "NBcommandCacheReply"),
    DEVICE_IMAGE_PROPERTY_UPDATE(603, "deviceImagePropertyUpdate"),

    // 联动规则（620）
    SCENE_LOG(620, "SceneLog"),

    // 设备位置信息（630）
    LBS(630, "LBS");

    private final int category;
    private final String description;

    OneNetMsgType(int category, String description) {
        this.category = category;
        this.description = description;
    }

    public static OneNetMsgType getByDescription(String description) {
        for (OneNetMsgType type : values()) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        return null;
    }

    public int getCategory() {
        return category;
    }

    public String getDescription() {
        return description;
    }
}
