diff --git a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml index c9a14ee169..3e12a1ebb2 100644 --- a/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml +++ b/OCH/mogo-och-bus-passenger/src/jinlvvan/res/layout/bus_p_base_fragment.xml @@ -51,7 +51,7 @@ listFSMFunctionStates = new ArrayList<>(); public final List listRoboSweeperTaskIndex = new ArrayList<>(); public final List listBagManagerCmd = new ArrayList<>(); - public final List listObuWarningData = new ArrayList<>(); public final List listObuSpat = new ArrayList<>(); public final List listObuRsi = new ArrayList<>(); public final List listObuRsm = new ArrayList<>(); @@ -159,7 +157,6 @@ public class DataDistribution { private long listFSMFunctionStatesSize = 0; private long listRoboSweeperTaskIndexSize = 0; private long listBagManagerCmdSize = 0; - private long listObuWarningDataSize = 0; private long listObuSpatSize = 0; private long listObuRsiSize = 0; private long listObuRsmSize = 0; @@ -189,7 +186,6 @@ public class DataDistribution { listFSMFunctionStatesSize = 1; listRoboSweeperTaskIndexSize = 1; listBagManagerCmdSize = 1; - listObuWarningDataSize = 1; listObuSpatSize = 1; listObuRsiSize = 1; listObuRsmSize = 1; @@ -246,14 +242,6 @@ 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, new DataShow(listObuWarningDataSize++, 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 ObuSpat) { listObuSpat.add(0, new DataShow(listObuSpatSize++, time + str)); if (listObuSpat.size() > LIST_SIZE) { 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 83e8d67fb7..9f355337f5 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 @@ -134,9 +134,7 @@ 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_OBU_SPAT.equals(title)) { + } else if (Constants.TITLE.RECEIVE_OBU_SPAT.equals(title)) { adapter.setData(DataDistribution.getInstance().listObuSpat); } else if (Constants.TITLE.RECEIVE_OBU_RSI.equals(title)) { adapter.setData(DataDistribution.getInstance().listObuRsi); @@ -144,7 +142,7 @@ public class InfoFragment extends BaseFragment { adapter.setData(DataDistribution.getInstance().listObuRsm); } else if (Constants.TITLE.RECEIVE_OBU_MAP.equals(title)) { adapter.setData(DataDistribution.getInstance().listObuMap); - } else if (Constants.TITLE.RECEIVE_RECORD_DATA_CONFIG_RESP.equals(title)) { + } 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)) { adapter.setData(DataDistribution.getInstance().listGlobalPathResp); 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 4f27b36e6a..50ddaa22bc 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 @@ -73,7 +73,6 @@ import com.zhidao.adas.client.bean.ObuMap; import com.zhidao.adas.client.bean.ObuRsi; import com.zhidao.adas.client.bean.ObuRsm; import com.zhidao.adas.client.bean.ObuSpat; -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; @@ -128,7 +127,6 @@ import chassis.VehicleStateOuterClass; import function_state_management.FunctionStates; import io.netty.channel.Channel; import mogo.telematics.pad.MessagePad; -import mogo.v2x.ObuWarningEvent; import mogo_msg.MogoReportMsg; import perception.TrafficLightOuterClass; import planning.RoboSweeperTaskIndexOuterClass; @@ -668,7 +666,6 @@ 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_OBU_SPAT); titleFragmentData.add(Constants.TITLE.RECEIVE_OBU_RSI); titleFragmentData.add(Constants.TITLE.RECEIVE_OBU_RSM); @@ -1038,11 +1035,6 @@ 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); - } @Override public void onObuSpatWarning(MessagePad.Header header, ObuScene.SpatWarningData spatWarningData) { 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 e9b2ae2466..f13f2de4e5 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 @@ -172,7 +172,6 @@ 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_OBU_SPAT = "OBU SPAT信息"; String RECEIVE_OBU_RSI = "OBU RSI信息"; String RECEIVE_OBU_RSM = "OBU RSM信息"; 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 7900d8cbdf..685f84610c 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 @@ -69,7 +69,6 @@ import chassis.ChassisStatesOuterClass; import chassis.VehicleStateOuterClass; import function_state_management.FunctionStates; import mogo.telematics.pad.MessagePad; -import mogo.v2x.ObuWarningEvent; import mogo_msg.MogoReportMsg; import perception.TrafficLightOuterClass; import planning.RoboSweeperTaskIndexOuterClass; @@ -546,10 +545,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas } - @Override - public void onObuWarningData(MessagePad.Header header, ObuWarningEvent.ObuWarningData obuWarningData) { - - } @Override public void onObuSpatWarning(MessagePad.Header header, ObuScene.SpatWarningData spatWarningData) { diff --git a/build.gradle b/build.gradle index cbd64fba4f..afc1ee4733 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ buildscript { 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' - classpath 'io.github.knight-zxw:lancet-plugin:0.0.4' + classpath 'io.github.knight-zxw:lancet-plugin:0.0.4_mogo' // classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true } } diff --git a/config.gradle b/config.gradle index e75a0bb462..fab8cfd576 100644 --- a/config.gradle +++ b/config.gradle @@ -93,7 +93,7 @@ ext { // obu sdk obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3", - mogoobu : 'com.mogo.support.obu:mogo-obu:1.1.0_beta0', + mogoobu : 'com.mogo.support.obu:mogo-obu:1.1.0_beta1', // google googlezxing : "com.google.zxing:core:3.3.3", @@ -126,9 +126,6 @@ ext { mogocustommapoperational : "com.zhidaoauto.map:operational:${MAP_SDK_OPERATION_VERSION}", modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}", - chat : "com.mogo.module.carchatim:module-chat:${MOGO_MODULE_CHAT_VERSION}", - callchat : "com.mogo.module.carchatim:module-carchatting:${MOGO_MODULE_CARCHATTING_VERSION}", - callchatprovider : "com.mogo.module.carchatim:module-carchatting-provider:${MOGO_MODULE_CARCHATTINGPROVIDER_VERSION}", // V2X moduleV2x : "com.mogo.module:module-v2x:${MOGO_MODULE_V2X_VERSION}", @@ -220,7 +217,7 @@ ext { //========================= LancetX =================== - lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4", + lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4_mogo", //========================= autosize ====================== androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1', 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 6f37a8d741..86a2933f6e 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 @@ -26,7 +26,7 @@ class FuncBizProvider : IMoGoFuncBizProvider { noticeSocketManager.init(context) dispatchAutoPilotManager.init(context) cronTaskManager.startCronTask() - + OverviewDb.getDb(context) MogoTrafficLightManager.INSTANCE.initServer(context) VipCarManager.INSTANCE.initServer(context) // RedLightWarningManager.INSTANCE.listenTrafficLight() @@ -75,10 +75,6 @@ class FuncBizProvider : IMoGoFuncBizProvider { OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn) } - override fun initOverViewDb(context: Context) { - OverviewDb.getDb(context) - } - override fun onDestroy() { noticeSocketManager.release() dispatchAutoPilotManager.release() diff --git a/core/function-impl/mogo-core-function-datacenter/build.gradle b/core/function-impl/mogo-core-function-datacenter/build.gradle index 7b49429b23..a689c55ff7 100644 --- a/core/function-impl/mogo-core-function-datacenter/build.gradle +++ b/core/function-impl/mogo-core-function-datacenter/build.gradle @@ -55,20 +55,18 @@ dependencies { implementation rootProject.ext.dependencies.androidxroomktx implementation rootProject.ext.dependencies.mogoaicloudtelematic - - implementation rootProject.ext.dependencies.mogoobu implementation rootProject.ext.dependencies.amapnavi3dmap + implementation project(':libraries:mogo-obu') + implementation project(':libraries:mogo-adas') + implementation project(':libraries:mogo-adas-data') if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_utils implementation rootProject.ext.dependencies.mogo_core_function_call - - implementation project(':libraries:mogo-adas') implementation rootProject.ext.dependencies.mogocommons } else { implementation project(':core:mogo-core-utils') implementation project(':core:mogo-core-function-call') - implementation project(':libraries:mogo-adas') implementation project(':foudations:mogo-commons') } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 501cb50af4..448913e959 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -8,12 +8,12 @@ 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.map.angle.Default +import com.mogo.eagle.core.function.api.map.angle.TooClose import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager 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.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager @@ -23,8 +23,8 @@ import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtils 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.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.support.obu.MogoObuManager -import com.mogo.support.obu.OnMogoObuListener +import com.mogo.support.obu.ObuBase +import com.mogo.support.obu.ObuScene import com.mogo.support.obu.constants.MogoObuComType import com.mogo.support.obu.constants.MogoObuConstants import com.mogo.support.obu.constants.MogoObuTopicId @@ -32,6 +32,9 @@ import com.mogo.support.obu.model.* import com.mogo.support.obu.model.advance.SpatLight import com.mogo.support.obu.option.MogoObuCom import com.mogo.support.obu.option.MogoObuOptions +import com.zhidao.support.obu.ObuManager +import com.zhidao.support.obu.OnObuListener +import mogo.telematics.pad.MessagePad import kotlin.math.roundToInt /** @@ -50,7 +53,7 @@ class MogoPrivateObuNewManager private constructor() { private var mObuStatusInfo = CallerObuConnectListenerManager.getObuStatusInfo() fun connectObu(context: Context, obuIpAddress: String, padIpAddress: String) { - MogoObuManager.getInstance().registerMogoObuListener(mogoObuListener) + ObuManager.getInstance().registerObuListener(mogoObuListener) val com = MogoObuCom.newBuilder() .setLocalIp(padIpAddress) .setComType(MogoObuComType.UDP) @@ -70,27 +73,27 @@ class MogoPrivateObuNewManager private constructor() { .build() //每次连接的时候如果连接连接了,先断开 - if (MogoObuManager.getInstance().connectStatus == 1) { + if (ObuManager.getInstance().connectStatus == 1) { try { - MogoObuManager.getInstance().disconnect() + ObuManager.getInstance().disconnect() } catch (e: Exception) { e.printStackTrace() } } - MogoObuManager.getInstance().connect(options) + ObuManager.getInstance().connect(options) } - fun getMogoObuListener(): OnMogoObuListener { + fun getMogoObuListener(): OnObuListener { return mogoObuListener } fun disconnect() { - MogoObuManager.getInstance().disconnect() + ObuManager.getInstance().disconnect() } - private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() { + private val mogoObuListener: OnObuListener = object : OnObuListener { /** * 连接状态的改变 */ @@ -105,23 +108,23 @@ class MogoPrivateObuNewManager private constructor() { } /** - * HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo + * HV车辆基础信息 gnssInfo */ - override fun onMogoObuHvBasics(mogoObuHvBasicsData: MogoObuHvBasicsData?) { - if (mogoObuHvBasicsData != null && mogoObuHvBasicsData.vehBasicsMsg != null) { + override fun onGnssInfo(gnssInfo: MessagePad.GnssInfo?) { + if (gnssInfo != null ) { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuHvBasics lon = ${mogoObuHvBasicsData.vehBasicsMsg.longitude} --- lat = ${mogoObuHvBasicsData.vehBasicsMsg.latitude} ---speed = ${mogoObuHvBasicsData.vehBasicsMsg.speed} ---heading = ${mogoObuHvBasicsData.vehBasicsMsg.heading} --acceleration = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accYaw}" + "onGnssInfo lon = ${gnssInfo.longitude} --- lat = ${gnssInfo.latitude} ---speed = ${gnssInfo.gnssSpeed} ---heading = ${gnssInfo.heading} --acceleration = ${gnssInfo.acceleration} --yawRate = ${gnssInfo.yawRate}" ) // 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU if (2 == FunctionBuildConfig.gpsProvider) { - // 同步给MAP地图 - CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(mogoObuHvBasicsData) + // 同步给MAP地图 TODO +// CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(gnssInfo) // 同步更新经纬度和系统时间至 AutoPilotStatusListener CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon( System.currentTimeMillis() / 1000.0, - mogoObuHvBasicsData.vehBasicsMsg.longitude, - mogoObuHvBasicsData.vehBasicsMsg.latitude + gnssInfo.longitude, + gnssInfo.latitude ) } } @@ -130,12 +133,11 @@ class MogoPrivateObuNewManager private constructor() { /** * v2v预警信息 CvxRvInfoIndInfo CvxV2vThreatIndInfo 他车 */ - override fun onMogoObuRvWarning(data: MogoObuRvWarningData) { - super.onMogoObuRvWarning(data) + override fun onObuRvWarning(data: ObuScene.RvWarningData) { // if (HmiBuildConfig.isShowObuV2vView) { //TODO 临时需要关闭v2v开关 - if (!data.warningMsg.warningData.isNullOrEmpty()) { + if (data.warningMsg != null && !data.warningMsg.warningDataList.isNullOrEmpty()) { // 更新数据,远车数据,之前要匹配uuid - TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let { + TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data.vehBasicsMsg)?.let { CallerMapUIServiceManager.getMarkerService()?.updateITrafficLocationInfo(it) } @@ -150,10 +152,10 @@ class MogoPrivateObuNewManager private constructor() { var level = -1 var status = -1 data.warningMsg?.let { - if (data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) { - level = data.warningMsg.warningData[0].warningLevel - appId = data.warningMsg.warningData[0].warningType.toString() - status = data.warningMsg.warningData[0].status + if (data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { + level = data.warningMsg.warningDataList[0].warningLevel + appId = data.warningMsg.warningDataList[0].warningType.toString() + status = data.warningMsg.warningDataList[0].status //拼凑数据 handleSdkObu(appId, direction, status, level, data) } @@ -174,38 +176,36 @@ class MogoPrivateObuNewManager private constructor() { /** * 红绿灯预警信息 CvxIvpThreatIndInfo */ - override fun onMogoObuSpatWarning(data: MogoObuSpatWarningData) { - super.onMogoObuSpatWarning(data) + override fun onObuSpatWarning(data: ObuScene.SpatWarningData) { handlerTrafficLight( data.warningType, data.status, - data.lights + data.lightsList ) } /** * RSI预警信息 onMogoObuRsiWarning(交通标志预警(前方限速、前方学校等等),交通事件预警(前方拥堵、前方积水等等)) */ - override fun onMogoObuRsiWarning(data: MogoObuRsiWarningData) { - super.onMogoObuRsiWarning(data) + override fun onObuRsiWarning(data: ObuScene.RsiWarningData) { // if (HmiBuildConfig.isShowObuV2iView) { - if (data.warningMsg != null && data.warningMsg.size > 0) { + if (data.warningMsgList != null && data.warningMsgList.size > 0) { var alertContent = "" var ttsContent = "" - var appId = data.warningMsg[0].sceneType.toString() + var appId = data.warningMsgList[0].sceneType.toString() val status = data.status - val level = data.warningMsg[0].warningLevel - val direction = getMessageDirection(data.warningMsg[0].targetPosition) + val level = data.warningMsgList[0].warningLevel + val direction = getMessageDirection(data.warningMsgList[0].targetPosition) CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warningMsg[0].eventSerialNum} ---signSerialNum = ${data.warningMsg[0].signSerialNum} --- direction = $direction -- targetPosition = ${data.warningMsg[0].targetPosition}" + "onMogoObuRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${data.warningMsgList[0].targetPosition}" ) if (appId != "0") { when (appId) { // 道路危险情况预警 MogoObuConstants.RSI_SCENE_TYPE.HLW.toString() -> { - when (data.warningMsg[0].eventSerialNum) { + when (data.warningMsgList[0].eventSerialNum) { MogoObuConstants.RTE.RTI_TYPE_BREAKDOWN -> {//车辆故障 appId = EventTypeEnumNew.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType @@ -231,19 +231,19 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(appId) alertContent = String.format( //事件才有影响范围 alertContent, - Math.round(data.warningMsg[0].distance).toString(), - Math.round(data.warningMsg[0].eventRadius).toString() + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() ) ttsContent = String.format( ttsContent, - Math.round(data.warningMsg[0].distance).toString(), - Math.round(data.warningMsg[0].eventRadius).toString() + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() ) } //车内标牌 MogoObuConstants.RSI_SCENE_TYPE.IVS.toString() -> { - when (data.warningMsg[0].signSerialNum) { + when (data.warningMsgList[0].signSerialNum) { // MogoObuConstants.RTS.RTI_TYPE_INTERSECTION -> { //十字路口 // appId = EventTypeEnumNew.TYPE_ID_NTERSECTION.poiType // } @@ -323,11 +323,11 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(appId) alertContent = String.format( //标牌是没有影响范围的 alertContent, - Math.round(data.warningMsg[0].distance).toString() + Math.round(data.warningMsgList[0].distance).toString() ) ttsContent = String.format( ttsContent, - Math.round(data.warningMsg[0].distance).toString() + Math.round(data.warningMsgList[0].distance).toString() ) } @@ -338,13 +338,13 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(appId) alertContent = String.format( //事件才有影响范围 alertContent, - Math.round(data.warningMsg[0].distance).toString(), - Math.round(data.warningMsg[0].eventRadius).toString() + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() ) ttsContent = String.format( ttsContent, - Math.round(data.warningMsg[0].distance).toString(), - Math.round(data.warningMsg[0].eventRadius).toString() + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() ) } @@ -358,9 +358,9 @@ class MogoPrivateObuNewManager private constructor() { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "new onMogoObuRsiWarning appId = $appId ---status = $status --- ttsContent = $ttsContent --alertContent = $alertContent -- eventSerialNum = ${data.warningMsg[0].eventSerialNum} ---signSerialNum = ${data.warningMsg[0].signSerialNum} ---direction = ${direction.direction} --distance = ${ - Math.round(data.warningMsg[0].distance) - } ---eventRadius = ${Math.round(data.warningMsg[0].eventRadius)} --speedMaxLimit = ${data.warningMsg[0].speedMaxLimit.toInt()}" + "new onMogoObuRsiWarning appId = $appId ---status = $status --- ttsContent = $ttsContent --alertContent = $alertContent -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} ---direction = ${direction.direction} --distance = ${ + Math.round(data.warningMsgList[0].distance) + } ---eventRadius = ${Math.round(data.warningMsgList[0].eventRadius)} --speedMaxLimit = ${data.warningMsgList[0].speedMaxLimit.toInt()}" ) when (status) { @@ -425,10 +425,9 @@ class MogoPrivateObuNewManager private constructor() { * 3:行人 * 4:OBU自身 */ - override fun onMogoObuRsmWarning( - data: MogoObuRsmWarningData? + override fun onObuRsmWarning( + data: ObuScene.RsmWarningData? ) { - super.onMogoObuRsmWarning(data) CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", "onMogoObuRsmWarning ------> ${data.toString()}" @@ -505,13 +504,13 @@ class MogoPrivateObuNewManager private constructor() { } //预警status - if (data.warningMsg != null && data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) { - level = data.warningMsg.warningData[0].warningLevel //默认是1个 + if (data.warningMsg != null && data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { + level = data.warningMsg.warningDataList[0].warningLevel //默认是1个 CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRsmWarning ---status---> ${data.status} ---data.warningMsg.warningData[0].status = ${data.warningMsg.warningData[0].status} ---v2xType = $v2xType ---alertContent = $alertContent ---ttsContent = $ttsContent ---level = $level" + "onMogoObuRsmWarning ---status---> ${data.status} ---data.warningMsg.warningData[0].status = ${data.warningMsg.warningDataList[0].status} ---v2xType = $v2xType ---alertContent = $alertContent ---ttsContent = $ttsContent ---level = $level" ) - when (data.warningMsg.warningData[0].status) { + when (data.warningMsg.warningDataList[0].status) { MogoObuConstants.STATUS.ADD -> { // 添加 //更新模型的颜色 TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) @@ -564,8 +563,7 @@ class MogoPrivateObuNewManager private constructor() { /** * 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道 */ - override fun onMogoObuMapMath(data: MogoObuMapMathData?) { - super.onMogoObuMapMath(data) + override fun onObuMapMath(data: ObuScene.MapMatchData?) { if (data != null) { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", @@ -595,371 +593,200 @@ class MogoPrivateObuNewManager private constructor() { } } } + } + } + } + + /** + * 获取消息的方位 车辆相关 + */ + private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { + // CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification") + 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 } } -} + /** + * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 + * + * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截 + * + * @see com.mogo.module.common.enums.EventTypeEnum + */ + private fun handleSdkObu( + appId: String, + direction: WarningDirectionEnum, + status: Int, + level: Int, + info: ObuScene.RvWarningData + ) { + // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 + var alertContent: String = "" + var ttsContent: String = "" + var changeVisualAngle = false + when (appId) { + //交叉路口碰撞预警 + MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + } -/** - * 获取消息的方位 车辆相关 - */ -private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { - // CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification") - return when (targetClassification) { - MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE, - MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 + //交叉路口碰撞预警 + MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + } - MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 + //左转辅助预警 + MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + } - MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 + //盲区预警 + MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> { + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + if ( + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + ) { //左后 + changeVisualAngle = true + ttsContent = String.format(ttsContent, "左") + alertContent = String.format(alertContent, "左") + } else if ( + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + ) { //右后 + changeVisualAngle = true + ttsContent = String.format(ttsContent, "右") + alertContent = String.format(alertContent, "右") + } + } - MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方 + // 变道预警,注意左后车辆/注意右后车辆 + MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) + if ( + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + ) { + ttsContent = String.format(ttsContent, "左") + alertContent = String.format(alertContent, "左") + } else if ( + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + ) { + ttsContent = String.format(ttsContent, "右") + alertContent = String.format(alertContent, "右") + } + } - 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.V2X_WARNING_TYPE.DNPW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + } - 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.V2X_WARNING_TYPE.EBW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + } - MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT, - -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方 + //异常车辆提醒 + MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } - MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT, - -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方 + //车辆失控预警 + MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } + //车辆失控预警 + MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + } - MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 - else -> WarningDirectionEnum.ALERT_WARNING_ALL - } -} - -/** - * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 - * - * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截 - * - * @see com.mogo.module.common.enums.EventTypeEnum - */ -private fun handleSdkObu( - appId: String, - direction: WarningDirectionEnum, - status: Int, - level: Int, - info: MogoObuRvWarningData -) { - // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 - var alertContent: String = "" - var ttsContent: String = "" - var changeVisualAngle = false - when (appId) { - //交叉路口碰撞预警 - MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - } - - //交叉路口碰撞预警 - MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) - } - - //左转辅助预警 - MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) - } - - //盲区预警 - MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> { - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) - if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT - ) { //左后 - changeVisualAngle = true - ttsContent = String.format(ttsContent, "左") - alertContent = String.format(alertContent, "左") - } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT - ) { //右后 - changeVisualAngle = true - ttsContent = String.format(ttsContent, "右") - alertContent = String.format(alertContent, "右") + // 这里处理固定的提示信息,包括了<紧急车辆提醒> + else -> { //TODO + // ttsContent = EventTypeEnumNew.getWarningTts(appId.toString()) + // alertContent = EventTypeEnumNew.getWarningContent(appId.toString()) } } - // 变道预警,注意左后车辆/注意右后车辆 - MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) - if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT - ) { - ttsContent = String.format(ttsContent, "左") - alertContent = String.format(alertContent, "左") - } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT - ) { - ttsContent = String.format(ttsContent, "右") - alertContent = String.format(alertContent, "右") - } - } - - //逆向超车预警 - MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) - } - - //紧急制动预警 - MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) - } - - //异常车辆提醒 - MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - - //车辆失控预警 - MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - //车辆失控预警 - MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) - } - - // 这里处理固定的提示信息,包括了<紧急车辆提醒> - else -> { //TODO -// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString()) -// alertContent = EventTypeEnumNew.getWarningContent(appId.toString()) - } - } - - when (status) { - // 添加,更新 add的时候,可能级别是2, - MogoObuConstants.STATUS.ADD, - MogoObuConstants.STATUS.UPDATE -> { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" - ) - if (level == 2 || level == 3) { - //不显示弹框,其它保留 - CallerMsgBoxManager.saveMsgBox( - MsgBoxBean( - MsgBoxType.V2X, - V2XMsg( - appId, - alertContent, - ttsContent - ) - ).apply { - sourceType = DataSourceType.OBU - } - ) - CallerHmiManager.warningV2X( - appId, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - object : IMoGoWarningStatusListener { - override fun onShow() { - super.onShow() - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(TooClose) - } - } - - override fun onDismiss() { - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(Default()) - } - } - }, direction - ) - } - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了 - TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) - } - } - // 删除 - MogoObuConstants.STATUS.DELETE -> { - // 关闭警告红边 - CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 - TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { - it.threatLevel = 0x01 - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) - } - } - } -} - -/** - * 处理红绿灯 - */ -private fun handlerTrafficLight(appId: Int, status: Int, lights: List) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "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 -> { - // 移除顶部弹窗 - CallerTrafficLightListenerManager.disableTrafficLight() - isShowGreenWave = false - isShowRunRedLight = false -// lightCountDownRed = 1 -// lightCountDownGreen = 1 -// lightCountDownYellow = 1 - } - } -} - -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.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}" - ) - // 闯红灯预警,绿波通行和闯红灯是互斥的 - when (appId) { - 0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效 - - } - 1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次 - if (!isShowRunRedLight) { - isShowRunRedLight = true + when (status) { + // 添加,更新 add的时候,可能级别是2, + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE -> { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "changeTrafficLightStatus 闯红灯 --------> " + "new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" ) - 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( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, - alertContent, - ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 - ) - } - } - - 2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候 - if (!isShowGreenWave) { - isShowGreenWave = true - - var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6) - var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6) - if (minSpeedTemp == maxSpeedTemp) { - minSpeedTemp -= 5 - } - - val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp" - val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp" - -// val adviceSpeed = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} - ${Math.round(currentLight.suggestMaxSpeed*3.6)}" -// val adviceSpeedTts = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} 到 ${Math.round(currentLight.suggestMaxSpeed*3.6)}" - - 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 - if (maxSpeed > 0) { + if (level == 2 || level == 3) { + //不显示弹框,其它保留 CallerMsgBoxManager.saveMsgBox( MsgBoxBean( MsgBoxType.V2X, V2XMsg( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + appId, alertContent, ttsContent ) @@ -968,50 +795,213 @@ private fun changeTrafficLightStatus( } ) CallerHmiManager.warningV2X( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + appId, alertContent, - ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + object : IMoGoWarningStatusListener { + override fun onShow() { + super.onShow() + if (changeVisualAngle) { + CallerVisualAngleManager.changeAngle(TooClose) + } + } + + override fun onDismiss() { + if (changeVisualAngle) { + CallerVisualAngleManager.changeAngle(Default()) + } + } + }, direction ) } + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + it.threatLevel = 0x01 + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } } } } - when (currentLight.light) { - // 灯光不可用 - 0 -> { - CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( - TrafficLightEnum.BLACK, - -1, - DataSourceType.OBU - ) - } - // 红灯 - 2, 3 -> { - val red = currentLight.countDown.toInt() - CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( - TrafficLightEnum.RED, - red, - DataSourceType.OBU - ) - } - // 绿灯 - 4, 5, 6 -> { - val green = currentLight.countDown.toInt() - CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( - TrafficLightEnum.GREEN, - green, - DataSourceType.OBU - ) - } - // 黄灯 - 7, 8 -> { - val yellow = currentLight.countDown.toInt() - CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( - TrafficLightEnum.YELLOW, - yellow, - DataSourceType.OBU - ) + /** + * 处理红绿灯 + */ + private fun handlerTrafficLight(appId: Int, status: Int, lights: MutableList) { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "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 -> { + // 移除顶部弹窗 + CallerTrafficLightListenerManager.disableTrafficLight() + isShowGreenWave = false + isShowRunRedLight = false + // lightCountDownRed = 1 + // lightCountDownGreen = 1 + // lightCountDownYellow = 1 + } } } -} + + private var isShowGreenWave = false + private var isShowRunRedLight = false + + + /** + * 修改红绿灯 + */ + @Synchronized + private fun changeTrafficLightStatus( + appId: Int, + lights: MutableList + ) { + var ttsContent = "" + var alertContent = "" + //这里需要根据真实数据确定 index 取值方式 + val currentLight = lights[0] + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseID} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}" + ) + // 闯红灯预警,绿波通行和闯红灯是互斥的 + when (appId) { + 0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效 + + } + 1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次 + if (!isShowRunRedLight) { + isShowRunRedLight = true + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "changeTrafficLightStatus 闯红灯 --------> " + ) + 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( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, + alertContent, + ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 + ) + } + } + + 2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候 + if (!isShowGreenWave) { + isShowGreenWave = true + var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6) + var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6) + if (minSpeedTemp == maxSpeedTemp) { + minSpeedTemp -= 5 + } + + val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp" + val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp" + 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 + if (maxSpeed > 0) { + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.OBU + } + ) + CallerHmiManager.warningV2X( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 + ) + } + } + } + } + + when (currentLight.light) { + // 灯光不可用 + 0 -> { + CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( + TrafficLightEnum.BLACK, + -1, + DataSourceType.OBU + ) + } + // 红灯 + 2, 3 -> { + val red = currentLight.countDown.toInt() + CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( + TrafficLightEnum.RED, + red, + DataSourceType.OBU + ) + } + // 绿灯 + 4, 5, 6 -> { + val green = currentLight.countDown.toInt() + CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( + TrafficLightEnum.GREEN, + green, + DataSourceType.OBU + ) + } + // 黄灯 + 7, 8 -> { + val yellow = currentLight.countDown.toInt() + CallerTrafficLightListenerManager.invokeTrafficLightPlusSource( + TrafficLightEnum.YELLOW, + yellow, + DataSourceType.OBU + ) + } + } + } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuReceiver.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuReceiver.kt index ed1abd5575..8a6eb1f7c0 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuReceiver.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuReceiver.kt @@ -47,11 +47,11 @@ class ObuTestNewObuReceiver : BroadcastReceiver() { val warningList = listOf(warningData1) warningMsg.warningData = warningList - val cvxHvInfoIndInfo = MogoObuRvWarningData(0, vehBasicsMsg, warningMsg) +// val cvxHvInfoIndInfo = MogoRvWarningData(0, vehBasicsMsg, warningMsg) - MogoPrivateObuNewManager.INSTANCE - .getMogoObuListener() - .onMogoObuRvWarning(cvxHvInfoIndInfo) +// MogoPrivateObuNewManager.INSTANCE +// .getMogoObuListener() +// .onGnssInfo(cvxHvInfoIndInfo) } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuRsiReceiver.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuRsiReceiver.kt index f0b78a14f8..abfa91fddd 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuRsiReceiver.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/receiver/ObuTestNewObuRsiReceiver.kt @@ -41,11 +41,11 @@ class ObuTestNewObuRsiReceiver : BroadcastReceiver() { val rsiWarningList = listOf(rsiWarning) //TODO - val cvxObuRsiInfo = MogoObuRsiWarningData(obuStatus, 1, rsiWarningList) - - MogoPrivateObuNewManager.INSTANCE - .getMogoObuListener() - .onMogoObuRsiWarning(cvxObuRsiInfo) +// val cvxObuRsiInfo = MogoObuRsiWarningData(obuStatus, 1, rsiWarningList) +// +// MogoPrivateObuNewManager.INSTANCE +// .getMogoObuListener() +// .onObuRsiWarning(cvxObuRsiInfo) } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/utils/TrafficDataConvertUtilsNew.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/utils/TrafficDataConvertUtilsNew.kt index 551c4d9c8b..d3bae2a27b 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/utils/TrafficDataConvertUtilsNew.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/utils/TrafficDataConvertUtilsNew.kt @@ -4,6 +4,8 @@ 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.ObuBase +import com.mogo.support.obu.ObuScene import com.mogo.support.obu.model.MogoObuRsiWarningData import com.mogo.support.obu.model.MogoObuRsmWarningData import com.mogo.support.obu.model.MogoObuRvWarningData @@ -20,18 +22,18 @@ object TrafficDataConvertUtilsNew { /** * OBU 远车 转换交通元素数据,是否需要 */ - fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? { - if (info.vehBasicsMsg == null) { + fun cvxRvInfoIndInfo2TrafficData(info: ObuBase.VehicleBasics): TrafficData? { + if (info == null) { CallerLogger.e("$M_OBU$TAG", "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全") return null } val trafficData = TrafficData() trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE - trafficData.uuid = info.vehBasicsMsg.id - trafficData.lat = info.vehBasicsMsg.latitude - trafficData.lon = info.vehBasicsMsg.longitude - trafficData.heading = info.vehBasicsMsg.heading - trafficData.speed = info.vehBasicsMsg.speed + trafficData.uuid = info.id + trafficData.lat = info.latitude + trafficData.lon = info.longitude + trafficData.heading = info.heading + trafficData.speed = info.speed return trafficData } @@ -39,25 +41,25 @@ object TrafficDataConvertUtilsNew { /** * OBU RSU道路事件预警信息 转换交通元素数据 标牌 为何要显示level */ - fun cvxRtiThreatIndInfo2TrafficData(info: MogoObuRsiWarningData): TrafficData? { - if (info.warningMsg == null || info.warningMsg.size < 1 || info.warningMsg[0].position == null) { + fun cvxRtiThreatIndInfo2TrafficData(info: ObuScene.RsiWarningData): TrafficData? { + if (info.warningMsgList == null || info.warningMsgList.size < 1 || info.warningMsgList[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 + trafficData.uuid = info.warningMsgList[0].signSerialNum.toString() + trafficData.lat = info.warningMsgList[0].position.position.positionLatLon.latitude + trafficData.lon = info.warningMsgList[0].position.position.positionLatLon.longitude + trafficData.threatLevel = info.warningMsgList[0].warningLevel return trafficData } /** * OBU 预警事件 转换交通元素数据 他车预警 */ - fun cvxV2vThreatIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? { - if (info == null || info.vehBasicsMsg == null || info.warningMsg == null) { + fun cvxV2vThreatIndInfo2TrafficData(info: ObuScene.RvWarningData): TrafficData? { + if (info?.vehBasicsMsg == null || info.warningMsg == null) { CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") return null } @@ -68,8 +70,8 @@ object TrafficDataConvertUtilsNew { trafficData.heading = info.vehBasicsMsg.heading trafficData.speed = info.vehBasicsMsg.speed // 判断车辆V2X预警级别,调整车辆颜色 - if (info.warningMsg.warningData != null) { - trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel + if (info.warningMsg.warningDataList != null) { + trafficData.threatLevel = info.warningMsg.warningDataList[0].warningLevel } else { trafficData.threatLevel = 1 } @@ -81,7 +83,7 @@ object TrafficDataConvertUtilsNew { /** * OBU 弱势交通参与者信息 转换交通元素数据 */ - fun cvxPtcThreatIndInfo2TrafficData(info: MogoObuRsmWarningData): TrafficData? { + fun cvxPtcThreatIndInfo2TrafficData(info: ObuScene.RsmWarningData): TrafficData? { if (info.participant == null) { CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") return null @@ -121,8 +123,8 @@ object TrafficDataConvertUtilsNew { } // 判断车辆V2X预警级别,调整车辆颜色 - if (info.warningMsg != null && info.warningMsg.warningData != null) { - trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel + if (info.warningMsg != null && info.warningMsg.warningDataList != null) { + trafficData.threatLevel = info.warningMsg.warningDataList[0].warningLevel } else { trafficData.threatLevel = 1 } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index 8ae5886370..06eb44312b 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -136,7 +136,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight super.onTrafficLightPlusSource(light, remain, lightSource) if (lightSource == DataSourceType.OBU) { - hasObuLightStatus = true //todo 会存在优先级高的数据没有回调,导致没有数据出现 + hasObuLightStatus = true } CallerTrafficLightListenerManager.showTrafficLight(light, lightSource) diff --git a/core/function-impl/mogo-core-function-devatools/build.gradle b/core/function-impl/mogo-core-function-devatools/build.gradle index 1467c96245..61321d4b6b 100644 --- a/core/function-impl/mogo-core-function-devatools/build.gradle +++ b/core/function-impl/mogo-core-function-devatools/build.gradle @@ -84,6 +84,8 @@ dependencies { implementation rootProject.ext.dependencies.androidxrecyclerview implementation rootProject.ext.dependencies.flexbox implementation rootProject.ext.dependencies.androidautoSize + implementation rootProject.ext.dependencies.koomnative + implementation rootProject.ext.dependencies.koomxhook if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_utils diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt index 7177fa3033..f27e3087b9 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt @@ -5,6 +5,8 @@ import android.content.Context import android.view.View import android.view.ViewGroup import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.debug.DebugConfig import com.mogo.eagle.core.data.EnvConfig import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo import com.mogo.eagle.core.data.constants.MogoServicePaths @@ -16,10 +18,11 @@ import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig -import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager import com.zhjt.mogo_core_function_devatools.binding.BindingCarManager.Companion.bindingCarManager +import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigCenter.Companion.bizConfigCenter import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigImpl +import com.zhjt.mogo_core_function_devatools.koom.KoomInitTask import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager import com.zhjt.mogo_core_function_devatools.mofang.MoFangManager.Companion.moFangManager import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager @@ -46,6 +49,9 @@ class DevaToolsProvider : IDevaToolsProvider { } override fun initBiz() { + if (DebugConfig.isDebug()) { + KoomInitTask.init(AbsMogoApplication.getApp()) + } ttsManager.initTts(mContext!!) //todo //链路相关 traceManager.init(mContext!!) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt similarity index 94% rename from core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt rename to core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt index 4fb06a0f67..6fca530bea 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.function.main +package com.zhjt.mogo_core_function_devatools.koom import android.app.Application import android.os.Build diff --git a/core/function-impl/mogo-core-function-hmi/build.gradle b/core/function-impl/mogo-core-function-hmi/build.gradle index 39490b0d6c..852be9bd7f 100644 --- a/core/function-impl/mogo-core-function-hmi/build.gradle +++ b/core/function-impl/mogo-core-function-hmi/build.gradle @@ -68,8 +68,7 @@ dependencies { // debugImplementation rootProject.ext.dependencies.debugleakcanary // releaseImplementation rootProject.ext.dependencies.releaseleakcanary - - implementation rootProject.ext.dependencies.mogoobu + implementation project(':libraries:mogo-obu') implementation rootProject.ext.dependencies.arouter kapt rootProject.ext.dependencies.aroutercompiler diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt index e21e0514a6..e38d41ccbd 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt @@ -11,8 +11,8 @@ import android.view.animation.Animation import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import chassis.Chassis +import com.mogo.eagle.core.function.api.map.angle.* import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Turning import com.mogo.eagle.core.function.hmi.R import kotlinx.android.synthetic.main.view_turn_light_status.view.* import kotlinx.coroutines.Dispatchers @@ -55,7 +55,7 @@ class TurnLightViewStatus @JvmOverloads constructor( //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 when (directionLight) { Chassis.LightSwitch.LIGHT_LEFT -> { //左转向 - CallerVisualAngleManager.changeVisualAngle(Turning(true)) + CallerVisualAngleManager.changeAngle(Turning(true)) showNormalAnimation() left_select_image.visibility = View.VISIBLE right_select_image.visibility = View.GONE @@ -63,7 +63,7 @@ class TurnLightViewStatus @JvmOverloads constructor( setAnimation(left_select_image) } Chassis.LightSwitch.LIGHT_RIGHT -> { //右转向 - CallerVisualAngleManager.changeVisualAngle(Turning(true)) + CallerVisualAngleManager.changeAngle(Turning(true)) showNormalAnimation() left_select_image.visibility = View.GONE right_select_image.visibility = View.VISIBLE @@ -71,7 +71,7 @@ class TurnLightViewStatus @JvmOverloads constructor( setAnimation(right_select_image) } else -> { //消失 - CallerVisualAngleManager.changeVisualAngle(Turning(false)) + CallerVisualAngleManager.changeAngle(Turning(false)) animationDisappear() } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index bcdd678bd5..4ef06c5609 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -3,35 +3,23 @@ package com.mogo.eagle.core.function.main; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI; import android.annotation.SuppressLint; -import android.app.NotificationManager; import android.content.Context; import android.os.Process; -import androidx.annotation.Nullable; -import androidx.core.app.NotificationCompat; - import com.bytedance.boost_multidex.BoostMultiDex; -import com.elegant.utils.UiThreadHandler; import com.mogo.cloud.socket.SocketBuildConfig; import com.mogo.commons.AbsMogoApplication; -import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.module.MogoModule; import com.mogo.commons.module.MogoModulePaths; import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.constants.MoGoConfig; import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.function.api.chat.biz.ChatConsts; -import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener; -import com.mogo.eagle.core.function.call.biz.CallerFuncBizManager; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; -import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager; -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager; import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.ProcessUtils; import com.mogo.eagle.core.utilcode.util.SPUtils; @@ -41,7 +29,7 @@ import java.text.SimpleDateFormat; import java.util.Date; /** - * 默认初始化一些基础服务配置 todo 分离 overView业务 和 msgBox去各自模块中 --- 扶风 + * 默认初始化一些基础服务配置 todo 分离 msgBox去自己的模块中 --- 扶风 */ public abstract class MainMoGoApplication extends AbsMogoApplication { @@ -61,10 +49,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { initTipToast(); initModules(); if (ProcessUtils.isMainProcess(this)) { - initOverviewDb(); - if (DebugConfig.isDebug()) { - initKoom(); - } clearMessageBoxTable(); CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } @@ -109,10 +93,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { }).start(); } - private void initKoom() { - KoomInitTask.INSTANCE.init(this); - } - /** * 初始化异常采集配置 */ @@ -135,10 +115,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { CallerDevaToolsManager.INSTANCE.init(); } - private void initOverviewDb() { - CallerFuncBizManager.getBizProvider().initOverViewDb(this); - } - private void initModules() { CallerLogger.INSTANCE.d(M_HMI + TAG, "initModules"); // OBU 模块 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_pnc_actions.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_pnc_actions.xml index 5d3a7ab8cb..81747337ad 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_pnc_actions.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_pnc_actions.xml @@ -2,7 +2,7 @@ + android:layout_height="wrap_content"> () + + private val distanceOfCarToStopLine = AtomicReference(0.0) + + private val travelled by lazy { AtomicReference(0.0) } + + /** + * 业务实体,不对外暴露 + * @param target: 目标场景 + * @param isDisplay: 是否正在展示 + * @param triggerTime: 触发时间 + */ + private data class Record(val target: Scene, var isDisplay: Boolean = false, var triggerTime: Long): Comparable { + override fun compareTo(other: Record): Int { + //如果时间一样,优先级越高,越靠近堆顶 + return other.target.priority - target.priority + } + } + + private val queue by lazy { + PriorityQueue() + } + + private val listener = object : OnRoadListener { + private val roadId = AtomicReference() + private val triggerRoadId = AtomicReference() + + override fun onRoadIdInfo(roadId: String) { + this.roadId.set(roadId) + Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId") + val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02() + var triggerClose = false + val distance = distanceOfCarToStopLine.get() + 5 + if (hasCrossRoad && distance > 0) { + val prev = triggerLocation.get() + if (prev != null && loc != null) { + travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get()) + triggerLocation.set(loc) + } + val oldRoadId = triggerRoadId.get() + Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}") + if ((travelled.get() > distance) && oldRoadId != null && oldRoadId != roadId) { + distanceOfCarToStopLine.set(0.0) + hasCrossRoad = false + triggerRoadId.set(null) + travelled.set(0.0) + triggerLocation.set(null) + Log.d(TAG, "-- onRoadIdInfo --: trigger close --") + triggerClose = true + } + } + if (triggerClose) { + changeAngle(CrossRoad(false)) + } + } + + + override fun onStopLineInfo(info: StopLine) { + Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}") + if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { + hasCrossRoad = true + triggerRoadId.set(this.roadId.get()) + distanceOfCarToStopLine.set(info.distanceOfCarToStopLine) + triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()) + changeAngle(CrossRoad(true)) + } + } + } + + override fun init(context: Context?) { + if (Thread.currentThread() != Looper.getMainLooper().thread) { + scope.launch { + initListen(context) + } + } else { + initListen(context) + } + } + + private fun initListen(ctx: Context?) { + ctx ?: return + ctx.lifeCycleOwner.lifecycle.addObserver(object : LifecycleEventObserver { + override fun onStateChanged(source: LifecycleOwner, event: Event) { + if (event == ON_DESTROY) { + CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") + } + } + }) + CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener) + } + + @Volatile + private var hasCrossRoad = false + + + private var scope: CoroutineScope = acquireScope() + @Synchronized + get() { + if (field.isActive) { + return field + } + val scope = acquireScope() + field = scope + return field + } + + private var defaultDelayJob: Job? = null + + private fun acquireScope(): CoroutineScope { + return CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher("change-visual-angle") + SupervisorJob()) + } + + + override fun onDestroy() { + CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") + } + + @Volatile + private var mLevel:Boolean = false + + override fun updateLongSightLevel(level:Boolean){ + mLevel = level + } + + override fun changeAngle(scene: Scene) { + val appIdentityMode = FunctionBuildConfig.appIdentityMode + if (AppIdentityModeUtils.isBus(appIdentityMode) && AppIdentityModeUtils.isPassenger(appIdentityMode)) { + return + } + if(mLevel){ + return + } + val triggerTime = SystemClock.elapsedRealtime() + scope.launch { + Log.d(TAG, "--- 1 ---") + val displayed = getDisplayed() + if (displayed == null) { + Log.d(TAG, "--- 2 ---") + if (scene is Turning) { + if (!scene.open) { + changeAngle(Default()) + return@launch + } + } + if (scene is CrossRoad) { + if (!scene.open) { + changeAngle(Default()) + return@launch + } + } + doRealVisualAngleChange(triggerTime, scene, null) + } else { + val prev = displayed.target + Log.d(TAG, "--- 3 --- old: $prev -> cur: $scene") + val prevTriggerTime = displayed.triggerTime + if (scene !is Default && prev.priority > scene.priority && (prev is RoadEvent || prev is TooClose)) { + val displayDuration = triggerTime - prevTriggerTime + Log.d(TAG, "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration") + if (displayDuration < prev.displayThreshold) { + Log.d(TAG, "--- 5 --- 场景[$prev]:仍在保护展示时长内,直接return") + return@launch + } else { + Log.d(TAG, "--- 6 --- 场景[$prev]:已过保护展示时长,从展示的队列中移除,显示默认视角") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev is Turning && scene is Turning) { + val isOpen = scene.open + if (!isOpen) { + Log.d(TAG, "--- 7 --- 场景[$scene], 收到关闭通知") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev is CrossRoad && scene is CrossRoad) { + val isOpen = scene.open + if (!isOpen) { + Log.d(TAG, "--- 8 --- old: $prev -> cur: $scene") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev.priority == scene.priority) { + Log.d(TAG, "--- 9 --- 场景[$prev]正在展示,尚未收到关闭,优先级一致,直接return") + return@launch + } + if (prev.priority > scene.priority && prev.displayThreshold < 0) { + Log.d(TAG, "--- 10 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") + return@launch + } + doRealVisualAngleChange(triggerTime, scene, displayed) + } + } + } + + private fun CoroutineScope.doRealVisualAngleChange(triggerTime: Long, target: Scene, displayed: Record? = null) { + if (target is Default) { + Log.d(TAG, "--- doRealVisualAngleChange --- 1 ---") + displayed?.also { + queue -= it + } + defaultDelayJob?.safeCancel() + launch { + val delay = target.unit.toMillis(target.delay) + Log.d(TAG, "--- doRealVisualAngleChange --- 2 ---") + delay(delay) + Log.d(TAG, "--- doRealVisualAngleChange --- 3 ---") + doChangeAngle(Record(target, triggerTime = triggerTime)) + }.also { itx -> + itx.invokeOnCompletion { + if (it is CancellationException) { + Log.d(TAG, "--- doRealVisualAngleChange --- 4 ---") + } + } + defaultDelayJob = itx + } + } else { + Log.d(TAG, "--- doRealVisualAngleChange --- 5 ---") + defaultDelayJob?.safeCancel() + if (displayed == null || displayed.target.priority <= target.priority) { + Log.d(TAG, "--- doRealVisualAngleChange --- 6 ---") + displayed?.also { + queue -= it + } + if (target is Turning) { + if (!target.open) { + Log.d(TAG, "--- doRealVisualAngleChange --- 7 ---") + changeAngle(Default()) + return + } + } + if (target is CrossRoad) { + if (!target.open) { + Log.d(TAG, "--- doRealVisualAngleChange --- 8 ---") + changeAngle(Default()) + return + } + } + Log.d(TAG, "--- doRealVisualAngleChange --- 10 ---") + doChangeAngle(Record(target, triggerTime = triggerTime)) + } + } + } + + @OptIn(InternalCoroutinesApi::class) + private fun doChangeAngle(record: Record) { + val angle = record.target.angle + CallerMapUIServiceManager.getMapUIController()?.also { + Log.d(TAG, "--- doChangeAngle ---: ${record.target}") + if (record.target !is Default) { + record.isDisplay = true + kotlinx.coroutines.internal.synchronized(queue) { + queue += record + } + } + it.changeMapVisualAngle(angle, null) + } + } + + /** + * 是否有正在展示的 + */ + @Synchronized + private fun getDisplayed() = queue.firstOrNull() +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java index 1516eeddbc..651b2a8a74 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java @@ -52,6 +52,5 @@ public class MogoMapService implements IMogoMapService { @Override public void init(Context context) { - CallerVisualAngleManager.INSTANCE.init(context); } } 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 6182939d78..b32b7b3793 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 @@ -52,7 +52,8 @@ class OverMapView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener { +) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener, + IMoGoPlanningRottingListener { // =============自定义属性相关============= private var mapStylePath: String? = null @@ -166,7 +167,7 @@ class OverMapView @JvmOverloads constructor( overLayerView?.background = resources.getDrawable(if (resetDrawable != -1) resetDrawable else R.drawable.amap_reset) arrivedBitmap = BitmapDescriptorFactory.fromResource(if (arrivedDrawable != -1) arrivedDrawable else R.drawable.taxi_map_arrow_arrived) unArrivedBitmap = BitmapDescriptorFactory.fromResource(if (unArrivedDrawable != -1) unArrivedDrawable else R.drawable.taxi_map_arrow_un_arrive) - CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener) + CallerPlanningRottingListenerManager.addListener(TAG, this) initAMapView(context) // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) @@ -262,20 +263,6 @@ class OverMapView @JvmOverloads constructor( ) } - private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener = - object : IMoGoPlanningRottingListener { - /** - * 根据全路径获取起始点和经停点进行导航路线绘制 - * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 - * 室内某个bag包自动驾驶启动8s后返回 - */ - override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { - globalPathResp?.let { - handlePlanningData(it.wayPointsList) - } - } - } - fun handlePlanningData(locationList: List?) { if (locationList.isNullOrEmpty()) return val list: List = locationList @@ -600,4 +587,15 @@ class OverMapView @JvmOverloads constructor( } } + + /** + * 根据全路径获取起始点和经停点进行导航路线绘制 + * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 + * 室内某个bag包自动驾驶启动8s后返回 + */ + override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { + globalPathResp?.let { + handlePlanningData(it.wayPointsList) + } + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt b/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt index 6c7cc96d89..cf2c47b420 100644 --- a/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt +++ b/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt @@ -111,6 +111,9 @@ class HttpDnsStartUp : AndroidStartup() { clientConfig.isUseOriginSocket = true // 设置是否输出网络日志 clientConfig.isShowNetDebugLog = false +// clientConfig.passportUrl //todo yakun +// clientConfig.socketBaseUrl +// clientConfig.socketTechUrl // 设置是否是直播推流的主播 clientConfig.isAnchor = true when (DebugConfig.getCarMachineType()) { @@ -132,7 +135,7 @@ class HttpDnsStartUp : AndroidStartup() { } else { clientConfig.thirdPartyDeviceId = Utils.getDevicesId() } - //设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作 + //设置长链接的secretKey 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作 clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ" clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation { diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt index 7f0be345a3..920a297268 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt @@ -31,6 +31,7 @@ import com.mogo.eagle.core.data.traffic.TrafficData import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener +import com.mogo.eagle.core.function.api.map.angle.* import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager @@ -38,8 +39,6 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.v2x.events.alarm.V2XAlarmServer import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi @@ -52,13 +51,12 @@ import com.mogo.eagle.core.function.v2x.events.utils.toV2XRoadEventEntity import com.mogo.eagle.core.function.v2x.internal.V2XManager import com.mogo.eagle.core.function.v2x.internal.callback.IV2XCallback import com.mogo.eagle.core.function.v2x.internal.config.V2XConfig -import com.mogo.eagle.core.function.v2x.internal.data.V2XAdvanceWarning -import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult -import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget +import com.mogo.eagle.core.function.v2x.internal.data.* import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler @@ -209,6 +207,13 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, } handleRoadMarkerEvent(event.data.toRoadMarker()) } + + is V2XEvent.RoadEventX -> { + handleRoadMarkerEvent(event.data.toRoadMarker()) + } + else -> { + Logger.e(TAG, "onAck other event: $event") + } } } @@ -367,13 +372,13 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, val change = changeVisualAngle override fun onShow() { if (change) { - CallerVisualAngleManager.changeVisualAngle(TooClose) + CallerVisualAngleManager.changeAngle(TooClose) } } override fun onDismiss() { if (change) { - CallerVisualAngleManager.changeVisualAngle(Default()) + CallerVisualAngleManager.changeAngle(Default()) } } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java index 7b0d9d278e..327a28d209 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java @@ -90,18 +90,18 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager { // 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常 mV2XRoadEventEntityArrayList.clear(); // 获取探路以及新鲜事儿 - List exploreWayList = markerCardResult.getExploreWay(); + List exploreWayList = markerCardResult.getExploreWay(); if (exploreWayList != null) { - for (V2XMarkerExploreWay markerExploreWay : exploreWayList) { + for (MarkerExploreWay markerExploreWay : exploreWayList) { if (EventTypeEnumNew.isRoadEvent(markerExploreWay.getPoiType())) { - V2XMarkerLocation markerLocation = markerExploreWay.getLocation(); + MarkerLocation markerLocation = markerExploreWay.getLocation(); // 记录道路事件 V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); - v2XRoadEventEntity.setLocation(EntityUtilsKt.toMarkerLocation(markerLocation)); + v2XRoadEventEntity.setLocation(markerLocation); // 探路目前只有上报拥堵 String poi = markerExploreWay.getPoiType(); v2XRoadEventEntity.setPoiType(poi); - v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay, markerCardResult.getExtras())); + v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); v2XRoadEventEntity.setExpireTime(20000); mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity); } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index 1a1bc8ce6c..c088868c50 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -7,7 +7,6 @@ import android.os.Looper import android.view.animation.DecelerateInterpolator import androidx.core.util.Pair import com.mogo.cloud.commons.utils.* -import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.data.map.MogoLatLng import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity import com.mogo.eagle.core.function.call.autopilot.* diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt index 26dacad912..2a1ee214bd 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt @@ -18,63 +18,39 @@ class V2XAiRoadEventMarker { private val current = AtomicReference?>>() - private val v2xLocation = AtomicReference() - private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager() } fun drawMarkers(entity: V2XRoadEventEntity, wrapper: MarkerWrapper) { - val extra = entity.noveltyInfo.extras["polygon"] + val polygon = entity.noveltyInfo.polygon v2xMarker()?.drawableAlarmPOI(context(), entity, null)?.also { wrapper.addMarker(it) } - if (extra is List<*> && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) { - if (extra.size > 0) { - val polygons: MutableList> = ArrayList() - for (i in extra.indices) { - val o = extra[i]!! as? androidx.core.util.Pair<*, *> ?: continue - val first = o.first - val second = o.second - if (first == null || second == null) { - continue - } - if (first !is Double || second !is Double) { - continue - } - polygons.add(androidx.core.util.Pair.create(second, first)) - } - if (polygons.size > 0) { - val l2 = entity.noveltyInfo?.location ?: return - v2xLocation.set(MogoLocation().also { - it.longitude = l2.lon; it.latitude = l2.lat; it.heading = l2.angle - }) + if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) { + val options = MogoPolylineOptions() + val colors = ArrayList() + colors.add(Color.argb(204, 237, 172, 21)) + colors.add(Color.argb(0, 255, 255, 255)) + options.colorValues(colors) + val points = ArrayList() - val options = MogoPolylineOptions() - val colors = ArrayList() - colors.add(Color.argb(204, 237, 172, 21)) - colors.add(Color.argb(0, 255, 255, 255)) - options.colorValues(colors) - val points = ArrayList() - - for (p in polygons) { - points.add(MogoLatLng(p.first, p.second)) - } - if (points.size > 2) { - points.add(points[0]) - } - options.points(points) - options.useGradient(true) - options.useFacade(true) - options.setGps(true) - options.width(5f) - options.zIndex(75000f) - options.maxIndex(800000f) - val line = overlayManager?.addPolyline(options) - line?.let { - current.set(Pair(line, wrapper.markers)) - line.isVisible = true - wrapper.addLine(line) - } - } + for (p in polygon) { + points.add(MogoLatLng(p.first, p.second)) + } + if (points.size > 2) { + points.add(points[0]) + } + options.points(points) + options.useGradient(true) + options.useFacade(true) + options.setGps(true) + options.width(5f) + options.zIndex(75000f) + options.maxIndex(800000f) + val line = overlayManager?.addPolyline(options) + line?.let { + current.set(Pair(line, wrapper.markers)) + line.isVisible = true + wrapper.addLine(line) } } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java index a743246918..b97689f35b 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java @@ -1,9 +1,7 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.road; import android.util.Log; - import androidx.core.util.Pair; - import com.mogo.eagle.core.data.enums.EventTypeEnumNew; import com.mogo.eagle.core.data.map.entity.MarkerExploreWay; import com.mogo.eagle.core.data.map.entity.MarkerLocation; @@ -15,7 +13,6 @@ import com.mogo.eagle.core.function.v2x.events.remove.MarkerRemoveManager; import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker; import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; import com.mogo.map.marker.IMogoMarker; - import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -34,10 +31,21 @@ public class V2XRoadEventMarker implements IV2XMarker { if (marker != null) { if (entity != null) { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType()); - if (!Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType())) { + if (isAiRoadEvent(entity.getPoiType())) { + MarkerExploreWay noveltyInfo = entity.getNoveltyInfo(); + Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo); + if (noveltyInfo != null) { + Pair gpsLocation = noveltyInfo.getGpsLocation(); + List> polygons = noveltyInfo.getPolygon(); + if (gpsLocation != null && polygons != null) { + MarkerLocation location = noveltyInfo.getLocation(); + AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity); + AiRoadMarker aiMarker = new AiRoadMarker(); + aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType())); + AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker); + } + } + } else { IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null); if (iMarker != null) { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- add Marker"); @@ -48,48 +56,6 @@ public class V2XRoadEventMarker implements IV2XMarker { } else { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker"); } - } else { - MarkerExploreWay noveltyInfo = entity.getNoveltyInfo(); - Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo); - if (noveltyInfo != null && noveltyInfo.extras != null) { - List> polygons = new ArrayList<>(); - Pair gpsLocation = null; - if (noveltyInfo.extras.containsKey("polygon")) { - Object extra = noveltyInfo.extras.get("polygon"); - if (extra instanceof List) { - List l = (List) extra; - if (l.size() > 0) { - for (int i = 0; i < l.size(); i++) { - Object o = l.get(i); - if (!(o instanceof Pair)) { - continue; - } - Pair p = (Pair) o; - Object first = p.first; - Object second = p.second; - if (first == null || second == null) { - continue; - } - if (!(first instanceof Double) || !(second instanceof Double)) { - continue; - } - polygons.add(Pair.create((Double) first, (Double) second)); - } - } - } - } - - if (noveltyInfo.extras.containsKey("gps_location")) { - gpsLocation = (Pair) ((List)(noveltyInfo.extras.get("gps_location"))).get(0); - } - if (!polygons.isEmpty() && gpsLocation != null) { - MarkerLocation location = noveltyInfo.getLocation(); - AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity); - AiRoadMarker aiMarker = new AiRoadMarker(); - aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType())); - AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker); - } - } } } } @@ -98,6 +64,13 @@ public class V2XRoadEventMarker implements IV2XMarker { } } + private boolean isAiRoadEvent(String poiType) { + return Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType()); + } + private boolean isDrawRoadLine(String poiType) { return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType); } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java index 1c4d34d86a..c604e02cc3 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java @@ -11,6 +11,8 @@ 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.map.angle.Default; +import com.mogo.eagle.core.function.api.map.angle.RoadEvent; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager; @@ -151,7 +153,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp @Override public void onShow() { if (isNeedChangeAngle()) { - CallerVisualAngleManager.INSTANCE.changeVisualAngle(CallerVisualAngleManager.Scene.RoadEvent.INSTANCE); + CallerVisualAngleManager.INSTANCE.changeAngle(RoadEvent.INSTANCE); } V2XMessageEntity entity = getV2XMessageEntity(); if (entity != null) { @@ -177,7 +179,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp public void onDismiss() { CallerHmiManager.INSTANCE.dismissWarning(WarningDirectionEnum.ALERT_WARNING_TOP); if (isNeedChangeAngle()) { - CallerVisualAngleManager.INSTANCE.changeVisualAngle(new CallerVisualAngleManager.Scene.Default(3, TimeUnit.SECONDS)); + CallerVisualAngleManager.INSTANCE.changeAngle(new Default(3, TimeUnit.SECONDS)); } release(); } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt index 65ebd78c9d..0b8602e86e 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt @@ -4,7 +4,6 @@ import androidx.core.util.Pair import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent import com.mogo.eagle.core.data.map.entity.MarkerExploreWay import com.mogo.eagle.core.data.map.entity.MarkerLocation -import com.mogo.eagle.core.data.map.entity.MarkerUserInfo import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker import com.mogo.eagle.core.function.v2x.internal.data.* @@ -13,85 +12,24 @@ import mogo.telematics.pad.MessagePad import roadwork.Road -fun V2XMarkerLocation?.toMarkerLocation(): MarkerLocation? = - if (this == null) null else MarkerLocation().also { - it.lon = this.lon - it.lat = this.lat - it.address = this.address - it.angle = this.angle - } - -fun MarkerExploreWayItem?.toMarkerExploreWayItem(): com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem? = - if (this == null) null else com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem().also { - it.illegalCount = this.illegalCount - it.content = this.content - it.url = this.url - it.thumbnail = this.thumbnail - } - -fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? = - if (this == null) null else MarkerUserInfo().also { - it.safeLabelType = this.safeLabelType - it.safeLabel = this.safeLabel - it.lastActiveweekAvgscore = this.lastActiveweekAvgscore - it.gender = this.gender - it.userHead = this.userHead - it.userName = this.userName - it.setAge(this.age) - } - -fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map? = null): MarkerExploreWay = - MarkerExploreWay().also { - it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() } - it.userInfo = this.userInfo?.toMarkerUserInfo() - it.distance = this.distance - it.cityName = this.cityName - it.setGenerateTime(this.generateTime) - it.infoId = this.infoId - it.setFileType(this.fileType) - it.setDirection(this.direction) - it.location = this.location?.toMarkerLocation() - it.sn = this.sn - it.canLive = this.canLive != "0" - it.poiType = this.poiType - it.type = this.type - it.infoCheckNode = this.infoCheckNode - it.isFabulous = this.isFabulous - it.uploadType = this.uploadType - it.isCanLive = this.canLive != "0" - it.extras = extras - } - fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> - Pair(d.lon, d.lat) - } - - extra["gps_location"] = listOf( - Pair( - this.roadwork?.center?.point?.lon ?: 0.0, - this.roadwork?.center?.point?.lat ?: 0.0 - ) - ) - } - } val centerX = this.roadwork?.center?.point?.lon ?: 0.0 val centerY = this.roadwork?.center?.point?.lat ?: 0.0 val id = "${centerX}_${centerY}" - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = this.roadwork?.poiType?.toString() - l3.generateTime = this.roadwork?.detectTime ?: 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(this.roadwork?.detectTime ?: 0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0) l4.lon = p[0] l4.lat = p[1] l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0 } l3.infoId = id + l3.gpsLocation = Pair(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0) + l3.polygon = this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) } }) } AiRoadMarker.aiMakers[id]?.receive() @@ -99,52 +37,41 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult = fun V2XRoadXData.toRoadMarker(): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.polygon?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> - Pair(d.lon, d.lat) - } - extra["gps_location"] = listOf(Pair(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0)) - } - } - - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = this.poiType - l3.generateTime = this.detectTime ?: 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(this.detectTime ?: 0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0) l4.lon = p[0] l4.lat = p[1] l4.angle = this.centerRoad?.bearing ?: 0.0 } l3.infoId = this.index + l3.gpsLocation = Pair(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0) + l3.polygon = this.polygon?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) } }) } - AiRoadMarker.aiMakers[this.index]?.receive() } fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.polygonList?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> Pair(d.longitude, d.latitude) } - extra["gps_location"] = listOf(Pair(this.longitude, this.latitude)) - } - } val id = "${this.longitude}_${this.latitude}" - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = poiType - l3.generateTime = 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.longitude, this.latitude) l4.lon = p[0] l4.lat = p[1] l4.angle = this.heading } l3.infoId = id + + l3.gpsLocation = Pair(this.longitude, this.latitude) + l3.polygon = this.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.longitude, it.latitude) } }) } AiRoadMarker.aiMakers[id]?.receive() @@ -152,14 +79,14 @@ fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult fun V2XMarkerCardResult.toV2XRoadEventEntity(): V2XRoadEventEntity = V2XRoadEventEntity().also { l1 -> - val exploreWayList: List? = this.exploreWay + val exploreWayList: List? = this.exploreWay if (!exploreWayList.isNullOrEmpty() && exploreWayList.isNotEmpty()) { for (markerExploreWay in exploreWayList) { if (isRoadEvent(markerExploreWay.poiType)) { val markerLocation = markerExploreWay.location - l1.location = markerLocation.toMarkerLocation() + l1.location = markerLocation l1.poiType = markerExploreWay.poiType - l1.noveltyInfo = markerExploreWay.toMarkExploreWay(this.extras) + l1.noveltyInfo = markerExploreWay l1.expireTime = 20000 } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt index db6a6b5754..a486687d10 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt @@ -1,6 +1,8 @@ package com.mogo.eagle.core.function.v2x.internal.data import androidx.annotation.Keep +import com.mogo.eagle.core.data.map.entity.MarkerExploreWay +import com.mogo.eagle.core.data.map.entity.MarkerLocation import java.io.Serializable @Keep @@ -41,20 +43,15 @@ class V2XMarkerCardResult: V2XBaseData(), Serializable { /** * 探路数据集合 */ - var exploreWay: List? = null + var exploreWay: List? = null /** * 服务端下发消息时间 */ var messageTime: Long = 0 - /** - * 额外信息 - */ - var extras: Map? = null - override fun toString(): String { - return "MarkerCardResult(dataType=$dataType, carChat=$carChat, shareMusic=$shareMusic, noveltyInfo=$noveltyInfo, onlineCar=$onlineCar, exploreWay=$exploreWay, messageTime=$messageTime, extras=$extras)" + return "MarkerCardResult(dataType=$dataType, carChat=$carChat, shareMusic=$shareMusic, noveltyInfo=$noveltyInfo, onlineCar=$onlineCar, exploreWay=$exploreWay, messageTime=$messageTime)" } } @@ -369,7 +366,7 @@ class V2XMarkerExploreWay: Serializable { /** * 位置信息 */ - var location: V2XMarkerLocation? = null + var location: MarkerLocation? = null /** * 车辆方位 diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java index b67cf92f55..f319c9556a 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java @@ -96,4 +96,7 @@ public class MogoServicePaths { @Keep public static final String PATH_IDENTIFY = "/map/identify"; + + @Keep + public static final String PATH_VISUAL_ANGLE = "/map/angle_change"; } diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java index 8516d97fcf..12287a8b76 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java @@ -4,6 +4,8 @@ package com.mogo.eagle.core.data.map.entity; import android.text.TextUtils; +import androidx.core.util.Pair; + import java.io.Serializable; import java.util.List; import java.util.Map; @@ -35,7 +37,10 @@ public class MarkerExploreWay implements Serializable { // 1 需要用户判断是否拥堵 进行UGC问答 private int infoCheckNode; - public Map extras = null; + + private Pair gpsLocation; + + private List> polygon; public String getAddr() { if (TextUtils.isEmpty(addr)) { @@ -170,6 +175,22 @@ public class MarkerExploreWay implements Serializable { this.uploadType = uploadType; } + public Pair getGpsLocation() { + return gpsLocation; + } + + public void setGpsLocation(Pair gpsLocation) { + this.gpsLocation = gpsLocation; + } + + public List> getPolygon() { + return polygon; + } + + public void setPolygon(List> polygon) { + this.polygon = polygon; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/core/mogo-core-function-api/build.gradle b/core/mogo-core-function-api/build.gradle index bb7c323f18..8672b4a8da 100644 --- a/core/mogo-core-function-api/build.gradle +++ b/core/mogo-core-function-api/build.gradle @@ -47,7 +47,7 @@ dependencies { kapt rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.coroutinescore implementation rootProject.ext.dependencies.coroutinesandroid - implementation rootProject.ext.dependencies.mogoobu + implementation project(':libraries:mogo-obu') if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_data diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt index 774812ef84..360416ca62 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt @@ -56,6 +56,4 @@ interface IMoGoFuncBizProvider : IMoGoFunctionServerProvider { fun fetchInfStructures() fun getAllV2XEvents() - - fun initOverViewDb(context: Context) } \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt new file mode 100644 index 0000000000..a4c1ec1712 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt @@ -0,0 +1,10 @@ +package com.mogo.eagle.core.function.api.map.angle + +import com.mogo.eagle.core.function.api.base.* + +interface IMoGoVisualAngleChangeProvider: IMoGoFunctionServerProvider { + + fun updateLongSightLevel(level: Boolean) + + fun changeAngle(scene: Scene) +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt new file mode 100644 index 0000000000..296f992b05 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt @@ -0,0 +1,104 @@ +package com.mogo.eagle.core.function.api.map.angle + +import com.mogo.map.uicontroller.* +import java.util.concurrent.* +import java.util.concurrent.TimeUnit.SECONDS + +private interface IAttach { + val angle: VisualAngleMode + val priority: Int + val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, + } + + +sealed class Scene: IAttach + + +/** + * 默认视图 + * @param delay: 表示多少稍后,默认值为2 + * @param unit: 时间单位,默认为秒 + */ +class Default(val delay: Long = 2, val unit: TimeUnit = SECONDS): Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MODE_MEDIUM_SIGHT + + override val priority: Int = 1 + + override val displayThreshold: Long + get() = 0 + + override fun toString(): String { + return "Default(delay=$delay, unit=$unit, angle=$angle, priority=$priority)" + } +} + + +/** + * 变道-接收到转向灯信息号 + */ +class Turning(var open: Boolean = false): Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP + + override val priority: Int = 3 + + override val displayThreshold: Long + get() = -1 + + override fun toString(): String { + return "Turning(open: ${open}, priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" + } +} + + +/** + * 后方车辆离自车过近 + */ +object TooClose: Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_300 + + override val priority: Int = 2 + + override val displayThreshold: Long + get() = SECONDS.toMillis(8) + + override fun toString(): String { + return "TooClose(priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" + } +} + + +/** + * 道路事件 + */ +object RoadEvent: Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MODE_LONG_SIGHT + + override val priority: Int = 5 + + override val displayThreshold: Long + get() = SECONDS.toMillis(8) + + override fun toString(): String { + return "RoadEvent(priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" + } +} + + +/** + * 十字路口 + */ +class CrossRoad(var open: Boolean = false): Scene() { + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS + override val priority: Int = 4 + override val displayThreshold: Long + get() = -1 + + override fun toString(): String { + return "CrossRoad(open: ${open}, priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" + } +} + diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuLocationWGS84Listener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuLocationWGS84Listener.kt index c98d8f8982..16c5fd57b3 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuLocationWGS84Listener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuLocationWGS84Listener.kt @@ -11,7 +11,7 @@ interface IMoGoObuLocationWGS84Listener { /** * HV车辆基础信息 - * + s * @param data 数据 * @since 1.0.0 */ diff --git a/core/mogo-core-function-call/build.gradle b/core/mogo-core-function-call/build.gradle index 94acda38e5..13a6502f25 100644 --- a/core/mogo-core-function-call/build.gradle +++ b/core/mogo-core-function-call/build.gradle @@ -50,9 +50,7 @@ dependencies { // MoGo 数据埋点工具 implementation rootProject.ext.dependencies.analytics compileOnly rootProject.ext.dependencies.mogocustommap - - implementation rootProject.ext.dependencies.mogoobu - + implementation project(':libraries:mogo-obu') if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_data diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt index 5970ebf407..4387d4a198 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt @@ -1,398 +1,24 @@ package com.mogo.eagle.core.function.call.map -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.os.SystemClock -import android.util.* -import androidx.lifecycle.Lifecycle.Event -import androidx.lifecycle.Lifecycle.Event.ON_DESTROY -import androidx.lifecycle.LifecycleEventObserver -import androidx.lifecycle.LifecycleOwner -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.map.* -import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine -import com.mogo.eagle.core.function.call.autopilot.* -import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.* -import com.mogo.eagle.core.utilcode.kotlin.lifeCycleOwner -import com.mogo.eagle.core.utilcode.kotlin.safeCancel -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA -import com.mogo.map.uicontroller.VisualAngleMode -import com.zhidaoauto.map.sdk.open.tools.MapTools -import kotlinx.coroutines.* -import kotlinx.coroutines.android.asCoroutineDispatcher -import kotlinx.coroutines.internal.synchronized -import java.util.* -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeUnit.SECONDS -import java.util.concurrent.atomic.* -import kotlin.math.* +import com.alibaba.android.arouter.launcher.* +import com.mogo.eagle.core.data.constants.* +import com.mogo.eagle.core.function.api.map.angle.* + /** * 高精地图视角管理类 */ object CallerVisualAngleManager { - private const val TAG = "VisualAngle" - - @Volatile - private var hasCrossRoad = false - - - private var scope: CoroutineScope = acquireScope() - @Synchronized - get() { - if (field.isActive) { - return field - } - val scope = acquireScope() - field = scope - return field - } - - private var defaultDelayJob: Job? = null - - private fun acquireScope(): CoroutineScope { - return CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher("change-visual-angle") + SupervisorJob()) + private val provider by lazy { ARouter.getInstance().build(MogoServicePaths.PATH_VISUAL_ANGLE) + .navigation() as? IMoGoVisualAngleChangeProvider } - private interface IAttach { - val angle: VisualAngleMode - val priority: Int - val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, + fun changeAngle(scene: Scene) { + provider?.changeAngle(scene) } - private val triggerLocation = AtomicReference() - - private val distanceOfCarToStopLine = AtomicReference(0.0) - - private val travelled by lazy { AtomicReference(0.0) } - - private val listener = object : OnRoadListener { - private val roadId = AtomicReference() - private val triggerRoadId = AtomicReference() - - override fun onRoadIdInfo(roadId: String) { - this.roadId.set(roadId) - Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId") - val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02() - var triggerClose = false - val distance = distanceOfCarToStopLine.get() + 5 - if (hasCrossRoad && distance > 0) { - val prev = triggerLocation.get() - if (prev != null && loc != null) { - travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get()) - triggerLocation.set(loc) - } - val oldRoadId = triggerRoadId.get() - Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}") - if ((travelled.get() > distance) && oldRoadId != null && oldRoadId != roadId) { - distanceOfCarToStopLine.set(0.0) - hasCrossRoad = false - triggerRoadId.set(null) - travelled.set(0.0) - triggerLocation.set(null) - Log.d(TAG, "-- onRoadIdInfo --: trigger close --") - triggerClose = true - } - } - if (triggerClose) { - changeVisualAngle(CrossRoad(false)) - } - } - - - override fun onStopLineInfo(info: StopLine) { - Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}") - if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { - hasCrossRoad = true - triggerRoadId.set(this.roadId.get()) - distanceOfCarToStopLine.set(info.distanceOfCarToStopLine) - triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()) - changeVisualAngle(CrossRoad(true)) - } - } + fun updateLongSightLevel(level: Boolean) { + provider?.updateLongSightLevel(level) } - - fun init(ctx: Context) { - if (Thread.currentThread() != Looper.getMainLooper().thread) { - scope.launch { - initListen(ctx) - } - } else { - initListen(ctx) - } - } - - private fun initListen(ctx: Context) { - ctx.lifeCycleOwner.lifecycle.addObserver(object : LifecycleEventObserver { - override fun onStateChanged(source: LifecycleOwner, event: Event) { - if (event == ON_DESTROY) { - CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") - } - } - }) - CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener) - } - - sealed class Scene private constructor(): IAttach { - - /** - * 默认视图 - * @param delay: 表示多少稍后,默认值为2 - * @param unit: 时间单位,默认为秒 - */ - class Default(val delay: Long = 2, val unit: TimeUnit = SECONDS): Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MODE_MEDIUM_SIGHT - - override val priority: Int = 1 - - override val displayThreshold: Long - get() = 0 - - override fun toString(): String { - return "Default(delay=$delay, unit=$unit, angle=$angle, priority=$priority)" - } - } - - /** - * 变道-接收到转向灯信息号 - */ - class Turning(var open: Boolean = false): Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP - - override val priority: Int = 3 - - override val displayThreshold: Long - get() = -1 - - override fun toString(): String { - return "Turning(open: ${open}, priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" - } - } - - /** - * 后方车辆离自车过近 - */ - object TooClose: Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_300 - - override val priority: Int = 2 - - override val displayThreshold: Long - get() = SECONDS.toMillis(8) - - override fun toString(): String { - return "TooClose(priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" - } - } - - /** - * 道路事件 - */ - object RoadEvent: Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MODE_LONG_SIGHT - - override val priority: Int = 5 - - override val displayThreshold: Long - get() = SECONDS.toMillis(8) - - override fun toString(): String { - return "RoadEvent(priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" - } - } - - - /** - * 十字路口 - */ - class CrossRoad(var open: Boolean = false): Scene() { - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS - override val priority: Int = 4 - override val displayThreshold: Long - get() = -1 - - override fun toString(): String { - return "CrossRoad(open: ${open}, priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" - } - } - } - - - /** - * 业务实体,不对外暴露 - * @param target: 目标场景 - * @param isDisplay: 是否正在展示 - * @param triggerTime: 触发时间 - */ - private data class Record(val target: Scene, var isDisplay: Boolean = false, var triggerTime: Long): Comparable { - override fun compareTo(other: Record): Int { - //如果时间一样,优先级越高,越靠近堆顶 - return other.target.priority - target.priority - } - } - - private val queue by lazy { - PriorityQueue() - } - - @Volatile - private var mLevel:Boolean = false - - fun updateLongSightLevel(level:Boolean){ - mLevel = level - } - - fun changeVisualAngle(current: Scene) { - val appIdentityMode = FunctionBuildConfig.appIdentityMode - if (AppIdentityModeUtils.isBus(appIdentityMode) && AppIdentityModeUtils.isPassenger(appIdentityMode)) { - return - } - if(mLevel){ - return - } - val triggerTime = SystemClock.elapsedRealtime() - scope.launch { - Log.d("${M_DEVA}${TAG}", "--- 1 ---") - val displayed = getDisplayed() - if (displayed == null) { - Log.d("${M_DEVA}${TAG}", "--- 2 ---") - if (current is Turning) { - if (!current.open) { - changeVisualAngle(Default()) - return@launch - } - } - if (current is CrossRoad) { - if (!current.open) { - changeVisualAngle(Default()) - return@launch - } - } - doRealVisualAngleChange(triggerTime, current, null) - } else { - val prev = displayed.target - Log.d("${M_DEVA}${TAG}", "--- 3 --- old: $prev -> cur: $current") - val prevTriggerTime = displayed.triggerTime - if (current !is Default && prev.priority > current.priority && (prev is RoadEvent || prev is TooClose)) { - val displayDuration = triggerTime - prevTriggerTime - Log.d("${M_DEVA}${TAG}", "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration") - if (displayDuration < prev.displayThreshold) { - Log.d("${M_DEVA}${TAG}", "--- 5 --- 场景[$prev]:仍在保护展示时长内,直接return") - return@launch - } else { - Log.d("${M_DEVA}${TAG}", "--- 6 --- 场景[$prev]:已过保护展示时长,从展示的队列中移除,显示默认视角") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev is Turning && current is Turning) { - val isOpen = current.open - if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 7 --- 场景[$current], 收到关闭通知") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev is CrossRoad && current is CrossRoad) { - val isOpen = current.open - if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 8 --- old: $prev -> cur: $current") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev.priority == current.priority) { - Log.d("${M_DEVA}${TAG}", "--- 9 --- 场景[$prev]正在展示,尚未收到关闭,优先级一致,直接return") - return@launch - } - if (prev.priority > current.priority && prev.displayThreshold < 0) { - Log.d("${M_DEVA}${TAG}", "--- 10 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") - return@launch - } - doRealVisualAngleChange(triggerTime, current, displayed) - } - } - } - - private fun CoroutineScope.doRealVisualAngleChange(triggerTime: Long, target: Scene, displayed: Record? = null) { - if (target is Default) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 1 ---") - displayed?.also { - queue -= it - } - defaultDelayJob?.safeCancel() - launch { - val delay = target.unit.toMillis(target.delay) - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 2 ---") - delay(delay) - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 3 ---") - doChangeAngle(Record(target, triggerTime = triggerTime)) - }.also { itx -> - itx.invokeOnCompletion { - if (it is CancellationException) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 4 ---") - } - } - defaultDelayJob = itx - } - } else { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 5 ---") - defaultDelayJob?.safeCancel() - if (displayed == null || displayed.target.priority <= target.priority) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 6 ---") - displayed?.also { - queue -= it - } - if (target is Turning) { - if (!target.open) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 7 ---") - changeVisualAngle(Default()) - return - } - } - if (target is CrossRoad) { - if (!target.open) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 8 ---") - changeVisualAngle(Default()) - return - } - } - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 10 ---") - doChangeAngle(Record(target, triggerTime = triggerTime)) - } - } - } - - @OptIn(InternalCoroutinesApi::class) - private fun doChangeAngle(record: Record) { - val angle = record.target.angle - CallerMapUIServiceManager.getMapUIController()?.also { - Log.d("${M_DEVA}${TAG}", "--- doChangeAngle ---: ${record.target}") - if (record.target !is Default) { - record.isDisplay = true - synchronized(queue) { - queue += record - } - } - it.changeMapVisualAngle(angle, null) - } - } - - /** - * 是否有正在展示的 - */ - @Synchronized - private fun getDisplayed() = queue.firstOrNull() - } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8764d7688e..9c88990a89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -66,23 +66,23 @@ SERVICE_BIZ_VERSION=1.2.4 LOGLIB_VERSION=1.5.10 ######## MogoAiCloudSDK Version ######## # 网络请求LOGLIB_VERSION -MOGO_NETWORK_VERSION=1.4.3.32-beta3 +MOGO_NETWORK_VERSION=1.4.4.1 # 鉴权 -MOGO_PASSPORT_VERSION=1.4.3.32-beta3 +MOGO_PASSPORT_VERSION=1.4.4.1 # 常链接 -MOGO_SOCKET_VERSION=1.4.3.32-beta3 +MOGO_SOCKET_VERSION=1.4.4.1 # 数据采集 -MOGO_REALTIME_VERSION=1.4.3.32-beta3 +MOGO_REALTIME_VERSION=1.4.4.1 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.4.3.32-beta3 +MOGO_TANLU_VERSION=1.4.4.1 # 直播推流 -MOGO_LIVE_VERSION=1.4.3.32-beta3 +MOGO_LIVE_VERSION=1.4.4.1 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.4.3.32-beta3 +MOGO_TRAFFICLIVE_VERSION=1.4.4.1 # 定位服务 -MOGO_LOCATION_VERSION=1.4.3.32-beta3 +MOGO_LOCATION_VERSION=1.4.4.1 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.4.3.32-beta2 +MOGO_TELEMATIC_VERSION=1.4.4.1 ######## MogoAiCloudSDK Version ######## # 自研地图 MAP_SDK_VERSION=2.10.0.2_test_01 @@ -130,12 +130,6 @@ TTS_NOOP_VERSION=2.1.16.10 # 自研地图 MAP_CUSTOM_VERSION=2.1.16.10 -# 车聊聊 -MOGO_MODULE_CHAT_VERSION=2.1.16.10 -MOGO_MODULE_CARCHATTING_VERSION=2.1.16.10 -# 车聊聊接口 -MOGO_MODULE_CARCHATTINGPROVIDER_VERSION=2.1.16.10 - # OCH MOGO_OCH_VERSION=2.1.16.10-test MOGO_OCH_BUS_VERSION=2.0.66 diff --git a/libraries/mogo-adas-data/src/main/proto/message_pad.proto b/libraries/mogo-adas-data/src/main/proto/message_pad.proto index a024bb74ee..4fbde4e724 100644 --- a/libraries/mogo-adas-data/src/main/proto/message_pad.proto +++ b/libraries/mogo-adas-data/src/main/proto/message_pad.proto @@ -135,6 +135,8 @@ message TrackedObject repeated Location polygon = 15; geometry.Point center = 16; AdditionalAttribute add_attribute = 17; // 事件类型 + reserved 18 to 100; + string strUuid = 101;//String类型车辆ID } message TrackedObjects @@ -188,7 +190,7 @@ message AutopilotState message PlanningObject { uint32 uuid = 1; - uint32 type = 2; //影响自车决策的类型, 和感知的障碍物类型不是一回事 + uint32 type = 2; //影响自车决策的类型, 和感知的障碍物类型不是一回事 0是leading障碍物,1是避障和择机的障碍物 } message PlanningObjects diff --git a/libraries/mogo-adas-data/src/main/proto/personal/obu_base.proto b/libraries/mogo-adas-data/src/main/proto/personal/obu_base.proto index 52174fb80e..0954d731da 100644 --- a/libraries/mogo-adas-data/src/main/proto/personal/obu_base.proto +++ b/libraries/mogo-adas-data/src/main/proto/personal/obu_base.proto @@ -5,13 +5,13 @@ package com.mogo.support.obu; //垂直方向偏差 目前OBU发送的数据未偏移,使用的是elevation message VerticalLLV{ oneof present{ - double offset1 = 1;//海拔,单位(m) - double offset2 = 2;//海拔,单位(m) - double offset3 = 3;//海拔,单位(m) - double offset4 = 4;//海拔,单位(m) - double offset5 = 5;//海拔,单位(m) - double offset6 = 6;//海拔,单位(m) - double elevation = 7;//海拔,单位(m) + double offset1 = 1; //海拔,单位(m) + double offset2 = 2; //海拔,单位(m) + double offset3 = 3; //海拔,单位(m) + double offset4 = 4; //海拔,单位(m) + double offset5 = 5; //海拔,单位(m) + double offset6 = 6; //海拔,单位(m) + double elevation = 7; //海拔,单位(m) } } @@ -33,135 +33,158 @@ message PositionOffset{ } message PositionLL1{ // (-2048..2047) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLL2{ // (-8192..8191) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLL3{ // (-32768..32767) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLL4{ // (-131072..131071) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLL5{ // (-2097152..2097151) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLL6{ // (-8388608..8388607) - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } message PositionLatLon{ // 定义经度数值。东经为正,西经为负。 //分辨率为1e-7°。 - double longitude = 1;//经度,单位(°) - double latitude = 2;//维度,单位(°) + double longitude = 1; //经度,单位(°) + double latitude = 2; //维度,单位(°) } ////////////////////////////////////////////////////////////////// //交通标志/事件位置信息 message PositionLLV{ - PositionOffset position = 1;//经纬度 - VerticalLLV vertical = 2;//垂直方向偏差 + PositionOffset position = 1; //经纬度 + VerticalLLV vertical = 2; //垂直方向偏差 } //交通参与者尺寸信息 message VehicleSize { - int32 width = 1;//宽度,单位(cm) - int32 length = 2;//长度,单位(cm) - int32 height = 3;//高度,单位(cm) + int32 width = 1; //宽度,单位(cm) + int32 length = 2; //长度,单位(cm) + int32 height = 3; //高度,单位(cm) } //四轴加速度 message AccFourAxes { - double accLng = 1;//纵向加速度,单位(m/s2) - double accLat = 2;//横向加速度,单位(m/s2) - double accVert = 3;//垂直加速度,单位(G) - double accYaw = 4;//横摆角加速度,单位(°/s) + double accLng = 1; //纵向加速度,单位(m/s2) + double accLat = 2; //横向加速度,单位(m/s2) + double accVert = 3; //垂直加速度,单位(G) + double accYaw = 4; //横摆角加速度,单位(°/s) } //节点信息 message NodeId{ - int32 region = 1;/* 定义地图中划分区域的ID号 */ - int32 id = 2; /* 定义地图节点ID */ + int32 region = 1; /* 定义地图中划分区域的ID号 */ + int32 id = 2; /* 定义地图节点ID */ } //灯色信息 message SpatLight{ - int32 phaseID = 1; /* 信号灯相位ID */ - int32 maneuvers = 2; /* 允许转向关系,bit0:直行,bit1:左转,bit2:右转,bit3:掉头 */ - int32 light = 3; /* 灯色,0:不可用,1:黑色,2:红闪,3:红色,4:绿闪,5:permissive_green,6:protected_green,7:黄色,8:黄闪 */ - double countDown = 4; /* 灯色倒计时,单位(s) */ + int32 phaseID = 1; /* 信号灯相位ID */ + int32 maneuvers = 2; /* 允许转向关系,bit0:直行,bit1:左转,bit2:右转,bit3:掉头 */ + int32 light = 3; /* 灯色,0:不可用,1:黑色,2:红闪,3:红色,4:绿闪,5:permissive_green,6:protected_green,7:黄色,8:黄闪 */ + double countDown = 4; /* 灯色倒计时,单位(s) */ double suggestMaxSpeed = 5; /* 建议最大车速,单位(m/s) */ double suggestMinSpeed = 6; /* 建议最小车速,单位(m/s) */ } //时间 message DateTime{ - int32 year = 1; /* 年份 */ + int32 year = 1; /* 年份 */ int32 month = 2; /* 月份 */ int32 day = 3; /* 日期 */ int32 hour = 4; /* 小时 */ int32 minute = 5; /* 分钟 */ - int32 millisecond = 6; /* 毫秒 */ + int32 millisecond = 6; /* 毫秒 */ int32 offset = 7; /* 定义与UTC时间的分钟差 */ } //预警数据 message WarningData{ - int32 unitMask = 1; /* 描述所属字段有效性 */ - int32 status = 2; /* 状态信息,0:更新,1:添加,2:删除 */ - int32 warningType = 3; /* 预警类型,0:前向碰撞预警,1:交叉路口碰撞预警,2:左转辅助预警,3:盲区预警,4:变道预警, - 5:逆向超车预警,6:紧急制动预警,7:异常车辆提醒,8:失控车辆预警,9:紧急车辆预警,10:弱势交通参与者碰撞预警 */ + int32 unitMask = 1; /* 描述所属字段有效性 */ + int32 status = 2; /* 状态信息,0:更新,1:添加,2:删除 */ + int32 warningType = 3; /* 预警类型,0:前向碰撞预警,1:交叉路口碰撞预警,2:左转辅助预警,3:盲区预警,4:变道预警, + 5:逆向超车预警,6:紧急制动预警,7:异常车辆提醒,8:失控车辆预警,9:紧急车辆预警,10:弱势交通参与者碰撞预警 */ int32 warningLevel = 4; /* 预警等级,0:无效,1:DETECTED,2:INFORM,3:WARNING */ - int32 warningPriority = 5; /* 预警优先级,默认为0,预留 */ + int32 warningPriority = 5; /* 预警优先级,默认为0,预留 */ } //弱势交通参与者预警信息 message V2xWarning{ - int32 unitMask = 1; /* 描述所属字段有效性 */ - repeated WarningData warningData = 2; - DateTime warningTime = 3; /* 预警触发时间 */ - double distance = 4; /* 预警触发时与自车之间的距离,单位(m) */ + int32 unitMask = 1; /* 描述所属字段有效性 */ + repeated WarningData warningData = 2; /*预警数据*/ + DateTime warningTime = 3; /* 预警触发时间 */ + double distance = 4; /* 预警触发时与自车之间的距离,单位(m) */ } //弱势交通参与者信息 message Participant{ - int32 ptcType = 1; /* 交通参与者类型,0:未知,1:机动车,2:非机动车,3:行人,4:OBU自身 */ - int32 ptcId = 2; /* 临时ID,取值范围(1..255) */ - int32 source = 3; /* 监测信息来源,0:未知,1:RSU自身,2:V2X广播,3:视频传感器,4:微波雷达,5:地磁线圈传感器,6:激光雷达传感器,7:两类或以上感知数据融合 */ - int64 secMark = 4; /* UTC时间,单位(ms) */ + int32 ptcType = 1; /* 交通参与者类型,0:未知,1:机动车,2:非机动车,3:行人,4:OBU自身 */ + int32 ptcId = 2; /* 临时ID,取值范围(1..255) */ + int32 source = 3; /* 监测信息来源,0:未知,1:RSU自身,2:V2X广播,3:视频传感器,4:微波雷达,5:地磁线圈传感器,6:激光雷达传感器,7:两类或以上感知数据融合 */ + int64 secMark = 4; /* UTC时间,单位(ms) */ double latitude = 5; /* 维度,单位(°) */ double longitude = 6; /* 经度,单位(°) */ double elevation = 7; /* 海拔,单位(m) */ double speed = 8; /* 速度,单位(m/s) */ - double heading = 9; /* 航向角,单位(°) */ + double heading = 9; /* 航向角,单位(°) */ AccFourAxes accFourAxes = 10; /* 四轴加速度 */ - VehicleSize ptcSize = 11; /* 交通参与者尺寸信息 */ - int32 vehicleClass = 12; /* 车辆类型,参考《OBU软件SDK使用文档》附录A中的表1 */ - int32 targetPosition = 13; /* 目标方位,参考mg_veh_target_position_t */ + VehicleSize ptcSize = 11; /* 交通参与者尺寸信息 */ + int32 vehicleClass = 12; /* 车辆类型,参考《OBU软件SDK使用文档》附录A中的表1 */ + int32 targetPosition = 13; /* 目标方位,参考mg_veh_target_position_t */ } message RsiWarning { - int32 unitMask = 1; /* 描述所属字段有效性 */ + int32 unitMask = 1; /* 描述所属字段有效性 */ int32 sceneType = 2; /* 预警类型,0:无效,1:限速信息,2:道路危险,3:车内标牌,4:前方拥堵 */ - PositionLLV position = 3; /* 交通标志/事件位置信息 */ - int32 signSerialNum = 4; /* 交通标志类型序号,根据预警类型匹配,0:无效,参照国标《GB 5768.2-2009中“交通标志中文名称索引》表序号 */ - int32 eventSerialNum = 5; /* 交通事件类型序号,根据预警类型匹配,0:无效,参考国标《GB/T 29100-2012》中定义的事件分类代码 */ - double speedMaxLimit = 6; /* 建议最大车速,单位(0.02m/s) */ - double speedMinLimit = 7; /* 建议最小车速,单位(0.02m/s) */ + PositionLLV position = 3; /* 交通标志/事件位置信息 */ + int32 signSerialNum = 4; /* 交通标志类型序号,根据预警类型匹配,0:无效,参照国标《GB 5768.2-2009中“交通标志中文名称索引》表序号 */ + int32 eventSerialNum = 5; /* 交通事件类型序号,根据预警类型匹配,0:无效,参考国标《GB/T 29100-2012》中定义的事件分类代码 */ + double speedMaxLimit = 6; /* 建议最大车速,单位(0.02m/s) */ + double speedMinLimit = 7; /* 建议最小车速,单位(0.02m/s) */ double eventRadius = 8; /* 交通事件触发半径,根据预警类型匹配,0:无效,单位(0.1m) */ int32 warningLevel = 9; /* 预警等级,0:无效,1:DETECTED,2:INFORM,3:WARNING */ - int32 targetPosition = 10; /* 目标方位,参考mg_rti_target_position_t */ - double distance = 11; /* 预警触发时与自车之间的距离,单位(0.01m) */ + int32 targetPosition = 10; /* 目标方位,参考mg_rti_target_position_t */ + double distance = 11; /* 预警触发时与自车之间的距离,单位(0.01m) */ +} + +message VehicleControl{ + int32 unitMask = 1; /* 描述所属字段有效性 */ + int32 brakePedalStatus = 2; /* 刹车踏板状态,0:未装备/未知/不可用,1:刹车踏板未踩下,2:刹车踏板已踩下 */ + int32 transmissionStatus = 3; /* 车辆档位状态,0:空挡,1:停止档,2:前进挡,3:倒挡,7:无效值 */ + int32 exteriorLights = 4; /* 车灯状态,0:近光灯,1:远光灯,2:左转信号灯,3:右转信号灯,4:危险信号灯,5:自动大灯,6:日间行车灯,7:雾灯,8:停车灯 */ +} + +message VehicleBasics{ + int32 unitMask = 1; /* 描述所属字段有效性 */ + string id = 2; /* OBU ID */ + int64 secMark = 3; /* UTC时间,单位(ms) */ + double latitude = 4; /* 维度,单位(°) */ + double longitude = 5; /* 经度,单位(°) */ + double elevation = 6; /* 海拔,单位(m) */ + double speed = 7; /* 速度,单位(m/s) */ + double heading = 8; /* 航向角,单位(°) */ + AccFourAxes accFourAxes = 9; /* 四轴加速度 */ + VehicleSize vehSize = 10; /* 车辆尺寸 */ + int32 vehClass = 11; /* 车辆类型,参考《OBU软件SDK使用文档》附录A中的表1 */ + VehicleControl vehControlMsg = 12; /* 车辆系统控制信息 */ + int32 targetPosition = 13; /* 目标方位,参考mg_veh_target_position_t */ } \ No newline at end of file diff --git a/libraries/mogo-adas-data/src/main/proto/personal/obu_scene.proto b/libraries/mogo-adas-data/src/main/proto/personal/obu_scene.proto index feb76afbc0..c2a0a62aca 100644 --- a/libraries/mogo-adas-data/src/main/proto/personal/obu_scene.proto +++ b/libraries/mogo-adas-data/src/main/proto/personal/obu_scene.proto @@ -2,35 +2,47 @@ syntax = "proto3"; package com.mogo.support.obu; import "personal/obu_base.proto"; -//场景PB 目前只有V2I(Rsi、Rsm、Spat、Map)相关场景,后期会添加V2V相关场景 +//场景PB:包括 RV HV(V2V) V2I(Rsi、Rsm、Spat、Map)相关场景 //预警事件 RSI Warning event message RsiWarningData { - int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ - //int32 warning_num = 2; /* 预警信息数量 */ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ repeated RsiWarning warningMsg = 2; /* 预警信息集合 */ } //RSM Warning Msg message RsmWarningData{ - int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ - Participant participant = 2; /* 弱势交通参与者信息 */ - V2xWarning warningMsg = 3; /* 弱势交通参与者预警信息 */ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ + Participant participant = 2; /* 弱势交通参与者信息 */ + V2xWarning warningMsg = 3; /* 弱势交通参与者预警信息 */ } //SPAT Msg message SpatWarningData{ - int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ - int32 warningType = 2; /* 预警类型信息 */ - repeated SpatLight lights = 3; /* 灯色信息集合 */ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ + int32 warningType = 2; /* 预警类型信息 */ + repeated SpatLight lights = 3; /* 灯色信息集合 */ } message MapMatchData{ - int32 status = 1;/* 状态信息,0:更新,1:添加,2:删除 */ - int32 unitMask = 2;/* 描述所属字段有效性 */ - NodeId currentNodeID = 3;/* 前方节点信息 */ - NodeId upstreamNodeID = 4;/* 上游节点信息 */ - int32 matchingLaneID = 5;/* 匹配车道ID,0:无效 */ - double speedMaxLimit = 6;/* 建议最大车速,单位(m/s) */ - double speedMinLimit = 7;/* 建议最小车速,单位(m/s) */ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ + int32 unitMask = 2; /* 描述所属字段有效性 */ + NodeId currentNodeID = 3; /* 前方节点信息 */ + NodeId upstreamNodeID = 4; /* 上游节点信息 */ + int32 matchingLaneID = 5; /* 匹配车道ID,0:无效 */ + double speedMaxLimit = 6; /* 建议最大车速,单位(m/s) */ + double speedMinLimit = 7; /* 建议最小车速,单位(m/s) */ +} + +//自车信息 +message HvBasicsData{ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ + VehicleBasics vehBasicsMsg = 2; /* 自车基础运行信息 */ +} + +//他车数据包括 V2V预警信息 +message RvWarningData{ + int32 status = 1; /* 状态信息,0:更新,1:添加,2:删除 */ + VehicleBasics vehBasicsMsg = 2; /* 临车基础运行信息 */ + V2xWarning warningMsg = 3; /* V2V预警信息 */ } diff --git a/libraries/mogo-obu/build.gradle b/libraries/mogo-obu/build.gradle index e3dc611b6f..bbd5333e3a 100644 --- a/libraries/mogo-obu/build.gradle +++ b/libraries/mogo-obu/build.gradle @@ -1,6 +1,5 @@ plugins { id 'com.android.library' - id 'com.google.protobuf' } android { @@ -21,31 +20,6 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - sourceSets { - main { - proto { - srcDir 'src/main/proto' - include '**/*.proto' - } - } - } - - protobuf { - protoc { - artifact = rootProject.ext.dependencies.protoc - } - - generateProtoTasks { - all().each { task -> - task.builtins { - remove java - } - task.builtins { - java {} - } - } - } - } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -54,8 +28,7 @@ android { } dependencies { - api project(':libraries:mogo-adas-data') - api rootProject.ext.dependencies.protobuf_java - api rootProject.ext.dependencies.protobuf_java_util + implementation project(':libraries:mogo-adas-data') + implementation rootProject.ext.dependencies.androidxappcompat api rootProject.ext.dependencies.mogoobu } diff --git a/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/ObuManager.java b/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/ObuManager.java new file mode 100644 index 0000000000..9844746ece --- /dev/null +++ b/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/ObuManager.java @@ -0,0 +1,825 @@ +package com.zhidao.support.obu; + +import android.content.Context; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.mogo.support.obu.MogoObuManager; +import com.mogo.support.obu.ObuBase; +import com.mogo.support.obu.ObuScene; +import com.mogo.support.obu.OnMogoObuListener; +import com.mogo.support.obu.constants.MogoObuConstants; +import com.mogo.support.obu.constants.MogoObuTopicId; +import com.mogo.support.obu.model.MogoObuHvBasicsData; +import com.mogo.support.obu.model.MogoObuMapMathData; +import com.mogo.support.obu.model.MogoObuRsiWarningData; +import com.mogo.support.obu.model.MogoObuRsmWarningData; +import com.mogo.support.obu.model.MogoObuRvWarningData; +import com.mogo.support.obu.model.MogoObuSpatWarningData; +import com.mogo.support.obu.model.advance.AccFourAxes; +import com.mogo.support.obu.model.advance.DateTime; +import com.mogo.support.obu.model.advance.NodeId; +import com.mogo.support.obu.model.advance.Participant; +import com.mogo.support.obu.model.advance.PositionLLV; +import com.mogo.support.obu.model.advance.RsiWarning; +import com.mogo.support.obu.model.advance.SpatLight; +import com.mogo.support.obu.model.advance.V2xWarning; +import com.mogo.support.obu.model.advance.VehBasics; +import com.mogo.support.obu.model.advance.VehControl; +import com.mogo.support.obu.model.advance.VehSize; +import com.mogo.support.obu.model.advance.VerticalLLV; +import com.mogo.support.obu.model.advance.WarningData; +import com.mogo.support.obu.option.MogoObuLog; +import com.mogo.support.obu.option.MogoObuOptions; +import com.mogo.support.obu.upgrade.OnUpgradeListener; + +import java.util.List; +import java.util.Set; + +import mogo.telematics.pad.MessagePad; + +public class ObuManager { + private static final String TAG = ObuManager.class.getSimpleName(); + private static volatile ObuManager INSTANCE; + private OnObuListener listener; + + public static ObuManager getInstance() { + if (INSTANCE == null) { + synchronized (ObuManager.class) { + if (INSTANCE == null) { + INSTANCE = new ObuManager(); + } + } + } + return INSTANCE; + } + + /** + * 获取当前连接状态 + * + * @return 连接状态 + * @since 1.0.0 + */ + public int getConnectStatus() { + return MogoObuManager.getInstance().getConnectStatus(); + } + + /** + * 获取已连接的OBU IP 断开连接会置null + * + * @return IP + * @since 1.0.0 + */ + public String getConnectedIp() { + return MogoObuManager.getInstance().getConnectedIp(); + } + + /** + * 获取已连接的OBU 端口 断开连接会置null + * + * @return 端口 + * @since 1.0.0 + */ + public int getConnectedPort() { + return MogoObuManager.getInstance().getConnectedPort(); + } + + /** + * 获取当前SDK版本 + * + * @return 版本 + * @since 1.0.0 + */ + public String getVersion() { + return MogoObuManager.getInstance().getVersion(); + } + + /** + * 获取当前SO版本号 + * + * @return 版本 未连接为null + * @since 1.0.0 + */ + public String getSoVersion() { + return MogoObuManager.getInstance().getSoVersion(); + } + + /** + * 获取当前OBU软件版本 + * 需主动调用获取{@link MogoObuManager#getObuVersion(Context, String, OnUpgradeListener)} + * + * @return 版本 null表示 无法连接OBU;无法获取版本; + * @since 1.1.0 + */ + @Nullable + public String getObuVersion() { + return MogoObuManager.getInstance().getObuVersion(); + } + + /** + * 获取已注册的 Topic ID + * + * @return Topic ID + * @since 1.0.0 + */ + public List getRegisteredTopicId() { + return MogoObuManager.getInstance().getRegisteredTopicId(); + } + + /** + * 获取未注册的 Topic ID + * + * @return Topic ID + * @since 1.0.0 + */ + public List getUnregisteredTopicId() { + return MogoObuManager.getInstance().getUnregisteredTopicId(); + } + + /** + * 注册回调 包括连接状态以及数据回调 + * + * @param obuListener 数据回调接口 + * @since 1.0.0 + */ + public void registerObuListener(OnObuListener obuListener) { + this.listener = obuListener; + MogoObuManager.getInstance().registerMogoObuListener(mogoObuListener); + } + + /** + * 取消注册 + * + * @since 1.0.0 + */ + public void unregisterObuListener() { + MogoObuManager.getInstance().unregisterMogoObuListener(); + listener = null; + } + + + /** + * 连接 + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * 异步结果回调回调顺序 每次一种类型 + * 1.result.function == MogoObuConstants.CALL_FUNCTION.CONFIG onMogoObuCallResult(MogoObuCallConfigResult result) 连接配置或日志配置(如果有配置) + * 2.result.function == MogoObuConstants.CALL_FUNCTION.INIT onMogoObuCallResult(MogoObuCallResult result) 初始化,进行连接操作 + * 3.result.function == MogoObuConstants.CALL_FUNCTION.TOPIC_REGIST onMogoObuCallResult(MogoObuCallRegisterResult result) 注册Topic ID(如果有配置) + * + * @param options 参数 + * @since 1.0.0 + */ + public void connect(MogoObuOptions options) { + MogoObuManager.getInstance().connect(options); + } + + + /** + * 断开连接 + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * + * @since 1.0.1 + */ + public void disconnect() { + MogoObuManager.getInstance().disconnect(); + } + + + /** + * 注册Topic + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * result.function == MogoObuConstants.CALL_FUNCTION.TOPIC_REGIST onMogoObuCallResult(MogoObuCallRegisterResult result) + * 此版本支持的Topic ID + * MogoObuTopicId.HV_BASIC + * MogoObuTopicId.RV_WARNING + * MogoObuTopicId.SPAT_WARNING + * MogoObuTopicId.RSI_WARNING + * MogoObuTopicId.RSM_WARNING + * MogoObuTopicId.MAP_MATCH + * + * @param topicId id + * @since 1.0.0 + */ + public void registerTopic(MogoObuTopicId topicId) { + MogoObuManager.getInstance().registerTopic(topicId); + } + + /** + * 注册多个Topic + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * result.function == MogoObuConstants.CALL_FUNCTION.TOPIC_REGIST onMogoObuCallResult(MogoObuCallRegisterResult result) + * 此版本支持的Topic ID + * MogoObuTopicId.HV_BASIC + * MogoObuTopicId.RV_WARNING + * MogoObuTopicId.SPAT_WARNING + * MogoObuTopicId.RSI_WARNING + * MogoObuTopicId.RSM_WARNING + * MogoObuTopicId.MAP_MATCH + * + * @param topicIds ids + * @since 1.0.0 + */ + public void registerTopic(Set topicIds) { + MogoObuManager.getInstance().registerTopic(topicIds); + } + + /** + * 取消注册Topic + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * + * @param topicId id + * @since @since 1.0.1 + */ + public void unregisterTopic(MogoObuTopicId topicId) { + MogoObuManager.getInstance().unregisterTopic(topicId); + } + + /** + * 取消注册多个Topic + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * + * @param topicIds ids + * @since 1.0.1 + */ + public void unregisterTopic(Set topicIds) { + MogoObuManager.getInstance().unregisterTopic(topicIds); + } + + /** + * OBU SDK 日志配置 + * 支持日志输出至LogCat和写入文件 + * 调用结果异步返回 listener.onMogoObuCallResult(BaseResult result) + * result.function == MogoObuConstants.CALL_FUNCTION.CONFIG onMogoObuCallResult(MogoObuCallConfigResult result) 日志配置 + * + * @param log 日志配置 + * @since 1.0.0 + */ + public void logConfig(MogoObuLog log) { + MogoObuManager.getInstance().logConfig(log); + } + + /** + * 配置Android日志 + * + * @param isEnableLog 是否开启日志输出 + * @since 1.0.0 + */ + public void setEnableLog(boolean isEnableLog) { + MogoObuManager.getInstance().setEnableLog(isEnableLog); + } + + + /** + * 检查更新 + * + * @param obuIp OBU IP + * @param listener 升级回调 + * @since 1.1.0 + */ + public boolean checkObuUpgrade(@NonNull Context context, @NonNull String obuIp, OnUpgradeListener listener) { + return MogoObuManager.getInstance().checkObuUpgrade(context, obuIp, listener); + } + + /** + * 检查更新 + * + * @param context 上下文 + * @param obuIp OBU IP + * @param isUpgradeNow 是否立即升级 + * false:OBU设备下次上电时执行升级程序 + * ture: OBU设备立即执行升级程序 TODO 警告:执行立即升级时请确保车辆是静止状态。车辆在运行过程中升级设备可能会影响驾驶,严重时可能造成安全隐患!!! + * @param listener 升级回调 + * @return 是否调用成功 + * @since 1.1.0 + */ + public boolean checkObuUpgrade(@NonNull Context context, @NonNull String obuIp, boolean isUpgradeNow, OnUpgradeListener listener) { + return MogoObuManager.getInstance().checkObuUpgrade(context, obuIp, isUpgradeNow, listener); + } + + /** + * 获取当前连接OBU的版本号 + * 如果调用 {@link MogoObuManager#checkObuUpgrade(Context, String, OnUpgradeListener)}方法可以不用调用此方法,检查更新会获取版本号 + * + * @param context 上下文 + * @param obuIp OBU IP + * @param listener 升级回调 + * @return 是否调用成功 + * @since 1.1.0 + */ + public boolean getObuVersion(@NonNull Context context, @NonNull String obuIp, OnUpgradeListener listener) { + return MogoObuManager.getInstance().getObuVersion(context, obuIp, listener); + } + + /** + * 传入升级包版本 + * + * @param newVersion 升级包版本 + * @since 1.1.0 + */ + public void setObuUpgradePackageVersion(@NonNull String newVersion) { + MogoObuManager.getInstance().setObuUpgradePackageVersion(newVersion); + } + + /** + * 传入升级包 + * + * @param newUpgradePackage 升级包文件绝对路径 只能包含 升级包MD5文件和升级包文件 + * @since 1.1.0 + */ + public void setObuUpgradePackage(@NonNull String[] newUpgradePackage) { + MogoObuManager.getInstance().setObuUpgradePackage(newUpgradePackage); + } + + /** + * 停止升级或停止版本查询 + * + * @since 1.1.0 + */ + public void stopObuUpgrade() { + MogoObuManager.getInstance().stopObuUpgrade(); + } + + private final OnMogoObuListener mogoObuListener = new OnMogoObuListener() { + @Override + public void onConnectStatus(int connectStatus) { + if (listener != null) { + listener.onConnectStatus(connectStatus); + } + } + + @Override + public void onMogoObuHvBasics(MogoObuHvBasicsData data) { + if (listener != null) { +// ObuScene.HvBasicsData.Builder builder = ObuScene.HvBasicsData.newBuilder(); +// builder.setStatus(data.getStatus()); + VehBasics vehBasics = data.getVehBasicsMsg(); +// if (vehBasics != null) { +// builder.setVehBasicsMsg(getVehBasics(vehBasics)); +// } +// listener.onObuHvBasics(builder.build()); + + + //转工控机PB 赋值的包括 satelliteTime systemTime latitude longitude altitude heading gnssSpeed acceleration vehicleSpeed 未赋值:yawRate + if (vehBasics != null) { + MessagePad.GnssInfo.Builder gnssInfoBuilder = MessagePad.GnssInfo.newBuilder(); + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.SEC_MARK)) { + double time = vehBasics.getSecMark() / 1000.0D; + gnssInfoBuilder.setSatelliteTime(time); + gnssInfoBuilder.setSystemTime(time); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.LATITUDE)) { + gnssInfoBuilder.setLatitude(vehBasics.getLatitude()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.LONGITUDE)) { + gnssInfoBuilder.setLongitude(vehBasics.getLongitude()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.ELEVATION)) { + gnssInfoBuilder.setAltitude(vehBasics.getElevation()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.SPEED)) { + gnssInfoBuilder.setGnssSpeed(vehBasics.getSpeed()); + gnssInfoBuilder.setVehicleSpeed(vehBasics.getSpeed()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.HEADING)) { + gnssInfoBuilder.setHeading(vehBasics.getHeading()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.ACC_FOUR_AXES)) { + AccFourAxes accFourAxes = vehBasics.getAccFourAxes(); + if (accFourAxes != null) { + gnssInfoBuilder.setAcceleration(accFourAxes.getAccLng()); + } + } + listener.onGnssInfo(gnssInfoBuilder.build()); + } + } + } + + @Override + public void onMogoObuRvWarning(MogoObuRvWarningData data) { + super.onMogoObuRvWarning(data); + if (listener != null) { + ObuScene.RvWarningData.Builder builder = ObuScene.RvWarningData.newBuilder(); + builder.setStatus(data.getStatus()); + VehBasics vehBasics = data.getVehBasicsMsg(); + if (vehBasics != null) { + builder.setVehBasicsMsg(getVehBasics(vehBasics)); + } + V2xWarning v2xWarning = data.getWarningMsg(); + if (v2xWarning != null) { + builder.setWarningMsg(getV2xWarning(v2xWarning)); + } + listener.onObuRvWarning(builder.build()); + + } + } + + @Override + public void onMogoObuSpatWarning(MogoObuSpatWarningData data) { + super.onMogoObuSpatWarning(data); + if (listener != null) { + ObuScene.SpatWarningData.Builder builder = ObuScene.SpatWarningData.newBuilder(); + builder.setStatus(data.getStatus()).setWarningType(data.getWarningType()); + List lights = data.getLights(); + if (lights != null && !lights.isEmpty()) { + for (SpatLight light : lights) { + builder.addLights(ObuBase.SpatLight.newBuilder() + .setPhaseID(light.getPhaseId()) + .setManeuvers(light.getManeuvers()) + .setLight(light.getLight()) + .setCountDown(light.getCountDown()) + .setSuggestMaxSpeed(light.getSuggestMaxSpeed()) + .setSuggestMinSpeed(light.getSuggestMinSpeed())); + } + } + listener.onObuSpatWarning(builder.build()); + } + } + + @Override + public void onMogoObuRsiWarning(MogoObuRsiWarningData data) { + super.onMogoObuRsiWarning(data); + if (listener != null) { + ObuScene.RsiWarningData.Builder builder = ObuScene.RsiWarningData.newBuilder(); + builder.setStatus(data.getStatus()); + List list = data.getWarningMsg(); + if (list != null && !list.isEmpty()) { + for (RsiWarning warning : list) { + ObuBase.RsiWarning.Builder rsiBuilder = ObuBase.RsiWarning.newBuilder(); + rsiBuilder.setUnitMask(warning.getUnitMask()); + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.SCENE_TYPE)) { + rsiBuilder.setSceneType(warning.getSceneType()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.POSITION)) { + PositionLLV positionLLV = warning.getPosition(); + int present = positionLLV.getPresent();//由于OBU数据没有给偏移量默认使用的是7 + double longitude = positionLLV.getLongitude(); + double latitude = positionLLV.getLatitude(); + ObuBase.PositionOffset.Builder positionOffsetBuilder = ObuBase.PositionOffset.newBuilder(); + if (present == 1) { + positionOffsetBuilder.setPositionLL1(ObuBase.PositionLL1.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else if (present == 2) { + positionOffsetBuilder.setPositionLL2(ObuBase.PositionLL2.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else if (present == 3) { + positionOffsetBuilder.setPositionLL3(ObuBase.PositionLL3.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else if (present == 4) { + positionOffsetBuilder.setPositionLL4(ObuBase.PositionLL4.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else if (present == 5) { + positionOffsetBuilder.setPositionLL5(ObuBase.PositionLL5.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else if (present == 6) { + positionOffsetBuilder.setPositionLL6(ObuBase.PositionLL6.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } else { + positionOffsetBuilder.setPositionLatLon(ObuBase.PositionLatLon.newBuilder() + .setLongitude(longitude) + .setLatitude(latitude)); + } + VerticalLLV verticalLLV = positionLLV.getVertical(); + present = verticalLLV.getPresent();//由于OBU数据没有给偏移量默认使用的是7 + double elevation = verticalLLV.getElevation(); + ObuBase.VerticalLLV.Builder verticalLLVBuilder = ObuBase.VerticalLLV.newBuilder(); + if (present == 1) { + verticalLLVBuilder.setOffset1(elevation); + } else if (present == 2) { + verticalLLVBuilder.setOffset2(elevation); + } else if (present == 3) { + verticalLLVBuilder.setOffset3(elevation); + } else if (present == 4) { + verticalLLVBuilder.setOffset4(elevation); + } else if (present == 5) { + verticalLLVBuilder.setOffset5(elevation); + } else if (present == 6) { + verticalLLVBuilder.setOffset6(elevation); + } else { + verticalLLVBuilder.setElevation(elevation); + } + rsiBuilder.setPosition(ObuBase.PositionLLV.newBuilder() + .setPosition(positionOffsetBuilder) + .setVertical(verticalLLVBuilder)); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.SIGN_SERIAL_NUM)) { + rsiBuilder.setSignSerialNum(warning.getSignSerialNum()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.EVENT_SERIAL_NUM)) { + rsiBuilder.setEventSerialNum(warning.getEventSerialNum()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.SPEED_MAX_LIMIT)) { + rsiBuilder.setSpeedMaxLimit(warning.getSpeedMaxLimit()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.SPEED_MIN_LIMIT)) { + rsiBuilder.setSpeedMinLimit(warning.getSpeedMinLimit()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.EVENT_RADIUS)) { + rsiBuilder.setEventRadius(warning.getEventRadius()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.WARNING_LEVEL)) { + rsiBuilder.setWarningLevel(warning.getWarningLevel()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.TARGET_POSITION)) { + rsiBuilder.setTargetPosition(warning.getTargetPosition()); + } + if (warning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_RSI_WARNING.DISTANCE)) { + rsiBuilder.setDistance(warning.getDistance()); + } + builder.addWarningMsg(rsiBuilder); + } + } + listener.onObuRsiWarning(builder.build()); + } + } + + @Override + public void onMogoObuRsmWarning(MogoObuRsmWarningData data) { + super.onMogoObuRsmWarning(data); + if (listener != null) { + ObuScene.RsmWarningData.Builder builder = ObuScene.RsmWarningData.newBuilder(); + builder.setStatus(data.getStatus()); + Participant participant = data.getParticipant(); + if (participant != null) { + ObuBase.Participant.Builder participantBuilder = ObuBase.Participant.newBuilder(); + participantBuilder.setPtcType(participant.getPtcType()) + .setPtcId(participant.getPtcId()) + .setSource(participant.getSource()) + .setSecMark(participant.getSecMark()) + .setLatitude(participant.getLatitude()) + .setLongitude(participant.getLongitude()) + .setSpeed(participant.getSpeed()) + .setHeading(participant.getHeading()); + AccFourAxes accFourAxes = participant.getAccFourAxes(); + if (accFourAxes != null) { + participantBuilder.setAccFourAxes(getAccFourAxes(accFourAxes)); + } + VehSize vehicleSize = participant.getPtcSize(); + if (vehicleSize != null) { + participantBuilder.setPtcSize(getVehSize(vehicleSize)); + } + participantBuilder.setVehicleClass(participant.getVehicleClass()) + .setTargetPosition(participant.getTargetPosition()); + builder.setParticipant(participantBuilder); + } + V2xWarning v2xWarning = data.getWarningMsg(); + if (v2xWarning != null) { + builder.setWarningMsg(getV2xWarning(v2xWarning)); + } + listener.onObuRsmWarning(builder.build()); + } + } + + @Override + public void onMogoObuMapMath(MogoObuMapMathData data) { + super.onMogoObuMapMath(data); + if (listener != null) { + ObuScene.MapMatchData.Builder builder = ObuScene.MapMatchData.newBuilder(); + builder.setStatus(data.getStatus()).setUnitMask(data.getUnitMask()); + if (data.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_MAP_MATH.CURRENT_NODE_ID)) { + NodeId nodeId = data.getCurrentNodeId(); + if (nodeId != null) { + builder.setCurrentNodeID(ObuBase.NodeId.newBuilder() + .setRegion(nodeId.getRegion()) + .setId(nodeId.getId())); + } + } + if (data.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_MAP_MATH.UPSTREAM_NODE_ID)) { + NodeId nodeId = data.getUpstreamNodeId(); + if (nodeId != null) { + builder.setUpstreamNodeID(ObuBase.NodeId.newBuilder() + .setRegion(nodeId.getRegion()) + .setId(nodeId.getId())); + } + } + if (data.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_MAP_MATH.MATCHING_LANE_ID)) { + builder.setMatchingLaneID(data.getMatchingLaneId()); + } + if (data.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_MAP_MATH.SPEED_MAX_LIMIT)) { + builder.setSpeedMaxLimit(data.getSpeedMaxLimit()); + } + if (data.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_MAP_MATH.SPEED_MIN_LIMIT)) { + builder.setSpeedMinLimit(data.getSpeedMinLimit()); + } + listener.onObuMapMath(builder.build()); + } + } + }; + + private ObuBase.AccFourAxes.Builder getAccFourAxes(AccFourAxes accFourAxes) { + return ObuBase.AccFourAxes.newBuilder() + .setAccLng(accFourAxes.getAccLng()) + .setAccLat(accFourAxes.getAccLat()) + .setAccVert(accFourAxes.getAccVert()) + .setAccYaw(accFourAxes.getAccYaw()); + } + + private ObuBase.VehicleSize.Builder getVehSize(VehSize vehSize) { + return ObuBase.VehicleSize.newBuilder() + .setWidth(vehSize.getWidth()) + .setLength(vehSize.getLength()) + .setHeight(vehSize.getHeight()); + } + + private ObuBase.VehicleBasics.Builder getVehBasics(VehBasics vehBasics) { + ObuBase.VehicleBasics.Builder builder = ObuBase.VehicleBasics.newBuilder(); + builder.setUnitMask(vehBasics.getUnitMask()); + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.ID)) { + builder.setId(vehBasics.getId()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.SEC_MARK)) { + builder.setSecMark(vehBasics.getSecMark()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.LATITUDE)) { + builder.setLatitude(vehBasics.getLatitude()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.LONGITUDE)) { + builder.setLongitude(vehBasics.getLongitude()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.ELEVATION)) { + builder.setElevation(vehBasics.getElevation()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.SPEED)) { + builder.setSpeed(vehBasics.getSpeed()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.HEADING)) { + builder.setHeading(vehBasics.getHeading()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.ACC_FOUR_AXES)) { + AccFourAxes accFourAxes = vehBasics.getAccFourAxes(); + if (accFourAxes != null) { + builder.setAccFourAxes(getAccFourAxes(accFourAxes)); + } + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.VEH_SIZE)) { + VehSize vehicleSize = vehBasics.getVehSize(); + if (vehicleSize != null) { + builder.setVehSize(getVehSize(vehicleSize)); + } + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.VEH_CLASS)) { + builder.setVehClass(vehBasics.getVehClass()); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.VEH_CONTROL_MSG)) { + VehControl vehControl = vehBasics.getVehControlMsg(); + if (vehControl != null) { + ObuBase.VehicleControl.Builder vehicleControlBuilder = ObuBase.VehicleControl.newBuilder(); + vehicleControlBuilder.setUnitMask(vehControl.getUnitMask()); + if (vehControl.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_CONTROL.BRAKE_PEDAL_STATUS)) { + vehicleControlBuilder.setBrakePedalStatus(vehControl.getBrakePedalStatus()); + } + if (vehControl.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_CONTROL.TRANSMISSION_STATUS)) { + vehicleControlBuilder.setTransmissionStatus(vehControl.getTransmissionStatus()); + } + if (vehControl.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_CONTROL.EXTERIOR_LIGHTS)) { + vehicleControlBuilder.setExteriorLights(vehControl.getExteriorLights()); + } + builder.setVehControlMsg(vehicleControlBuilder); + } + if (vehBasics.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_VEH_BASICS.TARGET_POSITION)) { + builder.setTargetPosition(vehBasics.getTargetPosition()); + } + } + return builder; + } + + private ObuBase.V2xWarning.Builder getV2xWarning(V2xWarning v2xWarning) { + ObuBase.V2xWarning.Builder builder = ObuBase.V2xWarning.newBuilder(); + builder.setUnitMask(v2xWarning.getUnitMask()); + if (v2xWarning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING.WARNING_DATA)) { + List list = v2xWarning.getWarningData(); + if (list != null && !list.isEmpty()) { + for (WarningData warningData : list) { + ObuBase.WarningData.Builder warningDataBuilder = ObuBase.WarningData.newBuilder(); + warningDataBuilder.setUnitMask(warningData.getUnitMask()); + if (warningData.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING_DATA.STATUS)) { + warningDataBuilder.setStatus(warningData.getStatus()); + } + if (warningData.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING_DATA.WARNING_TYPE)) { + warningDataBuilder.setWarningType(warningData.getWarningType()); + } + if (warningData.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING_DATA.WARNING_LEVEL)) { + warningDataBuilder.setWarningLevel(warningData.getWarningLevel()); + } + if (warningData.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING_DATA.WARNING_PRIORITY)) { + warningDataBuilder.setWarningPriority(warningData.getWarningPriority()); + } + builder.addWarningData(warningDataBuilder); + } + } + } + if (v2xWarning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING.WARNING_TIME)) { + DateTime dateTime = v2xWarning.getWarningTime(); + if (dateTime != null) { + builder.setWarningTime(ObuBase.DateTime.newBuilder() + .setYear(dateTime.getYear()) + .setMonth(dateTime.getMonth()) + .setDay(dateTime.getDay()) + .setHour(dateTime.getHour()) + .setMinute(dateTime.getMinute()) + .setMillisecond(dateTime.getMillisecond()) + .setOffset(dateTime.getOffset()) + ); + } + } + if (v2xWarning.has(MogoObuConstants.UNIT_MASK.MOGO_OBU_V2X_WARNING.DISTANCE)) { + builder.setDistance(v2xWarning.getDistance()); + } + return builder; + } + + /** + * RV数据转换为转工控机障碍物数据 + * 赋值的包括:uuid strUuid systemTime satelliteTime latitude longitude altitude speed heading tracked_source.source type + * + * @param rvWarningData OBU RV数据 + * @return 工控机障碍物数据 + */ + public MessagePad.TrackedObject obuRvToTrackedObject(ObuScene.RvWarningData rvWarningData) { + if (rvWarningData != null && rvWarningData.hasVehBasicsMsg()) { + ObuBase.VehicleBasics vehBasics = rvWarningData.getVehBasicsMsg(); + MessagePad.TrackedObject.Builder trackedObjectBuilder = MessagePad.TrackedObject.newBuilder(); + trackedObjectBuilder.setUuid(vehBasics.getId().hashCode()); + trackedObjectBuilder.setStrUuid(vehBasics.getId()); + double time = vehBasics.getSecMark() / 1000.0D; + trackedObjectBuilder.setSatelliteTime(time); + trackedObjectBuilder.setSystemTime(time); + trackedObjectBuilder.setLatitude(vehBasics.getLatitude()); + trackedObjectBuilder.setLongitude(vehBasics.getLongitude()); + trackedObjectBuilder.setAltitude(vehBasics.getElevation()); + trackedObjectBuilder.setSpeed(vehBasics.getSpeed()); + trackedObjectBuilder.setHeading(vehBasics.getHeading()); + trackedObjectBuilder.addTrackedSource(MessagePad.TrackedSource.newBuilder().setSource(2)); + /** + * 0 未知车辆 + * 1 特殊用途车辆 + * 10 乘用车类型(default type) + * 20 轻卡(default type) + * 25 卡车(default type) + * 27 卡车(Two axle, six tire single units) + * 28 卡车( Three axle, single units) + * 29 卡车( Four or more axle, single unit) + * 30 拖挂车(Four or less axle, single trailer) + * 31 拖挂车(Four or less axle, single trailer) + * 32 拖挂车(Six or more axle, single trailer) + * 33 多轴拖挂车( Five or less axle, multi-trailer) + * 34 多轴拖挂车( Six axle, multi-trailer) + * 35 多轴拖挂车(Seven or more axle, multi-trailer) + * 40 摩托车(default type) + * 42 摩托车(motorcycle-Cruiser-Standard) + * 43 摩托车(motorcycle - Sport Unclad) + * 44 摩托车(motorcycle - Sport Touring) + * 45 摩托车(motorcycle - Super Sport) + * 46 摩托车(motorcycle-Touring) + * 47 摩托车(motorcycle-Trike) + * 48 摩托车(motorcycle - w Passengers) + * 50 公交车( default type) + * 52 公交车(transit-BRT) + * 53 公交车(transit-ExpressBus) + * 54 公交车(transit-LocalBus) + * 55 公交车(transit-SchoolBus) + * 56 公交车(transit-FixedGuideway) + * 57 公交车(transit-Paratransit) + * 58 公交车(transit-Paratransit-Ambulance) + * 60 紧急车辆(default type) + * 62 紧急车辆(emergency-Fire-Light) + * 63 紧急车辆(emergency-Fire-Heavy) + * 64 紧急车辆(emergency-Fire-Paramedic) + * 65 紧急车辆(emergency-Fire-Ambulance) + * 66 紧急车辆(emergency-Police-Light) + * 67 紧急车辆(emergency-Police-Heavy) + * 68 紧急车辆(emergency-Other-Responder) + * 69 紧急车辆(emergency-Other-Ambulance) + * 80 其他配备 V2X 的道路参与者(default type) + * 82 其他配备 V2X 的道路参与者(otherTraveler-Pedestrian) + * 83 其他配备 V2X 的道路参与者(otherTraveler-Visually-Disabled) + * 84 其他配备 V2X 的道路参与者(otherTraveler-Physically-Disabled) + * 85 其他配备 V2X 的道路参与者(otherTraveler-Bicycle) + * 86 其他配备 V2X 的道路参与者(otherTraveler-Vulnerable-Roadworker) + */ + int vehClass = vehBasics.getVehClass(); + if (vehClass >= 20 && vehClass < 30) {//卡车 20 25 27 28 29 + vehClass = 8; + } else if (vehClass >= 40 && vehClass < 50) {//摩托车 40 42 43 44 45 46 47 48 + vehClass = 4; + } else if (vehClass >= 50 && vehClass < 60) {//公交车 50 52 53 54 55 56 57 58 + vehClass = 6; + } else if (vehClass == 82) {//其他配备 V2X 的道路参与者(otherTraveler-Pedestrian) + vehClass = 1; + } else if (vehClass == 85) {//其他配备 V2X 的道路参与者(otherTraveler-Bicycle) + vehClass = 2; + } else { + vehClass = 3; + } + trackedObjectBuilder.setType(vehClass); + return trackedObjectBuilder.build(); + } + return null; + } +} diff --git a/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/OnObuListener.java b/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/OnObuListener.java new file mode 100644 index 0000000000..cfb3cc76e1 --- /dev/null +++ b/libraries/mogo-obu/src/main/java/com/zhidao/support/obu/OnObuListener.java @@ -0,0 +1,70 @@ +package com.zhidao.support.obu; + +import com.mogo.support.obu.ObuScene; +import com.mogo.support.obu.constants.Define; + +import mogo.telematics.pad.MessagePad; + + +public interface OnObuListener { + + /** + * 连接状态 + * + * @param connectStatus 连接状态 + */ + void onConnectStatus(@Define.ConnectStatus int connectStatus); + + + /** + * HV车辆基础信息 + * + * @param hvBasicsData 数据 + */ +// void onObuHvBasics(ObuScene.HvBasicsData hvBasicsData); + + /** + * HV车辆基础信息转工控机自车数据格式 + * + * @param gnssInfo 数据 + */ + void onGnssInfo(MessagePad.GnssInfo gnssInfo); + + /** + * V2V预警信息 + * OBU RV数据转工控机障碍物数据:{@link ObuManager#obuRvToTrackedObject(ObuScene.RvWarningData)} + * + * @param rvWarningData 数据 + */ + void onObuRvWarning(ObuScene.RvWarningData rvWarningData); + + /** + * OBU 红绿灯预警信息 + * + * @param spatWarningData 数据 + */ + void onObuSpatWarning(ObuScene.SpatWarningData spatWarningData); + + /** + * OBU RSI预警信息 + * + * @param rsiWarningData 数据 + */ + void onObuRsiWarning(ObuScene.RsiWarningData rsiWarningData); + + /** + * OBU RSM预警信息 + * + * @param rsmWarningData 数据 + */ + void onObuRsmWarning(ObuScene.RsmWarningData rsmWarningData); + + /** + * OBU 地图匹配结果 + * + * @param mapMatchData 数据 + */ + void onObuMapMath(ObuScene.MapMatchData mapMatchData); + + +}