From 3b84838817f2069144e3e6cd77d98b5431765007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Wed, 18 Aug 2021 18:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BA=A2=E7=BB=BF=E7=81=AF?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/common/enums/WarningTypeEnum.kt | 11 +++ .../receiver/V2XWarningBroadcastReceiver.kt | 2 +- .../mogo/module/hmi/ui/MoGoWarningContract.kt | 22 +++++ .../mogo/module/hmi/ui/MoGoWarningFragment.kt | 21 ++++ .../module/hmi/ui/widget/ViewTrafficLight.kt | 40 ++++++++ .../hmi/warning/MoGoWarningProvider.java | 19 ++++ .../module/obu/mogo/MogoPrivateObuManager.kt | 98 ++++++++++++------- .../service/warning/IMoGoWaringProvider.kt | 22 +++++ 8 files changed, 198 insertions(+), 37 deletions(-) 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 292d8a55c4..c707ec6f8a 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 @@ -131,6 +131,13 @@ enum class WarningTypeEnum( "路口红灯,禁止通行", R.drawable.icon_warning_v2x_traffic_lights_red ), + TYPE_USECASE_ID_IVP_GREEN( + 0x2B091, + "绿波通行 %s km/h", + "路口红灯,禁止通行", + "保持车速 %s km/h,可直接通过路口", + R.drawable.icon_warning_v2x_traffic_lights_green + ), TYPE_USECASE_ID_COC( ObuConstants.USE_CASE_ID.COC, "预留", @@ -166,6 +173,7 @@ enum class WarningTypeEnum( ObuConstants.USE_CASE_ID.IVS -> TYPE_USECASE_ID_IVS ObuConstants.USE_CASE_ID.TJW -> TYPE_USECASE_ID_TJW ObuConstants.USE_CASE_ID.IVP -> TYPE_USECASE_ID_IVP + 0x2B091 -> TYPE_USECASE_ID_IVP_GREEN ObuConstants.USE_CASE_ID.COC -> TYPE_USECASE_ID_COC ObuConstants.USE_CASE_ID.ERROR -> TYPE_ERROR else -> TYPE_USECASE_ID_AVW @@ -191,6 +199,7 @@ enum class WarningTypeEnum( ObuConstants.USE_CASE_ID.IVS -> TYPE_USECASE_ID_IVS.warningIconId ObuConstants.USE_CASE_ID.TJW -> TYPE_USECASE_ID_TJW.warningIconId ObuConstants.USE_CASE_ID.IVP -> TYPE_USECASE_ID_IVP.warningIconId + 0x2B091 -> TYPE_USECASE_ID_IVP_GREEN.warningIconId ObuConstants.USE_CASE_ID.COC -> TYPE_USECASE_ID_COC.warningIconId ObuConstants.USE_CASE_ID.ERROR -> TYPE_ERROR.warningIconId else -> TYPE_USECASE_ID_AVW.warningIconId @@ -215,6 +224,7 @@ enum class WarningTypeEnum( ObuConstants.USE_CASE_ID.IVS -> TYPE_USECASE_ID_IVS.warningContent ObuConstants.USE_CASE_ID.TJW -> TYPE_USECASE_ID_TJW.warningContent ObuConstants.USE_CASE_ID.IVP -> TYPE_USECASE_ID_IVP.warningContent + 0x2B091 -> TYPE_USECASE_ID_IVP_GREEN.warningContent ObuConstants.USE_CASE_ID.COC -> TYPE_USECASE_ID_COC.warningContent ObuConstants.USE_CASE_ID.ERROR -> TYPE_ERROR.warningContent else -> TYPE_USECASE_ID_AVW.warningContent @@ -239,6 +249,7 @@ enum class WarningTypeEnum( ObuConstants.USE_CASE_ID.IVS -> TYPE_USECASE_ID_IVS.warningTts ObuConstants.USE_CASE_ID.TJW -> TYPE_USECASE_ID_TJW.warningTts ObuConstants.USE_CASE_ID.IVP -> TYPE_USECASE_ID_IVP.warningTts + 0x2B091 -> TYPE_USECASE_ID_IVP_GREEN.warningTts ObuConstants.USE_CASE_ID.COC -> TYPE_USECASE_ID_COC.warningTts ObuConstants.USE_CASE_ID.ERROR -> TYPE_ERROR.warningTts else -> TYPE_USECASE_ID_AVW.warningTts diff --git a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/receiver/V2XWarningBroadcastReceiver.kt b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/receiver/V2XWarningBroadcastReceiver.kt index 827332db4e..3a981edbc6 100644 --- a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/receiver/V2XWarningBroadcastReceiver.kt +++ b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/receiver/V2XWarningBroadcastReceiver.kt @@ -79,7 +79,7 @@ class V2XWarningBroadcastReceiver : BroadcastReceiver() { ttsContent: String?, tag: String? ) { - if (v2xType == WarningTypeEnum.WARNING_RED_LIGHT) { + if (v2xType == WarningTypeEnum.TYPE_USECASE_ID_IVP.useCaseId) { mIMoGoWaringProvider!!.showLimitingVelocity(1) } mIMoGoWaringProvider!!.showWarningV2X( diff --git a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningContract.kt b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningContract.kt index 92760a4c3c..cac952f4ab 100644 --- a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningContract.kt +++ b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningContract.kt @@ -48,6 +48,28 @@ interface MoGoWarningContract { */ fun disableWarningTrafficLight() + /** + * 修改红灯倒计时 + */ + fun changeCountdownRed(redNum: Int) + + /** + * 修改黄灯倒计时 + */ + fun changeCountdownYellow(yellowNum: Int) + + /** + * 修改绿灯倒计时 + */ + fun changeCountdownGreen(greenNum: Int) + + /** + * @param readNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + fun changeCountdownTrafficLightNum(readNum: Int, yellowNum: Int, greenNum: Int) + /** * 展示限速预警 * diff --git a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningFragment.kt b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningFragment.kt index 96f84c0c73..d8ba663d61 100644 --- a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningFragment.kt +++ b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/ui/MoGoWarningFragment.kt @@ -121,6 +121,27 @@ class MoGoWarningFragment : MvpFragment 0) { + ctvRedTrafficLight.text = "$readNum" + } else { + ctvRedTrafficLight.text = "" + } + } + + fun changeCountdownYellow(yellowNum: Int) { + if (yellowNum > 0) { + ctvYellowTrafficLight.text = "$yellowNum" + } else { + ctvYellowTrafficLight.text = "" + } + } + + fun changeCountdownRed(greenNum: Int) { + if (greenNum > 0) { + ctvGreenTrafficLight.text = "$greenNum" + } else { + ctvGreenTrafficLight.text = "" + } + } + + } \ No newline at end of file diff --git a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/warning/MoGoWarningProvider.java b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/warning/MoGoWarningProvider.java index eb2f49172b..62f186d0ad 100644 --- a/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/warning/MoGoWarningProvider.java +++ b/modules/mogo-module-hmi/src/main/java/com/mogo/module/hmi/warning/MoGoWarningProvider.java @@ -71,6 +71,25 @@ public class MoGoWarningProvider implements IMoGoWaringProvider { mMoGoWarningFragment.disableLimitingVelocity(); } + @Override + public void changeCountdownRed(int redNum) { + mMoGoWarningFragment.changeCountdownRed(redNum); + } + + @Override + public void changeCountdownYellow(int yellowNum) { + mMoGoWarningFragment.changeCountdownYellow(yellowNum); + } + + @Override + public void changeCountdownGreen(int greenNum) { + mMoGoWarningFragment.changeCountdownGreen(greenNum); + } + + @Override + public void changeCountdownTrafficLightNum(int readNum, int yellowNum, int greenNum) { + mMoGoWarningFragment.changeCountdownTrafficLightNum(readNum, yellowNum, greenNum); + } @Override public void showWarningV2X(int v2xType, @Nullable String alertContent, @Nullable String ttsContent, @Nullable String tag) { 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 c14a3b5afd..44d2e8280c 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 @@ -263,13 +263,7 @@ class MogoPrivateObuManager private constructor() { val level = info.threat_info.threat_level val status = info.status - handleSdkObu( - appId, - direction, - status, - level, - info - ) + handleSdkObu(appId, direction, status, level, info) } } } @@ -315,36 +309,8 @@ class MogoPrivateObuManager private constructor() { when (status) { // 添加 ObuConstants.STATUS.ADD -> { - lights.forEach { - when (it.phase) { - // 灯光不可用 - 0x0 -> { - mIMoGoWaringProvider?.showWarningTrafficLight(0) - } - // 红灯 - 0x1 -> { - mIMoGoWaringProvider?.showWarningTrafficLight(1) - ttsContent = WarningTypeEnum.getWarningTts(appId) - alertContent = WarningTypeEnum.getWarningContent(appId) - mIMoGoWaringProvider!!.showWarningV2X( - appId, - alertContent, - ttsContent, - appId.toString() - ) - } - // 绿灯 - 0x2 -> { - mIMoGoWaringProvider?.showWarningTrafficLight(3) - } - // 黄灯 - 0x3 -> { - mIMoGoWaringProvider?.showWarningTrafficLight(2) - } - } - } + changeTrfficLightStatus(lights, ttsContent, appId, alertContent) } - // 删除 ObuConstants.STATUS.DELETE -> { mIMoGoWaringProvider?.disableWarningTrafficLight() @@ -352,6 +318,66 @@ class MogoPrivateObuManager private constructor() { mIMoGoWaringProvider?.disableWarningV2X(appId.toString()) } else -> { + changeTrfficLightStatus(lights, ttsContent, appId, alertContent) + } + } + } + + /** + * 修改红绿灯 + */ + private fun changeTrfficLightStatus( + lights: List, + ttsContent: String, + appId: Int, + alertContent: String + ) { + var ttsContent1 = ttsContent + var alertContent1 = alertContent + lights.forEach { + when (it.phase) { + // 灯光不可用 + 0x0 -> { + mIMoGoWaringProvider?.showWarningTrafficLight(0) + } + // 红灯 + 0x1 -> { + mIMoGoWaringProvider?.showWarningTrafficLight(1) + mIMoGoWaringProvider?.changeCountdownRed(it.count_down.toInt()) + ttsContent1 = WarningTypeEnum.getWarningTts(appId) + alertContent1 = WarningTypeEnum.getWarningContent(appId) + mIMoGoWaringProvider!!.showWarningV2X( + appId, + alertContent1, + ttsContent1, + appId.toString() + ) + } + // 绿灯 + 0x2 -> { + mIMoGoWaringProvider?.showWarningTrafficLight(3) + mIMoGoWaringProvider?.changeCountdownGreen(it.count_down.toInt()) + // 拼接建议速度 + val adviceSpeed = + "${it.glosa_suggested_speed_min.toInt()} + ${it.glosa_suggested_speed_max.toInt()}" + + ttsContent1 = + String.format(WarningTypeEnum.getWarningTts(0x2B091), adviceSpeed) + alertContent1 = + String.format(WarningTypeEnum.getWarningTts(0x2B091), adviceSpeed) + + mIMoGoWaringProvider!!.showWarningV2X( + 0x2B091, + alertContent1, + ttsContent1, + appId.toString() + ) + } + // 黄灯 + 0x3 -> { + mIMoGoWaringProvider?.showWarningTrafficLight(2) + mIMoGoWaringProvider?.changeCountdownYellow(it.count_down.toInt()) + } } } } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt b/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt index cf694d8c04..1d09eaea5c 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt +++ b/services/mogo-service-api/src/main/java/com/mogo/service/warning/IMoGoWaringProvider.kt @@ -40,6 +40,28 @@ interface IMoGoWaringProvider : IMogoModuleProvider { */ fun disableWarningTrafficLight() + /** + * 修改红灯倒计时 + */ + fun changeCountdownRed(redNum: Int) + + /** + * 修改黄灯倒计时 + */ + fun changeCountdownYellow(yellowNum: Int) + + /** + * 修改绿灯倒计时 + */ + fun changeCountdownGreen(greenNum: Int) + + /** + * @param readNum 红灯倒计时 + * @param yellowNum 黄灯倒计时 + * @param greenNum 绿灯倒计时 + */ + fun changeCountdownTrafficLightNum(readNum: Int, yellowNum: Int, greenNum: Int) + /** * 展示限速预警 *