From 6cd25a6d7de612171a4f3b7e87b0f8c201f1fb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Fri, 20 Aug 2021 18:46:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BA=A2=E7=BB=BF=E7=81=AF?= =?UTF-8?q?=E7=9A=84=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../map/impl/custom/CustomMapApiBuilder.java | 2 +- .../module/common/enums/WarningTypeEnum.kt | 2 +- .../module/obu/mogo/MogoPrivateObuManager.kt | 87 ++++++++++--------- .../receiver/ObuRsuTestTriggerReceiver.kt | 38 ++++---- 4 files changed, 70 insertions(+), 59 deletions(-) diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java index 2640a5a819..c74e809667 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java @@ -95,7 +95,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder { public IMogoMapView getMapView( Context context ) { Log.d(TAG,"setDebugMode==true"); NavAutoApi.INSTANCE.init( context, MapParams.Companion.init() - .setDebugMode( DebugConfig.isDebug() ) + .setDebugMode( false ) .setDataFileSource(1) //todo 1-使用本地地图数据,0-使用在线地图数据 .setCoordinateType( MapParams.COORDINATETYPE_GCJ02 ) .setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D ) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/WarningTypeEnum.kt b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/WarningTypeEnum.kt index 0004e23e35..c3890acf54 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/WarningTypeEnum.kt +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/WarningTypeEnum.kt @@ -135,7 +135,7 @@ enum class WarningTypeEnum( 0x2B091, "绿波通行 %s km/h", "路口红灯,禁止通行", - "保持车速 %s km/h,可直接通过路口", + "保持车速 %s 公里每小时,可直接通过路口", R.drawable.icon_warning_v2x_traffic_lights_green ), TYPE_USECASE_ID_COC( 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 3390d86a84..11ad0ad2a2 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,7 +1,6 @@ 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 @@ -146,7 +145,7 @@ class MogoPrivateObuManager private constructor() { ObuConstants.STATUS.ADD -> { //显示警告红边 mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( - getOtherObjDirection(if (info.ext_info != null) info.ext_info.pos_classification else 7 ), + getOtherObjDirection(if (info.ext_info != null) info.ext_info.pos_classification else 7), "ACTION_V2X_FRONT_WARNING" ) //显示弹框,语音提示 @@ -225,7 +224,7 @@ class MogoPrivateObuManager private constructor() { ObuConstants.STATUS.ADD -> { //显示警告红边 mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( - getOtherObjDirection(if (!info.threat_exts.isNullOrEmpty()) info.threat_exts[0].pos_classification else 7), + getOtherObjDirection(if (!info.threat_exts.isNullOrEmpty()) info.threat_exts[0].pos_classification else 7), "ACTION_V2X_FRONT_WARNING" ) val ttsContent = WarningTypeEnum.getWarningTts(appId) @@ -255,19 +254,25 @@ class MogoPrivateObuManager private constructor() { // CVX_IVP_THREAT_IND 红绿灯 override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) { Logger.d(MogoObuConst.TAG_MOGO_OBU, "CvxIvpThreatIndInfo ------> $info") - info?.let { - handlerTrafficLight(info.status, info.ext_info.lights, info.threat_info.app_id) + if (info != null && info.ext_info != null && info.ext_info.lights.isNotEmpty()) { + handlerTrafficLight( + info.threat_info.app_id, + info.status, + info.ext_info.lights, + info.ext_info.indicator + ) } } // CVX_MAP_SPAT_INFO_IND 地图红绿灯信息 override fun onCvxMapSpatInfoIndInfo(info: CvxMapSpatInfoIndInfo?) { Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxMapSpatInfoIndInfo ------> $info") - info?.let { + if (info != null && info.ivp_threat_ext != null && info.ivp_threat_ext.lights.isNotEmpty()) { handlerTrafficLight( + info.ivp_threat_info.app_id, info.status, info.ivp_threat_ext.lights, - info.ivp_threat_info.app_id + info.ivp_threat_ext.indicator ) } } @@ -287,7 +292,8 @@ class MogoPrivateObuManager private constructor() { var ttsContent = "" var alertContent = "" ttsContent = WarningTypeEnum.getWarningTts(ObuConstants.USE_CASE_ID.VRUCW) - alertContent = WarningTypeEnum.getWarningContent(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, "摩托车") @@ -297,10 +303,10 @@ class MogoPrivateObuManager private constructor() { } mIMoGoWaringProvider!!.showWarningV2X( - ObuConstants.USE_CASE_ID.VRUCW, - alertContent, - ttsContent, - ObuConstants.USE_CASE_ID.VRUCW.toString() + ObuConstants.USE_CASE_ID.VRUCW, + alertContent, + ttsContent, + ObuConstants.USE_CASE_ID.VRUCW.toString() ) } // 删除 @@ -391,8 +397,8 @@ class MogoPrivateObuManager private constructor() { * 获取道路其他 的方位 */ private fun getOtherObjDirection(posClassification: Int): Int { - return when(posClassification) { - 0x01 -> 0 //事件中 + return when (posClassification) { + 0x01 -> 0 //事件中 0x02 -> 3 //左侧 0x03 -> 4 //右侧 0x04 -> 1 //前方 @@ -410,14 +416,11 @@ class MogoPrivateObuManager private constructor() { /** * 处理红绿灯 */ - private fun handlerTrafficLight(status: Int, lights: List, appId: Int) { - var alertContent = "" - var ttsContent = "" - + private fun handlerTrafficLight(appId: Int, status: Int, lights: List, indicator: Int) { when (status) { // 添加 ObuConstants.STATUS.ADD -> { - changeTrafficLightStatus(lights, ttsContent, appId, alertContent) + changeTrafficLightStatus(appId, lights, indicator) } // 删除 ObuConstants.STATUS.DELETE -> { @@ -426,7 +429,7 @@ class MogoPrivateObuManager private constructor() { mIMoGoWaringProvider?.disableWarningV2X(appId.toString()) } else -> { - changeTrafficLightStatus(lights, ttsContent, appId, alertContent) + changeTrafficLightStatus(appId, lights, indicator) } } } @@ -435,15 +438,15 @@ class MogoPrivateObuManager private constructor() { * 修改红绿灯 */ private fun changeTrafficLightStatus( - lights: List, - ttsContent: String, appId: Int, - alertContent: String + lights: List, + indicator: Int ) { - var ttsContent1 = ttsContent - var alertContent1 = alertContent - lights.forEach { - when (it.phase) { + var ttsContent = "" + var alertContent = "" + if (lights.size >= indicator) { + val currentLight = lights[indicator] + when (currentLight.phase) { // 灯光不可用 0x0 -> { mIMoGoWaringProvider?.showWarningTrafficLight(0) @@ -456,43 +459,47 @@ class MogoPrivateObuManager private constructor() { "ACTION_V2X_FRONT_WARNING" ) mIMoGoWaringProvider?.showWarningTrafficLight(1) - mIMoGoWaringProvider?.changeCountdownRed(it.count_down.toInt()) - ttsContent1 = WarningTypeEnum.getWarningTts(appId) - alertContent1 = WarningTypeEnum.getWarningContent(appId) + mIMoGoWaringProvider?.changeCountdownRed(currentLight.count_down.toInt()) + ttsContent = WarningTypeEnum.getWarningTts(appId) + alertContent = WarningTypeEnum.getWarningContent(appId) mIMoGoWaringProvider!!.showWarningV2X( appId, - alertContent1, - ttsContent1, + alertContent, + ttsContent, appId.toString() ) } // 绿灯 0x2 -> { mIMoGoWaringProvider?.showWarningTrafficLight(3) - mIMoGoWaringProvider?.changeCountdownGreen(it.count_down.toInt()) + mIMoGoWaringProvider?.changeCountdownGreen(currentLight.count_down.toInt()) // 拼接建议速度 val adviceSpeed = - "${it.glosa_suggested_speed_min.toInt()} + ${it.glosa_suggested_speed_max.toInt()}" + "${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}" - ttsContent1 = - String.format(WarningTypeEnum.getWarningTts(0x2B091), adviceSpeed) - alertContent1 = + val adviceSpeedTts = + "${currentLight.glosa_suggested_speed_min.toInt()}到${currentLight.glosa_suggested_speed_max.toInt()}" + + ttsContent = + String.format(WarningTypeEnum.getWarningTts(0x2B091), adviceSpeedTts) + alertContent = String.format(WarningTypeEnum.getWarningTts(0x2B091), adviceSpeed) mIMoGoWaringProvider!!.showWarningV2X( 0x2B091, - alertContent1, - ttsContent1, + alertContent, + ttsContent, appId.toString() ) } // 黄灯 0x3 -> { mIMoGoWaringProvider?.showWarningTrafficLight(2) - mIMoGoWaringProvider?.changeCountdownYellow(it.count_down.toInt()) + mIMoGoWaringProvider?.changeCountdownYellow(currentLight.count_down.toInt()) } } } + } 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 6b05d77e97..a1a7e4a572 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 @@ -3,7 +3,6 @@ package com.mogo.module.obu.mogo.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import android.util.Log import com.mogo.module.obu.mogo.MogoObuConst import com.mogo.module.obu.mogo.MogoPrivateObuManager import com.mogo.utils.logger.Logger @@ -35,11 +34,11 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) - val phase = intent.getIntExtra(MogoObuConst.BROADCAST_LIGHT_LEVEL_EXTRA_KEY, 0) + val indicator = intent.getIntExtra(MogoObuConst.BROADCAST_LIGHT_LEVEL_EXTRA_KEY, 0) val pctType = intent.getIntExtra(MogoObuConst.BROADCAST_PTC_INFO_EXTRA_KEY, 0) Logger.d( - TAG, "obuStatus:$obuStatus phase:$phase obuType:$obuType obuLevel:$obuLevel" + TAG, "obuStatus:$obuStatus phase:$indicator obuType:$obuType obuLevel:$obuLevel" ) when (obuType) { @@ -50,14 +49,19 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { cvxIvpThreatIndInfo.threat_info = ivpThreat - val lightList = listOf(Light(1, phase, 1000, 100, 100, 1, 100, 1000)) - val ivpThreatExt = IvpThreatExt(1, 1000, 1000, 0, 2, lightList) + val lightList = listOf( + Light(1, 0x0, 1000, 100, 6000, 3000, 100, 1000), + Light(1, 0x1, 1000, 100, 6000, 3000, 100, 1000), + Light(1, 0x2, 1000, 100, 6000, 3000, 100, 1000), + Light(1, 0x3, 1000, 100, 6000, 3000, 100, 1000) + ) + val ivpThreatExt = IvpThreatExt(1, 1000, 1000, 0, indicator, lightList) cvxIvpThreatIndInfo.ext_info = ivpThreatExt cvxIvpThreatIndInfo.status = obuStatus cvxIvpThreatIndInfo.link_id = "1" MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo) + .onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo) } ObuConstants.USE_CASE_ID.SLW -> { //限速预警 @@ -67,12 +71,13 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { cvxSlwThreatIndInfo.ext_info = slwThreatExt cvxSlwThreatIndInfo.status = obuStatus - MogoPrivateObuManager.INSTANCE.getMogoObuListener().onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo) + MogoPrivateObuManager.INSTANCE.getMogoObuListener() + .onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo) } //弱势交通参与者碰撞预警,行人/摩托车碰撞预警 ObuConstants.USE_CASE_ID.VRUCW -> { - val cvxPtcIndInfo = CvxPtcInfoIndInfo(1,1,1) + val cvxPtcIndInfo = CvxPtcInfoIndInfo(1, 1, 1) val position = Position(1, 399739429, 1164115207, 20) val movingObjectInfo = MovingObjectInfo(1, position, 1800, 6000) cvxPtcIndInfo.basic_info = movingObjectInfo @@ -80,23 +85,22 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { cvxPtcIndInfo.ptc_type = pctType cvxPtcIndInfo.status = obuStatus - MogoPrivateObuManager.INSTANCE.getMogoObuListener().onCvxPtcInfoIndInfo(cvxPtcIndInfo) + MogoPrivateObuManager.INSTANCE.getMogoObuListener() + .onCvxPtcInfoIndInfo(cvxPtcIndInfo) } //道路危险情况, 车内标牌, 前方拥堵提醒 - ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS,ObuConstants.USE_CASE_ID.TJW -> { - val cvxRtiThreatIndInfo = CvxRtiThreatIndInfo(1,1, 1L) - val dateTime = DateTime(1,1,1,1,1,1,1,1) - val rtiThread = RtiThreat(1, obuType, dateTime,100000, obuLevel, 100) + ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, ObuConstants.USE_CASE_ID.TJW -> { + val cvxRtiThreatIndInfo = CvxRtiThreatIndInfo(1, 1, 1L) + val dateTime = DateTime(1, 1, 1, 1, 1, 1, 1, 1) + val rtiThread = RtiThreat(1, obuType, dateTime, 100000, obuLevel, 100) cvxRtiThreatIndInfo.threat_info = rtiThread cvxRtiThreatIndInfo.status = obuStatus - MogoPrivateObuManager.INSTANCE.getMogoObuListener().onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo) + MogoPrivateObuManager.INSTANCE.getMogoObuListener() + .onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo) } - - - } }