| | |
| | | package com.flightfeather.monitor.analysis.dust |
| | | |
| | | import com.flightfeather.monitor.analysis.DataAnalysisInterface |
| | | import com.flightfeather.monitor.domain.ds1.entity.DustExceptionSetting |
| | | import com.flightfeather.monitor.domain.ds1.entity.DustSiteData |
| | | import java.util.* |
| | | import kotlin.properties.Delegates |
| | | import com.flightfeather.monitor.enumration.dust.ExceptionType |
| | | import kotlin.math.abs |
| | | |
| | | /** |
| | | * 量级突变异常分析 |
| | | */ |
| | | class ExceptionValueMutation(config: DustExceptionSetting) : DataAnalysisInterface<DustSiteData, |
| | | DustExceptionSetting>(config) { |
| | | class ExceptionValueMutation(config: DustExceptionSetting) : BaseExceptionContinuous(config) { |
| | | |
| | | private var mutationNum by Delegates.notNull<Int>() |
| | | override fun getExceptionType(): ExceptionType = ExceptionType.TYPE4 |
| | | |
| | | private var mutationRate by Delegates.notNull<Double>() |
| | | |
| | | private var lastDataTime: Date? = null |
| | | |
| | | override fun initConfig(config: DustExceptionSetting) { |
| | | mutationNum = config.mutationNum |
| | | mutationRate = config.mutationRate |
| | | override fun judgeException(p: DustSiteData?, n: DustSiteData): Boolean { |
| | | if (p == null) return false |
| | | return abs((p.dustValue - n.dustValue) / p.dustValue) >= config.mutationRate |
| | | } |
| | | |
| | | override fun onNextData(data: DustSiteData) { |
| | | if (lastDataTime != null) { |
| | | // 相邻数据时间小于或等于30分钟分为一组 |
| | | } |
| | | |
| | | lastDataTime = data.lst |
| | | override fun judgeDuration(sIndex: Int, eIndex: Int): Boolean { |
| | | return (eIndex - sIndex) >= config.mutationNum |
| | | } |
| | | |
| | | override fun toDb() { |
| | | TODO("Not yet implemented") |
| | | } |
| | | |
| | | |
| | | } |