feiyu02
2025-09-12 61871594dfa0a5ac2c4d895d9ec4034feba57094
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.flightfeather.uav.lightshare.bean
 
import com.flightfeather.uav.socket.eunm.FactorType
 
/**
 * 监测因子数据统计
 * @date 2025/8/25 11:26
 * @author feiyu
 */
data class FactorStatistics(
    // 监测因子类型
    var factor: FactorType,
    // 最小值
    var minValue: Float = Float.NaN,
    // 最大值
    var maxValue: Float = Float.NaN,
    // 均值
    var avgValue: Float = Float.NaN,
){
    fun updateMinAndMaxValue(value: Float?){
        minValue = if (minValue.isNaN()) {
            value ?: Float.NaN
        } else {
            minValue.coerceAtMost(value ?: minValue)
        }
        maxValue = if (maxValue.isNaN()) {
            value ?: Float.NaN
        } else {
            maxValue.coerceAtLeast(value ?: maxValue)
        }
    }
}