src/main/kotlin/com/flightfeather/uav/socket/bean/AirData.kt
@@ -1,15 +1,35 @@
package com.flightfeather.uav.socket.bean
import com.fasterxml.jackson.annotation.JsonInclude
import com.flightfeather.uav.socket.eunm.FactorType
import kotlin.math.round
/**
 * @author riku
 * Date: 2020/6/10
 */
class AirData:DataUnit(){
@JsonInclude(JsonInclude.Include.NON_NULL)
class AirData : DataUnit() {
    var factorId: String? = null
    var factorName: String? = null
    var sensorId: String? = null
    //监测因子实际值
    var factorData: Double? = null
    //监测因子物理量(电压)
    var physicalQuantity: Double? = null
    //状态位
    var statusList: List<String>? = null
    fun setData(factorType: FactorType, value: Float?) {
        setData(factorType, round(value?.toDouble()?.times(1000) ?: .0) / 1000)
    }
    fun setData(factorType: FactorType, value: Double?) {
        factorId = factorType.value.toString()
        factorName = factorType.des
        factorData = value
    }
}