package com.dji.sample.manage.model.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author hqjiang
 * @version 1.0
 * @date 2024/7/2
 */
public enum DeviceStatusEnum {

    /**
     * 飞行器未连接
     */
    DRONE_DISCONNECTED(0,"飞行器未连接"),

    /**
     *  飞行器已连接
     */
    DRONE_CONNECTED(1,"飞行器已连接"),

    /**
     * 飞行器待机
     */
    DRONE_STANDBY(3,"待机"),

    /**
     * 飞行器手动飞行
     */
    DRONE_FLY_BY_HAND(4,"手动飞行"),

    /**
     * 飞行器航线飞行
     */
    DRONE_FLY_WAYLINE(5,"航线飞行"),

    /**
     * 飞行器 舱内关机
     */
    DRONE_SHUTDOWN_IN_DOCK(6,"舱内关机"),

    /**
     * 遥控器 设备已离线
     */
    REMOTER_CONTROL_DISCONNECTED(20,"设备已离线"),

    /**
     * 遥控器 设备空闲中
     */
    REMOTER_CONTROL_STANDBY(21,"设备空闲中"),

    /**
     * 遥控器 飞行作业中
     */
    REMOTER_CONTROL_FLYING(22,"飞行作业中"),

    /**
     * 机场 设备已离线
     */
    DOCK_DISCONNECTED(30,"设备已离线"),

    /**
     * 机场 设备空闲中
     */
    DOCK_STANDBY(31,"设备空闲中"),

    /**
     * 机场 飞行作业中
     */
    DOCK_FLYING(32,"飞行作业中"),

    UNKNOWN(-1,"N/A");

    int val;

    String text;

    @JsonValue
    public int getVal() {
        return val;
    }

    public String getText() {
        return text;
    }

    DeviceStatusEnum(int val,String text) {
        this.val = val;
        this.text = text;
    }

    @JsonCreator
    public static DeviceStatusEnum find(int val) {
        return Arrays.stream(DeviceStatusEnum.values())
                .filter(firmwareStatus -> firmwareStatus.val == val)
                .findFirst().orElse(UNKNOWN);
    }


}
