From e8f935a01d75c89ac591a80b9318eac2480e2dcd Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 27 六月 2024 17:40:01 +0800 Subject: [PATCH] 1. 新增走航轨迹融合功能 --- src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt | 182 +++++++++++++++++++++++++++++++------------- 1 files changed, 127 insertions(+), 55 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt index 9177f77..2ea3314 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt @@ -1,7 +1,9 @@ package com.flightfeather.uav.biz.dataanalysis +import com.flightfeather.uav.biz.FactorFilter import com.flightfeather.uav.biz.dataanalysis.model.DataAnalysisConfig import com.flightfeather.uav.domain.entity.BaseRealTimeData +import com.flightfeather.uav.socket.eunm.FactorType /** * 杩炵画绫诲瀷鐨勫紓甯稿垎鏋愬熀绫�,閫傜敤浜庡綋鍓嶆暟鎹笌鐩搁偦鏁版嵁涔嬮棿鏈夊叧鑱斿叧绯荤殑鎯呭喌 @@ -13,29 +15,58 @@ private const val OFFSET = 10 } - // 璧峰鏁版嵁涓嬫爣 - protected var sIndex = mutableListOf<Int>() + inner class Tag { + // 璧峰鏁版嵁涓嬫爣 + var sIndex = 0 - // 璧峰鏁版嵁瀵硅薄 - protected var startData = mutableListOf<BaseRealTimeData?>() + // 璧峰鏁版嵁瀵硅薄 + var startData :BaseRealTimeData? = null - // 鏈熬鏁版嵁涓嬫爣 - protected var eIndex = mutableListOf<Int>() + // 鏈熬鏁版嵁涓嬫爣 + var eIndex = -1 - // 鏈熬鏁版嵁瀵硅薄 - protected var lastData: BaseRealTimeData? = null + // 鏈熬鏁版嵁瀵硅薄 + var endData: BaseRealTimeData? = null - // 寮傚父鏁版嵁娈� - protected var exceptionData = mutableListOf<MutableList<BaseRealTimeData>>() + // 寮傚父鏁版嵁娈� + var exceptionData = mutableListOf<BaseRealTimeData>() + + // 鏄惁瀛樺湪寮傚父 + var existException = false + + fun refreshAfterCheckResult(data: BaseRealTimeData) { + sIndex = eIndex + startData = data + exceptionData.clear() + exceptionData.add(data) + } + } + + protected val tagMap = mutableMapOf<FactorType, Tag>() + +// // 璧峰鏁版嵁涓嬫爣 +// protected var sIndex = mutableListOf<Int>() +// +// // 璧峰鏁版嵁瀵硅薄 +// protected var startData = mutableListOf<BaseRealTimeData?>() +// +// // 鏈熬鏁版嵁涓嬫爣 +// protected var eIndex = mutableListOf<Int>() +// +// // 寮傚父鏁版嵁娈� +// protected var exceptionData = mutableListOf<MutableList<BaseRealTimeData>>() + +// protected var existException = mutableListOf<Boolean>() // 璧峰鏁版嵁涓庢湯灏炬暟鎹棿闅� open var durationCount = 1 - protected var existException = mutableListOf<Boolean>() + // 鏈熬鏁版嵁瀵硅薄 + protected var lastData: BaseRealTimeData? = null /** * 鍒ゆ柇鏄惁婊¤冻寮傚父鏉′欢 */ - abstract fun judgeException(p: BaseRealTimeData?, n: BaseRealTimeData): List<Boolean> + abstract fun judgeException(p: BaseRealTimeData?, n: BaseRealTimeData): MutableMap<FactorType, Boolean> /** * 鍒ゆ柇寮傚父鍑虹幇鐨勮繛缁椂闀挎槸鍚︽弧瓒虫潯浠� @@ -45,44 +76,75 @@ override fun init() { super.init() lastData = null - repeat(config.factorCount) { - startData.add(null) - sIndex.add(0) - eIndex.add(-1) - existException.add(false) - exceptionData.add(mutableListOf()) +// repeat(config.factorCount) { +// startData.add(null) +// sIndex.add(0) +// eIndex.add(-1) +// existException.add(false) +// exceptionData.add(mutableListOf()) +// } + config.factorFilter.mainList().forEach {f-> + tagMap[f] = Tag() } } override fun onNextData(data: BaseRealTimeData) { val isContinue = isContinuous(lastData, data) val hasException = judgeException(lastData, data) - repeat(config.factorCount) { i -> - eIndex[i]++ - // 璧峰鏁版嵁 - if (lastData == null) { - refreshAfterCheckResult(i, data) - } - // 鍒ゆ柇鐩搁偦鏁版嵁鏄惁杩炵画骞朵笖鏄惁婊¤冻寮傚父鍒ゆ柇 - if (!isContinue) { - checkResult() - // 鏁版嵁涓嶈繛缁椂锛岃褰曞紓甯告儏鍐� - if (eIndex[i] - sIndex[i] >= durationCount) { - refreshAfterCheckResult(i, data) + config.factorFilter.mainList().forEach {f-> + tagMap[f]?.let { + it.eIndex++ + // 璧峰鏁版嵁 + if (it.endData == null) { + it.refreshAfterCheckResult(data) } - } else { - if (hasException[i]) { - existException[i] = true - exceptionData[i].add(data) - } else { - // 寮傚父涓嶅啀閲嶅鍑虹幇鏃讹紝璁板綍寮傚父鎯呭喌 + // 鍒ゆ柇鐩搁偦鏁版嵁鏄惁杩炵画骞朵笖鏄惁婊¤冻寮傚父鍒ゆ柇 + if (!isContinue) { checkResult() - if (eIndex[i] - sIndex[i] >= durationCount) { - refreshAfterCheckResult(i, data) + // 鏁版嵁涓嶈繛缁椂锛岃褰曞紓甯告儏鍐� + if (it.eIndex - it.sIndex >= durationCount) { + it.refreshAfterCheckResult(data) + } + } else { + if (hasException[f] == true) { + it.existException = true + it.exceptionData.add(data) + } else { + // 寮傚父涓嶅啀閲嶅鍑虹幇鏃讹紝璁板綍寮傚父鎯呭喌 + checkResult() + if (it.eIndex - it.sIndex >= durationCount) { + it.refreshAfterCheckResult(data) + } } } } } +// repeat(config.factorCount) { i -> +// eIndex[i]++ +// // 璧峰鏁版嵁 +// if (lastData == null) { +// refreshAfterCheckResult(i, data) +// } +// // 鍒ゆ柇鐩搁偦鏁版嵁鏄惁杩炵画骞朵笖鏄惁婊¤冻寮傚父鍒ゆ柇 +// if (!isContinue) { +// checkResult() +// // 鏁版嵁涓嶈繛缁椂锛岃褰曞紓甯告儏鍐� +// if (eIndex[i] - sIndex[i] >= durationCount) { +// refreshAfterCheckResult(i, data) +// } +// } else { +// if (hasException[i]) { +// existException[i] = true +// exceptionData[i].add(data) +// } else { +// // 寮傚父涓嶅啀閲嶅鍑虹幇鏃讹紝璁板綍寮傚父鎯呭喌 +// checkResult() +// if (eIndex[i] - sIndex[i] >= durationCount) { +// refreshAfterCheckResult(i, data) +// } +// } +// } +// } lastData = data } @@ -90,33 +152,43 @@ checkResult() } - fun refreshAfterCheckResult(i:Int, data: BaseRealTimeData) { - sIndex[i] = eIndex[i] - startData[i] = data - exceptionData[i].clear() - exceptionData[i].add(data) - } +// fun refreshAfterCheckResult(i:Int, data: BaseRealTimeData) { +// sIndex[i] = eIndex[i] +// startData[i] = data +// exceptionData[i].clear() +// exceptionData[i].add(data) +// } /** * 妫�鏌ヨ繛缁紓甯哥粨鏉熸椂锛屾槸鍚︾鍚堝紓甯稿瓨鍌ㄦ潯浠� */ - open fun checkResult(index: Int? = null) { - if (index != null) { - if (existException[index] && judgeDuration(sIndex[index], eIndex[index])) { - startData[index]?.let { - resultList.add(newResult(it, lastData, index, exceptionData[index])) + open fun checkResult(factor: FactorFilter.SelectedFactor? = null) { + val tag = tagMap[factor?.main] + if (factor != null && tag != null) { + if (tag.existException && judgeDuration(tag.sIndex, tag.eIndex)) { + tag.startData?.let { + resultList.add(newResult(it, lastData, factor, tag.exceptionData)) } - existException[index] = false + tag.existException = false } } else { - repeat(config.factorCount) { i -> - if (existException[i] && judgeDuration(sIndex[i], eIndex[i])) { - startData[i]?.let { - resultList.add(newResult(it, lastData, i, exceptionData[i])) + config.factorFilter.selectedList.forEach { f -> + val tag1 = tagMap[f.main] ?: return@forEach + if (tag1.existException && judgeDuration(tag1.sIndex, tag1.eIndex)) { + tag1.startData?.let { + resultList.add(newResult(it, lastData, f, tag1.exceptionData)) } - existException[i] = false + tag1.existException = false } } +// repeat(config.factorCount) { i -> +// if (existException[i] && judgeDuration(sIndex[i], eIndex[i])) { +// startData[i]?.let { +// resultList.add(newResult(it, lastData, i, exceptionData[i])) +// } +// existException[i] = false +// } +// } } } } \ No newline at end of file -- Gitblit v1.9.3