From da2a9a9add7c17e7f111185f98fced74afad7051 Mon Sep 17 00:00:00 2001 From: renwj Date: Thu, 25 Jul 2024 11:54:57 +0800 Subject: [PATCH] =?UTF-8?q?[6.5.0][=E9=81=93=E8=B7=AF=E4=BA=8B=E4=BB=B6]?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E9=81=93=E8=B7=AF=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=8D=A0=E9=81=93=E7=AD=96=E7=95=A5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=EF=BC=8C=E7=BB=9F=E4=B8=80=E6=96=87?= =?UTF-8?q?=E6=A1=88=E5=92=8Ctts=E8=AF=AD=E9=9F=B3=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt | 208 +++++++++--------- 1 file changed, 109 insertions(+), 99 deletions(-) diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt index 3d36910837..914ca0f22e 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt @@ -3,7 +3,6 @@ package com.mogo.eagle.function.biz.v2x.v2n.pnc import android.os.Handler import android.os.HandlerThread import android.os.Message -import android.util.Log import androidx.core.util.Pair import com.mogo.commons.voice.AIAssist import com.mogo.eagle.core.data.config.FunctionBuildConfig @@ -28,7 +27,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NC import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.hmi.CallerRoadV2NEventWindowListenerManager -import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger @@ -46,7 +44,6 @@ import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker.Ma import com.mogo.eagle.function.biz.v2x.v2n.utils.EventDismissBean import com.mogo.eagle.function.biz.v2x.v2n.utils.EventDismissManager import com.mogo.eagle.function.biz.v2x.v2n.utils.IEventDismissListener -import com.mogo.eagle.function.biz.v2x.v2n.utils.V2NUtils import com.mogo.eagle.function.biz.v2x.v2n.utils.V2XEventAnalyticsManager import com.mogo.map.entities.Lane import kotlinx.coroutines.CoroutineScope @@ -104,11 +101,11 @@ internal object V2NIdentifyDrawer: IEventDismissListener { AiRoadMarker.aiMakers.getOrPut(id) { AiRoadMarker().apply { scope.launch { - Log.d("V2NIdentifyDrawer", "--- 判断是否在路口 ---") - while (CallerMapRoadListenerManager.isInRoadCross()) { - delay(2000) - } - Log.d("V2NIdentifyDrawer", "--- 不在路口了 ---") +// Log.d("V2NIdentifyDrawer", "--- 判断是否在路口 ---") +// while (CallerMapRoadListenerManager.isInRoadCross()) { +// delay(2000) +// } +// Log.d("V2NIdentifyDrawer", "--- 不在路口了 ---") val poiType = getPoiType(itx.type).poiType val polygon = itx.polygonList.map { Pair.create(it.longitude, it.latitude) } marker(Marker(id, @@ -143,69 +140,82 @@ internal object V2NIdentifyDrawer: IEventDismissListener { car.longitude, car.latitude ) - val alertContent = getAlertContent(poiType, distance.toDouble()) - val ttsContent = getTtsContent(poiType, distance.toDouble()) +// if (polygon.isNotEmpty()) { +// val decision = V2NUtils.computeOccupyLanesInfo(Triple(car.longitude, car.latitude, car.heading.toFloat()), Triple(itx.longitude, itx.latitude, itx.heading.toFloat()), polygon.map { kotlin.Pair(it.first, it.second) }) +// if (decision != null) { +// val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) +// val total = decision.total +// val occupy = decision.occupy +// val laneId = decision.laneId +// val sb = StringBuilder() +// V2XBizTrace.onAck(decision, "计算出道路事件占道决策数据1") +// if (laneId != null) { +// val isOccupy = occupy.find { it.id == laneId } != null +// if (isOccupy) { +// if (isDriver) { +// val bestLane = V2NUtils.computeBestLane(laneId, occupy, total) +// V2XBizTrace.onAck(bestLane, "计算出最优车道") +// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇建议您尽快${bestLane.second}") +// } else { +// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") +// } +// } else { +// if (isDriver) { +// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇提醒您小心${ if (computeDirection(laneId, occupy) > 0) "右侧" else "左侧" }行人及来车") +// } else { +// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") +// } +// } +// } else { +// sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") +// } +// if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { +// runCatching { +// CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START) +// } +// scope.launch { +// delay(5000) +// runCatching { +// CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP) +// } +// } +// } +// val ss = sb.toString() +// val content = ss.substring(0, ss.indexOf("@@")) +// val tts = ss.replace("@@", "") +// CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude) +// } +// } + val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) + if (!isDriver) { + runCatching { + CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START) + } + scope.launch { + delay(5000) + runCatching { + CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP) + } + } + } + val content = "发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }" + val tts = "$content, 蘑菇提醒您小心行人及来车" V2XBizTrace.onAck(TAG, "绘制poi事件:$poiType") saveMsgBox( MsgBoxBean( V2X, V2XMsg( poiType, - alertContent, - ttsContent, + content, + tts, CommunicationType.V2N.name ) ) ) - if (polygon.isNotEmpty()) { - val decision = V2NUtils.computeOccupyLanesInfo(Triple(car.longitude, car.latitude, car.heading.toFloat()), Triple(itx.longitude, itx.latitude, itx.heading.toFloat()), polygon.map { kotlin.Pair(it.first, it.second) }) - if (decision != null) { - val isDriver = AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) - val total = decision.total - val occupy = decision.occupy - val laneId = decision.laneId - val sb = StringBuilder() - V2XBizTrace.onAck(decision, "计算出道路事件占道决策数据1") - if (laneId != null) { - val isOccupy = occupy.find { it.id == laneId } != null - if (isOccupy) { - if (isDriver) { - val bestLane = V2NUtils.computeBestLane(laneId, occupy, total) - V2XBizTrace.onAck(bestLane, "计算出最优车道") - sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇建议您尽快${bestLane.second}") - } else { - sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") - } - } else { - if (isDriver) { - sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇提醒您小心${ if (computeDirection(laneId, occupy) > 0) "右侧" else "左侧" }行人及来车") - } else { - sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") - } - } - } else { - sb.append("发现前方${distance.toInt()}米${ if (poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType) "车道施工" else "车道事故" }@@, 蘑菇时刻为您守护") - } - if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { - runCatching { - CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), START) - } - scope.launch { - delay(5000) - runCatching { - CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), STOP) - } - } - } - val ss = sb.toString() - val content = ss.substring(0, ss.indexOf("@@")) - val tts = ss.replace("@@", "") - CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude) - } - } + CallerRoadV2NEventWindowListenerManager.showLiveVideo(id, itx.detectStartTime.takeIf { it > 0 } ?: System.currentTimeMillis(), EventTypeEnumNew.getUpdateIconRes(poiType), content, isDriver, tts, itx.cameraIp, itx.longitude, itx.latitude) //消息埋点 V2XEventAnalyticsManager.triggerV2XEvent( - poiType, alertContent, ttsContent, + poiType, content, tts, DataSourceType.AICLOUD, CommunicationType.V2N ) } @@ -416,31 +426,31 @@ internal object V2NIdentifyDrawer: IEventDismissListener { true } - private fun computeDirection(laneId: Int, occupy: List): Int { - val left = occupy.first() - return if (laneId <= left.id) { - 1 - } else { - -1 - } - } +// private fun computeDirection(laneId: Int, occupy: List): Int { +// val left = occupy.first() +// return if (laneId <= left.id) { +// 1 +// } else { +// -1 +// } +// } - private fun getTtsContent(poiType: String, distance: Double): String { - return when (poiType) { - EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> { - "前方${distance.toInt()}米道路施工" - } - EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> { - "前方${distance.toInt()}米交通事故" - } - EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> { - "前方${distance.toInt()}米交通拥堵" - } - else -> { - throw AssertionError("error!!!") - } - } - } +// private fun getTtsContent(poiType: String, distance: Double): String { +// return when (poiType) { +// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> { +// "前方${distance.toInt()}米道路施工" +// } +// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> { +// "前方${distance.toInt()}米交通事故" +// } +// EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> { +// "前方${distance.toInt()}米交通拥堵" +// } +// else -> { +// throw AssertionError("error!!!") +// } +// } +// } private fun computeCrossCountBetween(start: Triple, end: kotlin.Pair): Int { // val points = V2NUtils.generateIntermediatePoints(kotlin.Pair(start.first, start.second), end, 50.0 * 1e-7) @@ -458,22 +468,22 @@ internal object V2NIdentifyDrawer: IEventDismissListener { return 1 } - private fun getAlertContent(poiType: String, distance: Double): String { - return when (poiType) { - EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> { - "前方${distance.toInt()}米道路施工" - } - EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> { - "前方${distance.toInt()}米交通事故" - } - EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> { - "前方${distance.toInt()}米交通拥堵" - } - else -> { - throw AssertionError("error!!!") - } - } - } +// private fun getAlertContent(poiType: String, distance: Double): String { +// return when (poiType) { +// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType -> { +// "前方${distance.toInt()}米道路施工" +// } +// EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.poiType -> { +// "前方${distance.toInt()}米交通事故" +// } +// EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.poiType -> { +// "前方${distance.toInt()}米交通拥堵" +// } +// else -> { +// throw AssertionError("error!!!") +// } +// } +// } private fun isDrawRoadLine(poiType: String): Boolean { // return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType == poiType