diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java index b86800b5ba..fc56d5c187 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java @@ -20,6 +20,8 @@ import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.entity.V2XMessageEntity; import com.mogo.module.common.entity.V2XObuEventEntity; import com.mogo.module.common.entity.V2XPushMessageEntity; +import com.mogo.module.service.MarkerServiceHandler; +import com.mogo.module.service.receiver.MogoReceiver; import com.mogo.module.v2x.listener.V2XLocationListener; import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario; import com.mogo.module.v2x.utils.ADASUtils; @@ -96,6 +98,13 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { NebulaObuClient.getInstance().registerObu(100); NebulaObuClient.getInstance().registerObuListener(listener); +// UiThreadHandler.postDelayed( () -> { +// //TODO 测试 +// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(3, MogoReceiver.ACTION_V2X_FRONT_WARNING); +// handleSdkObu(1); +// +// }, 5_000L ); + IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE"); context.registerReceiver(obuTypeExchangeReceiver, filter); } @@ -137,7 +146,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { Logger.d("liyz", "onWarningInfo type ------> " + info.getWarningtype() + "--size = " + infoList.size()); if (info.getWarningtype() == 3) { if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - handleSdkObu(); + handleSdkObu(2); } } } @@ -145,14 +154,23 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { } }; - private void handleSdkObu() { + + private void handleSdkObu(int type) { V2XMessageEntity messageEntity = new V2XMessageEntity<>(); messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT); - // 前车紧急制动预警 V2XObuEventEntity urgencyEvent = new V2XObuEventEntity(); - urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING); - urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT); + if (type == 1) { //交叉路口碰撞预警 TODO + urgencyEvent.setType(ObuConstant.TYPE_CROSS_COLLISION_WARNING); + urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_CROING_WARN_TEXT); + } else if (type == 2) { // 前车紧急制动预警 + urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING); + urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT); + } else { + urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING); + urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT); + } + messageEntity.setContent(urgencyEvent); V2XObuEventScenario.getInstance().init(messageEntity); } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventScenario.java index 8cec04c52e..ec962d4b1b 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventScenario.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventScenario.java @@ -44,6 +44,8 @@ public class V2XObuEventScenario extends AbsV2XScenario imple public static final String URGENCY_COLLISION_WARN_TEXT_ONE = "前车急刹,注意保持安全距离!"; public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹"; + public static final String URGENCY_CROING_WARN_TEXT = "交叉路口碰撞预警"; + private static final int MSG_CLOSE_OBU_WINDOW = 1001; private static final int DEFAULT_EXPIRE_TIME = 20_000; @@ -110,7 +112,12 @@ public class V2XObuEventScenario extends AbsV2XScenario imple } else { optimalSpeedMarker.clearPOI(); } + } else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CROSS_COLLISION_WARNING) { + AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_CROING_WARN_TEXT); + } else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_URGENCY_COLLISION_WARNING) { + AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE); } + show(); } @@ -121,7 +128,7 @@ public class V2XObuEventScenario extends AbsV2XScenario imple */ @Override public void show() { - AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE); +// AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE); showWindow(); if (handler.hasMessages(MSG_CLOSE_OBU_WINDOW)) { handler.removeMessages(MSG_CLOSE_OBU_WINDOW); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java index fca42116b3..44b5f8a400 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java @@ -66,7 +66,7 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow - +