package com.flightfeather.uav.biz.sourcetrace.model
|
|
import com.flightfeather.uav.biz.FactorFilter
|
import com.flightfeather.uav.biz.dataanalysis.model.ExceptionTag
|
import com.flightfeather.uav.socket.eunm.FactorType
|
|
/**
|
* 待合并异常
|
* 异常出现后,若相关的其他因子累计异常次数接近阈值,则该异常可以等待若干个数据周期后再合并。
|
* @date 2025/8/1
|
* @author feiyu02
|
*/
|
class RemainException<T : ExceptionTag>(
|
exceptions: List<Pair<FactorFilter.SelectedFactor, T>>,
|
combination: List<FactorType>,
|
) {
|
|
// 已有的异常
|
var exceptions = mutableListOf<Pair<FactorFilter.SelectedFactor, T>>()
|
|
// 需要延迟检测的因子关联关系
|
val combination = mutableListOf<FactorType>()
|
|
// 缺失的监测因子
|
val lackFactors = mutableListOf<FactorType>()
|
|
// 已经过的数据周期
|
var period: Int = 1
|
|
init {
|
// 存储监测因子异常对象的克隆版本,
|
this.exceptions.addAll(exceptions.map {
|
it.first to (it.second.clone() as T)
|
})
|
this.combination.addAll(combination)
|
calLackFactors()
|
}
|
|
/**
|
* 添加新的异常集合
|
*/
|
fun addExceptions(exceptions: List<Pair<FactorFilter.SelectedFactor, T>>) {
|
// 存储监测因子异常对象的克隆版本,
|
this.exceptions.addAll(exceptions.map {
|
it.first to (it.second.clone() as T)
|
})
|
calLackFactors()
|
}
|
|
/**
|
* 计算缺失的监测因子
|
*/
|
private fun calLackFactors() {
|
lackFactors.clear()
|
combination.forEach { c ->
|
val e = exceptions.find { it.first.main == c }
|
if (e == null) {
|
lackFactors.add(c)
|
}
|
}
|
}
|
}
|