From 6ec74b30292eb828621ed3c5af279ab498f9f624 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Wed, 18 Aug 2021 16:27:10 +0800 Subject: [PATCH] add test data --- .../src/main/AndroidManifest.xml | 9 +++ .../mogo/module/obu/mogo/MogoObuConst.java | 3 + .../module/obu/mogo/MogoPrivateObuManager.kt | 50 +++++------- .../receiver/ObuRsuTestTriggerReceiver.kt | 81 +++++++++++++++++++ 4 files changed, 112 insertions(+), 31 deletions(-) create mode 100644 modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt diff --git a/modules/mogo-module-obu-mogo/src/main/AndroidManifest.xml b/modules/mogo-module-obu-mogo/src/main/AndroidManifest.xml index b43b74fa98..a368667a0d 100644 --- a/modules/mogo-module-obu-mogo/src/main/AndroidManifest.xml +++ b/modules/mogo-module-obu-mogo/src/main/AndroidManifest.xml @@ -18,5 +18,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoObuConst.java b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoObuConst.java index e68dcd1ad8..bad9ce5b9b 100644 --- a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoObuConst.java +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoObuConst.java @@ -19,5 +19,8 @@ public class MogoObuConst { public static String BROADCAST_OBU_STATES_EXTRA_KEY = "obuStates"; // 场景预警等级,2-弹窗,3-弹窗+tts+地图绘制 public static String BROADCAST_OBU_LEVEL_EXTRA_KEY = "obuLevel"; + //红绿灯标识 0:不可用,1:红灯,2:绿灯,3:黄灯 + public static String BROADCAST_LIGHT_LEVEL_EXTRA_KEY = "lightLevel"; + } 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 ea8fa589f0..575cec6b96 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 @@ -184,7 +184,7 @@ class MogoPrivateObuManager private constructor() { override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) { Logger.d(MogoObuConst.TAG_MOGO_OBU, "CvxIvpThreatIndInfo ------> $info") info?.let { - handlerTrafficLight(info.status, info.ext_info.lights) + handlerTrafficLight(info.status, info.ext_info.lights, info.threat_info.app_id) } } @@ -192,7 +192,7 @@ class MogoPrivateObuManager private constructor() { override fun onCvxMapSpatInfoIndInfo(info: CvxMapSpatInfoIndInfo?) { Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxMapSpatInfoIndInfo ------> $info") info?.let { - handlerTrafficLight(info.status, info.ivp_threat_ext.lights) +// handlerTrafficLight(info.status, info.ivp_threat_ext.lights) } } @@ -299,7 +299,10 @@ class MogoPrivateObuManager private constructor() { /** * 处理红绿灯 */ - private fun handlerTrafficLight(status: Int, lights: List) { + private fun handlerTrafficLight(status: Int, lights: List, appId: Int) { + var alertContent = "" + var ttsContent = "" + when (status) { // 添加 ObuConstants.STATUS.ADD -> { @@ -312,6 +315,14 @@ class MogoPrivateObuManager private constructor() { // 红灯 0x1 -> { mIMoGoWaringProvider?.showWarningTrafficLight(1) + ttsContent = WarningTypeEnum.getWarningTts(appId) + alertContent = WarningTypeEnum.getWarningContent(appId) + mIMoGoWaringProvider!!.showWarningV2X( + appId, + alertContent, + ttsContent, + appId.toString() + ) } // 绿灯 0x2 -> { @@ -324,9 +335,12 @@ class MogoPrivateObuManager private constructor() { } } } + // 删除 ObuConstants.STATUS.DELETE -> { mIMoGoWaringProvider?.disableWarningTrafficLight() + // 移除顶部弹窗 + mIMoGoWaringProvider?.disableWarningV2X(appId.toString()) } else -> { } @@ -408,22 +422,6 @@ class MogoPrivateObuManager private constructor() { alertContent = WarningTypeEnum.getWarningContent(appId) } - // 弱势交通参与者碰撞预警,行人/摩托车碰撞预警 TODO - WarningTypeEnum.TYPE_USECASE_ID_VRUCW.useCaseId -> { - - } - - //限速预警 TODO - WarningTypeEnum.TYPE_USECASE_ID_SLW.useCaseId -> { - ttsContent = WarningTypeEnum.getWarningTts(appId) - alertContent = WarningTypeEnum.getWarningContent(appId) - if (status == ObuConstants.STATUS.ADD) { - mIMoGoWaringProvider!!.showLimitingVelocity(0) - } else if (status == ObuConstants.STATUS.DELETE) { - mIMoGoWaringProvider!!.disableLimitingVelocity() - } - } - // 前方拥堵提醒,前方XXX米道路拥堵,请减速慢行 TODO WarningTypeEnum.TYPE_USECASE_ID_TJW.useCaseId -> { ttsContent = WarningTypeEnum.getWarningTts(appId) @@ -431,18 +429,6 @@ class MogoPrivateObuManager private constructor() { alertContent = WarningTypeEnum.getWarningContent(appId) } - //闯红灯预警,应该是红灯。其他灯的时候 TODO - WarningTypeEnum.TYPE_USECASE_ID_IVP.useCaseId -> { - ttsContent = WarningTypeEnum.getWarningTts(appId) - alertContent = WarningTypeEnum.getWarningContent(appId) - - if (status == ObuConstants.STATUS.ADD) { - mIMoGoWaringProvider!!.showWarningTrafficLight(0) - } else if (status == ObuConstants.STATUS.DELETE) { - mIMoGoWaringProvider!!.disableWarningTrafficLight() //关闭交通灯 - } - } - // 这里处理固定的提示信息 else -> { ttsContent = WarningTypeEnum.getWarningTts(appId) @@ -482,4 +468,6 @@ class MogoPrivateObuManager private constructor() { } } } + + } \ No newline at end of file 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 new file mode 100644 index 0000000000..e4d67a2b9a --- /dev/null +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt @@ -0,0 +1,81 @@ +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 +import com.zhidao.support.obu.constants.ObuConstants +import com.zhidao.support.obu.model.CvxIvpThreatIndInfo +import com.zhidao.support.obu.model.CvxSlwThreatIndInfo +import com.zhidao.support.obu.model.advance.* + + +/** + * @author lixiaopeng + * @date 2021/8/18 + * + * OBU 测试使用 + * 红绿灯 + */ +class ObuRsuTestTriggerReceiver : BroadcastReceiver() { + private var mContext: Context? = null + + companion object { + private const val TAG = "ObuRsuTestTriggerReceiver" + } + + override fun onReceive(context: Context, intent: Intent) { + mContext = context + + 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) + + Logger.d( + TAG, "obuStatus:$obuStatus phase:$phase obuType:$obuType obuLevel:$obuLevel" + ) + + when (obuType) { + ObuConstants.USE_CASE_ID.IVP -> { //构建红绿灯数据 + var cvxIvpThreatIndInfo = CvxIvpThreatIndInfo(1, 1, 1L) + + val ivpThreat = IvpThreat(1, obuType, null, 1000, obuLevel, 100) + + 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) + cvxIvpThreatIndInfo.ext_info = ivpThreatExt + cvxIvpThreatIndInfo.status = obuStatus + cvxIvpThreatIndInfo.link_id = "1" + + MogoPrivateObuManager.INSTANCE.getMogoObuListener() + .onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo) + } + + ObuConstants.USE_CASE_ID.SLW -> { //限速预警 + val cvxSlwThreatIndInfo = CvxSlwThreatIndInfo(1, 1, 1L) + val slwThreatExt = SlwThreatExt(1, 2, 6000, 2000) + + cvxSlwThreatIndInfo.ext_info = slwThreatExt + cvxSlwThreatIndInfo.status = obuStatus + + MogoPrivateObuManager.INSTANCE.getMogoObuListener().onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo) + } + + //弱势交通参与者碰撞预警,行人/摩托车碰撞预警 + ObuConstants.USE_CASE_ID.VRUCW -> { + + } + + + + } + + } + +}