package cn.iocoder.yudao.module.system.config.mqtt.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 默认订阅的话题 -- 枚举类
 */
@Getter
@AllArgsConstructor
public enum DefineSubTopicEnum {

    //qos 0-至多1次、1-至少1次、2-正好一次
    ROBOT_STATUS("ROBOT_STATUS", 2,"点位"),
    ROBOT_TASK_STATUS("ROBOT_TASK_STATUS", 2,"机器人任务完成上报"),
    ROBOT_REACTIVE_STATUS("ROBOT_REACTIVE_STATUS", 2,"机器人响应式状态上报"),
    ROBOT_GENERICS_STATUS("ROBOT_GENERICS_STATUS", 2,"机器人异常"),
    ROBOT_PATH_STATUS("ROBOT_PATH_STATUS", 2,"导航实时行为上报"),
    ROBOT_WORK_STATUS("ROBOT_WORK_STATUS", 2,"作业实时行为上报"),
    ROBOT_UPDATE_PALLET_HEIGHT("UPDATE_PALLET_HEIGHT", 2,"放货后货物高度反馈和取货后货物高度反馈"),
    ROBOT_OBSTACLES_STATUS("ROBOT_OBSTACLES_STATUS", 2,"障碍物状态上报"),
    ROBOT_WIRELESS_SIGNAL_STATUS("ROBOT_WIRELESS_SIGNAL_STATUS", 2,"信号强度上报"),
    PLANNING_INIT_DATA("SYNCHRONOUS_ALL_MAP_REQUEST", 2,"路径规划需要初始数据上报"),
    PLANNING_DISTRIBUTION_TASK("TASK_ASSIGNMENT_FEEDBACK", 2,"路径规划任务分配上报"),
    PLANNING_DISTRIBUTION_FAIL("TASK_ASSIGNMENT_FAIL", 2,"路径规划失败上报"),
    PLANNING_SIMULATION_ROBOT_POSE_REQUEST("SIMULATION_ROBOT_POSE_REQUEST", 2,"仿真初始化点位信息"),
    PLANNING_MOVE("UPDATE_ROUTE_DISPLAY_PLANNING", 2,"车辆即将走的点位"),
    PLANNING_ROUTE_DISPLAY("ROBOT_MOVE_POSE_PLANNING", 2,"路径规划上报实时路径"),
    PLANNING_GRAPH_MATCH_DATA("GRAPH_MATCH_DATA", 2,"路网匹配实时数据"),
    PLANNING_ROBOT_WALKING_DISTANCE("ROBOT_WALKING_DISTANCE", 2,"车辆行走路程"),
    PLANNING_ROBOT_LINE_DISTANCE("ROBOT_LINE_DISTANCE", 2,"车辆行走路线上报"),
    PLANNING_REMOTE_ROBOT_MOVE_POSE_PLANNING("REMOTE_ROBOT_MOVE_POSE_PLANNING", 2,"远遥车辆行走导航");


    private final String topic;

    private final int qos;

    private final String msg;

    /**
     * 获取所有话题名
     *
     * @return topicArr
     */
    public static String[] queryAllTopic() {
        List<String> topicList = new ArrayList<>();
        for (DefineSubTopicEnum item : DefineSubTopicEnum.values()) {
            topicList.add(item.getTopic());
        }
        String[] topicArr = new String[topicList.size()];
        topicArr = topicList.toArray(topicArr);
        return topicArr;
    }


    /**
     * 获取所有qos
     *
     * @return qosArr
     */
    public static int[] queryAllQos() {
        List<Integer> qosList = new ArrayList<>();
        for (DefineSubTopicEnum item : DefineSubTopicEnum.values()) {
            qosList.add(item.getQos());
        }

        int[] qosArr = new int[qosList.size()];
        qosArr = qosList.stream().mapToInt(Integer::intValue).toArray();

        return qosArr;
    }

    public static DefineSubTopicEnum getDefineSubTopicEnumByTopic(String topic) {
        for (DefineSubTopicEnum item : DefineSubTopicEnum.values()) {
            if (item.getTopic().equals(topic)) {
                return item;
            }
        }
        return null;
    }

}