opt BlockStrategy.kt
This commit is contained in:
@@ -50,7 +50,7 @@ private const val SPEED_NORMAL_COUNT = "SPEED _NORMAL_COUNT"
|
||||
*/
|
||||
class BlockStrategy(private val context: Context, private val apis: IMogoServiceApis) {
|
||||
private var startRecordTime: Long = 0
|
||||
private var speedCacheList = ArrayList<Float>()
|
||||
private var speedCacheList = ArrayList<Int>()
|
||||
|
||||
/**
|
||||
* 停车标志位,当速度为0时加1,超过[STOP_FLAG_THRESHOLD]判定为停车,不认为是拥堵,这组数据无效
|
||||
@@ -91,9 +91,9 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService
|
||||
speedCacheList.clear()
|
||||
}
|
||||
|
||||
speedCacheList.add(speed)
|
||||
speedCacheList.add(currentSpeed)
|
||||
|
||||
if (speed == 0F) {
|
||||
if (currentSpeed == 0) {
|
||||
stopFlag++
|
||||
} else if (stopFlag < STOP_FLAG_THRESHOLD) {
|
||||
// 如果本次计算期间,stopFlag还没超过阈值,就置为零,如果超过阈值了,说明本次计算期间存在超过阈值的停止次数,就舍弃掉本次计算
|
||||
@@ -135,7 +135,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService
|
||||
// 到达时间限制,上报速度,数据清空
|
||||
if (stopFlag < STOP_FLAG_THRESHOLD) {
|
||||
// 停车标志位小于阈值,判定不是停车,计算平均值,进行上报
|
||||
var sum = 0F
|
||||
var sum = 0
|
||||
speedCacheList.forEach {
|
||||
sum += it
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user