From f75e84e8d64179a80149ff573295b62a467d26ed Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Fri, 20 Aug 2021 16:52:43 +0800 Subject: [PATCH] opt --- .../mogo/och/bus/fragment/OchBusFragment.java | 2 - .../och/bus/presenter/OchBusPresenter.java | 8 --- .../main/launcher/MainLauncherActivity.java | 4 ++ .../common/entity/V2XMessageEntity.java | 5 ++ .../module/obu/mogo/MogoPrivateObuManager.kt | 72 ++++++++++++++----- .../receiver/ObuRsuTestTriggerReceiver.kt | 7 +- .../scene/obu/V2XObuEventScenario.java | 2 - .../scenario/scene/obu/V2XObuEventWindow.java | 1 - 8 files changed, 67 insertions(+), 34 deletions(-) diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java index bc38972400..4c2bd8e0e3 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/fragment/OchBusFragment.java @@ -101,7 +101,6 @@ public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPrese getActivity().runOnUiThread( () -> { if ( stationList == null ) { // 获取小巴数据失败 - Logger.e("liyz", " stationList == null "); return; } @@ -164,7 +163,6 @@ public class OchBusFragment extends BaseOchFragment< OchBusFragment, OchBusPrese } else if ( isArriveAtStation ) { showSlidePanle( "滑动出发" ); } - Logger.d("liyz", "renderCurrentStationStatus -----> "); mCurrentStationName.setText( currentStationName ); mNextStationName.setText( nextStationName ); mStartStationFlag.setVisibility( startStationFlagVisibility ); diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java index 78a2a38e33..c7c63589bf 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java @@ -96,7 +96,6 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog public void onCreate( @NonNull LifecycleOwner owner ) { super.onCreate( owner ); Log.d(TAG, "onCreate ------> "); - Log.d("liyz", "onCreate ------> "); queryOperationStatus(); queryBusRoutes(); } @@ -106,7 +105,6 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog */ public void queryBusRoutes() { Logger.d( TAG, "查询小巴路线"); - Logger.d( "liyz", "查询小巴路线------->"); double lat = 40.1974932972; double lon = 116.7354579447; @@ -122,16 +120,13 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog @Override public void onSuccess( OchBusRoutesResponse o ) { super.onSuccess( o ); - Logger.d( "liyz", "-----1-------- o =" + o); if ( o == null || o.getResult() == null || o.getResult().getSite() == null || o.getResult().getSite().isEmpty() ) { - Logger.e( "liyz", "-----2-------- "); return; } Logger.d( TAG, "获取到小巴路线数据: " + o ); - Logger.d( "liyz", "获取到小巴路线数据: " + o ); renderBusStationsStatus( o.getResult().getSite() ); } @@ -139,7 +134,6 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog public void onError( Throwable e ) { super.onError( e ); Logger.e( TAG, e, "获取小巴路线图失败" ); - Logger.d( "liyz", "获取小巴路线图失败 "); // 重复请求小巴路线,直至成功 queryBusStationDelay(); } @@ -148,7 +142,6 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog public void onError( String message, int code ) { super.onError( message, code ); Logger.e( TAG, "获取小巴路线失败 code: " + code + " msg: " + message ); - Logger.e( "liyz", "获取小巴路线失败 code: " + code + " msg: " + message ); // 重复请求小巴路线,直至成功 queryBusStationDelay(); } @@ -162,7 +155,6 @@ public class OchBusPresenter extends Presenter< OchBusFragment > implements IMog */ private void renderBusStationsStatus( List< OchBusStation > site ) { Logger.d( TAG, "渲染站点信息"); - Logger.e( "liyz", "渲染站点信息"); int lastStopStation = getNextStopStation(); diff --git a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java index d629165e9e..5cd1973a53 100644 --- a/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java +++ b/main-extensions/mogo-module-main-launcher/src/main/java/com/zhidao/mogo/module/main/launcher/MainLauncherActivity.java @@ -26,6 +26,8 @@ import com.mogo.service.v2x.IV2XWarningListener; import com.mogo.utils.logger.Logger; import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_LEFT; +import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_RIGHT; import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT; import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT; import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP; @@ -197,6 +199,8 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis startCountDownWithView(mWarningRight); break; case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM: + case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_LEFT: + case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_RIGHT: mWarningBottom.setVisibility(View.VISIBLE); mWarningRight.setVisibility(View.GONE); mWarningTop.setVisibility(View.GONE); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java index 40101c1a17..a03fb2780c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XMessageEntity.java @@ -155,6 +155,11 @@ public class V2XMessageEntity implements Serializable { int ALERT_THE_FRONT_CRASH_WARNING_LEFT = 3; // 右前方碰撞预警 int ALERT_THE_FRONT_CRASH_WARNING_RIGHT = 4; + // 左后方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_LEFT = 5; + // 右后方碰撞预警 + int ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_RIGHT = 6; + // 推送VR消息展示 int ALERT_PUSH_VR_SHOW = 2_000; // 自车求助 diff --git a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt index d474b43fe7..3390d86a84 100644 --- a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt @@ -1,6 +1,7 @@ package com.mogo.module.obu.mogo import android.content.Context +import android.util.Log import com.alibaba.android.arouter.launcher.ARouter import com.mogo.module.common.drawer.TrafficMarkerDrawer import com.mogo.module.common.enums.WarningTypeEnum @@ -145,7 +146,7 @@ class MogoPrivateObuManager private constructor() { ObuConstants.STATUS.ADD -> { //显示警告红边 mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( - getMessageDirection(5), + getOtherObjDirection(if (info.ext_info != null) info.ext_info.pos_classification else 7 ), "ACTION_V2X_FRONT_WARNING" ) //显示弹框,语音提示 @@ -224,7 +225,7 @@ class MogoPrivateObuManager private constructor() { ObuConstants.STATUS.ADD -> { //显示警告红边 mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( - getMessageDirection(5), + getOtherObjDirection(if (!info.threat_exts.isNullOrEmpty()) info.threat_exts[0].pos_classification else 7), "ACTION_V2X_FRONT_WARNING" ) val ttsContent = WarningTypeEnum.getWarningTts(appId) @@ -282,10 +283,30 @@ class MogoPrivateObuManager private constructor() { TrafficDataConvertUtils.cvxPtcInfoIndInfo2TrafficData(info)?.let { TrafficMarkerDrawer.updateITrafficInfo(it) } + + var ttsContent = "" + var alertContent = "" + ttsContent = WarningTypeEnum.getWarningTts(ObuConstants.USE_CASE_ID.VRUCW) + alertContent = WarningTypeEnum.getWarningContent(ObuConstants.USE_CASE_ID.VRUCW) + if (info.ptc_type == 1) { //摩托车 + ttsContent = String.format(ttsContent, "摩托车") + alertContent = String.format(alertContent, "摩托车") + } else if (info.ptc_type == 2) { //行人 + ttsContent = String.format(ttsContent, "行人") + alertContent = String.format(alertContent, "行人") + } + + mIMoGoWaringProvider!!.showWarningV2X( + ObuConstants.USE_CASE_ID.VRUCW, + alertContent, + ttsContent, + ObuConstants.USE_CASE_ID.VRUCW.toString() + ) } // 删除 ObuConstants.STATUS.DELETE -> { TrafficMarkerDrawer.removeCvxRvInfoIndInfo(info.id) + mIMoGoWaringProvider?.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString()) } // 更新 else -> { @@ -349,23 +370,38 @@ class MogoPrivateObuManager private constructor() { } /** - * 获取消息的方位 + * 获取消息的方位 车辆相关 */ private fun getMessageDirection(targetClassification: Int): Int { return when (targetClassification) { ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE -> 1 //正前方 + ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT, + ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 2 //正后方 ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> 3 //左前方 ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> 4 //右前方 - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 2 //左后方 弹框目前后方分为左后,右后,正后方 - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 2 //右后方 - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 2 //正后方 + ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 5 //左后方 弹框目前后方分为左后,右后,正后方 + ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 6 //右后方 ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> 0 //未知 else -> 7 } } + /** + * 获取道路其他 的方位 + */ + private fun getOtherObjDirection(posClassification: Int): Int { + return when(posClassification) { + 0x01 -> 0 //事件中 + 0x02 -> 3 //左侧 + 0x03 -> 4 //右侧 + 0x04 -> 1 //前方 + 0x05 -> 2 //后方 + + else -> 7 + } + + } fun release() { MogoObuManager.getInstance().unregisterListener() @@ -416,7 +452,7 @@ class MogoPrivateObuManager private constructor() { 0x1 -> { //显示警告红边 mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( - getMessageDirection(5), + 1, "ACTION_V2X_FRONT_WARNING" ) mIMoGoWaringProvider?.showWarningTrafficLight(1) @@ -482,9 +518,9 @@ class MogoPrivateObuManager private constructor() { WarningTypeEnum.TYPE_USECASE_ID_LCW.useCaseId -> { alertContent = WarningTypeEnum.getWarningContent(appId) ttsContent = WarningTypeEnum.getWarningTts(appId) - if (direction == 2) { + if (direction == 5) { ttsContent = String.format(ttsContent, "左") - } else if (direction == 4) else { + } else if (direction == 6) else { ttsContent = String.format(ttsContent, "右") } } @@ -494,13 +530,13 @@ class MogoPrivateObuManager private constructor() { alertContent = WarningTypeEnum.getWarningContent(appId) ttsContent = WarningTypeEnum.getWarningTts(appId) when (direction) { - 1 -> { //左前 + 3 -> { //左前 ttsContent = String.format(ttsContent, "左") } - 3 -> { //右前 + 4 -> { //右前 ttsContent = String.format(ttsContent, "右") } - 5 -> { //正前 + 1 -> { //正前 ttsContent = alertContent } } @@ -511,13 +547,13 @@ class MogoPrivateObuManager private constructor() { alertContent = WarningTypeEnum.getWarningContent(appId) ttsContent = WarningTypeEnum.getWarningTts(appId) when (direction) { - 1 -> { //左前 + 3 -> { //左前 ttsContent = String.format(ttsContent, "左") } - 3 -> { //右前 + 4 -> { //右前 ttsContent = String.format(ttsContent, "右") } - 5 -> { //正前 + 1 -> { //正前 ttsContent = alertContent } } @@ -526,9 +562,9 @@ class MogoPrivateObuManager private constructor() { //盲区预警 WarningTypeEnum.TYPE_USECASE_ID_BSW.useCaseId -> { ttsContent = WarningTypeEnum.getWarningTts(appId) - if (direction == 2) { + if (direction == 5) { //左后 ttsContent = String.format(ttsContent, "左") - } else if (direction == 4) else { + } else if (direction == 6) else { //右后 ttsContent = String.format(ttsContent, "右") } alertContent = WarningTypeEnum.getWarningContent(appId) diff --git a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt index fd4c1d524a..6b05d77e97 100644 --- a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt @@ -73,9 +73,8 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { //弱势交通参与者碰撞预警,行人/摩托车碰撞预警 ObuConstants.USE_CASE_ID.VRUCW -> { val cvxPtcIndInfo = CvxPtcInfoIndInfo(1,1,1) - - val position = Position(0, 399739429, 1164115207, 20) - val movingObjectInfo = MovingObjectInfo(0, position, 1800, 6000) + val position = Position(1, 399739429, 1164115207, 20) + val movingObjectInfo = MovingObjectInfo(1, position, 1800, 6000) cvxPtcIndInfo.basic_info = movingObjectInfo cvxPtcIndInfo.id = "111" cvxPtcIndInfo.ptc_type = pctType @@ -96,6 +95,8 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { MogoPrivateObuManager.INSTANCE.getMogoObuListener().onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo) } + + } } 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 1c31e14dc8..8d832562f5 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 @@ -114,11 +114,9 @@ public class V2XObuEventScenario extends AbsV2XScenario imple } } else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CROSS_COLLISION_WARNING && !isCrossWarning) { AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_CROING_WARN_TEXT); - Log.d("liyz", "jiao cha lu kou---->"); isCrossWarning = true; } else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_URGENCY_COLLISION_WARNING && !isUrgenchyWarning) { AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE); - Log.d("liyz", " jin ji zhi dong---->"); isUrgenchyWarning = true; } 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 fc5bbfb829..0bf1a5ed0b 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,6 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow