package com.njcn.gather.detection.pojo.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * @Description:
 * @Author: wr
 * @Date: 2025/2/12 10:15
 */
@Getter
public enum DetectionCodeEnum {

    FREQ("FREQ", "频率"),
    VRMS("VRMS", "相电压有效值"),
    PVRMS("PVRMS", "线电压有效值"),
    DELTA_V("DELTA_V", "电压偏差"),
    VA("VA", "电压相角"),
    U1A("U1A", "相电压基波有效值角度值"),
    PU1A("PU1A", "线电压基波有效值角度值"),
    U1("U1", "基波电压"),
    PU1("PU1", "线电压基波电压"),
    V2_50("V2-50", "谐波电压"),
    PV2_50("PV2-50", "线电压谐波电压"),
    I2_50("I2-50", "谐波电流"),
    P2_50("P2-50", "谐波有功功率"),
    SV_1_49("SV_1-49", "间谐波电压"),
    PSV_1_49("PSV_1-49", "线电压间谐波电压"),
    SI_1_49("SI_1-49", "间谐波电流"),
    MAG("MAG", "电压幅值"),
    DUR("DUR", "持续时间"),
    IRMS("IRMS", "电流有效值"),
    IA("IA", "电流相角"),
    I1A("I1A", "电流基波角度值"),
    V_UNBAN("V_UNBAN", "三相电压负序不平衡度"),
    SeqV("SeqV", "电压序分量"),
    I_UNBAN("I_UNBAN", "三相电流负序不平衡度"),
    SeqA("SeqA", "电流序分量"),
    PST("PST", "短时间闪变"),
    PLT("PLT", "长时间闪变"),
    W("W", "总有功功率"),
    VARW("VARW", "总无功功率"),
    VAW("VAW", "总视在功率"),
    PF("PF", "功率因数"),
    TOTW("TotW", "三相总有功功率"),
    TOTVA("TotVA", "三相总视在功率"),
    TOTVAR("TotVAr", "三相总无功功率"),
    TOTPF("TotPF","三相功率因数"),
    //    P_FUND("P_FUND", "基波有功功率"),
//    P_HVAR("P_HVAR", "基波无功功率"),
//    P_HVA("P_HVA", "基波视在功率"),
    I1("I1", "基波电流"),
    UNKNOWN_ERROR("-1", "未知异常"),


    STAR("Star", "星型接线"),
    DELTA("Delta", "角型接线"),

    REAL_PREFIX("real$", "实时数据前缀"),
    CP_95_PREFIX("cp95$", "分钟统计-CP95值数据前缀"),
    MAX_PREFIX("max$", "分钟统计-最大值数据前缀"),
    MIN_PREFIX("min$", "分钟统计-最小值数据前缀"),
    AVG_PREFIX("avg$", "分钟统计-平均值数据前缀");

    private final String code;
    private final String message;

    DetectionCodeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static DetectionCodeEnum getDetectionCodeByCode(String code) {
        for (DetectionCodeEnum detectionCodeEnum : DetectionCodeEnum.values()) {
            if (ObjectUtil.equals(code, detectionCodeEnum.getCode())) {
                return detectionCodeEnum;
            }
        }
        return UNKNOWN_ERROR;
    }
}
