feiyu02
2024-05-31 da431c25dfe5122e4ed70372da36ede3e4eaec4a
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
@@ -1,5 +1,7 @@
package com.flightfeather.uav.socket.eunm
import com.flightfeather.uav.biz.dataanalysis.BaseExceptionAnalysis
/**
 * @author riku
 * Date: 2020/6/10
@@ -26,7 +28,23 @@
    companion object {
        /**
         * 通过索引获取枚举类型,用于数据分析
         * @see [BaseExceptionAnalysis]
         */
        fun getByIndex(index: Int): FactorType? = when (index) {
            0 -> NO2
            1 -> CO
            2 -> H2S
            3 -> SO2
            4 -> O3
            5 -> PM25
            6 -> PM10
            7 -> VOC
            else -> null
        }
        fun getByValue(value: Int): FactorType? = when (value) {
            NO2.value -> NO2
            CO.value -> CO
            H2S.value -> H2S
@@ -133,5 +151,23 @@
            HEIGHT -> 0.0
            else -> null
        }
        fun outputFactor(factorName: String?): Boolean {
            return when (factorName) {
                NO2.des,
                CO.des,
                H2S.des,
                SO2.des,
                O3.des,
                PM25.des,
                PM10.des,
                TEMPERATURE.des,
                HUMIDITY.des,
                VOC.des,
                WIND_SPEED.des,
                WIND_DIRECTION.des -> true
                else -> false
            }
        }
    }
}