PmControlTypeEnum.java

package com.mycim.valueobject.ems;

/**
 * @author xinzhan.zhou
 * @version 6.0.0
 * @date 2020/5/1
 **/
public enum PmControlTypeEnum {
    //By PM TIME: PM_TIME
    PM_TIME("PM_TIME"), PM_COUNT("PM_COUNT"), PM_TRIGGER_READING("PM_TRIGGER_READING"), //By PMCount: BY_JOB, BY_LOT, BY_WAFER
    BY_JOB("BY_JOB"), BY_LOT("BY_LOT"), BY_WAFER("BY_WAFER"),BY_CHECK_MAX_VALUE("BY_CHECK_MAX_VALUE"),BY_CHECK_MIX_VALUE("BY_CHECK_MIX_VALUE");

    private String controlType;

    PmControlTypeEnum(String controlType) {
        this.controlType = controlType;
    }

    public String getControlType() {
        return controlType;
    }

    public static int countStatus(double toleranceMax, double specMax, double toleranceMin, boolean checkMax){
        int toleranceStatus = 0;
        if (checkMax){
            if (toleranceMax <= 0){//设定的值 + 允许的差值 <= 实际读取值,代表已达触发条件
                toleranceStatus = 3;
            } else if (toleranceMax > 0 && specMax <= 0){//设定的值 + 允许的差值 > 实际读取值,但是 设定的值 <= 实际读取值
                toleranceStatus = 2;
            } else if (specMax > 0 && toleranceMin <= 0){//设定的值 > 实际读取值,但是 设定的值 - 允许的差值 <= 实际读取值
                toleranceStatus = 1;
            } else if (toleranceMin > 0){//设定的值 - 允许的差值 > 实际读取值
                toleranceStatus = -1;
            }
        } else {
            if (toleranceMin < 0){//设定的值 < 实际读取值
                toleranceStatus = -1;
            } else if (specMax < 0 && toleranceMin >= 0){//设定的值 = 实际读取值
                toleranceStatus = 1;
            } else if (toleranceMax < 0 && specMax >= 0){//设定的值 + 允许的差值 >= 实际读取值,但是 设定的值 < 实际读取值
                toleranceStatus = 2;
            } else if (toleranceMax >= 0){//设定的值 + 允许的差值 > 实际读取值,代表已达触发条件
                toleranceStatus = 3;
            }
        }
        return toleranceStatus;
    }
}