From f815c71c4db702a6432807c3417c1b72b7ba3b07 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 21 Sep 2022 12:14:05 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E8=A7=A3=E5=86=B3=E7=BE=8E=E5=8C=96?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=97=B6=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autopilot/MoGoAutopilotProvider.kt | 13 +++++- .../autopilot/telematic/TeleMsgHandler.kt | 46 +++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt index 037bcb6bd5..12fb24808b 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt @@ -344,7 +344,12 @@ class MoGoAutopilotProvider : override fun setDemoMode(isEnable: Boolean) { // 同步给乘客端 if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { - val byteArray = if (isEnable) byteArrayOf(1) else byteArrayOf(0) + val byteArray = if (isEnable) { + "1;${System.currentTimeMillis()}".toByteArray() + } else { + "0;${System.currentTimeMillis()}".toByteArray() + } +// val byteArray = if (isEnable) byteArrayOf(1) else byteArrayOf(0) if (NSDNettyManager.getInstance().isServerStart) { NSDNettyManager.getInstance() .sendMsgToAllClients( @@ -363,7 +368,11 @@ class MoGoAutopilotProvider : override fun setIgnoreConditionDraw(isIgnore: Boolean) { // 同步给乘客端 if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { - val byteArray = if (isIgnore) byteArrayOf(1) else byteArrayOf(0) + val byteArray = if (isIgnore) { + "1;${System.currentTimeMillis()}".toByteArray() + } else { + "0;${System.currentTimeMillis()}".toByteArray() + } if (NSDNettyManager.getInstance().isServerStart) { NSDNettyManager.getInstance() .sendMsgToAllClients( diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/telematic/TeleMsgHandler.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/telematic/TeleMsgHandler.kt index 461b9fd7f4..bff0d93ae0 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/telematic/TeleMsgHandler.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/telematic/TeleMsgHandler.kt @@ -41,6 +41,12 @@ class TeleMsgHandler : IMsgHandler { @Volatile private var isReceiveSN = false + @Volatile + private var demoModeTime = 0L + + @Volatile + private var timestamp = 0L + override fun handleMsgFromServer(msg: MogoProtocolMsg?, channel: Channel?) { msg?.let { when (it.protocolType) { @@ -57,11 +63,23 @@ class TeleMsgHandler : IMsgHandler { } } MogoProtocolMsg.SYNC_MODE_STATUS -> { - FunctionBuildConfig.isDemoMode = when (it.body[0].toInt()) { - 1 -> true - else -> false + val content = String(it.body) + if (content.contains(";")) { + val strArr = content.split(";") + if (strArr.size == 2) { + val currTime = strArr[1].toLong() + if (currTime > demoModeTime) { + FunctionBuildConfig.isDemoMode = when (strArr[0]) { + "1" -> true + else -> false + } + demoModeTime = currTime + invokeNettyConnResult("乘客屏收到的美化模式DemoMode为:${FunctionBuildConfig.isDemoMode}") + } else { + invokeNettyConnResult("乘客屏收到过时的美化模式DemoMode为:${FunctionBuildConfig.isDemoMode}") + } + } } - invokeNettyConnResult("乘客屏收到的美化模式DemoMode为:${FunctionBuildConfig.isDemoMode}") } MogoProtocolMsg.REQ_MAC_ADDRESS -> { val carConfig = MessagePad.CarConfigResp.parseFrom(msg.body) @@ -86,11 +104,23 @@ class TeleMsgHandler : IMsgHandler { } // 美化模式是否忽略条件直接绘制 11 -> { - FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = when (it.body[0].toInt()) { - 1 -> true - else -> false + val content = String(it.body) + if (content.contains(";")) { + val strArr = content.split(";") + if (strArr.size == 2) { + val currTime = strArr[1].toLong() + if (currTime > timestamp) { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = when (strArr[0]) { + "1" -> true + else -> false + } + timestamp = currTime + invokeNettyConnResult("乘客屏收到的美化模式isIgnore为:${FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData}") + } else { + invokeNettyConnResult("乘客屏收到过时的美化模式isIgnore为:${FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData}") + } + } } - invokeNettyConnResult("乘客屏收到的美化模式isIgnore为:${FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData}") } else -> { }