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 e1c42574d3..6098e7236e 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 @@ -8,6 +8,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider import com.mogo.eagle.core.function.api.biz.IMoGoNoticeNetCallBack +import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.dispatchAutoPilotManager import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager @@ -117,8 +118,7 @@ class FuncBizProvider : IMoGoFuncBizProvider { } override fun queryV2XEvents() { - if ((AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && (!FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData)) - || AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + if (V2NCarTypeCheck.verifyCarType() && (!FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData)) { v2xPoiLoader.queryWholeRoadEvents() } } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt index 21fd03bc72..496ddc44b2 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt @@ -6,9 +6,9 @@ import com.mogo.commons.constants.HostConst import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.Infrastructure import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager import com.mogo.eagle.core.network.MoGoRetrofitFactory -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb @@ -107,8 +107,7 @@ object OverViewDataManager { .observeOn(AndroidSchedulers.mainThread()) .subscribe { it?.apply { - if ((AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && (!FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData)) - || AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + if (V2NCarTypeCheck.verifyCarType() && (!FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData)) { CallerFuncBizListenerManager.invokeV2XEvents(this) } } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/V2XEventManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/V2XEventManager.kt index e12c0b4ef1..1340f5a967 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/V2XEventManager.kt @@ -7,7 +7,6 @@ import androidx.annotation.* import androidx.localbroadcastmanager.content.* import com.mogo.eagle.core.data.config.* import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_V2X_MSG -import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_ADAS import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_CLOUD import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS import com.mogo.eagle.core.data.enums.* @@ -17,14 +16,17 @@ import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP import com.mogo.eagle.core.data.map.* import com.mogo.eagle.core.data.map.entity.* import com.mogo.eagle.core.data.msgbox.* +import com.mogo.eagle.core.data.multidisplay.TelematicConstant import com.mogo.eagle.core.data.v2x.* import com.mogo.eagle.core.function.api.autopilot.* import com.mogo.eagle.core.function.api.cloud.* import com.mogo.eagle.core.function.call.autopilot.* import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02 +import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck.Companion.verifyCarType import com.mogo.eagle.core.function.call.cloud.* import com.mogo.eagle.core.function.call.hmi.* import com.mogo.eagle.core.function.call.msgbox.* +import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.utilcode.mogo.* import com.mogo.eagle.core.utilcode.mogo.logger.* import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X @@ -43,6 +45,7 @@ import kotlinx.coroutines.* import kotlinx.coroutines.android.* import mogo.telematics.pad.MessagePad.PlanningObject import mogo.v2x.* +import java.nio.charset.Charset import java.util.concurrent.* import java.util.concurrent.atomic.* @@ -170,9 +173,21 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback, handleRoadMarkerEvent(event.data.toRoadMarker()) } is V2XEvent.RoadEventX -> { - if (!AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData) { + val flag = verifyCarType() + Log.d("$M_V2X$TAG", "---- 收到ai云V2N事件 ---:${flag}, ${FunctionBuildConfig.v2nMainSwitch}, ${FunctionBuildConfig.isNewV2NData}") + if (flag && (!FunctionBuildConfig.v2nMainSwitch || !FunctionBuildConfig.isNewV2NData)) { + try { + if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { + Log.d("$M_V2X$TAG", "onAck -> 司机端: 将收到云端事件给到乘客端...") + CallerTelematicManager.sendMsgToAllClients(TelematicConstant.V2N_AI_ROAD_DATA_TO_PASSENGER, GsonUtils.toJson(event).toByteArray(Charset.defaultCharset())) + } else { + Log.d("$M_V2X$TAG", "onAck -> 乘客端: 收到V2N事件...") + } + } catch (t: Throwable) { + t.printStackTrace() + } handleRoadMarkerEvent(event.data.toRoadMarker()) - }else{ + } else{ V2XBizTrace.onAck("事件未触发,被开关拦截",mapOf("roadEvent" to event, "v2nMainSwitch" to FunctionBuildConfig.v2nMainSwitch,"isNewV2NData" to FunctionBuildConfig.isNewV2NData), true) } } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt index f06b170ccf..8d281816a8 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt @@ -21,10 +21,10 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.util.CoordinateTransform import com.mogo.eagle.core.utilcode.util.CoordinateUtils import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils @@ -317,11 +317,11 @@ internal object V2NIdentifyDrawer { override fun onAutopilotIdentifyDataUpdate(trafficData: List?) { super.onAutopilotIdentifyDataUpdate(trafficData) val shiGong = trafficData?.filter { it.type == 501 || it.type == 502 } - if (shiGong != null && shiGong.isNotEmpty()) { + if (!shiGong.isNullOrEmpty()) { drawShiGong(shiGong) } val shiGu = trafficData?.filter { it.type == 13 } - if (shiGu != null && shiGu.isNotEmpty()) { + if (!shiGu.isNullOrEmpty()) { drawShiGu(shiGu) } } @@ -340,21 +340,21 @@ internal object V2NIdentifyDrawer { } private fun drawShiGong(events: List) { - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { + if (V2NCarTypeCheck.verifyCarType() && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { handler.removeMessages(MSG_WHAT_DRAW_SHIGONE) handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_SHIGONE, events)) } } private fun drawShiGu(events: List) { - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { + if (V2NCarTypeCheck.verifyCarType() && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { handler.removeMessages(MSG_WHAT_DRAW_SHIGU) handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_SHIGU, events)) } } private fun drawYongDu(events: List) { - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { + if (V2NCarTypeCheck.verifyCarType() && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { handler.removeMessages(MSG_WHAT_DRAW_YONGDU) handler.sendMessage(Message.obtain(handler, MSG_WHAT_DRAW_YONGDU, events)) } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt index f002941989..d2331334fe 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt @@ -119,7 +119,7 @@ class AiRoadMarker { countDown.incrementAndGet() realMark(marker, wrapper, l1, l2, location.heading) }) - }else{ + } else { wrapper.onRemoved = { id -> aiMakers.remove(id) } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XAiRoadEventMarker.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XAiRoadEventMarker.kt index 09335d777d..c705faae1e 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XAiRoadEventMarker.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XAiRoadEventMarker.kt @@ -67,7 +67,7 @@ class V2XAiRoadEventMarker { CallerMapUIServiceManager.getOverlayManager()?.removeLine(line.id) } val markers = pair.second - if (markers != null && markers.isNotEmpty()) { + if (!markers.isNullOrEmpty()) { for (m in markers) { CallerMapUIServiceManager.getOverlayManager()?.removePoint(m.id) } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt index 0592eb97a2..ad4743829f 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt @@ -1,5 +1,6 @@ package com.mogo.eagle.core.function.datacenter.autopilot.telematic +import android.util.Log import androidx.lifecycle.ProcessLifecycleOwner import androidx.lifecycle.lifecycleScope import com.google.protobuf.TextFormat @@ -11,9 +12,11 @@ import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.data.deva.chain.ChainConstant import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS import com.mogo.eagle.core.data.multidisplay.TelematicConstant +import com.mogo.eagle.core.data.v2x.V2XEvent.RoadEventX import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw +import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager @@ -32,6 +35,7 @@ import io.netty.channel.Channel import kotlinx.coroutines.delay import kotlinx.coroutines.launch import mogo.telematics.pad.MessagePad +import java.nio.charset.Charset class TeleMsgHandler : IMsgHandler { @@ -58,6 +62,20 @@ class TeleMsgHandler : IMsgHandler { override fun handleMsgFromServer(msg: MogoProtocolMsg?, channel: Channel?) { msg?.let { + if (it.protocolType == TelematicConstant.V2N_AI_ROAD_DATA_TO_PASSENGER) { + try { + Log.d(TAG, "乘客屏收到司机屏转发云端下发的V2N事件 --- 1 ---") + val content = String(it.body, Charset.defaultCharset()) + Log.d(TAG, "乘客屏收到司机屏转发云端下发的V2N事件 --- 2 ---:$content") + val data = GsonUtils.fromJson(content, RoadEventX::class.java) + Log.d(TAG, "乘客屏收到司机屏转发云端下发的V2N事件 --- 3 ---:$data") + CallerCloudListenerManager.invokeSocketAck(data) + } catch (t: Throwable) { + t.printStackTrace() + Log.e(TAG, "乘客屏收到司机屏转发云端下发的V2N事件异常", t) + } + return + } when (it.protocolType) { MogoProtocolMsg.NORMAL_DATA -> { try { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt index 4a663b8a58..fdc6dea1bc 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt @@ -604,7 +604,7 @@ class OverMapView @JvmOverloads constructor( * 显示V2X事件的Marker */ private fun showV2XEventMarkers(v2XEventData: List?) { - if (v2XEventData == null || v2XEventData.isEmpty()) return + if (v2XEventData.isNullOrEmpty()) return clearV2XMarkers() val markerOptionsList = ArrayList() for (v2xEvent in v2XEventData) { diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt index e7105b12e0..72b3b57eb3 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/multidisplay/TelematicConstant.kt @@ -11,6 +11,7 @@ class TelematicConstant { const val SHOW_TRAFFIC_LIGHT = 101 const val HIDE_TRAFFIC_LIGHT = 102 const val CONTROL_PASSENGER_DRIVER_MONITOR = 105 + const val V2N_AI_ROAD_DATA_TO_PASSENGER = 106 // V2N老链路云端下发给司机屏的数据,转发给乘客端 const val OBU_RUNREDLIGHT_WARNING = 200 //闯红灯预警开关 const val OBU_GREENWAVE_WARNING = 201 //绿波通行开关 diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerV2XListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerV2XListenerManager.kt index 0123b30139..0021cf174d 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerV2XListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerV2XListenerManager.kt @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.call.autopilot import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.api.autopilot.IMoGoV2XListener +import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NCarTypeCheck.Companion.verifyCarType import com.mogo.eagle.core.function.call.base.CallerBase import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import mogo.v2x.MogoV2X @@ -18,9 +19,23 @@ object CallerV2XListenerManager : CallerBase() { private var congestionTmp: MogoV2X.RSI_PB? = null private var parkingViolationTmp: MogoV2X.RSM_PB? = null + class V2NCarTypeCheck { + companion object { + + @JvmStatic + fun verifyCarType(): Boolean { + val appIdentityMode = FunctionBuildConfig.appIdentityMode + return AppIdentityModeUtils.isTaxi(appIdentityMode) || //Taxi司乘屏 + AppIdentityModeUtils.isBus(appIdentityMode) || //公交司乘屏 + AppIdentityModeUtils.isM2(appIdentityMode) || //B2接驳司乘屏 + AppIdentityModeUtils.isJL(appIdentityMode) //B1接驳司乘屏 + } + } + } + override fun doSomeAfterAddListener(tag: String, listener: IMoGoV2XListener) { if (eventCountTmp >= 0) { - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { + if (verifyCarType() && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { listener.onV2nGlobalPathEvents(eventCountTmp, constructTmp, triangleTmp, congestionTmp, parkingViolationTmp) } } @@ -37,7 +52,7 @@ object CallerV2XListenerManager : CallerBase() { parkingViolationTmp = parkingViolation M_LISTENERS.forEach { val listener = it.value - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { + if (verifyCarType() && FunctionBuildConfig.v2nMainSwitch && FunctionBuildConfig.isNewV2NData) { listener.onV2nGlobalPathEvents(eventCount, construct, triangle, congestion, parkingViolation) } }