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 dfc51cfcd7..58109c2de8 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 @@ -122,6 +122,7 @@ class TeleMsgHandler : IMsgHandler { if (!isFirstDisc) { isFirstDisc = true } + AdasManager.getInstance().startDispatchHandler() ToastUtils.showShort("连接司机屏成功!") invokeNettyConnResult("乘客屏连接司机屏成功") val byteArray = byteArrayOf(0) @@ -138,14 +139,18 @@ class TeleMsgHandler : IMsgHandler { AppConfigInfo.iPCMacAddress = "" ToastUtils.showLong("断开和司机屏的连接!") invokeNettyConnResult("断开和司机屏的连接!") + AdasManager.getInstance().stopDispatchHandler() } } ConnectState.STATUS_CONNECT_ERROR -> { AppConfigInfo.plateNumber = "" ToastUtils.showLong("和司机端连接异常!") invokeNettyConnResult("乘客屏和司机屏连接异常,错误为:$content") + AdasManager.getInstance().stopDispatchHandler() + } + else -> { + AdasManager.getInstance().stopDispatchHandler() } - else -> {} } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java index 51851456f5..84fc8dfe2d 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java @@ -473,34 +473,44 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus.get(), reason); } if (status == Constants.IPC_CONNECTION_STATUS.CONNECTED) { - if (dispatchHandler != null) { - dispatchHandler.start(); - } - if (dispatchHandlerPointCloud != null) { - dispatchHandlerPointCloud.start(); - } - if (dispatchHandlerParsePointCloud != null) { - dispatchHandlerParsePointCloud.start(); - } + startDispatchHandler(); startCheckCompatibility(); } else { stopCheckCompatibility(); } if (status == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) { AdasManager.getInstance().setCarConfig(null); - if (dispatchHandler != null) { - dispatchHandler.stop(); - } - if (dispatchHandlerPointCloud != null) { - dispatchHandlerPointCloud.stop(); - } - if (dispatchHandlerParsePointCloud != null) { - dispatchHandlerParsePointCloud.stop(); - } + stopDispatchHandler(); } CupidLogUtils.i(TAG, "工控机连接状态 status=" + status + " reason=" + reason); } + @Override + public void startDispatchHandler() { + if (dispatchHandler != null) { + dispatchHandler.start(); + } + if (dispatchHandlerPointCloud != null) { + dispatchHandlerPointCloud.start(); + } + if (dispatchHandlerParsePointCloud != null) { + dispatchHandlerParsePointCloud.start(); + } + } + + @Override + public void stopDispatchHandler() { + if (dispatchHandler != null) { + dispatchHandler.stop(); + } + if (dispatchHandlerPointCloud != null) { + dispatchHandlerPointCloud.stop(); + } + if (dispatchHandlerParsePointCloud != null) { + dispatchHandlerParsePointCloud.stop(); + } + } + /** * 检查兼容性 */ diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java index a7352e41c5..b1bcf17274 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java @@ -200,6 +200,20 @@ public class AdasManager implements IAdasNetCommApi { } } + @Override + public void startDispatchHandler() { + if (mChannel != null) { + mChannel.startDispatchHandler(); + } + } + + @Override + public void stopDispatchHandler() { + if (mChannel != null) { + mChannel.stopDispatchHandler(); + } + } + /** * 获取工控机链接配置 * diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java index ebafd862e6..363854d6c8 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java @@ -214,6 +214,16 @@ public interface IAdasNetCommApi { */ void decoderRaw(byte[] bytes); + /** + * 启动分发线程 + */ + void startDispatchHandler(); + + /** + * 停止分发线程 + */ + void stopDispatchHandler(); + /** * Log是否开启打印 */