From 4bec76e02dc7924b8b55f0d2ca4bf182e0cac89c Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 15 Feb 2023 21:09:04 +0800 Subject: [PATCH] [2.13.0-arch-opt] fix bug of thread problem and add new func obu fusion and warning union --- .../sweeper/view/SweeperTrafficDataView.java | 26 +++--- .../obu/MogoPrivateObuNewManager.kt | 84 ++++++++++++++----- .../hmi/ui/vehicle/SteeringBrakeView.kt | 13 +-- .../identify/MapIdentifySubscriber.kt | 51 ++++++++++- .../api/obu/IMoGoObuStatusListener.kt | 9 +- .../obu/CallerObuWarningListenerManager.kt | 8 ++ 6 files changed, 150 insertions(+), 41 deletions(-) diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java index 7db1cbbe2f..b8e5c3c370 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java @@ -89,18 +89,20 @@ public class SweeperTrafficDataView extends ConstraintLayout */ @Override public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) { - //转向灯状态 0是正常 1是左转 2是右转 - if (lightSwitch != null) { - CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString()); - if (lightSwitch.getNumber()==1){ - CallerVisualAngleManager.INSTANCE.showTurning(true); - sweeperTurnSignal.showLeftSignal(); - }else if(lightSwitch.getNumber()==2){ - CallerVisualAngleManager.INSTANCE.showTurning(true); - sweeperTurnSignal.showRightSignal(); - }else{ - CallerVisualAngleManager.INSTANCE.showTurning(false); - sweeperTurnSignal.showDirection(); + ThreadUtils.runOnUiThread { + //转向灯状态 0是正常 1是左转 2是右转 + if (lightSwitch != null) { + CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString()); + if (lightSwitch.getNumber()==1){ + CallerVisualAngleManager.INSTANCE.showTurning(true); + sweeperTurnSignal.showLeftSignal(); + }else if(lightSwitch.getNumber()==2){ + CallerVisualAngleManager.INSTANCE.showTurning(true); + sweeperTurnSignal.showRightSignal(); + }else{ + CallerVisualAngleManager.INSTANCE.showTurning(false); + sweeperTurnSignal.showDirection(); + } } } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 56ccec4d4b..71a0eab932 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -11,12 +11,14 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener import com.mogo.eagle.core.function.api.map.angle.Default import com.mogo.eagle.core.function.api.map.angle.TooClose import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew @@ -577,18 +579,24 @@ class MogoPrivateObuNewManager private constructor() { info: ObuScene.RvWarningData ) { // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 - var alertContent: String = "" - var ttsContent: String = "" + var alertContent = "" + var ttsContent = "" + var v2xType = appId var changeVisualAngle = false when (appId) { //前向碰撞预警 MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - -// ObuManager.getInstance().obuRvToTrackedObject(info) //todo emArrow + if (FunctionBuildConfig.isObuWarningFusionUnion) { + alertContent = "前车距离过近" + ttsContent = "前车距离过近" + CallerObuWarningListenerManager.invokeTrackerFusionData(ObuManager.getInstance().obuRvToTrackedObject(info)) + } else { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + } + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType } //交叉路口碰撞预警 @@ -597,6 +605,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType } //左转辅助预警 @@ -605,6 +614,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType } //盲区预警 @@ -613,6 +623,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType if ( direction == WarningDirectionEnum.ALERT_WARNING_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || @@ -638,7 +649,8 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) - if ( + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType + if ( direction == WarningDirectionEnum.ALERT_WARNING_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT @@ -661,6 +673,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType } //紧急制动预警 @@ -669,6 +682,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType } //异常车辆提醒 @@ -687,6 +701,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType alertContent = String.format(alertContent, direction.desc) ttsContent = String.format(ttsContent, direction.desc) } @@ -696,6 +711,7 @@ class MogoPrivateObuNewManager private constructor() { EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + v2xType = EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType } // 这里处理固定的提示信息,包括了<紧急车辆提醒> @@ -715,9 +731,9 @@ class MogoPrivateObuNewManager private constructor() { ) if (level == 2 || level == 3) { //不显示弹框,其它保留 - saveObuData(appId, alertContent, ttsContent) + saveObuData(v2xType, alertContent, ttsContent) CallerHmiManager.warningV2X( - appId, + v2xType, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 object : IMoGoWarningStatusListener { @@ -736,10 +752,12 @@ class MogoPrivateObuNewManager private constructor() { }, direction ) } + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了 TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { CallerMapUIServiceManager.getMarkerService() ?.updateITrafficThreatLevelInfo(it) + CallerObuWarningListenerManager.invokeTrackerWarningInfo(it) } } // 删除 @@ -751,6 +769,7 @@ class MogoPrivateObuNewManager private constructor() { it.threatLevel = 0x01 CallerMapUIServiceManager.getMarkerService() ?.updateITrafficThreatLevelInfo(it) + CallerObuWarningListenerManager.removeTrackerWarningInfo(it) } } } @@ -815,13 +834,24 @@ class MogoPrivateObuNewManager private constructor() { if (!isShowRunRedLight) { isShowRunRedLight = true CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", "changeTrafficLightStatus 闯红灯 --------> ") + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "changeTrafficLightStatus 闯红灯 --------> " + ) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) - saveObuData(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent) - showWarning(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent, WarningDirectionEnum.ALERT_WARNING_NON) + saveObuData( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, + alertContent, + ttsContent + ) + showWarning( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, + alertContent, + ttsContent, + WarningDirectionEnum.ALERT_WARNING_NON + ) } } @@ -839,16 +869,27 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = String.format( EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeedTts) + adviceSpeedTts + ) alertContent = String.format( EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeed) + adviceSpeed + ) val maxSpeed = currentLight.suggestMaxSpeed if (maxSpeed > 0) { - saveObuData(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, alertContent, ttsContent) - showWarning(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, alertContent, ttsContent, WarningDirectionEnum.ALERT_WARNING_NON) + saveObuData( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent + ) + showWarning( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent, + WarningDirectionEnum.ALERT_WARNING_NON + ) } } } @@ -914,7 +955,12 @@ class MogoPrivateObuNewManager private constructor() { /** * 消息盒子对应消息的语音播报 */ - private fun showWarning(type: String, content: String, tts: String, direction: WarningDirectionEnum) { + private fun showWarning( + type: String, + content: String, + tts: String, + direction: WarningDirectionEnum + ) { CallerHmiManager.warningV2X( type, content, diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt index 7746dfe9c5..604ae04474 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/SteeringBrakeView.kt @@ -32,6 +32,7 @@ class SteeringBrakeView(context: Context, attrs: AttributeSet?) : ConstraintLayo private const val TAG = "SteeringBrakeView" } + @Volatile private var isShowTurnLight = false private var brakeLight = -1 @@ -61,11 +62,13 @@ class SteeringBrakeView(context: Context, attrs: AttributeSet?) : ConstraintLayo "$M_HMI$TAG", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.acceleration + "-- brakeLight = " + brakeLight ) - if (!isShowTurnLight) { //在不展示转向灯的情况下,展示车辆刹车的动效 - brakeView.visibility = View.VISIBLE - brakeView.setBrakeLight(brakeLight) - } else { - brakeView.visibility = View.GONE + ThreadUtils.runOnUiThread { + if (!isShowTurnLight) { //在不展示转向灯的情况下,展示车辆刹车的动效 + brakeView.visibility = View.VISIBLE + brakeView.setBrakeLight(brakeLight) + } else { + brakeView.visibility = View.GONE + } } } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt index 0cd59447a9..fa308abe33 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt @@ -4,10 +4,13 @@ import android.content.Context import com.alibaba.android.arouter.facade.annotation.Route import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_IDENTIFY +import com.mogo.eagle.core.data.traffic.TrafficData import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.base.IMoGoSubscriber import com.mogo.eagle.core.function.api.map.marker.IMoGoIdentifyListener +import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager +import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.utilcode.util.ThreadUtils import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject @@ -21,7 +24,7 @@ import mogo.yycp.api.proto.SocketDownData */ @Route(path = PATH_IDENTIFY) class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGoSubscriber, - IMoGoAutopilotIdentifyListener { + IMoGoAutopilotIdentifyListener, IMoGoObuStatusListener { private val TAG = "MapIdentifySubscriber" @@ -37,11 +40,12 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo override fun onCrate() { CallerAutopilotIdentifyListenerManager.addListener(TAG, this) - + CallerObuWarningListenerManager.addListener(TAG, this) } override fun onDestroy() { CallerAutopilotIdentifyListenerManager.removeListener(TAG) + CallerObuWarningListenerManager.removeListener(TAG) } override fun onAutopilotIdentifyDataUpdate(trafficData: List?) { @@ -62,7 +66,6 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo try { if (FunctionBuildConfig.isDrawAiCloudFusion) { ThreadUtils.getSinglePool().execute { -// aiCloudDataDrawer.renderAiCloudResult(cloudData) IdentifyFactory.renderAiCloudResult(cloudData) } } else { @@ -74,7 +77,6 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo } fun clearAiCloudRoma() { -// aiCloudDataDrawer.clearAiMarker() IdentifyFactory.clearAiMarker() } @@ -92,6 +94,47 @@ class MapIdentifySubscriber private constructor() : IMoGoIdentifyListener, IMoGo } } + override fun updateTrackerFusionData(trackObject: TrackedObject?) { + super.updateTrackerFusionData(trackObject) + try { + if (FunctionBuildConfig.isObuWarningFusionUnion) { + ThreadUtils.getSinglePool().execute { + //todo emArrow + } + } else { + + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun updateTrackerWarningInfo(trafficData: TrafficData) { + super.updateTrackerWarningInfo(trafficData) + try { + if (FunctionBuildConfig.isObuWarningFusionUnion) { + ThreadUtils.getSinglePool().execute { + IdentifyFactory.renderOBUWarningObj(true, trafficData) + } + } else { + IdentifyFactory.renderOBUWarningObj(false, trafficData) + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun removeTrackerWarningInfo(trafficData: TrafficData) { + super.removeTrackerWarningInfo(trafficData) + try { + ThreadUtils.getSinglePool().execute { + IdentifyFactory.renderOBUWarningObj(false, trafficData) + } + } catch (e: Exception) { + e.printStackTrace() + } + } + override fun getIdentifyObj(uuid: String): TrackedObject? { return IdentifyFactory.getIdentifyObj(uuid) } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt index 27446d7979..72980475f5 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt @@ -1,7 +1,7 @@ package com.mogo.eagle.core.function.api.obu -import com.mogo.eagle.core.data.obu.ObuStatusInfo import com.mogo.eagle.core.data.traffic.TrafficData +import mogo.telematics.pad.MessagePad /** * @author xiaoyuzhou @@ -17,6 +17,13 @@ interface IMoGoObuStatusListener { } + /** + * obu Tracker data + */ + fun updateTrackerFusionData(trackObject: MessagePad.TrackedObject?){ + + } + /** * 更新obu Tracker 预警信息 */ diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuWarningListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuWarningListenerManager.kt index 228bb7fb73..0e94a35120 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuWarningListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuWarningListenerManager.kt @@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.call.obu import com.mogo.eagle.core.data.traffic.TrafficData import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener import com.mogo.eagle.core.function.call.base.CallerBase +import mogo.telematics.pad.MessagePad /** * OBU 监听管理 @@ -19,6 +20,13 @@ object CallerObuWarningListenerManager : CallerBase() { } } + fun invokeTrackerFusionData(trackObject: MessagePad.TrackedObject?){ + M_LISTENERS.forEach { + val listener = it.value + listener.updateTrackerFusionData(trackObject) + } + } + fun invokeTrackerWarningInfo(trafficData: TrafficData) { M_LISTENERS.forEach { val listener = it.value