package com.pwt.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author linyun
 * @version V1.0
 * @Title: ChangePowerStep
 * @Description: 换电步骤
 * @date 2022/11/23
 **/
public enum ChangePowerStep {
    STEP_NONE(-1, ""),
    STEP_O(0, "停止状态"),
    STEP_1(1, "初始化"),
    STEP_2(2, "行车向取电池仓位运行中"),
    STEP_3(3, "空吊具下降"),
    STEP_4(4, "夹具打开"),
    STEP_5(5, "满吊具上升"),
    STEP_6(6, "行车到空电池仓位运行中"),
    STEP_7(7, "满吊具下降"),
    STEP_8(8, "松开夹具"),
    STEP_9(9, "空吊具上升"),
    STEP_10(10, "行车回到原点中心位置"),
    STEP_11(11, ""),
    STEP_12(12, "换仓完成"),
    STEP_13(13, "换仓暂停"),
    STEP_3O(30, "初始化"),
    STEP_31(31, "激光定位判断车是否停到位"),
    STEP_32(32, "行车到车位运行中"),
    STEP_33(33, "空吊具下降"),
    STEP_34(34, "夹具打开"),
    STEP_35(35, "满吊具上升"),
    STEP_36(36, "行车到空电池仓位运行中"),
    STEP_37(37, "满吊具下降"),
    STEP_38(38, "松开夹具"),
    STEP_39(39, "空吊具上升"),
    STEP_4O(40, "行车到满电池仓位运行中"),
    STEP_41(41, "满仓位吊具下降"),
    STEP_42(42, "满仓位夹具打开"),
    STEP_43(43, "满吊具上升"),
    STEP_44(44, "行车到车位运行中"),
    STEP_45(45, "车位满吊具下降"),
    STEP_46(46, "车位松开夹具"),
    STEP_47(47, "车位空吊具上升"),
    STEP_48(48, ""),
    STEP_49(49, ""),
    STEP_5O(50, "换电完成"),
    STEP_51(51, "换电暂停");



    public static ChangePowerStep getStepByCode(int code)
    {
        Optional<ChangePowerStep> optional = Arrays.stream(ChangePowerStep.values()).filter(s -> s.code == code)
            .findFirst();
        return optional.orElse(null);
    }

    private final int code;
    private final String desc;

    ChangePowerStep(int code, String desc)
    {
        this.code = code;
        this.desc = desc;
    }

    public int getCode()
    {
        return code;
    }

    public String getDesc()
    {
        return desc;
    }

    @Override
    public String toString() {
        return this.getDesc();
    }
}
