From 79780c804bc764bcc4e24ae7c8b55b0940c61997 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 9 Nov 2022 14:22:00 +0800 Subject: [PATCH] =?UTF-8?q?[change]=20=E7=BB=9F=E8=AE=A1=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E5=86=8C=E5=8F=96=E6=B6=88=E6=B3=A8?= =?UTF-8?q?=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autopilot/adapter/MoGoAdasListenerImpl.kt | 3 +- .../IMoGoAutopilotStatisticsListener.kt | 16 +++++ ...allerAutopilotStatisticsListenerManager.kt | 60 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatisticsListener.kt create mode 100644 core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt index 0e3a30e99a..2f87c60356 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -48,6 +48,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListen import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPointCloudListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordConfig import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordResult +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager.invokeAutopilotStatistics import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerStartAutopilotFailedListenerManager.invokeStartAutopilotFailed import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager @@ -467,7 +468,7 @@ class MoGoAdasListenerImpl : OnAdasListener { * @param statistics 统计数据 */ override fun onAutopilotStatistics(statistics: AutopilotStatistics?) { - + invokeAutopilotStatistics(statistics); } /** diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatisticsListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatisticsListener.kt new file mode 100644 index 0000000000..deebe23b33 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotStatisticsListener.kt @@ -0,0 +1,16 @@ +package com.mogo.eagle.core.function.api.autopilot + +import com.zhidao.support.adas.high.bean.AutopilotStatistics + + +interface IMoGoAutopilotStatisticsListener { + + /** + * 启动自动驾驶状态统计 + * 触发机制:下发启动自动驾驶命令,根据MAP返回状态判断成功或失败 + * 统计四种状态:成功 失败 取消 超时 + * + * @param statistics 统计数据 + */ + fun onAutopilotStatistics(statistics: AutopilotStatistics?) +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt new file mode 100644 index 0000000000..3e8dd76882 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt @@ -0,0 +1,60 @@ +package com.mogo.eagle.core.function.call.autopilot + +import androidx.annotation.Nullable +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatisticsListener +import com.mogo.eagle.core.function.call.base.CallerBase +import com.zhidao.support.adas.high.bean.AutopilotStatistics +import java.util.concurrent.ConcurrentHashMap + + +object CallerAutopilotStatisticsListenerManager : CallerBase() { + + private val M_AUTOPILOT_STATISTICS_LISTENER: ConcurrentHashMap = + ConcurrentHashMap() + + /** + * 添加监听 + * @param tag 标记,用来注销监听使用 + * @param listener 监听回调 + */ + fun addListener( + @Nullable tag: String, + @Nullable listener: IMoGoAutopilotStatisticsListener + ) { + if (M_AUTOPILOT_STATISTICS_LISTENER.containsKey(tag)) { + return + } + M_AUTOPILOT_STATISTICS_LISTENER[tag] = listener + } + + /** + * 删除监听 + * @param tag 标记,用来注销监听使用 + */ + fun removeListener(@Nullable tag: String) { + if (!M_AUTOPILOT_STATISTICS_LISTENER.containsKey(tag)) { + return + } + M_AUTOPILOT_STATISTICS_LISTENER.remove(tag) + } + + /** + * 删除自动驾驶按钮选中监听 + * @param listener 要删除的监听对象 + */ + fun removeListener(@Nullable listener: IMoGoAutopilotStatisticsListener) { + M_AUTOPILOT_STATISTICS_LISTENER.forEach { + if (it.value == listener) { + M_AUTOPILOT_STATISTICS_LISTENER.remove(it.key) + } + } + } + + @Synchronized + fun invokeAutopilotStatistics(statistics: AutopilotStatistics?) { + M_AUTOPILOT_STATISTICS_LISTENER.forEach { + val listener = it.value + listener.onAutopilotStatistics(statistics) + } + } +} \ No newline at end of file