diff --git a/app/build.gradle b/app/build.gradle index 726a2d8cef..02e2bede7f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,14 +36,14 @@ if (!isAndroidTestBuild()) { apply plugin: 'apm-plugin' } -//if (!isAndroidTestBuild()) { -// apply plugin: 'bytex.threadOpt' -// thread_opt { -// enable !isReleaseBuild -// enableInDebug !isReleaseBuild -// logLevel "DEBUG" -// } -//} +if (!isAndroidTestBuild()) { + apply plugin: 'bytex.threadOpt' + thread_opt { + enable !isReleaseBuild + enableInDebug !isReleaseBuild + logLevel "DEBUG" + } +} if (!isAndroidTestBuild()) { apply plugin: 'LancetX' diff --git a/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt b/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt index b593f616ba..b3a3d8345a 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/APMStartup.kt @@ -24,6 +24,6 @@ class APMStartup : AndroidStartup() { } override fun dependenciesByName(): List { - return listOf("com.mogo.launcher.stageone.ARouterStartUp") + return listOf("com.mogo.launcher.stageone.ARouterStartUp", "com.mogo.launcher.stageone.ThreadOptStartup") } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt index 1cab03977a..15c913da9b 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/ARouterStartUp.kt @@ -31,4 +31,8 @@ class ARouterStartUp : AndroidStartup() { } override fun waitOnMainThread() = false + + override fun dependenciesByName(): List? { + return listOf("com.mogo.launcher.stageone.ThreadOptStartup") + } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt index 71babd15d0..4c151ffa25 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/ConfigStartUp.kt @@ -105,4 +105,8 @@ class ConfigStartUp : AndroidStartup() { } } + + override fun dependenciesByName(): List { + return listOf("com.mogo.launcher.stageone.ThreadOptStartup") + } } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt b/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt index 794e9ef28b..dd5ef2f13b 100644 --- a/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt +++ b/app/src/main/java/com/mogo/launcher/stageone/HttpDnsStartUp.kt @@ -70,7 +70,8 @@ class HttpDnsStartUp : AndroidStartup() { override fun dependenciesByName(): List { return listOf( "com.mogo.launcher.stageone.APMStartup", - "com.mogo.launcher.stageone.ConfigStartUp" + "com.mogo.launcher.stageone.ConfigStartUp", + "com.mogo.launcher.stageone.ThreadOptStartup" ) } @@ -367,5 +368,4 @@ class HttpDnsStartUp : AndroidStartup() { MogoAiCloudSocketManager.getInstance(context) .init(context, DebugConfig.getSocketAppId(), lat, lon) } - } \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt b/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt new file mode 100644 index 0000000000..4f86a8f3ff --- /dev/null +++ b/app/src/main/java/com/mogo/launcher/stageone/ThreadOptStartup.kt @@ -0,0 +1,32 @@ +package com.mogo.launcher.stageone + +import android.content.* +import com.mogo.thread.ext.core.* +import com.mogo.thread.ext.core.config.* +import com.rousetime.android_startup.* +import java.io.* +import java.text.SimpleDateFormat +import java.util.* +import java.util.concurrent.TimeUnit.SECONDS + +class ThreadOptStartup: AndroidStartup() { + + override fun create(context: Context): Boolean { + ThreadManager + .init(ThreadConfig.Builder() + .maxKeepAliveTime(5, SECONDS) + /*.dump(DumpConfig.Builder() + .dumpLogFilePath(File(context.getExternalFilesDir(null), "thread_dump_log_${ SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.ROOT).format(Date()) }.txt").absolutePath) + .dumpPeriod(5, SECONDS) + .build())*/) + return true + } + + override fun callCreateOnMainThread(): Boolean { + return true + } + + override fun waitOnMainThread(): Boolean { + return true + } +} \ No newline at end of file diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java index 9421872e3f..fb8fafd35b 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java @@ -11,6 +11,7 @@ import com.zhidao.adas.client.bean.ErrorData; import com.zhidao.adas.client.bean.GlobalPathResp; import com.zhidao.adas.client.bean.GnssInfo; import com.zhidao.adas.client.bean.MogoReportMessage; +import com.zhidao.adas.client.bean.ObuWarningData; import com.zhidao.adas.client.bean.OriginalPointCloudData; import com.zhidao.adas.client.bean.PerceptionTrafficLight; import com.zhidao.adas.client.bean.PlanningDecisionState; @@ -117,6 +118,7 @@ public class DataDistribution { public final List listOriginalPointCloud = new ArrayList<>(); public final List listPlanningObjects = new ArrayList<>(); public final List listPlanningDecisionState = new ArrayList<>(); + public final List listObuWarningData = new ArrayList<>(); public String cutDown(String str) { if (isCutDown && str.length() > 650) { @@ -168,6 +170,14 @@ public class DataDistribution { if (listener != null && Constants.TITLE.RECEIVE_PLANNING_DECISION_STATE.equals(listener.first)) { listener.second.onRefresh(); } + } else if (data instanceof ObuWarningData) { + listObuWarningData.add(0, time + str); + if (listObuWarningData.size() > LIST_SIZE) { + listObuWarningData.remove(listObuWarningData.size() - 1); + } + if (listener != null && Constants.TITLE.RECEIVE_OBU_WARNING_DATA.equals(listener.first)) { + listener.second.onRefresh(); + } } else if (data instanceof GnssInfo) { listGnssInfo.add(0, time + str); if (listGnssInfo.size() > LIST_SIZE) { diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/ObuWarningData.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/ObuWarningData.java new file mode 100644 index 0000000000..7ea1bca9af --- /dev/null +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/ObuWarningData.java @@ -0,0 +1,24 @@ +package com.zhidao.adas.client.bean; + +import com.google.protobuf.TextFormat; + +import java.text.SimpleDateFormat; + +import mogo.telematics.pad.MessagePad; +import mogo.v2x.ObuWarningEvent; + +public class ObuWarningData extends BaseInfo { + public final ObuWarningEvent.ObuWarningData bean; + + public ObuWarningData(MessagePad.Header header, ObuWarningEvent.ObuWarningData bean, SimpleDateFormat sdf) { + super("接收", bean.getSerializedSize(), header, sdf); + this.bean = bean; + } + + + @Override + public String toString() { + return super.toString() + TextFormat.printer().escapingNonAscii(false).printToString(bean); + } + +} diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/InfoFragment.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/InfoFragment.java index 7cf79e26e6..f1cdaed48e 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/InfoFragment.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/InfoFragment.java @@ -117,6 +117,8 @@ public class InfoFragment extends BaseFragment { adapter.setData(DataDistribution.getInstance().listArrivalNotification); } else if (Constants.TITLE.RECEIVE_STATUS_QUERY_RESP.equals(title)) { adapter.setData(DataDistribution.getInstance().listStatusInfo); + } else if (Constants.TITLE.RECEIVE_OBU_WARNING_DATA.equals(title)) { + adapter.setData(DataDistribution.getInstance().listObuWarningData); } else if (Constants.TITLE.RECEIVE_RECORD_DATA_CONFIG_RESP.equals(title)) { adapter.setData(DataDistribution.getInstance().listRecordDataConfig); } else if (Constants.TITLE.RECEIVE_GLOBAL_PATH_RESP.equals(title)) { diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java index 185f094cd6..538eea185c 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java @@ -64,6 +64,7 @@ import com.zhidao.adas.client.bean.GlobalPathResp; import com.zhidao.adas.client.bean.GnssInfo; import com.zhidao.adas.client.bean.IPCConnectState; import com.zhidao.adas.client.bean.MogoReportMessage; +import com.zhidao.adas.client.bean.ObuWarningData; import com.zhidao.adas.client.bean.OriginalPointCloudData; import com.zhidao.adas.client.bean.PerceptionTrafficLight; import com.zhidao.adas.client.bean.PlanningDecisionState; @@ -116,6 +117,7 @@ import chassis.Chassis; import chassis.VehicleStateOuterClass; import io.netty.channel.Channel; import mogo.telematics.pad.MessagePad; +import mogo.v2x.ObuWarningEvent; import mogo_msg.MogoReportMsg; import perception.TrafficLightOuterClass; import prediction.Prediction; @@ -642,6 +644,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas titleFragmentData.add(Constants.TITLE.RECEIVE_GLOBAL_PATH_RESP); titleFragmentData.add(Constants.TITLE.RECEIVE_ARRIVAL_NOTIFICATION); titleFragmentData.add(Constants.TITLE.RECEIVE_STATUS_QUERY_RESP); + titleFragmentData.add(Constants.TITLE.RECEIVE_OBU_WARNING_DATA); titleFragmentData.add(Constants.TITLE.RECEIVE_WARN); titleFragmentData.add(Constants.TITLE.RECEIVE_ERROR); @@ -1016,6 +1019,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas DataDistribution.getInstance().addData(base); } + @Override + public void onObuWarningData(MessagePad.Header header, ObuWarningEvent.ObuWarningData obuWarningData) { + ObuWarningData base = new ObuWarningData(header, obuWarningData, sdf); + DataDistribution.getInstance().addData(base); + } private void initAdas() { CupidLogUtils.e(TAG, "--->初始化"); diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/Constants.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/Constants.java index 77a8b48dff..6214902d6d 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/Constants.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/Constants.java @@ -168,6 +168,7 @@ public class Constants { String RECEIVE_WARN = MessageType.TYPE_RECEIVE_WARN.desc; String RECEIVE_ARRIVAL_NOTIFICATION = MessageType.TYPE_RECEIVE_ARRIVAL_NOTIFICATION.desc; String RECEIVE_STATUS_QUERY_RESP = MessageType.TYPE_RECEIVE_STATUS_QUERY_RESP.desc; + String RECEIVE_OBU_WARNING_DATA = MessageType.TYPE_RECEIVE_OBU_WARNING_DATA.desc; String RECEIVE_ERROR = "错误数据"; diff --git a/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java b/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java index c995bae83d..7c39af50bb 100644 --- a/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java +++ b/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java @@ -538,6 +538,10 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas } + @Override + public void onObuWarningData(MessagePad.Header header, ObuWarningEvent.ObuWarningData obuWarningData) { + + } private void initAdas() { CupidLogUtils.e(TAG, "--->初始化"); diff --git a/build.gradle b/build.gradle index 81379d1baa..0eb109a8a4 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ buildscript { classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}" classpath "com.mogo.cloud:bizconfig:${BIZCONFIG_VERSION}" classpath 'com.volcengine:apm_insight_plugin:1.4.1' -// classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}" + classpath "com.mogo.thread.opt:plg:${THREAD_OPT_VERSION}" classpath 'com.mogo.cloud:systrace:1.0.1' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' classpath 'com.mogo.sticky:service:1.0.8' 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 e2be4c4680..a58f67846a 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 @@ -52,6 +52,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsList 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 +import com.mogo.eagle.core.function.call.obucombine.CallerObuDcCombineListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.zhidao.support.adas.high.AdasManager import com.zhidao.support.adas.high.OnAdasListener @@ -62,6 +63,7 @@ import com.zhjt.service.chain.ChainLog import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject +import mogo.v2x.ObuWarningEvent import mogo_msg.MogoReportMsg import perception.TrafficLightOuterClass import prediction.Prediction @@ -441,7 +443,15 @@ class MoGoAdasListenerImpl : OnAdasListener { } } - + /** + * OBU预警事件 + * + * @param header 头 + * @param obuWarningData 数据 + */ + override fun onObuWarningData(header: MessagePad.Header?, obuWarningData: ObuWarningEvent.ObuWarningData?) { + CallerObuDcCombineListenerManager.invokeObuDcData(obuWarningData) + } /** * 是否可以启动自动驾驶 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 a61e243f31..3800210806 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 @@ -207,7 +207,7 @@ class DebugSettingView @JvmOverloads constructor( logInfoView!!.onEnterForeground() } // 开启定时查询速度 - Timer().schedule(timerTaskRefresh, Date(), 100) + Timer().schedule(timerTaskRefresh, Date(), 300) if (AppConfigInfo.isConnectAutopilot && (AppConfigInfo.plateNumber.isNullOrEmpty() || AppConfigInfo.iPCMacAddress.isNullOrEmpty())) { //查询工控机基础配置信息 CallerAutoPilotManager.getCarConfig() @@ -1806,10 +1806,10 @@ class DebugSettingView @JvmOverloads constructor( }" ) - - tvAutopilotInfo.text = GsonUtils.toJson(mAutoPilotStatusInfo) - tvIpcInfo.text = GsonUtils.toJson(mAutoPilotStatusInfo) - tvIpcInfoKey.text = GsonUtils.toJson(mAutoPilotStatusInfo) + val autopilotJson = GsonUtils.toJson(mAutoPilotStatusInfo) + tvAutopilotInfo.text = autopilotJson + tvIpcInfo.text = autopilotJson + tvIpcInfoKey.text = autopilotJson tvCarInfo.text = "GPS时间:${(mGnssInfo?.satelliteTime?.times(1000))?.toLong()}\n" + diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedChartView.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedChartView.java index f6d69a53ee..47a53c4ce8 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedChartView.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedChartView.java @@ -178,7 +178,7 @@ public class SpeedChartView extends View { setAnimation(lastAngle, currentAngle, 1000); lastAngle = currentAngle; //重新绘制 - postInvalidate(); + invalidate(); } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedPanelView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedPanelView.kt index f0f2cbce26..6a4e148a1a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedPanelView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SpeedPanelView.kt @@ -89,7 +89,7 @@ class SpeedPanelView @JvmOverloads constructor( } } this.timerTask = task - timer.schedule(task, Date(), 100) + timer.schedule(task, Date(), 200) } override fun onDetachedFromWindow() { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyData.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyData.kt new file mode 100644 index 0000000000..fca6942f1e --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/ai/AiCloudIdentifyData.kt @@ -0,0 +1,38 @@ +package com.mogo.eagle.core.function.business.ai + +import android.content.Context +import com.mogo.cloud.socket.entity.SocketDownData + +import com.mogo.commons.debug.DebugConfig +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.realtime.api.MoGoAiCloudRealTime +import com.mogo.realtime.socket.IMogoCloudOnMsgListener + +class AiCloudIdentifyData{ + + companion object{ + private const val TAG = "AiCloudIdentifyData" + + @JvmStatic + val aiCloudIdentifyData by lazy(LazyThreadSafetyMode.SYNCHRONIZED){ + AiCloudIdentifyData() + } + } + + fun init(mContext:Context){ + //todo emArrow + MoGoAiCloudRealTime.startRealTime(mContext, DebugConfig.getSocketAppId()) + MoGoAiCloudRealTime.registerOnMsgListener(object :IMogoCloudOnMsgListener { + override fun onMsgSend(id: Long) { + } + + override fun onMsgReceived(mogoSnapshotSetData: SocketDownData.LauncherSnapshotProto?) { + mogoSnapshotSetData?.let { + CallerLogger.d(TAG,"mogoSnapshotSetData : $mogoSnapshotSetData") + } + } + + }) + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java index 4add2174dc..69bbf943ca 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java @@ -9,12 +9,14 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.mvp.MvpFragment; import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; import com.mogo.eagle.core.data.map.CenterLine; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider; import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener; +import com.mogo.eagle.core.function.business.ai.AiCloudIdentifyData; import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber; import com.mogo.eagle.core.function.business.MapPointCloudSubscriber; import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager; @@ -191,6 +193,7 @@ public class MapFragment extends MvpFragment MapIdentifySubscriber.Companion.getInstance(); MogoRouteOverlayManager.getInstance().init(); MapPointCloudSubscriber.Companion.getInstance(); + AiCloudIdentifyData.Companion.getAiCloudIdentifyData().init(AbsMogoApplication.getApp()); } private void queryInfStructure() { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt index eb67733969..9250e8fd6e 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt @@ -8,6 +8,8 @@ import com.mogo.eagle.core.function.overview.OverviewDao import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi import com.mogo.eagle.core.function.overview.remote.V2XEvent import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable @@ -22,6 +24,10 @@ class OverViewModel( private val _V2XEvents = MutableLiveData>() private var disposable: Disposable? = null + companion object { + const val TAG = "OverViewModel" + } + val infStructures get() = _infStructures @@ -90,8 +96,10 @@ class OverViewModel( .queryAllV2XEventsByLineId(lineId.toString(), sn) .map { if (it.code == 200 || it.code == 0) { + CallerLogger.d(SceneConstant.M_MAP + TAG, "请求成功,size为:${it.result?.v2XEventList?.size}") return@map it.result?.v2XEventList } else { + CallerLogger.d(SceneConstant.M_MAP + TAG, "请求失败,code为:${it.code}") return@map ArrayList() } } @@ -121,7 +129,12 @@ class OverViewModel( if (parameter != null) { if (parameter.autoPilotLine != null) { lineId = parameter.autoPilotLine!!.lineId + CallerLogger.d(SceneConstant.M_MAP + TAG, "lineId为:$lineId") + } else { + CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter.autoPilotLine为null") } + } else { + CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter为null") } return lineId } diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt index 9d8693a859..38ffb90102 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt @@ -32,7 +32,10 @@ class MoGoObuProvider : IMoGoObuProvider { } override fun init(context: Context) { - CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress() + "--") + //obu融合数据 +// MogoObuDcCombineManager.INSTANCE.init(context) +// CallerLogger.d("${M_OBU}${MogoObuConst.TAG_MOGO_OBU}","MogoObuDcCombineManager 初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress() ) + CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress()) //bus乘客版本obu功能去掉 if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger( FunctionBuildConfig.appIdentityMode diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoObuDcCombineManager.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoObuDcCombineManager.kt new file mode 100644 index 0000000000..4604450741 --- /dev/null +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoObuDcCombineManager.kt @@ -0,0 +1,664 @@ +package com.mogo.eagle.core.function.obu.mogo + +import android.content.Context +import com.mogo.eagle.core.data.config.HmiBuildConfig +import com.mogo.eagle.core.data.enums.EventTypeEnumNew +import com.mogo.eagle.core.data.enums.WarningDirectionEnum +import com.mogo.eagle.core.data.msgbox.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.hmi.warning.IMoGoWarningStatusListener +import com.mogo.eagle.core.function.api.obucombine.IMoGoObuDcCombineListener +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager +import com.mogo.eagle.core.function.call.obucombine.CallerObuDcCombineListenerManager +import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertDcCombineUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +import com.mogo.support.obu.constants.MogoObuConstants +import mogo.v2x.ObuWarningEvent +import mogo.v2x.ObuWarningEvent.* + + +/** + * + * @author lixiaopeng + * @since 2021/11/30 + * @description 工控机融合数据 + */ +class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener { + companion object { + val INSTANCE: MogoObuDcCombineManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + MogoObuDcCombineManager() + } + } + + private var mContext: Context? = null + private val TAG = "MogoObuDcCombineManager" + + + fun init(context: Context) { + mContext = context + CallerObuDcCombineListenerManager.addListener(TAG, this) + } + + fun destoryListener() { + CallerObuDcCombineListenerManager.removeListener(TAG) + } + + /** + * 通过工控机中转的obu数据,包括rsi,rsm,spat + * + */ + override fun onMoGoObuDcCombineData(obuWarningData: ObuWarningEvent.ObuWarningData?) { + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager onMoGoObuDcCombineData obuWarningData = ${obuWarningData.toString()} ---obuWarningData.msgDataType = ${obuWarningData?.msgDataType}" + ) + + obuWarningData?.let { + when (obuWarningData.msgDataType) { + 1 -> { //rsiEvent + onMogoObuDcRsiWarning(obuWarningData.rsiEvent) + } + + 2 -> { //RsmEvent + onMogoObuDcRsmWarning(obuWarningData.rsmEvent) + } + + 3 -> { //SpatEvent + onMogoObuDcSpatWarning(obuWarningData.spatEvent) + } + + 4 -> { //map + onMogoObuMapMath(obuWarningData.mapMatchData) + } + } + } + + } + + /** + * RSI预警信息 CvxRtiThreatIndInfo(交通标志预警(前方限速、前方学校等等),交通事件预警(前方拥堵、前方积水等等)) + */ + fun onMogoObuDcRsiWarning(rsiWarningData: RsiWarningData?) { + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuRsiWarning ------> ${rsiWarningData.toString()}" + ) + if (rsiWarningData != null && rsiWarningData.warningMsgList != null && rsiWarningData.warningMsgList.size > 0) { + var alertContent = "" + var ttsContent = "" //TODO 列表还是只有一项吗? + var appId = rsiWarningData.warningMsgList[0].sceneType.toString() + val status = rsiWarningData.status + val level = rsiWarningData.warningMsgList[0].warningLevel + val direction = getMessageDirection(rsiWarningData.warningMsgList[0].targetPosition) + CallerLogger.d("${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuDcRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${rsiWarningData.warningMsgList[0].eventSerialNum} ---signSerialNum = ${rsiWarningData.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${rsiWarningData.warningMsgList[0].targetPosition}" + ) + + when (appId) { + // 道路危险情况预警 + MogoObuConstants.RSI_SCENE_TYPE.HLW.toString() -> { + when (rsiWarningData.warningMsgList[0].eventSerialNum) { + MogoObuConstants.RTE.RTI_TYPE_BREAKDOWN -> {//车辆故障 + appId = EventTypeEnumNew.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType + } + MogoObuConstants.RTE.RTI_TYPE_ROAD_WATER -> { //道路积水 + appId = EventTypeEnumNew.FOURS_PONDING.poiType + } + MogoObuConstants.RTE.RTI_TYPE_PARKING_VIOLATION -> { //异常停车 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PARKING.poiType + } +// MogoObuConstants.RTE.RTI_TYPE_CONSTRUCTION_RTE -> { //施工占道,和标牌重复 +// appId = EventTypeEnumNew.FOURS_ROAD_WORK.poiType +// } + MogoObuConstants.RTE.RTI_TYPE_SPEEDING -> { //超速行驶 + appId = EventTypeEnumNew.TYPE_USECASE_ID_SLW.poiType + } + MogoObuConstants.RTE.RTI_TYPE_RETRIGRADE -> { //车辆逆行 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType + } + } + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //事件才有影响范围 + alertContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(), + Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(), + Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString() + ) + } + + //车内标牌 + MogoObuConstants.RSI_SCENE_TYPE.IVS.toString() -> { + when (rsiWarningData.warningMsgList[0].signSerialNum) { +// MogoObuConstants.RTS.RTI_TYPE_INTERSECTION -> { //十字路口 +// appId = V2iEventTypeEnum.TYPE_ID_NTERSECTION.poiType +// } + MogoObuConstants.RTS.RTI_TYPE_SHAPR_TURNS -> { //急转弯 + appId = EventTypeEnumNew.TYPE_ID_SHAPR_TURNS.poiType + } + MogoObuConstants.RTS.RTI_TYPE_BRIDGE -> { //桥梁 + appId = EventTypeEnumNew.TYPE_ID_BRIDGE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_PEDESTRIAN -> { //行人 + appId = EventTypeEnumNew.TYPE_ID_PEDESTRIAN.poiType + } + MogoObuConstants.RTS.RTI_TYPE_SLIPPERY_ROAD -> { //路滑 + appId = EventTypeEnumNew.TYPE_ID_SLIPPERY_ROAD.poiType + } + MogoObuConstants.RTS.RTI_TYPE_TUNNEL -> { //隧道 + appId = EventTypeEnumNew.TYPE_ID_TUNNEL.poiType + } + MogoObuConstants.RTS.RTI_TYPE_FERRY -> { //渡轮 + appId = EventTypeEnumNew.TYPE_ID_FERRY.poiType + } + MogoObuConstants.RTS.RTI_TYPE_UNEVEN_ROAD -> { //路面不平 + appId = EventTypeEnumNew.TYPE_ID_UNEVEN_ROAD.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NON_MOTOR_VEHICLE -> { //非机动车 + appId = EventTypeEnumNew.TYPE_ID_NON_MOTOR_VEHICLE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_OBSTACLE -> { //障碍 + appId = EventTypeEnumNew.TYPE_ID_OBSTACLE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_CONSTRUCTION -> { //施工 + appId = EventTypeEnumNew.TYPE_FOURS_ROAD_WORK.poiType + } + MogoObuConstants.RTS.RTI_TYPE_VEHICLE_QUEUE -> { //车队 + appId = EventTypeEnumNew.TYPE_VEHICLE_QUEUE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_PASSING -> { //不通 + appId = EventTypeEnumNew.TYPE_NO_PASSING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_TURNING_AROUND -> { //禁止掉头 + appId = EventTypeEnumNew.TYPE_NO_TURNING_AROUND.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_STOPPING -> { //禁止停车 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_TOOTING -> { //禁止鸣笛 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_SPEED_LIMIT -> { //限速 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType + } +// MogoObuConstants.RTS.RTI_TYPE_GO_STRAIGHT_TURN_RIGHT -> { //直行或右转 +// appId = +// EventTypeEnumNew.TYPE_USECASE_ID_GO_STRAIGHT_TURN_RIGHT.poiType +// } + MogoObuConstants.RTS.RTI_TYPE_BUS_WARNING -> { //公交提醒 + appId = EventTypeEnumNew.TYPE_USECASE_ID_BUS_WARNING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NARROW_RIGHT -> { //右侧变窄/车道数减少 + appId = EventTypeEnumNew.TYPE_USECASE_ID_NARROW_RIGHT.poiType + } + MogoObuConstants.RTS.RTI_TYPE_GAS_STATION -> { //加油站 + appId = EventTypeEnumNew.TYPE_USECASE_ID_GAS_STATION.poiType + } + MogoObuConstants.RTS.RTI_TYPE_SCHOOL -> { //学校 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType + } + MogoObuConstants.RTS.RTI_TYPE_ACCIDENT -> { //事故 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ACCIDENT.poiType + } + } + + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //标牌是没有影响范围的 + alertContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString() + ) + } + + // 拥堵 + MogoObuConstants.RSI_SCENE_TYPE.TJW.toString() -> { + appId = EventTypeEnumNew.TYPE_USECASE_ID_TJW.poiType + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //事件才有影响范围 + alertContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(), + Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(), + Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString() + ) + } + + //限速预警, ADD处理一次 + MogoObuConstants.RSI_SCENE_TYPE.SLW.toString() -> { + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + } + } + + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}" + ) + when (status) { + // 添加 + MogoObuConstants.STATUS.ADD -> { + //显示警告红边 + CallerHmiManager.showWarning(direction) + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + appId, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.TELEMATIC + } + ) + CallerHmiManager.warningV2X( + appId, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (appId + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 5000L + ) + + // 更新数据,是否需要 +// TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(rsiWarningData)?.let { +// CallerMapUIServiceManager.getMarkerService() +// ?.updateITrafficThreatLevelInfo(it) +// } + } + + MogoObuConstants.STATUS.UPDATE -> { // 更新 + } + + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 移除顶部弹窗 + CallerHmiManager.disableWarningV2X((appId + direction.direction)) + // 更新数据,删除标牌? +// TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(rsiWarningData) +// ?.let { +// // 事件结束,还原车辆颜色 +// it.threatLevel = 0x01 +// CallerMapUIServiceManager.getMarkerService() +// ?.updateITrafficInfo(it) +// } + } + } + } + } + + /** + * RSM预警信息 CvxPtcThreatIndInfo CvxPtcInfoIndInfo(主车与弱势交通参与者之间的预警(如:弱势交通参与者碰撞预警)) + */ + fun onMogoObuDcRsmWarning(rsmWarningData: RsmWarningData?) { + if (HmiBuildConfig.isShowObuWeaknessTrafficView) { + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuRsmWarning ------> ${rsmWarningData.toString()}" + ) + // 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu + if (rsmWarningData != null && rsmWarningData.participantOfOne != null) { + var v2xType = "" + if (rsmWarningData.participantOfOne.ptcType == 1) { //机动车 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType + } else if (rsmWarningData.participantOfOne.ptcType == 2) { //非机动车 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType + } else if (rsmWarningData.participantOfOne.ptcType == 3) { //行人 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.poiType + } else { //未知 + v2xType = EventTypeEnumNew.TYPE_ERROR.poiType + } + val ttsContent = EventTypeEnumNew.getWarningTts(v2xType) + val alertContent = + EventTypeEnumNew.getWarningContent(v2xType) + var level = -1 + val direction = + getMessageDirection(rsmWarningData.participantOfOne.targetPosition) //TODO 只有一个 + if (rsmWarningData.warningMsg != null && rsmWarningData.warningMsg.warningDataList != null && rsmWarningData.warningMsg.warningDataList.size > 0) { + level = rsmWarningData.warningMsg.warningDataList[0].warningLevel + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuRsmWarning ---status---> ${rsmWarningData.status} --list status----> ${rsmWarningData.warningMsg.warningDataList.get(0).status} --v2xType--- $v2xType ---alertContent = $alertContent ---ttsContent= $ttsContent" + ) + + when (rsmWarningData.warningMsg.warningDataList.get(0).status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + //显示警告红边 + CallerHmiManager.showWarning(direction) + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + v2xType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.TELEMATIC + } + ) + CallerHmiManager.warningV2X( + v2xType, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (v2xType + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning( + WarningDirectionEnum.ALERT_WARNING_NON + ) + } + }, + true, + 5000L + ) + + // 更新数据 TODO + TrafficDataConvertDcCombineUtils.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)?.let { +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + } + + MogoObuConstants.STATUS.UPDATE -> {// 更新 + } + + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 更新数据 TODO 由于obu通过域控需要转换单位,这里临时转换,后面3.0不需要转换 + TrafficDataConvertDcCombineUtils.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)?.let { + // 事件结束,还原交通参与者颜色 + it.threatLevel = 0x01 +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + //删除弱势交通元素 + CallerMapUIServiceManager.getMarkerService() + ?.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString()) +// TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString()) + } + } + } + } + } + + } + + /** + * 红绿灯预警信息 + */ + fun onMogoObuDcSpatWarning(spatWarningData: SpatWarningData?) { + CallerLogger.d("${M_OBU}${TAG}", "onMogoObuDcSpatWarning warningType = ${spatWarningData!!.warningType} --status = ${spatWarningData?.status} --lightsList = ${spatWarningData.lightsList}") + handlerTrafficLight( + spatWarningData!!.warningType, + spatWarningData?.status, + spatWarningData?.lightsList + ) + } + + /** + * 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道 + */ + fun onMogoObuMapMath(data: MapMatchData?) { + CallerLogger.d("${M_OBU}${TAG}", "MogoObuDcCombineManager onMogoObuMapMath HmiBuildConfig.isShowObuLimitSpeedView = " + HmiBuildConfig.isShowObuLimitSpeedView) + if(HmiBuildConfig.isShowObuLimitSpeedView) { + if (data != null) { + CallerLogger.d("${M_OBU}${TAG}", + "MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${Math.round((data.speedMaxLimit*0.02*3.6))} --- data.speedMaxLimit = ${data.speedMaxLimit}") + when (data.status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + CallerHmiManager.showLimitingVelocity(Math.round((data.speedMaxLimit*0.02*3.6)).toInt()) + } + + MogoObuConstants.STATUS.UPDATE -> { // 更新 + } + + MogoObuConstants.STATUS.DELETE -> { // 删除 + CallerHmiManager.disableLimitingVelocity() + } + } + } + } + } + + /** + * 获取消息的方位 车辆相关 + */ + private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { + return when (targetClassification) { + MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE, + MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 + + MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 + + MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 + + MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方 + + MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT, + MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT + -> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方 + + MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT, + MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT + -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方 + + MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT, + -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方 + + MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT, + -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方 + + MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 + else -> WarningDirectionEnum.ALERT_WARNING_ALL + } + } + + /** + * 处理红绿灯 + */ + private fun handlerTrafficLight(appId: Int, status: Int, lights: List) { + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId" + ) + when (status) { + // 添加 + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE + -> { + if (lights != null && lights.isNotEmpty()) { + changeTrafficLightStatus(appId, lights) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 移除顶部弹窗,当收不到信号的时候触发一次 + CallerHmiManager.disableWarningTrafficLight() + CallerHmiManager.disableWarningV2X(appId.toString()) + isShowGreenWave = false + isShowRunRedLight = false + } + } + } + + private var isRedLight = false + private var isGreenLight = false + private var isShowGreenWave = false + private var isShowRunRedLight = false + + /** + * 修改红绿灯 + */ + @Synchronized + private fun changeTrafficLightStatus( + appId: Int, + lights: List + ) { + var ttsContent = "" + var alertContent = "" + //这里需要根据真实数据确定 index 取值方式 + val currentLight = lights[0] + CallerLogger.e( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager currentLight = $currentLight ---currentLight.phaseID = ${currentLight.phaseID} ---appId = $appId ---isShowRunRedLight = $isShowRunRedLight ---isShowGreenWave = $isShowGreenWave" + ) + + // 闯红灯预警和绿波通行底层是互斥的 + when (appId) { + 0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效 + + } + 1 -> { //闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次 + if (!isShowRunRedLight) { + isShowRunRedLight = true + CallerHmiManager.disableWarningV2X(2.toString()) + ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + CallerLogger.d("${M_OBU}${TAG}","MogoObuDcCombineManager changeTrafficLightStatus 闯红灯 --------> ttsContent = $ttsContent ---alertContent = $alertContent ") + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.TELEMATIC + } + ) + + CallerHmiManager.showWarningV2X( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, null, true, 5000L) + } + } + + 2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 + if (!isShowGreenWave) { + isShowGreenWave = true + CallerHmiManager.disableWarningV2X(1.toString()) + CallerLogger.d( + "${M_OBU}${TAG}", + "MogoObuDcCombineManager 绿波通行引导 --------> speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}") + val adviceSpeed = + "${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}" + val adviceSpeedTts = + "${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}" + + ttsContent = + String.format( + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeedTts + ) + alertContent = + String.format( + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeed + ) + val maxSpeed = currentLight.suggestMaxSpeed*3.6 + if (maxSpeed > 0) { + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.TELEMATIC + } + ) + + CallerHmiManager.warningV2X( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + appId.toString(), + null, + true, + 5000L + ) + } + } + } + } + + when (currentLight.light) { + // 灯光不可用 + 0 -> { + CallerHmiManager.showWarningTrafficLight(0, 2) + } + + // 红灯 + 2, 3 -> { + if (!isRedLight) { + CallerHmiManager.disableWarningV2X(appId.toString()) + isRedLight = true + } + isGreenLight = false + CallerHmiManager.showWarningTrafficLight(1, 2) + val red = currentLight.countDown / 10 + CallerHmiManager.changeCountdownRed(red) + } + + // 绿灯 + 4, 5, 6 -> { + if (!isGreenLight) { + CallerHmiManager.disableWarningV2X(appId.toString()) + isGreenLight = true + } + isRedLight = false + CallerHmiManager.showWarningTrafficLight(3, 2) + val green = currentLight.countDown / 10 + CallerHmiManager.changeCountdownGreen(green) + } + + // 黄灯 + 7, 8 -> { + CallerHmiManager.disableWarningV2X(appId.toString()) + CallerHmiManager.showWarningTrafficLight(2, 2) + val yellow = currentLight.countDown / 10 + CallerHmiManager.changeCountdownYellow(yellow) + } + } + } + +} diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt index 897a9432fe..dc66e9ec3b 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt @@ -6,6 +6,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig.isShowObuLimitSpeedView import com.mogo.eagle.core.data.enums.* +import com.mogo.eagle.core.data.msgbox.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 @@ -417,13 +418,15 @@ class MogoPrivateObuNewManager private constructor() { } CallerMsgBoxManager.saveMsgBox( MsgBoxBean( - MsgBoxType.OBU, + MsgBoxType.V2X, V2XMsg( appId, alertContent, ttsContent ) - ) + ).apply { + sourceType = DataSourceType.OBU + } ) CallerHmiManager.warningV2X( appId, @@ -437,7 +440,7 @@ class MogoPrivateObuNewManager private constructor() { } }, true, - 3000L + 5000L ) // 更新数据 @@ -525,13 +528,15 @@ class MogoPrivateObuNewManager private constructor() { } CallerMsgBoxManager.saveMsgBox( MsgBoxBean( - MsgBoxType.OBU, + MsgBoxType.V2X, V2XMsg( v2xType, alertContent, ttsContent ) - ) + ).apply { + sourceType = DataSourceType.OBU + } ) CallerHmiManager.warningV2X( v2xType, @@ -759,13 +764,15 @@ class MogoPrivateObuNewManager private constructor() { //不显示弹框,其它保留 CallerMsgBoxManager.saveMsgBox( MsgBoxBean( - MsgBoxType.OBU, + MsgBoxType.V2X, V2XMsg( appId, alertContent, ttsContent ) - ) + ).apply { + sourceType = DataSourceType.OBU + } ) CallerHmiManager.warningV2X( appId, @@ -789,7 +796,7 @@ class MogoPrivateObuNewManager private constructor() { } }, true, - 3000L + 5000L ) //显示警告红边 CallerHmiManager.showWarning(direction) @@ -873,11 +880,24 @@ class MogoPrivateObuNewManager private constructor() { isShowRunRedLight = true CallerHmiManager.disableWarningV2X(0x2.toString()) CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}","changeTrafficLightStatus 闯红灯 --------> ") - ttsContent = EventTypeEnumNew.getWarningTts(appId.toString()) - alertContent = EventTypeEnumNew.getWarningContent(appId.toString()) + ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.OBU + } + ) + CallerHmiManager.warningV2X( - appId.toString(), alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - appId.toString(), null, true, 5000L) + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, null, true, 5000L) } } @@ -911,13 +931,15 @@ class MogoPrivateObuNewManager private constructor() { } CallerMsgBoxManager.saveMsgBox( MsgBoxBean( - MsgBoxType.OBU, + MsgBoxType.V2X, V2XMsg( EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, alertContent, ttsContent ) - ) + ).apply { + sourceType = DataSourceType.OBU + } ) CallerHmiManager.warningV2X( diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertDcCombineUtils.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertDcCombineUtils.kt new file mode 100644 index 0000000000..721454634b --- /dev/null +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertDcCombineUtils.kt @@ -0,0 +1,97 @@ +package com.mogo.eagle.core.function.obu.mogo.utils + +import android.util.Log +import com.mogo.eagle.core.data.enums.TrafficTypeEnum +import com.mogo.eagle.core.data.traffic.TrafficData +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +import com.mogo.support.obu.model.MogoObuRsiWarningData +import com.mogo.support.obu.model.MogoObuRsmWarningData +import com.mogo.support.obu.model.MogoObuRvWarningData +import mogo.v2x.ObuWarningEvent + +/** + * @description 自研obu数据通过工控机转发 + * + * @author lixiaopeng + * @since 2022/12/2 + */ +object TrafficDataConvertDcCombineUtils { + val TAG = "TrafficDataConvertDcCombineUtils" + + /** + * OBU RSU道路事件预警信息 转换交通元素数据 标牌 为何要显示level + */ + fun cvxRtiThreatIndInfo2TrafficData(info: MogoObuRsiWarningData): TrafficData? { + if (info.warningMsg == null || info.warningMsg.size < 1 || info.warningMsg[0].position == null) { + CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") + return null + } + val trafficData = TrafficData() + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG + trafficData.uuid = info.warningMsg[0].signSerialNum.toString() + trafficData.lat = info.warningMsg[0].position.latitude + trafficData.lon = info.warningMsg[0].position.longitude + trafficData.threatLevel = info.warningMsg[0].warningLevel + Log.e("liyz", "cvxRtiThreatIndInfo2TrafficData trafficData -- ${trafficData.toString()}") + return trafficData + } + + /** + * OBU 弱势交通参与者信息 转换交通元素数据 + */ + fun cvxPtcThreatIndInfo2TrafficData(info: ObuWarningEvent.RsmWarningData): TrafficData? { + if (info.participantOfOne == null) { + CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") + Log.e("liyz", "cvxPtcThreatIndInfo2TrafficData info.participant ") + return null + } + val trafficData = TrafficData() + trafficData.uuid = info.participantOfOne.ptcID.toString() + trafficData.lat = info.participantOfOne.latitude / 10000000.0 + trafficData.lon = info.participantOfOne.longitude / 10000000.0 + trafficData.heading = info.participantOfOne.heading / 80.0 + trafficData.speed = info.participantOfOne.speed / 50.0 + + CallerLogger.e( + "${M_OBU}${"MogoObuDcCombineManager"}", + " cvxPtcThreatIndInfo2TrafficData ---uuid---> ${trafficData.uuid} --lat-- ${trafficData.lat} --lon-- ${trafficData.lon} --heading-- ${trafficData.heading} --speed-- ${trafficData.speed} --type --${info.participantOfOne.ptcType}" + ) + + when (info.participantOfOne.ptcType) { + // 未知 + 0 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI + } + //机动车 + 1 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO + } + // 非机动车 + 2 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE + } + // 行人 + 3 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE + } + } + + /** + * 交通参与者类型 + * 0:未知 + * 1:机动车 + * 2:非机动车 + * 3:行人 + * 4:OBU自身 + */ + // 判断车辆V2X预警级别,调整车辆颜色 + if (info.warningMsg != null && info.warningMsg.warningDataList != null) { + trafficData.threatLevel = info.warningMsg.warningDataList[0].warningLevel + } else { + trafficData.threatLevel = 1 + } + return trafficData + } + +} \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt index 748b847aef..68da05ad2a 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/enums/EventTypeEnumNew.kt @@ -133,7 +133,7 @@ enum class EventTypeEnumNew( // 违章停车 ALERT_ILLEGAL_PARK("99992"), - //-------------v2n start ------------> + //-------------obu v2n start ------------> TYPE_USECASE_ID_FCW( 2000.toString(), "前向碰撞预警", @@ -205,10 +205,9 @@ enum class EventTypeEnumNew( content = "注意特种车辆通行", tts = "请避让特种车辆" ), - //-------------v2n end ------------> + //-------------obu v2n end ------------> - - //---------弱势交通参与者 start ------> + //---------弱势交通参与者 obu and cloud start ------> TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES( 1001.toString(), "弱势交通参与者碰撞预警", @@ -237,8 +236,7 @@ enum class EventTypeEnumNew( content = "前方有未知障碍物", tts = "前方有未知障碍物" ), - //---------弱势交通参与者 end --------> - + //---------弱势交通参与者 obu and cloud end --------> //--------------红绿灯 start -------> TODO 修改重复 TYPE_USECASE_ID_IVP_RED( @@ -258,7 +256,7 @@ enum class EventTypeEnumNew( ), //-------------红绿灯 end ----------> - //-----------道路危险情况预警 start ---------------> + //-----------道路危险情况预警 obu start ---------------> TYPE_USECASE_ID_BREAKDOWN_WARNING( //故障车辆 101.toString(), "车辆故障", @@ -308,10 +306,9 @@ enum class EventTypeEnumNew( content = "您已超速,请减速行驶", tts = "您已超速,请减速行驶" ), - //------------道路危险情况预警 end -----------> + //------------道路危险情况预警 obu end -----------> - - //------------车内标牌 start --------------> + //------------车内标牌 obu start --------------> TYPE_ID_SHAPR_TURNS( 2.toString(), "急转弯", @@ -452,8 +449,7 @@ enum class EventTypeEnumNew( content = "前方%s米事故", tts = "前方%s米事故" ), - //------------车内标牌 end --------------> - + //------------车内标牌 obu end --------------> TYPE_ERROR( 0.toString(), diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/DataSourceType.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/DataSourceType.kt new file mode 100644 index 0000000000..60561f77de --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/DataSourceType.kt @@ -0,0 +1,5 @@ +package com.mogo.eagle.core.data.msgbox + +enum class DataSourceType { + DEFAULT, OBU, TELEMATIC, AICLOUD +} \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxBean.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxBean.kt index 7a08d71212..9c370be85d 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxBean.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxBean.kt @@ -3,4 +3,5 @@ package com.mogo.eagle.core.data.msgbox data class MsgBoxBean(val type: MsgBoxType, val bean: Any) { var timestamp: Long = 0 var bean2Json: String = "" + var sourceType: DataSourceType = DataSourceType.DEFAULT } 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 new file mode 100644 index 0000000000..942102318c --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obucombine/IMoGoObuDcCombineListener.kt @@ -0,0 +1,17 @@ +package com.mogo.eagle.core.function.api.obucombine + +import mogo.v2x.ObuWarningEvent + +/** + * obu和dc 通道打通融合 + */ +interface IMoGoObuDcCombineListener { + + /** + * obu透传v2i数据,(标牌,弱势交通,红绿灯,限速,道路危险状况) + * @param obuWarningData + */ + 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/obucombine/CallerObuDcCombineListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt new file mode 100644 index 0000000000..8e126441f2 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obucombine/CallerObuDcCombineListenerManager.kt @@ -0,0 +1,65 @@ +package com.mogo.eagle.core.function.call.obucombine + +import androidx.annotation.Nullable +import com.mogo.eagle.core.function.api.obucombine.IMoGoObuDcCombineListener +import com.mogo.eagle.core.function.call.base.CallerBase +import mogo.v2x.ObuWarningEvent +import java.util.concurrent.ConcurrentHashMap + +/** + * obu和dc数据通道 回调监听 + */ +object CallerObuDcCombineListenerManager : CallerBase() { + // 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步 + 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数据 + */ + fun invokeObuDcData(obuWarningData: ObuWarningEvent.ObuWarningData?){ + M_DC_COMBINE_LISTENERS.forEach{ + val listener = it.value + listener.onMoGoObuDcCombineData(obuWarningData) + } + } + +} \ No newline at end of file diff --git a/foudations/mogo-commons/build.gradle b/foudations/mogo-commons/build.gradle index 296811e92f..c8fe582aea 100644 --- a/foudations/mogo-commons/build.gradle +++ b/foudations/mogo-commons/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation rootProject.ext.dependencies.arouter annotationProcessor rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.rxjava - implementation rootProject.ext.dependencies.mogoaicloudrealtime + api rootProject.ext.dependencies.mogoaicloudrealtime implementation rootProject.ext.dependencies.amapnavi3dmap if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/module/MogoServices.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/module/MogoServices.java index 5926f0af9d..bfd828a29b 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/module/MogoServices.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/module/MogoServices.java @@ -58,9 +58,6 @@ public class MogoServices implements IMogoIntentListener { intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); mContext.sendBroadcast(intent); -// if (DebugConfig.isNeedUploadCoordinatesDurationInTime()) { -// MoGoAiCloudRealTime.startRealTime(mContext, DebugConfig.getSocketAppId()); -// } } private void registerMogoReceiver(Context context) { diff --git a/gradle.properties b/gradle.properties index e36cf509ed..6b7dbc5b19 100644 --- a/gradle.properties +++ b/gradle.properties @@ -175,4 +175,4 @@ ADAS_DATA_LIB_CHILD_VERSION=.0 # 线程优化版本 -THREAD_OPT_VERSION=3.0.2 +THREAD_OPT_VERSION=4.0.0 diff --git a/libraries/mogo-adas-data/src/main/proto/SocketDownDataProto3.proto b/libraries/mogo-adas-data/src/main/proto/SocketDownDataProto3.proto deleted file mode 100644 index b101f6234c..0000000000 --- a/libraries/mogo-adas-data/src/main/proto/SocketDownDataProto3.proto +++ /dev/null @@ -1,78 +0,0 @@ -syntax = "proto3"; -package mogo.yycp.service; -option java_package = "mogo.yycp.api.proto"; -option java_outer_classname = "SocketDownData"; -/* -message xxx { - // 字段规则:required -> 字段只能也必须出现 1 次 - // 字段规则:optional -> 字段可出现 0 次或1次 - // 字段规则:repeated -> 字段可出现任意多次(包括 0) - // 类型:int32、int64、sint32、sint64、string、32-bit .... - // 字段编号:0 ~ 536870911(除去 19000 到 19999 之间的数字) - 字段规则 类型 名称 = 字段编号; -} -*/ -//返回车机主实体 -message SocketDownDataProto { - uint64 seq = 1; - uint32 msgType = 2; - string sn = 3; - LauncherSnapshotProto data = 4; - uint64 utcTime = 5; - uint64 upUtcTime = 6; - string cityCode = 7; -} - -//LauncherSnapshot数据响应VO -message LauncherSnapshotProto { - //总数据集合 RoadDataVo - repeated CloudRoadDataProto allList = 1; - //前方50米数据集合 RoadDataVo - repeated CloudRoadDataProto nearList = 2; - //摄像头 RoadDataVo - CloudRoadDataProto camera = 3; - string msgId = 4; - uint64 time = 5; - //过期时间 - uint64 expire = 6; -} -//RoadDataVo -message CloudRoadDataProto { - /**物体类型 1-人 2-自行车 3-小轿车 4-摩托车 5-红绿灯 6-bus 8-truck 9-路边摄像头*/ - uint32 type = 1; - /**数据来源 1,"自车数据" 2,"ADAS数据" 3,"路测设备识别数据" */ - uint32 fromType = 2; - /** - * 车机上行pgs坐标给lat,lon两个成员变量 - * - * 在下发车机时计算高德经纬度 - * 1.将gps(lat,lon)给wgslat,wgalon - * 2.高德算法算出高德经纬度,给lat,lon - */ - double lat = 3; //gps->gd - double lon = 4; //gps->gd - double wgslat = 5; //原gps - double wgslon = 6; //原gps - //车机sn - string sn = 7; - //车辆UUID - string uuid = 8; - /** 车牌号 */ - string cardId = 9; - /**速度*/ - double speed = 10; - /**方向*/ - double heading = 11; - /** 系统时间 */ - uint64 systemTime = 12; - /** 星历时间 */ - uint64 satelliteTime = 13; - /**红绿灯状态 1红 2绿 3黄*/ - uint32 lightStatus = 14; - /**红绿灯剩余时间 读秒*/ - uint32 lightLeftTime = 15; - /**视频流直播地址*/ - string rtmpUrl = 16; - /**距离*/ - double distance = 17; -} diff --git a/libraries/mogo-adas-data/src/main/proto/chassis.proto b/libraries/mogo-adas-data/src/main/proto/chassis.proto index c0d10d8dca..015f089efb 100644 --- a/libraries/mogo-adas-data/src/main/proto/chassis.proto +++ b/libraries/mogo-adas-data/src/main/proto/chassis.proto @@ -24,7 +24,8 @@ enum PilotMode { MODE_STEER_ONLY = 2; MODE_SPEED_ONLY = 3; MODE_REMOTE_DRIVE = 6; - CHASSID_TELECONTROL_DRIVE = 7; + MODE_TELECONTROL_DRIVE = 7; + MODE_INVALID = 8; } enum LongitudeDrivingMode { @@ -98,4 +99,4 @@ enum CleanSystemControlMode { Clean_PureWash_Both_Side_Work = 12; Clean_PureWash_Left_Work = 13; Clean_PureWash_Right_Work = 14; -} \ No newline at end of file +} diff --git a/libraries/mogo-adas-data/src/main/proto/obu_warning_event.proto b/libraries/mogo-adas-data/src/main/proto/obu_warning_event.proto index 3d3f89e613..5dd9552082 100644 --- a/libraries/mogo-adas-data/src/main/proto/obu_warning_event.proto +++ b/libraries/mogo-adas-data/src/main/proto/obu_warning_event.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package mogo.v2x.v2i; +package mogo.v2x; import "header.proto"; import "mogo_v2x.proto"; @@ -91,10 +91,27 @@ message SpatWarningData{ repeated SpatLight lights = 3; /* 灯色信息集合 */ } -message ObuWarningData{ - common.Header header = 1; - int32 MsgDataType = 2; /*1:rsiEvent; 2:RsmEvent; 3:SpatEvent*/ - RsiWarningData rsiEvent = 3; - RsmWarningData RsmEvent = 4; - SpatWarningData SpatEvent = 5; +message NodeID{ + int32 region = 1;/* 定义地图中划分区域的ID号 */ + int32 id = 2; /* 定义地图节点ID */ } + +message MapMatchData{ + int32 status = 1;/* 状态信息,0:更新,1:添加,2:删除 */ + int32 unitMask = 2;/* 描述所属字段有效性 */ + NodeID currentNodeID = 3;/* 前方节点信息 */ + NodeID upstreamNodeID = 4;/* 上游节点信息 */ + int32 matchingLaneID = 5;/* 匹配车道ID,0:无效 */ + int32 speedMaxLimit = 6;/* 建议最大车速,单位(0.02m/s) */ + int32 speedMinLimit = 7;/* 建议最小车速,单位(0.02m/s) */ +} + +message ObuWarningData{ + common.Header header = 1; + int32 msgDataType = 2; /*1:rsiEvent; 2:rsmEvent; 3:spatEvent; 4:mapMatchData*/ + RsiWarningData rsiEvent = 3; + RsmWarningData rsmEvent = 4; + SpatWarningData spatEvent = 5; + MapMatchData mapMatchData = 6; +} + diff --git a/libraries/mogo-adas-data/src/main/proto/system_status_info.proto b/libraries/mogo-adas-data/src/main/proto/system_status_info.proto index 58c511d8c8..0a4953f7f8 100644 --- a/libraries/mogo-adas-data/src/main/proto/system_status_info.proto +++ b/libraries/mogo-adas-data/src/main/proto/system_status_info.proto @@ -30,7 +30,6 @@ message HealthInfo{ message TopicInfo{ optional string name = 1; //topic name optional int32 hz = 2; //Topic发送的频率 - // optional int32 max_delay = 3; //unit: msec } message DropTopic{ @@ -38,10 +37,28 @@ message DropTopic{ repeated TopicInfo topic = 2; } +message NodeInfo{ + optional string node_name = 1; //node name + optional string launch_name = 2; //launch name + optional int32 state = 3; //0:未知状态None,1:依赖未就绪Waiting,2:启动中Starting,3:运行running,4:停止stopping,5:无法启动状态,6:人为启动状态,7:人为关闭状态 +} + +message NodeFaultList{ + required int32 sum = 1; //下述node总数 + repeated NodeInfo node = 2; +} message StatusInfo { - required SystemState sys_state=1; // 当前消息状态 + required SystemState sys_state=1; // 当前系统状态 repeated HealthInfo health_info=2; // 健康检查状态信息 optional DropTopic topic_drop_info=3; // topic 掉频信息, 如有掉频添加没有不添加 - optional string reserved = 4; // 预留可选字段,用于接口扩充或者,其他信息补充 + optional string reserved = 4; // 用于表示idle模式,'idle' 表示idle模式 'work' 表示正常工作 + // add by liyl 20220907 + optional int32 pilot_mode = 5; // 0: manaul 1: autopilot 2: RemotePilot + optional string map_version = 6; // MAP 版本信息 + optional string master_version = 7; // system_master 版本信息 + optional bool auto_pilot_ready = 8; // 自动驾驶状态就绪, 20221111增加 + optional bool remote_pilot_ready = 9; // 平行驾驶状态就绪 + optional NodeFaultList auto_pilot_unready_list = 10; //20221128 增加 + optional NodeFaultList remote_pilot_unready_list = 11; //20221128 增加 } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java index 649cbf48d7..5f0b6395e8 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java @@ -6,6 +6,7 @@ import com.zhidao.support.adas.high.common.ProtocolStatus; import chassis.VehicleStateOuterClass; import mogo.telematics.pad.MessagePad; +import mogo.v2x.ObuWarningEvent; import mogo_msg.MogoReportMsg; import perception.TrafficLightOuterClass; import prediction.Prediction; @@ -180,6 +181,13 @@ public interface OnAdasListener { */ void onPlanningActionMsg(MessagePad.Header header, MessagePad.PlanningActionMsg planningActionMsg); + /** + * OBU预警事件 + * + * @param header 头 + * @param obuWarningData 数据 + */ + void onObuWarningData(MessagePad.Header header, ObuWarningEvent.ObuWarningData obuWarningData); /** * 是否有能力启动自动驾驶 diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java index af484038ee..2de37de94f 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java @@ -53,7 +53,8 @@ public enum MessageType { TYPE_SEND_TRIP_INFO_REQ(MessagePad.MessageType.MsgTypeTripInfoEvent, "行程信息"), TYPE_SEND_SPECIAL_VEHICLE_TASK_CMD(MessagePad.MessageType.MsgTypeSpecialVehicleTaskCmd, "特种车辆命令"), //透传 原始pb文件中不存在以下type。由于Java中无法强转所以在mogo-adas-data message_pad.proto中放开注释 - TYPE_RECEIVE_PLANNING_DECISION_STATE(MessagePad.MessageType.MsgTypePlanningDecisionState, "Planning决策状态"); + TYPE_RECEIVE_PLANNING_DECISION_STATE(MessagePad.MessageType.MsgTypePlanningDecisionState, "Planning决策状态"), + TYPE_RECEIVE_OBU_WARNING_DATA(MessagePad.MessageType.MsgTypeObuWarningData, "OBU预警事件"); /** diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java index 5786c0803b..db9df5b63e 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java @@ -31,6 +31,7 @@ public class MyMessageFactory implements IMyMessageFactory { private IMsg statusQueryRespMessage;//状态查询应答 private IMsg recordDataConfigRespMessage;//数据采集配置应答 private IMsg planningDecisionStateMessage;//planning决策状态 + private IMsg obuWarningDataMessage;//工控机透传OBU V2I数据 private final AutopilotReview autopilotReview; @@ -148,6 +149,12 @@ public class MyMessageFactory implements IMyMessageFactory { planningDecisionStateMessage = new PlanningDecisionStateMessage(); } return planningDecisionStateMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_OBU_WARNING_DATA.typeCode) { + //OBU预警事件 + if (obuWarningDataMessage == null) { + obuWarningDataMessage = new ObuWarningDataMessage(); + } + return obuWarningDataMessage; } else { //MessageType.TYPE_DEFAULT.typeCode return null; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ObuWarningDataMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ObuWarningDataMessage.java new file mode 100644 index 0000000000..98075ce004 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ObuWarningDataMessage.java @@ -0,0 +1,31 @@ +package com.zhidao.support.adas.high.msg; + +import android.os.SystemClock; + +import com.google.protobuf.InvalidProtocolBufferException; +import com.zhidao.support.adas.high.AdasChannel; +import com.zhidao.support.adas.high.OnAdasListener; +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.protocol.RawData; + +import mogo.v2x.ObuWarningEvent; + + +/** + * OBU预警事件 + */ +public class ObuWarningDataMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException { + ObuWarningEvent.ObuWarningData obuWarningData = ObuWarningEvent.ObuWarningData.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue()); + AdasChannel.calculateTimeConsumingOnDispatchRaw("OBU预警事件", raw.receiveTime); + long nowTime = 0; + if (CupidLogUtils.isEnableLog()) + nowTime = SystemClock.elapsedRealtime(); + if (adasListener != null) { + adasListener.onObuWarningData(raw.getHeader(), obuWarningData); + } + AdasChannel.calculateTimeConsumingBusiness("OBU预警事件", nowTime); + } +}