[6.10.0][Fix]解决车龙事件频繁展示的问题
This commit is contained in:
@@ -61,7 +61,6 @@ import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.telematics.pad.MessagePad.V2nCrossSpeed
|
||||
import mogo.v2x.MogoV2X
|
||||
import mogo.v2x.MogoV2X.RSI_PB
|
||||
import java.util.HashMap
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
@@ -80,6 +79,10 @@ internal object V2NIdentifyDrawer : IEventDismissListener {
|
||||
|
||||
private val scope by lazy { CoroutineScope(ThreadUtils.getCpuPool().asCoroutineDispatcher()) }
|
||||
|
||||
private var lastMap = HashMap<Int, Int>()
|
||||
private var lastMap2 = HashMap<Int, String>()
|
||||
private var lastTime = 0L
|
||||
|
||||
private val callback = Handler.Callback { msg ->
|
||||
if (msg.what == MSG_WHAT_DRAW_SHIGONE || msg.what == MSG_WHAT_DRAW_SHIGU) {
|
||||
val events = msg.obj as? List<*>
|
||||
@@ -619,7 +622,6 @@ internal object V2NIdentifyDrawer : IEventDismissListener {
|
||||
Handler(thread.looper, callback)
|
||||
}
|
||||
|
||||
private var lastMap = HashMap<Int, Int>()
|
||||
private val listener = object : IMoGoAutopilotIdentifyListener {
|
||||
|
||||
override fun onAutopilotIdentifyDataUpdate(trafficData: List<TrackedObject>?) {
|
||||
@@ -635,48 +637,7 @@ internal object V2NIdentifyDrawer : IEventDismissListener {
|
||||
if (!shiGu.isNullOrEmpty()) {
|
||||
drawShiGu(shiGu)
|
||||
}
|
||||
var hasCheLong = false
|
||||
val roadMsgList = ArrayList<NDEMsg.RoadMsg>()
|
||||
trafficData?.forEach { obj ->
|
||||
if (obj.type == 707 && obj.polygonCount > 1) {// 当次数据有车龙事件
|
||||
synchronized(this) {
|
||||
val isSameSize = (lastMap.isNotEmpty() && lastMap.size == trafficData.size)// 判断是否是重复数据
|
||||
// 个数不一样或前后两次uuid不同
|
||||
if (!isSameSize || lastMap[obj.uuid] == null) {
|
||||
// 所有车道的uuid都要存储起来
|
||||
trafficData.forEach { objNew ->
|
||||
lastMap[objNew.uuid] = 1
|
||||
roadMsgList.add(
|
||||
NDEMsg.RoadMsg(
|
||||
objNew.arrowType, laneNum = objNew.laneNum,
|
||||
isRecommend = objNew.suggestedLanes, isCheLong = objNew.polygonCount > 1
|
||||
)
|
||||
)
|
||||
}
|
||||
hasCheLong = true
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasCheLong) {
|
||||
val sortedList = roadMsgList.sortedWith(compareByDescending { it.laneNum })
|
||||
saveMsgBox(MsgBoxBean(
|
||||
MsgBoxType.NDE,
|
||||
NDEMsg(
|
||||
"", "路口车龙", "前方路口有车龙"
|
||||
).also {
|
||||
it.setRoadList(sortedList)
|
||||
}
|
||||
))
|
||||
// 司机屏才TTS
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
AIAssist.getInstance(Utils.getApp())
|
||||
.speakTTSVoiceWithLevel("蘑菇发现前方路口有车龙", AIAssist.NEW_LEVEL_2)
|
||||
}
|
||||
}
|
||||
}
|
||||
handleCheLong(trafficData)
|
||||
}
|
||||
|
||||
|
||||
@@ -794,4 +755,73 @@ internal object V2NIdentifyDrawer : IEventDismissListener {
|
||||
// val targetIds = event.exts.split(",")
|
||||
// }
|
||||
}
|
||||
|
||||
private fun handleCheLong(trafficData: List<TrackedObject>?) {
|
||||
var hasCheLong = false
|
||||
var isNewData = false
|
||||
val roadMsgList = ArrayList<NDEMsg.RoadMsg>()
|
||||
val curMap = HashMap<Int, String>()
|
||||
if (lastTime > 0 && System.currentTimeMillis() - lastTime > 60000) {
|
||||
lastMap2.clear()// 清除上次车龙事件的缓存
|
||||
}
|
||||
var lastLocStr: String? = ""
|
||||
trafficData?.forEach { obj ->
|
||||
if (obj.type == 707) {// 当前方向所有车道
|
||||
if (obj.polygonCount > 1) {// 当次数据有车龙事件
|
||||
lastLocStr = lastMap2[obj.laneNum]
|
||||
// 1. 上次无车龙但此次有车龙,认为是新车龙事件
|
||||
// 2. 两次都有车龙,则判断车龙的长度是否相同
|
||||
if (lastLocStr == null || lastLocStr == "0" || lastLocStr != "${obj.polygonList[0]}-${obj.polygonList[obj.polygonCount - 1]}") {
|
||||
isNewData = true
|
||||
}
|
||||
hasCheLong = true
|
||||
|
||||
// key: 车道号,value: 非0代表有车龙且首、尾两个点可计算车龙长度
|
||||
curMap[obj.laneNum] =
|
||||
"${obj.polygonList[0]}-${obj.polygonList[obj.polygonCount - 1]}"
|
||||
} else {// 当次没有车龙
|
||||
if (lastMap2[obj.laneNum] != null && lastMap2[obj.laneNum] != "0") {// 3. 上次有车龙,这次无车龙
|
||||
isNewData = true
|
||||
}
|
||||
// key: 车道号,value: 0代表无车龙
|
||||
curMap[obj.laneNum] = "0"
|
||||
}
|
||||
// 保存所有车道信息
|
||||
roadMsgList.add(
|
||||
NDEMsg.RoadMsg(
|
||||
obj.arrowType,
|
||||
laneNum = obj.laneNum,
|
||||
isRecommend = obj.suggestedLanes,
|
||||
isCheLong = obj.polygonCount > 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (isNewData) {
|
||||
// 清除上次车道信息
|
||||
lastMap2.clear()
|
||||
if (hasCheLong) {
|
||||
// 缓存当次车龙事件所有车道信息
|
||||
lastMap2.putAll(curMap)
|
||||
lastTime = System.currentTimeMillis()
|
||||
|
||||
val sortedList = roadMsgList.sortedWith(compareByDescending { it.laneNum })
|
||||
saveMsgBox(MsgBoxBean(
|
||||
MsgBoxType.NDE,
|
||||
NDEMsg(
|
||||
"", "路口车龙", "前方路口有车龙"
|
||||
).also {
|
||||
it.setRoadList(sortedList)
|
||||
}
|
||||
))
|
||||
// 司机屏才TTS
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
AIAssist.getInstance(Utils.getApp())
|
||||
.speakTTSVoiceWithLevel("蘑菇发现前方路口有车龙", AIAssist.NEW_LEVEL_2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user