From 4e9ca584091f9cf98a1ae5af129fc9e3aab4f0ed Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 1 Feb 2023 18:35:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20[Change]=20[=201?= =?UTF-8?q?=E3=80=81=E5=A2=9E=E5=8A=A0=E6=8E=A7=E5=88=B6=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?HZ=E7=9A=84=E5=9B=9E=E8=B0=83=E7=94=A8=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../autopilot/adapter/MoGoAdasListenerImpl.kt | 2 +- .../location/IMoGoLocationListener.kt | 16 +++++ .../location/MoGoLocationManager.kt | 70 +++++++++++++++++++ .../function/datacenter/location/README.md | 17 +++++ .../badcase/biz/AIDataCollectWindow.kt | 6 +- .../badcase/biz/InitiativeBadCaseWindow.kt | 6 +- .../badcase/biz/PassiveBadCaseWindow.kt | 2 +- .../status/flow/rtk/RTKImpl.kt | 2 +- .../hmi/ui/setting/DebugSettingView.kt | 2 +- .../mogo-core-function-map/build.gradle | 1 + .../eagle/core/function/map/MapFragment.kt | 15 ++-- .../IMoGoChassisLocationWGS84Listener.kt | 2 +- ...llerChassisLocationWGS84ListenerManager.kt | 2 +- .../core/function/call/base/CallerBase.kt | 25 ++++++- 14 files changed, 147 insertions(+), 21 deletions(-) create mode 100644 core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/IMoGoLocationListener.kt create mode 100644 core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/MoGoLocationManager.kt create mode 100644 core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/README.md diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index e1bf14c4ad..21224916e5 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -129,7 +129,7 @@ class MoGoAdasListenerImpl : OnAdasListener { paramIndexes = [0, 1], clientPkFileName = "sn" ) - override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo?) { + override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo) { // WGS84坐标系高精度位置信息 invokeChassisLocationWGS84(gnssInfo) // GCJ02高德坐标系位置信息 diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/IMoGoLocationListener.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/IMoGoLocationListener.kt new file mode 100644 index 0000000000..4398708010 --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/IMoGoLocationListener.kt @@ -0,0 +1,16 @@ +package com.mogo.eagle.core.function.datacenter.location + +import com.mogo.eagle.core.data.enums.DataSourceType +import mogo.telematics.pad.MessagePad + +/** + * 位置回调监听 + */ +interface IMoGoLocationListener { + /** + * 位置改变回调用 + * @param gnssInfo 位置信息 + * @param sourceType 数据来源 + */ + fun onLocationChanged(gnssInfo: MessagePad.GnssInfo, sourceType: DataSourceType) +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/MoGoLocationManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/MoGoLocationManager.kt new file mode 100644 index 0000000000..eb12f9251e --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/MoGoLocationManager.kt @@ -0,0 +1,70 @@ +package com.mogo.eagle.core.function.datacenter.location + +import com.mogo.eagle.core.data.enums.DataSourceType +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener +import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.base.CallerBase +import com.mogo.eagle.core.utilcode.util.TimeUtils +import com.mogo.support.obu.model.MogoObuHvBasicsData +import mogo.telematics.pad.MessagePad + +/** + * 融合定位服务,这里同时监听多来源的位置信息,并支持修改频率 + * + * @author donghongyu + */ +object MoGoLocationManager : + CallerBase(), + IMoGoChassisLocationWGS84Listener, + IMoGoObuLocationWGS84Listener { + private val TAG = "MoGoLocationManager" + + init { + CallerChassisLocationWGS84ListenerManager.addListener(TAG, this) + } + + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) { + M_LISTENERS.forEach { + val tag = it.key + // 获取数据监听需要的HZ + val hz = M_LISTENERS_HZ[tag] + if (hz != null && hz > 0) { + val hzTime = (1.0 / hz.toDouble()) * 1000 + // 获取最后一次回调的时间 + val hzLastSendTime = M_LISTENERS_HZ_LAST_SEND_TIME[tag] + if (hzLastSendTime != null && hzLastSendTime > 0) { + // 计算是否进入下一次回调周期 + val nowTime = TimeUtils.getNowMills() + if (nowTime - hzLastSendTime > hzTime) { + syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC) + } + } else { + syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC) + } + } else { + syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC) + } + } + } + + /** + * 向订阅位置信息的发出定位信息 + */ + private fun syncLocationCallback( + tag: String, + it: Map.Entry, + gnssInfo: MessagePad.GnssInfo, + sourceType: DataSourceType + ) { + // 记录最后一次回调时间 + M_LISTENERS_HZ_LAST_SEND_TIME[tag] = TimeUtils.getNowMills() + val listener = it.value + listener.onLocationChanged(gnssInfo, sourceType) + } + + override fun onObuLocationWGS84(data: MogoObuHvBasicsData) { + + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/README.md b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/README.md new file mode 100644 index 0000000000..5a2b95898c --- /dev/null +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/location/README.md @@ -0,0 +1,17 @@ +#### 说明 + +##### 位置回调:融合工控机、OBU、高德地图 + +```kotlin +// 注册监听位置变换 +MoGoLocationManager.addListener(Companion.functionName, object : IMoGoLocationListener { + override fun onLocationChanged( + gnssInfo: MessagePad.GnssInfo, + sourceType: DataSourceType + ) { + TODO("Not yet implemented") + } +}) +// 设置数据回调频率,单位HZ,1HZ的周期是1秒;50HZ的周期是1/50=0.02秒;10HZ的周期是1/10=0.1秒。 +MoGoLocationManager.setListenerHz(Companion.functionName, 20) +``` \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt index a37d4520a6..8a66b2e9c2 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/AIDataCollectWindow.kt @@ -353,9 +353,9 @@ class AIDataCollectWindow constructor(activity: Activity) : View.OnTouchListener fun closeWindow() } - override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { - latitude = gnssInfo?.latitude - longitude = gnssInfo?.longitude + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) { + latitude = gnssInfo.latitude + longitude = gnssInfo.longitude } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt index ed8dc2da88..35581f2fee 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt @@ -394,9 +394,9 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList fun closeWindow() } - override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { - latitude = gnssInfo?.latitude - longitude = gnssInfo?.longitude + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) { + latitude = gnssInfo.latitude + longitude = gnssInfo.longitude } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt index f2f2355594..9f35b20204 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/PassiveBadCaseWindow.kt @@ -380,7 +380,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene fun closeWindow() } - override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) { latitude = gnssInfo?.latitude longitude = gnssInfo?.longitude } diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt index 825574fb98..656730b240 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/status/flow/rtk/RTKImpl.kt @@ -85,7 +85,7 @@ internal class RTKImpl(ctx: Context): IFlow(ctx), IMoGoAutopilotStatu } } - override fun onChassisLocationWGS84(gnssInfo: GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: GnssInfo) { if (isOldVersion.get()) { if (isRTKEnabled()) { send(RTKStatus("RTK", 0)) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 4effeef6d8..a662a61c12 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -1848,7 +1848,7 @@ internal class DebugSettingView @JvmOverloads constructor( } } - override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { + override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) { mGnssInfo = gnssInfo //实时加速度列表 ThreadUtils.runOnUiThread { diff --git a/core/function-impl/mogo-core-function-map/build.gradle b/core/function-impl/mogo-core-function-map/build.gradle index 151a0660e6..1b1996082c 100644 --- a/core/function-impl/mogo-core-function-map/build.gradle +++ b/core/function-impl/mogo-core-function-map/build.gradle @@ -81,6 +81,7 @@ dependencies { implementation project(':core:mogo-core-res') implementation project(':core:mogo-core-data') implementation project(':core:mogo-core-utils') + implementation project(':core:function-impl:mogo-core-function-datacenter') implementation project(':core:mogo-core-function-call') implementation project(":libraries:mogo-map") } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt index 6a0f9ffb49..403a8d640c 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt @@ -8,8 +8,8 @@ import com.alibaba.android.arouter.facade.annotation.Route import com.mogo.commons.mvp.MvpFragment import com.mogo.eagle.core.data.constants.MoGoConfig import com.mogo.eagle.core.data.constants.MoGoFragmentPaths +import com.mogo.eagle.core.data.enums.DataSourceType import com.mogo.eagle.core.data.map.CenterLine -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider @@ -18,15 +18,14 @@ import com.mogo.eagle.core.function.business.MapPointCloudSubscriber import com.mogo.eagle.core.function.business.SpeedLimitDataManager import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager -import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight import com.mogo.eagle.core.function.call.map.CallerHDMapManager -import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager +import com.mogo.eagle.core.function.datacenter.location.IMoGoLocationListener +import com.mogo.eagle.core.function.datacenter.location.MoGoLocationManager import com.mogo.eagle.core.function.overview.InfStructureManager import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData import com.mogo.eagle.core.function.overview.obtainViewModel @@ -55,7 +54,7 @@ class MapFragment : MvpFragment(), MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener, - IMoGoChassisLocationWGS84Listener, + IMoGoLocationListener, IMoGoPlanningRottingListener, IMoGoChassisLamplightListener { @@ -115,7 +114,7 @@ class MapFragment : MvpFragment(), // 添加换肤监听 CallerSkinModeListenerManager.addListener(Companion.functionName, this) CallerPlanningRottingListenerManager.addListener(Companion.functionName, this) - CallerChassisLocationWGS84ListenerManager.addListener(Companion.functionName, this) + MoGoLocationManager.addListener(Companion.functionName, this) CallerChassisLamplightListenerManager.addListener(Companion.functionName, this) } @@ -219,7 +218,7 @@ class MapFragment : MvpFragment(), override fun onDestroyView() { CallerSkinModeListenerManager.removeListener(Companion.functionName) CallerPlanningRottingListenerManager.removeListener(Companion.functionName) - CallerChassisLocationWGS84ListenerManager.removeListener(Companion.functionName) + MoGoLocationManager.removeListener(Companion.functionName) CallerChassisLamplightListenerManager.removeListener(Companion.functionName) if (mMogoMapView != null) { @@ -347,7 +346,7 @@ class MapFragment : MvpFragment(), private var isShowTurnLight = false private var brakeLight = -1 - override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) { + override fun onLocationChanged(gnssInfo: MessagePad.GnssInfo,sourceType: DataSourceType) { // 跟新地图控件 mMogoMapView?.setExtraGPSData(gnssInfo) diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt index 6786ce6430..c6c1a7e9ce 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoChassisLocationWGS84Listener.kt @@ -14,5 +14,5 @@ interface IMoGoChassisLocationWGS84Listener { * * @param gnssInfo */ - fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) + fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt index 577718120d..20801f9171 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerChassisLocationWGS84ListenerManager.kt @@ -23,7 +23,7 @@ object CallerChassisLocationWGS84ListenerManager : CallerBase { - // 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步 + /** + * 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步 + */ protected val M_LISTENERS: ConcurrentHashMap = ConcurrentHashMap() + /** + * 存储所有注册了监听的对象,并设定监听频率,invokeXXXX进行遍历回调,将信息同步, + */ + protected val M_LISTENERS_HZ: ConcurrentHashMap = ConcurrentHashMap() + + /** + * HZ发送,记录最后一次发送时间 + */ + protected val M_LISTENERS_HZ_LAST_SEND_TIME: ConcurrentHashMap = + ConcurrentHashMap() + + /** + * 设置对应监听,指定Hz频率 + */ + fun setListenerHz(tag: String, hz: Int) { + if (M_LISTENERS_HZ.containsKey(tag)) { + return + } + M_LISTENERS_HZ[tag] = hz + } + /** * 添加 监听 * @param tag 标记,用来注销监听使用 From 3c8f69d83a982a87c42f76d29c29893b407189c4 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 1 Feb 2023 19:07:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20[Change]=20[=201?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E5=A4=8D=E5=88=B9=E8=BD=A6=E7=AD=89=E5=BC=82?= =?UTF-8?q?=E5=B8=B8@=E9=92=9F=E8=B6=85=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 6b8a0b345f..b63e9828b0 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -520,7 +520,7 @@ class MoGoHmiFragment : MvpFragment(), CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500) } } - brakeView.setBrakeLight(light) + //brakeView.setBrakeLight(light) } } /** todo----------------------------------------------- **/