diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt index d4b9bc0d22..d1336af45f 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt @@ -13,6 +13,7 @@ import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.d import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager +import com.mogo.eagle.function.biz.v2x.obu.V2xObuEventManager import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb import com.mogo.eagle.function.biz.v2x.road.LineUploadManager @@ -44,6 +45,7 @@ class FuncBizProvider : IMoGoFuncBizProvider { if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){ LineUploadManager.getInstance(context)?.init() } + V2xObuEventManager.init(context) // RedLightWarningManager.INSTANCE.listenTrafficLight() } @@ -110,6 +112,7 @@ class FuncBizProvider : IMoGoFuncBizProvider { LineUploadManager.getInstance(it)?.onDestroy() } } + V2xObuEventManager.release() // RedLightWarningManager.INSTANCE.onDestroy() } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/obu/V2xObuEventManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/obu/V2xObuEventManager.kt new file mode 100644 index 0000000000..7677124647 --- /dev/null +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/obu/V2xObuEventManager.kt @@ -0,0 +1,56 @@ +package com.mogo.eagle.function.biz.v2x.obu + +import android.content.Context +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType +import com.mogo.eagle.core.data.msgbox.V2XMsg +import com.mogo.eagle.core.function.api.obu.IMoGoObuSaveMessageListener +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager +import com.mogo.eagle.core.function.call.obu.CallerObuSaveMessageListenerManager + +/** + * 处理obu分发出来,在消息盒子展示的消息 + */ +object V2xObuEventManager : IMoGoObuSaveMessageListener { + + private const val TAG = "V2xObuEventManager" + + fun init(context: Context) { + registerListener() + } + + private fun registerListener() { + CallerObuSaveMessageListenerManager.addListener(TAG,this) + } + + private fun unRegisterListener() { + CallerObuSaveMessageListenerManager.removeListener(TAG) + } + + /** + * @param type 事件id,类似与uuid + * @param content 事件内容 + * @param tts 事件语音播报 + */ + override fun onMoGoObuSaveMessage(type: String, content: String, tts: String) { + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + type, + content, + tts + ) + ).apply { + sourceType = DataSourceType.OBU + } + ) + } + + fun release() { + unRegisterListener() + } + +} + diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 7ab13fcfb4..fcba382bc8 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -18,6 +18,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.obu.CallerObuSaveMessageListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager @@ -968,18 +969,7 @@ class MogoPrivateObuNewManager private constructor() { * 保存obu直连数据到消息盒子 */ private fun saveObuData(type: String, content: String, tts: String) { - CallerMsgBoxManager.saveMsgBox( - MsgBoxBean( - MsgBoxType.V2X, - V2XMsg( - type, - content, - tts - ) - ).apply { - sourceType = DataSourceType.OBU - } - ) + CallerObuSaveMessageListenerManager.invokeObuSaveMessage(type, content, tts) } /** diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuSaveMessageListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuSaveMessageListener.kt new file mode 100644 index 0000000000..ec5e0531fd --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuSaveMessageListener.kt @@ -0,0 +1,18 @@ +package com.mogo.eagle.core.function.api.obu + +/** + * OBU 数据保存 + * @author lixiaopeng + * @date 2023-02-01 + */ +interface IMoGoObuSaveMessageListener { + + /** + * @param type 事件id,类似与uuid + * @param content 事件内容 + * @param tts 事件语音播报 + * + */ + fun onMoGoObuSaveMessage(type: String, content: String, tts: String) + +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obucombine/IMoGoObuDcCombineListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obucombine/IMoGoObuDcCombineListener.kt index 942102318c..16c52fd6d9 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obucombine/IMoGoObuDcCombineListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obucombine/IMoGoObuDcCombineListener.kt @@ -13,5 +13,4 @@ interface IMoGoObuDcCombineListener { */ fun onMoGoObuDcCombineData(obuWarningData: ObuWarningEvent.ObuWarningData?) - } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuSaveMessageListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuSaveMessageListenerManager.kt new file mode 100644 index 0000000000..3865080049 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuSaveMessageListenerManager.kt @@ -0,0 +1,22 @@ +package com.mogo.eagle.core.function.call.obu + +import com.mogo.eagle.core.function.api.obu.IMoGoObuSaveMessageListener +import com.mogo.eagle.core.function.api.obu.IMoGoObuWarningRsiListener +import com.mogo.eagle.core.function.call.base.CallerBase +import com.mogo.support.obu.ObuScene + +/** + * OBU 保存到数据中心,展示在消息盒子的数据 + * + */ +object CallerObuSaveMessageListenerManager : CallerBase() { + + fun invokeObuSaveMessage(type: String, content: String, tts: String) { + M_LISTENERS.forEach { + val tag = it.key + val listener = it.value + listener.onMoGoObuSaveMessage(type, content, tts) + } + } + +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt index 2ecbf31c29..5e86cc9b9e 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt @@ -1,7 +1,5 @@ package com.mogo.eagle.core.function.call.obucombine -import androidx.annotation.Nullable -import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener import com.mogo.eagle.core.function.api.obucombine.IMoGoObuDcCombineListener import com.mogo.eagle.core.function.call.base.CallerBase import mogo.v2x.ObuWarningEvent @@ -15,44 +13,6 @@ object CallerObuDcCombineListenerManager : CallerBase private val M_DC_COMBINE_LISTENERS: ConcurrentHashMap = ConcurrentHashMap() - /** - * 添加 obu和dc数据通道 监听 - * @param tag 标记,用来注销监听使用 - * @param listener 监听回调 - */ -// fun addListener( -// @Nullable tag: String, -// @Nullable listener: IMoGoObuDcCombineListener -// ) { -// if (M_DC_COMBINE_LISTENERS.containsKey(tag)) { -// return -// } -// M_DC_COMBINE_LISTENERS[tag] = listener -// } - - /** - * 删除监听 - * @param tag 标记,用来注销监听使用 - */ -// fun removeListener(@Nullable tag: String) { -// if (!M_DC_COMBINE_LISTENERS.containsKey(tag)) { -// return -// } -// M_DC_COMBINE_LISTENERS.remove(tag) -// } - - /** - * 删除自动驾驶按钮选中监听 - * @param listener 要删除的监听对象 - */ -// fun removeListener(@Nullable listener: IMoGoObuDcCombineListener) { -// M_DC_COMBINE_LISTENERS.forEach { -// if (it.value == listener) { -// M_DC_COMBINE_LISTENERS.remove(it.key) -// } -// } -// } - /** * v2i数据 */