package jtznyj.engineer.service.dataDiagnosticService.data;

/**
 * 钻井状态
 */
public enum DrillState {
    None(0),
    /**
     * 钻进
     */
    Drilling(1),
    /**
     * 循环
     */
    Circulate(2),        //循环

    /**
     * 起钻
     */
    Trip ( 4),         //起钻

    /**
     * 下钻
     */
    DrillDown   (8),    //下钻

    /**
     * 停钻
     */
    Stop   (16),        //停钻


    /**
     * 下套管
     */
    Casing(20),
    /**
     * 坐卡
     */
    TakePipe   (32),    //坐卡

    /**
     * 划眼
     */
    ClearHole   (64),   //划眼

    /**
     * 所有钻井状态
     */
    AllDrillState   (111),
    All   (65535);

    private int index;

    private DrillState(int index) {
        this.index = index;
    }

    public int value() {
        return this.index;
    }

    public static DrillState valueOf(int value) {    //手写的从int到enum的转换函数
        switch (value) {
            case 0:
                return None;
            case 1:
                return Drilling;
            case 2:
                return Circulate;
            case 4:
                return Trip;
            case 8:
                return DrillDown;
            case 16:
                return Stop;
            case 20:
                return Casing;
            case 32:
                return TakePipe;
            case 64:
                return ClearHole;
            case 111:
                return AllDrillState;
            case 65535:
                return All;
            default:
                return null;
        }
    }
}
