| | |
| | | |
| | | /** |
| | | * 判断异常出现的连续时长是否满足条件 |
| | | * @param sIndex |
| | | * @param eIndex |
| | | */ |
| | | abstract fun judgeDuration(sIndex: Int, eIndex: Int): Boolean |
| | | |
| | |
| | | // existException.add(false) |
| | | // exceptionData.add(mutableListOf()) |
| | | // } |
| | | tagMap.clear() |
| | | config.factorFilter.mainList().forEach {f-> |
| | | tagMap[f] = Tag() |
| | | } |
| | |
| | | override fun onNextData(data: BaseRealTimeData) { |
| | | val isContinue = isContinuous(lastData, data) |
| | | val hasException = judgeException(lastData, data) |
| | | config.factorFilter.mainList().forEach {f-> |
| | | config.factorFilter.selectedList.forEach {s-> |
| | | val f = s.main |
| | | tagMap[f]?.let { |
| | | it.eIndex++ |
| | | // 起始数据 |
| | | it.endData = lastData |
| | | if (it.endData == null) { |
| | | it.refreshAfterCheckResult(data) |
| | | } |
| | | // 判断相邻数据是否连续并且是否满足异常判断 |
| | | if (!isContinue) { |
| | | checkResult() |
| | | checkResult(s) |
| | | // 数据不连续时,记录异常情况 |
| | | if (it.eIndex - it.sIndex >= durationCount) { |
| | | it.refreshAfterCheckResult(data) |
| | |
| | | it.exceptionData.add(data) |
| | | } else { |
| | | // 异常不再重复出现时,记录异常情况 |
| | | checkResult() |
| | | checkResult(s) |
| | | if (it.eIndex - it.sIndex >= durationCount) { |
| | | it.refreshAfterCheckResult(data) |
| | | } |
| | |
| | | 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)) { |
| | | if (tag.existException && judgeDuration(tag.sIndex, tag.eIndex - 1)) { |
| | | tag.startData?.let { |
| | | resultList.add(newResult(it, lastData, factor, tag.exceptionData)) |
| | | } |
| | |
| | | } else { |
| | | config.factorFilter.selectedList.forEach { f -> |
| | | val tag1 = tagMap[f.main] ?: return@forEach |
| | | if (tag1.existException && judgeDuration(tag1.sIndex, tag1.eIndex)) { |
| | | if (tag1.existException && judgeDuration(tag1.sIndex, tag1.eIndex - 1)) { |
| | | tag1.startData?.let { |
| | | resultList.add(newResult(it, lastData, f, tag1.exceptionData)) |
| | | } |