diff --git a/config.gradle b/config.gradle index 16a1600dfe..4f0e551a16 100644 --- a/config.gradle +++ b/config.gradle @@ -112,7 +112,8 @@ ext { // obu sdk obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3", - mogoobu : 'com.zhidao.support.obu:mogoobu:1.0.0.33', +// mogoobu : 'com.zhidao.support.obu:mogoobu:1.0.0.33', + mogoobu : 'com.mogo.support.obu:mogo-obu:1.0.0_beta5', mogoami : 'com.zhidao.support.obu.ami:mogoami:1.0.0.24', // google diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt index e427bfe345..3bbbe00e6a 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MoGoObuProvider.kt @@ -3,13 +3,12 @@ package com.mogo.eagle.core.function.obu.mogo import android.content.Context import com.alibaba.android.arouter.facade.annotation.Route 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.obu.IMoGoObuProvider import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr +import com.mogo.eagle.core.utilcode.util.CommonUtils /** * @author xiaoyuzhou @@ -21,6 +20,9 @@ class MoGoObuProvider : IMoGoObuProvider { private var mContext: Context? = null + private val busObuIp = "192.168.8.199" + private val taxiObuIp = "192.168.1.199" + override val functionName: String get() = TAG @@ -30,27 +32,23 @@ class MoGoObuProvider : IMoGoObuProvider { override fun init(context: Context) { - CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU……") + CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress()) + //bus乘客版本obu功能去掉 if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { //不处理 } else { mContext = context - val ipAddress = - SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, "192.168.1.199") - MogoPrivateObuManager.INSTANCE.init(context, ipAddress) + mContext?.let { + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + MogoPrivateObuNewManager.INSTANCE.connectObu(it, CommonUtils.getLocalIPAddress(), busObuIp) + } else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { + MogoPrivateObuNewManager.INSTANCE.connectObu(it, CommonUtils.getLocalIPAddress(), taxiObuIp) + } + } } } override fun connect(ipAddress: String) { - if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { - //不处理 - } else { - mContext?.let { - // 保存本地OBU IP地址 - SharedPrefsMgr.getInstance(it).putString(MoGoConfig.OBU_IP, ipAddress) - MogoPrivateObuManager.INSTANCE.connectObu(it, ipAddress) - } - } } diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuManager.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuManager.kt index b79d01c83f..7b5ca673dc 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuManager.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuManager.kt @@ -1,33 +1,33 @@ package com.mogo.eagle.core.function.obu.mogo -import android.content.Context -import com.alibaba.android.arouter.launcher.ARouter -import com.mogo.cloud.passport.MoGoAiCloudClientConfig -import com.mogo.eagle.core.data.app.AppConfigInfo -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.constants.MogoServicePaths -import com.mogo.eagle.core.data.enums.WarningDirectionEnum -import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener -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.obu.CallerObuListenerManager -import com.mogo.eagle.core.function.obu.mogo.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.mogo.storage.SharedPrefsMgr -import com.mogo.module.common.drawer.TrafficMarkerDrawer -import com.mogo.module.common.enums.EventTypeEnum -import com.mogo.service.IMogoServiceApis -import com.zhidao.support.obu.MogoObuManager -import com.zhidao.support.obu.OnMogoObuListener -import com.zhidao.support.obu.constants.ObuConstants -import com.zhidao.support.obu.model.* -import com.zhidao.support.obu.model.advance.Light -import org.json.JSONObject +//import android.content.Context +//import com.alibaba.android.arouter.launcher.ARouter +//import com.mogo.cloud.passport.MoGoAiCloudClientConfig +//import com.mogo.eagle.core.data.app.AppConfigInfo +//import com.mogo.eagle.core.data.config.FunctionBuildConfig +//import com.mogo.eagle.core.data.constants.MogoServicePaths +//import com.mogo.eagle.core.data.enums.WarningDirectionEnum +//import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener +//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.obu.CallerObuListenerManager +//import com.mogo.eagle.core.function.obu.mogo.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.mogo.storage.SharedPrefsMgr +//import com.mogo.module.common.drawer.TrafficMarkerDrawer +//import com.mogo.module.common.enums.EventTypeEnum +//import com.mogo.service.IMogoServiceApis +//import com.zhidao.support.obu.MogoObuManager +//import com.zhidao.support.obu.OnMogoObuListener +//import com.zhidao.support.obu.constants.ObuConstants +//import com.zhidao.support.obu.model.* +//import com.zhidao.support.obu.model.advance.Light +//import org.json.JSONObject /** * @@ -42,861 +42,861 @@ class MogoPrivateObuManager private constructor() { } } - private var mMogoServiceApis: IMogoServiceApis? = null - private var mContext: Context? = null - private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo() - - fun init(context: Context, ipAddress: String) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "obuManager初始化--") - mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS) - .navigation(context) as IMogoServiceApis - mContext = context - connectObu(context, ipAddress) - //控制日志输出 - MogoObuManager.getInstance().init(MoGoAiCloudClientConfig.getInstance().getSn(), AppConfigInfo.toString()) - MogoObuManager.getInstance().registerListener(mogoObuListener) - } - - fun connectObu(context: Context, ipAddress: String) { - //自研obu初始化 - mObuStatusInfo.connectIP = ipAddress - mObuStatusInfo.obuSdkVersion = MogoObuManager.getInstance().versionName - - if (!MogoObuManager.getInstance().isConnected) { - MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP) - } else { - MogoObuManager.getInstance().disConnect() - try { - Thread.sleep(500) - MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() { - // OBU连接成功 - override fun onConnected() { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnected ------> ") - mObuStatusInfo.obuStatus = true - CallerObuListenerManager.invokeListener(mObuStatusInfo) - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) } - } - - // OBU连接失败 - override fun onConnectFail(isNeedReconnect: Boolean) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnectFail ------> ") - mObuStatusInfo.obuStatus = false - mObuStatusInfo.obuHvStatus = false - mObuStatusInfo.obuRvStatus = false - CallerObuListenerManager.invokeListener(mObuStatusInfo) - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) } - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) } - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) } - } - - // OBU断开连接 - override fun onDisconnect() { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onDisconnect ------> ") - mObuStatusInfo.obuStatus = false - mObuStatusInfo.obuHvStatus = false - mObuStatusInfo.obuRvStatus = false - CallerObuListenerManager.invokeListener(mObuStatusInfo) - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) } - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) } - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) } - } - - // 接收到的原始数据 - override fun onReceiveOriginData(data: String) { - super.onReceiveOriginData(data) - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onReceiveOriginData ------> data = $data") - - } - - // 发送的数据 - override fun onSendData(bytes: ByteArray) { - super.onSendData(bytes) - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onSendData ------> ") - } - - // CV2X系统信息 - override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) { - super.onCvxAppInitIndInfo(info) - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxAppInitIndInfo ------> $info") - if (info != null) { - if (!info.stack_info.isNullOrEmpty()) { - mObuStatusInfo.stackInfo = info.stack_info - } - - if (!info.app_info.isNullOrEmpty()) { - mObuStatusInfo.appInfo = info.app_info - } - - if (!info.hli_info.isNullOrEmpty()) { - mObuStatusInfo.hliInfo = info.hli_info - } - CallerObuListenerManager.invokeListener(mObuStatusInfo) - } - } - - // (2) 车辆信息:CVX_HV_INFO_IND - override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo?) { - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", true) } - mObuStatusInfo.obuHvStatus = true - CallerObuListenerManager.invokeListener(mObuStatusInfo) - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxHvInfoIndInfo ------> $info") - if (info != null && info.basic_info != null && info.basic_info.position != null) { - val movingObjectInfo = info.basic_info - val position = movingObjectInfo.position - val data = JSONObject() - try { - data.putOpt("lon", position.longitude) - data.putOpt("lat", position.latitude) - data.putOpt("speed", movingObjectInfo.speed) - data.putOpt("heading", movingObjectInfo.heading) - if (info.acceleration_set != null) { - data.putOpt("acceleration", info.acceleration_set.lateral) - data.putOpt("yawRate", info.acceleration_set.yaw_rate) - } - try { - data.putOpt("systemTime", System.currentTimeMillis()) - } catch (e: Exception) { - e.printStackTrace() - } - try { - data.putOpt("satelliteTime", System.currentTimeMillis()) - } catch (e: Exception) { - e.printStackTrace() - } - - // 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU - if (2 == FunctionBuildConfig.gpsProvider) { - // 同步给MAP地图 - CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data) - // 同步更新经纬度和系统时间至 AutoPilotStatusListener - CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(System.currentTimeMillis()/1000.0,position.longitude, position.latitude) - } - - } catch (e: Exception) { - e.printStackTrace() - } - } - - } - - // (3) 远车信息:CVX_RV_INFO_IND - override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxRvInfoIndInfo ------> $info") - mObuStatusInfo.obuRvStatus = true - CallerObuListenerManager.invokeListener(mObuStatusInfo) - mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", true) } - // 更新数据 - TrafficDataConvertUtils.cvxRvInfoIndInfo2TrafficData(info)?.let { - TrafficMarkerDrawer.updateITrafficLocationInfo(it) - } - } - - // (3) 道路事件预警信息:CVX_RTI_THREAT_IND - override fun onCvxRtiThreatIndInfo(info: CvxRtiThreatIndInfo?) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxRtiThreatIndInfo ------> $info") - - if (info != null && info.threat_info != null && info.ext_info != null) { - var alertContent = "" - var ttsContent = "" - var appId = info.threat_info.app_id.toString() - val status = info.status - val level = info.threat_info.threat_level - val direction = - getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1) - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxRtiThreatIndInfo direction = $direction -- pos_classification = ${info.ext_info.pos_classification}" - ) - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type} --direction = $direction -- pos_classification = ${info.ext_info.pos_classification} " - ) - when (appId) { - // 道路危险情况预警 - EventTypeEnum.TYPE_USECASE_ID_HLW.poiType, - EventTypeEnum.TYPE_USECASE_ID_IVS.poiType - -> { - when (info.ext_info.rti_type) { - //急转弯 - 0x2 -> { - // 特殊处理左、右方向的 - when (direction) { - WarningDirectionEnum.ALERT_WARNING_LEFT, - WarningDirectionEnum.ALERT_WARNING_TOP_LEFT, - WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType - } - WarningDirectionEnum.ALERT_WARNING_RIGHT, - WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT, - WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType - } - } - } - //施工 - 0x7 -> { - appId = EventTypeEnum.FOURS_ROAD_WORK.poiType - } - //限速 - 0xA -> { - appId = EventTypeEnum.TYPE_USECASE_ID_SLW.poiType - } - //事故 - 0xC -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType - } - //拥堵 - 0xD -> { - appId = EventTypeEnum.TYPE_USECASE_ID_TJW.poiType - } - //行人 - 0xF -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType - } - //禁止停车 - 0x13 -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType - } - //学校 - 0x14 -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType - } - //桥梁 - 0x17 -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType - } - //轻轨电车 - 0x18 -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_TRAMCAR.poiType - } - //人行横道 - 0x19 -> { - appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType - } - //减速慢行 - 0x1A -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType - } - //事故易发路段 - 0x1B -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType - } - //环岛行驶 - 0x1C -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_ROUNDABOUTPNG.poiType - } - //环岛行驶 - 0x1D -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_TEST_SECTION.poiType - } - //驼峰桥 - 0x1E -> { - appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType - } - } - alertContent = EventTypeEnum.getWarningContent(appId) - ttsContent = EventTypeEnum.getWarningTts(appId) - } - // 前方拥堵提醒 - EventTypeEnum.TYPE_USECASE_ID_TJW.poiType -> { - ttsContent = EventTypeEnum.getWarningTts(appId) - if (info.threat_info != null) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "ttsContent = $ttsContent --alertContent = $alertContent ---info.threat_info.distance = ${info.threat_info.distance} " - ) - if (info.threat_info.distance.toInt() != 0) { - alertContent = String.format( - EventTypeEnum.getWarningContent(appId), - info.threat_info.distance.toInt() - ) - } else { - alertContent = "前方拥堵,减速慢行" - } - } - - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "ttsContent = $ttsContent --alertContent = $alertContent" - ) - } - } - - when (status) { - // 添加 - ObuConstants.STATUS.ADD, - ObuConstants.STATUS.UPDATE// 更新 - -> { - //显示警告红边 TODO 需要确定是什么值 -// CallerHmiManager.showWarning(direction) - - //显示弹框,语音提示 - CallerHmiManager.showWarningV2X(appId, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - } - }, - true, - 5000L - ) - // 更新数据 - TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let { - TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) - } - } - // 删除 - ObuConstants.STATUS.DELETE -> { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - // 移除顶部弹窗 - CallerHmiManager.disableWarningV2X((appId + direction.direction).toString()) - // 更新数据 - TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let { - // 事件结束,还原车辆颜色 - it.threatLevel = 0x01 - TrafficMarkerDrawer.updateITrafficInfo(it) - } - } - } - } - - } - - // (4) V2I预警信息:CVX_IVP_THREAT_IND,红绿灯 - override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "CvxIvpThreatIndInfo ------> $info") - if (info != null && info.ext_info != null - && info.threat_info != null - && info.ext_info.lights != null - && info.ext_info.lights.isNotEmpty() - ) { - //v2i数据传输延迟 -// val hvMillTime = info.threat_info.hv_time.millisecond -// val hvSecondMillTime = (info.threat_info.hv_time.second) * 1000 -// val hvTime = hvMillTime + hvSecondMillTime -// val currentTime = TimeUtils.getNowMills() % 60000 -// val delayTime = currentTime - hvTime - -// CallerObuListenerManager.invokeDelayTime(delayTime) -// CallerLogger.e( -// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", -// "onCvxIvpThreatIndInfo red ---delayTime---> $delayTime" -// ) - - handlerTrafficLight( - info.threat_info.app_id, - info.status, - info.ext_info.lights, - info.ext_info.index - ) - } - } - - // (2) 弱势交通参与者预警信息:CVX_PTC_THREAT_IND - override fun onCvxPtcThreatIndInfo(info: CvxPtcThreatIndInfo?) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxPtcInfoIndInfo ------> $info") - // 交通参与者类型 0x0:未知 UNKNOWN | 0x1:非机动车 NON_MOTOR | 0x2:行人 PEDESTRIAN 0x3:RSU - if (info != null && (info.ptc_type == 1 || info.ptc_type == 2)) { - //v2i数据传输延迟 -// val hvMillTime = info.threat_info.hv_time.millisecond -// val hvSecondMillTime = (info.threat_info.hv_time.second) * 1000 -// val hvTime = hvMillTime + hvSecondMillTime -// val currentTime = TimeUtils.getNowMills() % 60000 -// val delayTime = currentTime - hvTime - -// CallerObuListenerManager.invokeDelayTime(delayTime) +// private var mMogoServiceApis: IMogoServiceApis? = null +// private var mContext: Context? = null +// private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo() +// +// fun init(context: Context, ipAddress: String) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "obuManager初始化--") +// mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS) +// .navigation(context) as IMogoServiceApis +// mContext = context +// connectObu(context, ipAddress) +// //控制日志输出 +// MogoObuManager.getInstance().init(MoGoAiCloudClientConfig.getInstance().getSn(), AppConfigInfo.toString()) +// MogoObuManager.getInstance().registerListener(mogoObuListener) +// } +// +// fun connectObu(context: Context, ipAddress: String) { +// //自研obu初始化 +// mObuStatusInfo.connectIP = ipAddress +// mObuStatusInfo.obuSdkVersion = MogoObuManager.getInstance().versionName +// +// if (!MogoObuManager.getInstance().isConnected) { +// MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP) +// } else { +// MogoObuManager.getInstance().disConnect() +// try { +// Thread.sleep(500) +// MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP) +// } catch (e: Exception) { +// e.printStackTrace() +// } +// } +// } +// +// private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() { +// // OBU连接成功 +// override fun onConnected() { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnected ------> ") +// mObuStatusInfo.obuStatus = true +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) } +// } +// +// // OBU连接失败 +// override fun onConnectFail(isNeedReconnect: Boolean) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnectFail ------> ") +// mObuStatusInfo.obuStatus = false +// mObuStatusInfo.obuHvStatus = false +// mObuStatusInfo.obuRvStatus = false +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) } +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) } +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) } +// } +// +// // OBU断开连接 +// override fun onDisconnect() { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onDisconnect ------> ") +// mObuStatusInfo.obuStatus = false +// mObuStatusInfo.obuHvStatus = false +// mObuStatusInfo.obuRvStatus = false +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) } +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) } +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) } +// } +// +// // 接收到的原始数据 +// override fun onReceiveOriginData(data: String) { +// super.onReceiveOriginData(data) +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onReceiveOriginData ------> data = $data") +// +// } +// +// // 发送的数据 +// override fun onSendData(bytes: ByteArray) { +// super.onSendData(bytes) +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onSendData ------> ") +// } +// +// // CV2X系统信息 +// override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) { +// super.onCvxAppInitIndInfo(info) +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxAppInitIndInfo ------> $info") +// if (info != null) { +// if (!info.stack_info.isNullOrEmpty()) { +// mObuStatusInfo.stackInfo = info.stack_info +// } +// +// if (!info.app_info.isNullOrEmpty()) { +// mObuStatusInfo.appInfo = info.app_info +// } +// +// if (!info.hli_info.isNullOrEmpty()) { +// mObuStatusInfo.hliInfo = info.hli_info +// } +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// } +// } +// +// // (2) 车辆信息:CVX_HV_INFO_IND +// override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo?) { +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", true) } +// mObuStatusInfo.obuHvStatus = true +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxHvInfoIndInfo ------> $info") +// if (info != null && info.basic_info != null && info.basic_info.position != null) { +// val movingObjectInfo = info.basic_info +// val position = movingObjectInfo.position +// val data = JSONObject() +// try { +// data.putOpt("lon", position.longitude) +// data.putOpt("lat", position.latitude) +// data.putOpt("speed", movingObjectInfo.speed) +// data.putOpt("heading", movingObjectInfo.heading) +// if (info.acceleration_set != null) { +// data.putOpt("acceleration", info.acceleration_set.lateral) +// data.putOpt("yawRate", info.acceleration_set.yaw_rate) +// } +// try { +// data.putOpt("systemTime", System.currentTimeMillis()) +// } catch (e: Exception) { +// e.printStackTrace() +// } +// try { +// data.putOpt("satelliteTime", System.currentTimeMillis()) +// } catch (e: Exception) { +// e.printStackTrace() +// } +// +// // 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU +// if (2 == FunctionBuildConfig.gpsProvider) { +// // 同步给MAP地图 +// CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data) +// // 同步更新经纬度和系统时间至 AutoPilotStatusListener +// CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(System.currentTimeMillis()/1000.0,position.longitude, position.latitude) +// } +// +// } catch (e: Exception) { +// e.printStackTrace() +// } +// } +// +// } +// +// // (3) 远车信息:CVX_RV_INFO_IND +// override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxRvInfoIndInfo ------> $info") +// mObuStatusInfo.obuRvStatus = true +// CallerObuListenerManager.invokeListener(mObuStatusInfo) +// mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", true) } +// // 更新数据 +// TrafficDataConvertUtils.cvxRvInfoIndInfo2TrafficData(info)?.let { +// TrafficMarkerDrawer.updateITrafficLocationInfo(it) +// } +// } +// +// // (3) 道路事件预警信息:CVX_RTI_THREAT_IND +// override fun onCvxRtiThreatIndInfo(info: CvxRtiThreatIndInfo?) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxRtiThreatIndInfo ------> $info") +// +// if (info != null && info.threat_info != null && info.ext_info != null) { +// var alertContent = "" +// var ttsContent = "" +// var appId = info.threat_info.app_id.toString() +// val status = info.status +// val level = info.threat_info.threat_level +// val direction = +// getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1) // CallerLogger.d( // "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", -// "onCvxPtcInfoIndInfo ---delayTime---> $delayTime" +// "onCvxRtiThreatIndInfo direction = $direction -- pos_classification = ${info.ext_info.pos_classification}" // ) - - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxPtcInfoIndInfo ---status---> ${info.status}" - ) - var v2xType = "" - if (info.ptc_type == 1) { //摩托车 - v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType - } else if (info.ptc_type == 2) { //行人 - v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType - } - val ttsContent = EventTypeEnum.getWarningTts(v2xType) - val alertContent = EventTypeEnum.getWarningContent(v2xType) - val direction = - getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1) - val level = if (info.threat_info != null) info.threat_info.threat_level else -1 - - when (info.status) { - // 添加 - ObuConstants.STATUS.ADD, - ObuConstants.STATUS.UPDATE// 更新 - -> { -// if (level == 2 || level == 3) { //不考虑level - //显示警告红边 - CallerHmiManager.showWarning(direction) - CallerHmiManager.showWarningV2X(v2xType, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - } - }, - true, - 5000L - ) +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type} --direction = $direction -- pos_classification = ${info.ext_info.pos_classification} " +// ) +// when (appId) { +// // 道路危险情况预警 +// EventTypeEnum.TYPE_USECASE_ID_HLW.poiType, +// EventTypeEnum.TYPE_USECASE_ID_IVS.poiType +// -> { +// when (info.ext_info.rti_type) { +// //急转弯 +// 0x2 -> { +// // 特殊处理左、右方向的 +// when (direction) { +// WarningDirectionEnum.ALERT_WARNING_LEFT, +// WarningDirectionEnum.ALERT_WARNING_TOP_LEFT, +// WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType +// } +// WarningDirectionEnum.ALERT_WARNING_RIGHT, +// WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT, +// WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType +// } +// } +// } +// //施工 +// 0x7 -> { +// appId = EventTypeEnum.FOURS_ROAD_WORK.poiType +// } +// //限速 +// 0xA -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_SLW.poiType +// } +// //事故 +// 0xC -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType +// } +// //拥堵 +// 0xD -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_TJW.poiType +// } +// //行人 +// 0xF -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType +// } +// //禁止停车 +// 0x13 -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType +// } +// //学校 +// 0x14 -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType +// } +// //桥梁 +// 0x17 -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType +// } +// //轻轨电车 +// 0x18 -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_TRAMCAR.poiType +// } +// //人行横道 +// 0x19 -> { +// appId = +// EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType +// } +// //减速慢行 +// 0x1A -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType +// } +// //事故易发路段 +// 0x1B -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType +// } +// //环岛行驶 +// 0x1C -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_ROUNDABOUTPNG.poiType +// } +// //环岛行驶 +// 0x1D -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_TEST_SECTION.poiType +// } +// //驼峰桥 +// 0x1E -> { +// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType +// } // } - // 更新数据 - TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let { - TrafficMarkerDrawer.updateITrafficInfo(it) - } - } - // 删除 - ObuConstants.STATUS.DELETE -> { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - // 更新数据 - TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let { - // 事件结束,还原交通参与者颜色 - it.threatLevel = 0x01 - TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) - } - CallerHmiManager.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString()) - } - } - - } - - } - - // (5) 限速预警信息:CVX_SLW_THREAT_IND - override fun onCvxSlwThreatIndInfo(info: CvxSlwThreatIndInfo?) { - //todo 限速走高精地图 屏蔽OBU限速\ -// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxSlwThreatIndInfo ------> $info") -// if (info != null) { -// when (info.status) { +// alertContent = EventTypeEnum.getWarningContent(appId) +// ttsContent = EventTypeEnum.getWarningTts(appId) +// } +// // 前方拥堵提醒 +// EventTypeEnum.TYPE_USECASE_ID_TJW.poiType -> { +// ttsContent = EventTypeEnum.getWarningTts(appId) +// if (info.threat_info != null) { +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "ttsContent = $ttsContent --alertContent = $alertContent ---info.threat_info.distance = ${info.threat_info.distance} " +// ) +// if (info.threat_info.distance.toInt() != 0) { +// alertContent = String.format( +// EventTypeEnum.getWarningContent(appId), +// info.threat_info.distance.toInt() +// ) +// } else { +// alertContent = "前方拥堵,减速慢行" +// } +// } +// +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "ttsContent = $ttsContent --alertContent = $alertContent" +// ) +// } +// } +// +// when (status) { // // 添加 // ObuConstants.STATUS.ADD, -// ObuConstants.STATUS.UPDATE +// ObuConstants.STATUS.UPDATE// 更新 // -> { -// if (info.ext_info != null) { -// // 计算为千米每小时 TODO 这里需要做一下向上取整数,40,60,80,120等 -// CallerLogger.d( -// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", -// "info.ext_info.speed_limit_max ------> ${info.ext_info.speed_limit_max}" -// ) -// CallerHmiManager.showLimitingVelocity((Math.round(((info.ext_info.speed_limit_max * 60 * 60) / 1000) / 10) * 10).toInt()) +// //显示警告红边 TODO 需要确定是什么值 +//// CallerHmiManager.showWarning(direction) +// +// //显示弹框,语音提示 +// CallerHmiManager.showWarningV2X(appId, +// alertContent, +// ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 +// (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 +// object : IMoGoWarningStatusListener { +// override fun onDismiss() { +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// } +// }, +// true, +// 5000L +// ) +// // 更新数据 +// TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let { +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) // } // } // // 删除 // ObuConstants.STATUS.DELETE -> { -// CallerHmiManager.disableLimitingVelocity() +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// // 移除顶部弹窗 +// CallerHmiManager.disableWarningV2X((appId + direction.direction).toString()) +// // 更新数据 +// TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let { +// // 事件结束,还原车辆颜色 +// it.threatLevel = 0x01 +// TrafficMarkerDrawer.updateITrafficInfo(it) +// } // } // } // } - } - - - // (1) V2V预警信息:CVX_V2V_THREAT_IND - override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxV2vThreatIndInfo ------> $info") - info?.let { - //预警信息,预警类型 threat_level 2、3 - info.threat_info?.let { - //预警方位 - val direction = getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1) - //处理预警类型 - val appId = info.threat_info.app_id - val level = info.threat_info.threat_level - val status = info.status - if (info.ext_info != null) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxV2vThreatIndInfo target_classification = ${ - getMessageDirection(info.ext_info.target_classification) - } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" - ) - } - - handleSdkObu(appId, direction, status, level, info) - } - } - } - } - - /** - * 返回OBU监听 - */ - fun getMogoObuListener(): OnMogoObuListener { - return mogoObuListener - } - - /** - * 获取消息的方位 车辆相关 - */ - private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "预警红边:预警方向->$targetClassification") - return when (targetClassification) { - ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE, - 0x04 -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 - - 0x03 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 - - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE, - 0x05 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 - - 0x02 -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方 - - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, - ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, - ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT, - ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方 - - ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方 - - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方 - - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, - ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方 - - ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 - else -> WarningDirectionEnum.ALERT_WARNING_ALL - } - } - - fun release() { - MogoObuManager.getInstance().unregisterListener() - } - - /** - * 处理红绿灯 - */ - private fun handlerTrafficLight(appId: Int, status: Int, lights: List, index: Int) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "handlerTrafficLight appId = $appId --- status = $status ---index = $index ---lights.size = ${lights.size} ---lights = $lights " - ) - when (status) { - // 添加 - ObuConstants.STATUS.ADD, - ObuConstants.STATUS.UPDATE - -> { - changeTrafficLightStatus(appId, lights, index) - } - // 删除 - ObuConstants.STATUS.DELETE -> { - // 移除顶部弹窗 - CallerHmiManager.disableWarningTrafficLight() - CallerHmiManager.disableWarningV2X(appId.toString()) - } - } - } - - private var isRedLight = false - private var isGreenLight = false - - /** - * 修改红绿灯 - */ - @Synchronized - private fun changeTrafficLightStatus( - appId: Int, - lights: List, - index: Int - ) { - var ttsContent = "" - var alertContent = "" - //这里需要根据真实数据确定 index 取值方式 - if (index != -1 && lights.size >= index) { - val currentLight = lights[index] - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} ---rlvw_violation_type = ${currentLight.rlvw_violation_type} --- index = $index ---appId = $appId ---appId = $appId" - ) - // 闯红灯预警 - when (currentLight.rlvw_violation_type) { - 0x0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE - } - 0x1 -> {//无违规 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION - CallerHmiManager.disableWarningV2X(appId.toString()) - } - 0x2 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - CallerHmiManager.showWarningV2X( - appId.toString(), alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - appId.toString(), null, true, 5000L - ) - } - 0x3 -> {//闯黄灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_YELLOW_LIGHT - } - } - - when (currentLight.phase) { - // 灯光不可用 - 0x0 -> { - CallerHmiManager.showWarningTrafficLight(0,2) - } - // 红灯 - 0x1 -> { - if (!isRedLight) { - CallerHmiManager.disableWarningV2X(appId.toString()) - isRedLight = true - } - isGreenLight = false - CallerHmiManager.showWarningTrafficLight(1,2) - - val red = currentLight.count_down.toInt() - CallerHmiManager.changeCountdownRed(red) - CallerHmiManager.changeCountdownGreen(0) - CallerHmiManager.changeCountdownYellow(0) - - } - // 绿灯 - 0x2 -> { - if (!isGreenLight) { - CallerHmiManager.disableWarningV2X(appId.toString()) - isGreenLight = true - } - isRedLight = false - CallerHmiManager.showWarningTrafficLight(3,2) - val green = currentLight.count_down.toInt() - CallerHmiManager.changeCountdownGreen(green) - //防止数据出现问题的容错 - CallerHmiManager.changeCountdownRed(0) - CallerHmiManager.changeCountdownYellow(0) - // 拼接建议速度 - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}" - ) - val adviceSpeed = - "${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}" - - val adviceSpeedTts = - "${currentLight.glosa_suggested_speed_min.toInt()}到${currentLight.glosa_suggested_speed_max.toInt()}" - - ttsContent = - String.format( - EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeedTts - ) - - alertContent = - String.format( - EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeed - ) - - val maxSpeed = currentLight.glosa_suggested_speed_max.toInt() - if (maxSpeed > 0) { - CallerHmiManager.showWarningV2X( - EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - appId.toString(), - null, - true, - 5000L - ) - } - } - // 黄灯 - 0x3 -> { - CallerHmiManager.disableWarningV2X(appId.toString()) - CallerHmiManager.showWarningTrafficLight(2,2) - val yellow = currentLight.count_down.toInt() - CallerHmiManager.changeCountdownYellow(yellow) - CallerHmiManager.changeCountdownGreen(0) - CallerHmiManager.changeCountdownRed(0) - } - } - } - - } - - - /** - * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 - * - * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 - * - * @see com.mogo.module.common.enums.EventTypeEnum - */ - private fun handleSdkObu( - appId: Int, - direction: WarningDirectionEnum, - status: Int, - level: Int, - info: CvxV2vThreatIndInfo - ) { - // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的 - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status" - ) - var alertContent: String - var ttsContent: String - var changeVisualAngle = false - when (appId.toString()) { - // 变道预警,注意左后车辆/注意右后车辆 - EventTypeEnum.TYPE_USECASE_ID_LCW.poiType -> { - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - 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, "右") - } - } - - //车辆失控预警 - EventTypeEnum.TYPE_USECASE_ID_CLW.poiType -> { - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - - //左转辅助 - EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> { - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - } - - //异常车辆提醒 - EventTypeEnum.TYPE_USECASE_ID_AVW.poiType -> { - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - - //盲区预警 - EventTypeEnum.TYPE_USECASE_ID_BSW.poiType -> { - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - - 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 -> { - ttsContent = EventTypeEnum.getWarningTts(appId.toString()) - alertContent = EventTypeEnum.getWarningContent(appId.toString()) - } - } - - when (status) { - // 添加,更新 add的时候,可能级别是2, - ObuConstants.STATUS.ADD, - ObuConstants.STATUS.UPDATE -> { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" - ) - if (level == 2 || level == 3) { - //显示弹框,语音提示 - CallerHmiManager.showWarningV2X(appId.toString(), - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - - override fun onShow() { - super.onShow() - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(TooClose) - } - } - - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(Default()) - } - } - }, - true, - 5000L - ) - //显示警告红边 - CallerHmiManager.showWarning(direction) - } - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 - TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let { - TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) - } - } - // 删除 - ObuConstants.STATUS.DELETE -> { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - // 移除顶部弹窗 - CallerHmiManager.disableWarningV2X((appId + direction.direction).toString()) - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 - TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let { - it.threatLevel = 0x01 - TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) - } - } - } - } +// +// } +// +// // (4) V2I预警信息:CVX_IVP_THREAT_IND,红绿灯 +// override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "CvxIvpThreatIndInfo ------> $info") +// if (info != null && info.ext_info != null +// && info.threat_info != null +// && info.ext_info.lights != null +// && info.ext_info.lights.isNotEmpty() +// ) { +// //v2i数据传输延迟 +//// val hvMillTime = info.threat_info.hv_time.millisecond +//// val hvSecondMillTime = (info.threat_info.hv_time.second) * 1000 +//// val hvTime = hvMillTime + hvSecondMillTime +//// val currentTime = TimeUtils.getNowMills() % 60000 +//// val delayTime = currentTime - hvTime +// +//// CallerObuListenerManager.invokeDelayTime(delayTime) +//// CallerLogger.e( +//// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +//// "onCvxIvpThreatIndInfo red ---delayTime---> $delayTime" +//// ) +// +// handlerTrafficLight( +// info.threat_info.app_id, +// info.status, +// info.ext_info.lights, +// info.ext_info.index +// ) +// } +// } +// +// // (2) 弱势交通参与者预警信息:CVX_PTC_THREAT_IND +// override fun onCvxPtcThreatIndInfo(info: CvxPtcThreatIndInfo?) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxPtcInfoIndInfo ------> $info") +// // 交通参与者类型 0x0:未知 UNKNOWN | 0x1:非机动车 NON_MOTOR | 0x2:行人 PEDESTRIAN 0x3:RSU +// if (info != null && (info.ptc_type == 1 || info.ptc_type == 2)) { +// //v2i数据传输延迟 +//// val hvMillTime = info.threat_info.hv_time.millisecond +//// val hvSecondMillTime = (info.threat_info.hv_time.second) * 1000 +//// val hvTime = hvMillTime + hvSecondMillTime +//// val currentTime = TimeUtils.getNowMills() % 60000 +//// val delayTime = currentTime - hvTime +// +//// CallerObuListenerManager.invokeDelayTime(delayTime) +//// CallerLogger.d( +//// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +//// "onCvxPtcInfoIndInfo ---delayTime---> $delayTime" +//// ) +// +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "onCvxPtcInfoIndInfo ---status---> ${info.status}" +// ) +// var v2xType = "" +// if (info.ptc_type == 1) { //摩托车 +// v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType +// } else if (info.ptc_type == 2) { //行人 +// v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType +// } +// val ttsContent = EventTypeEnum.getWarningTts(v2xType) +// val alertContent = EventTypeEnum.getWarningContent(v2xType) +// val direction = +// getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1) +// val level = if (info.threat_info != null) info.threat_info.threat_level else -1 +// +// when (info.status) { +// // 添加 +// ObuConstants.STATUS.ADD, +// ObuConstants.STATUS.UPDATE// 更新 +// -> { +//// if (level == 2 || level == 3) { //不考虑level +// //显示警告红边 +// CallerHmiManager.showWarning(direction) +// CallerHmiManager.showWarningV2X(v2xType, +// alertContent, +// ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 +// (v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 +// object : IMoGoWarningStatusListener { +// override fun onDismiss() { +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// } +// }, +// true, +// 5000L +// ) +//// } +// // 更新数据 +// TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let { +// TrafficMarkerDrawer.updateITrafficInfo(it) +// } +// } +// // 删除 +// ObuConstants.STATUS.DELETE -> { +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// // 更新数据 +// TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let { +// // 事件结束,还原交通参与者颜色 +// it.threatLevel = 0x01 +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) +// } +// CallerHmiManager.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString()) +// } +// } +// +// } +// +// } +// +// // (5) 限速预警信息:CVX_SLW_THREAT_IND +// override fun onCvxSlwThreatIndInfo(info: CvxSlwThreatIndInfo?) { +// //todo 限速走高精地图 屏蔽OBU限速\ +//// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxSlwThreatIndInfo ------> $info") +//// if (info != null) { +//// when (info.status) { +//// // 添加 +//// ObuConstants.STATUS.ADD, +//// ObuConstants.STATUS.UPDATE +//// -> { +//// if (info.ext_info != null) { +//// // 计算为千米每小时 TODO 这里需要做一下向上取整数,40,60,80,120等 +//// CallerLogger.d( +//// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +//// "info.ext_info.speed_limit_max ------> ${info.ext_info.speed_limit_max}" +//// ) +//// CallerHmiManager.showLimitingVelocity((Math.round(((info.ext_info.speed_limit_max * 60 * 60) / 1000) / 10) * 10).toInt()) +//// } +//// } +//// // 删除 +//// ObuConstants.STATUS.DELETE -> { +//// CallerHmiManager.disableLimitingVelocity() +//// } +//// } +//// } +// } +// +// +// // (1) V2V预警信息:CVX_V2V_THREAT_IND +// override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxV2vThreatIndInfo ------> $info") +// info?.let { +// //预警信息,预警类型 threat_level 2、3 +// info.threat_info?.let { +// //预警方位 +// val direction = getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1) +// //处理预警类型 +// val appId = info.threat_info.app_id +// val level = info.threat_info.threat_level +// val status = info.status +// if (info.ext_info != null) { +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "onCvxV2vThreatIndInfo target_classification = ${ +// getMessageDirection(info.ext_info.target_classification) +// } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" +// ) +// } +// +// handleSdkObu(appId, direction, status, level, info) +// } +// } +// } +// } +// +// /** +// * 返回OBU监听 +// */ +// fun getMogoObuListener(): OnMogoObuListener { +// return mogoObuListener +// } +// +// /** +// * 获取消息的方位 车辆相关 +// */ +// private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { +// CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "预警红边:预警方向->$targetClassification") +// return when (targetClassification) { +// ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, +// ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE, +// 0x04 -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 +// +// 0x03 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE, +// 0x05 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 +// +// 0x02 -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, +// ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, +// ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, +// ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT, +// ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT, +// ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, +// ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, +// ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT, +// ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, +// ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, +// ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方 +// +// ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 +// else -> WarningDirectionEnum.ALERT_WARNING_ALL +// } +// } +// +// fun release() { +// MogoObuManager.getInstance().unregisterListener() +// } +// +// /** +// * 处理红绿灯 +// */ +// private fun handlerTrafficLight(appId: Int, status: Int, lights: List, index: Int) { +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "handlerTrafficLight appId = $appId --- status = $status ---index = $index ---lights.size = ${lights.size} ---lights = $lights " +// ) +// when (status) { +// // 添加 +// ObuConstants.STATUS.ADD, +// ObuConstants.STATUS.UPDATE +// -> { +// changeTrafficLightStatus(appId, lights, index) +// } +// // 删除 +// ObuConstants.STATUS.DELETE -> { +// // 移除顶部弹窗 +// CallerHmiManager.disableWarningTrafficLight() +// CallerHmiManager.disableWarningV2X(appId.toString()) +// } +// } +// } +// +// private var isRedLight = false +// private var isGreenLight = false +// +// /** +// * 修改红绿灯 +// */ +// @Synchronized +// private fun changeTrafficLightStatus( +// appId: Int, +// lights: List, +// index: Int +// ) { +// var ttsContent = "" +// var alertContent = "" +// //这里需要根据真实数据确定 index 取值方式 +// if (index != -1 && lights.size >= index) { +// val currentLight = lights[index] +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} ---rlvw_violation_type = ${currentLight.rlvw_violation_type} --- index = $index ---appId = $appId ---appId = $appId" +// ) +// // 闯红灯预警 +// when (currentLight.rlvw_violation_type) { +// 0x0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE +// } +// 0x1 -> {//无违规 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION +// CallerHmiManager.disableWarningV2X(appId.toString()) +// } +// 0x2 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// CallerHmiManager.showWarningV2X( +// appId.toString(), alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 +// appId.toString(), null, true, 5000L +// ) +// } +// 0x3 -> {//闯黄灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_YELLOW_LIGHT +// } +// } +// +// when (currentLight.phase) { +// // 灯光不可用 +// 0x0 -> { +// CallerHmiManager.showWarningTrafficLight(0,2) +// } +// // 红灯 +// 0x1 -> { +// if (!isRedLight) { +// CallerHmiManager.disableWarningV2X(appId.toString()) +// isRedLight = true +// } +// isGreenLight = false +// CallerHmiManager.showWarningTrafficLight(1,2) +// +// val red = currentLight.count_down.toInt() +// CallerHmiManager.changeCountdownRed(red) +// CallerHmiManager.changeCountdownGreen(0) +// CallerHmiManager.changeCountdownYellow(0) +// +// } +// // 绿灯 +// 0x2 -> { +// if (!isGreenLight) { +// CallerHmiManager.disableWarningV2X(appId.toString()) +// isGreenLight = true +// } +// isRedLight = false +// CallerHmiManager.showWarningTrafficLight(3,2) +// val green = currentLight.count_down.toInt() +// CallerHmiManager.changeCountdownGreen(green) +// //防止数据出现问题的容错 +// CallerHmiManager.changeCountdownRed(0) +// CallerHmiManager.changeCountdownYellow(0) +// // 拼接建议速度 +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}" +// ) +// val adviceSpeed = +// "${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}" +// +// val adviceSpeedTts = +// "${currentLight.glosa_suggested_speed_min.toInt()}到${currentLight.glosa_suggested_speed_max.toInt()}" +// +// ttsContent = +// String.format( +// EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), +// adviceSpeedTts +// ) +// +// alertContent = +// String.format( +// EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), +// adviceSpeed +// ) +// +// val maxSpeed = currentLight.glosa_suggested_speed_max.toInt() +// if (maxSpeed > 0) { +// CallerHmiManager.showWarningV2X( +// EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType, +// alertContent, +// ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 +// appId.toString(), +// null, +// true, +// 5000L +// ) +// } +// } +// // 黄灯 +// 0x3 -> { +// CallerHmiManager.disableWarningV2X(appId.toString()) +// CallerHmiManager.showWarningTrafficLight(2,2) +// val yellow = currentLight.count_down.toInt() +// CallerHmiManager.changeCountdownYellow(yellow) +// CallerHmiManager.changeCountdownGreen(0) +// CallerHmiManager.changeCountdownRed(0) +// } +// } +// } +// +// } +// +// +// /** +// * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 +// * +// * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 +// * +// * @see com.mogo.module.common.enums.EventTypeEnum +// */ +// private fun handleSdkObu( +// appId: Int, +// direction: WarningDirectionEnum, +// status: Int, +// level: Int, +// info: CvxV2vThreatIndInfo +// ) { +// // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的 +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status" +// ) +// var alertContent: String +// var ttsContent: String +// var changeVisualAngle = false +// when (appId.toString()) { +// // 变道预警,注意左后车辆/注意右后车辆 +// EventTypeEnum.TYPE_USECASE_ID_LCW.poiType -> { +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// 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, "右") +// } +// } +// +// //车辆失控预警 +// EventTypeEnum.TYPE_USECASE_ID_CLW.poiType -> { +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// +// alertContent = String.format(alertContent, direction.desc) +// ttsContent = String.format(ttsContent, direction.desc) +// } +// +// //左转辅助 +// EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> { +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// } +// +// //异常车辆提醒 +// EventTypeEnum.TYPE_USECASE_ID_AVW.poiType -> { +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// alertContent = String.format(alertContent, direction.desc) +// ttsContent = String.format(ttsContent, direction.desc) +// } +// +// //盲区预警 +// EventTypeEnum.TYPE_USECASE_ID_BSW.poiType -> { +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// +// 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 -> { +// ttsContent = EventTypeEnum.getWarningTts(appId.toString()) +// alertContent = EventTypeEnum.getWarningContent(appId.toString()) +// } +// } +// +// when (status) { +// // 添加,更新 add的时候,可能级别是2, +// ObuConstants.STATUS.ADD, +// ObuConstants.STATUS.UPDATE -> { +// CallerLogger.d( +// "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", +// "appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" +// ) +// if (level == 2 || level == 3) { +// //显示弹框,语音提示 +// CallerHmiManager.showWarningV2X(appId.toString(), +// alertContent, +// ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 +// (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 +// object : IMoGoWarningStatusListener { +// +// override fun onShow() { +// super.onShow() +// if (changeVisualAngle) { +// CallerVisualAngleManager.changeVisualAngle(TooClose) +// } +// } +// +// override fun onDismiss() { +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// if (changeVisualAngle) { +// CallerVisualAngleManager.changeVisualAngle(Default()) +// } +// } +// }, +// true, +// 5000L +// ) +// //显示警告红边 +// CallerHmiManager.showWarning(direction) +// } +// //更新周边车辆进行预警颜色变换,车辆实时移动和变色 +// TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let { +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) +// } +// } +// // 删除 +// ObuConstants.STATUS.DELETE -> { +// // 关闭警告红边 +// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) +// // 移除顶部弹窗 +// CallerHmiManager.disableWarningV2X((appId + direction.direction).toString()) +// //更新周边车辆进行预警颜色变换,车辆实时移动和变色 +// TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let { +// it.threatLevel = 0x01 +// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) +// } +// } +// } +// } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt new file mode 100644 index 0000000000..b31a34235f --- /dev/null +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt @@ -0,0 +1,731 @@ +package com.mogo.eagle.core.function.obu.mogo + +import android.content.Context +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.enums.WarningDirectionEnum +import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener +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.obu.CallerObuListenerManager +import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtilsNew +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.mogo.storage.SharedPrefsMgr +import com.mogo.module.common.drawer.TrafficMarkerDrawer +import com.mogo.module.common.enums.EventTypeEnum +import com.mogo.support.obu.MogoObuManager +import com.mogo.support.obu.OnMogoObuListener +import com.mogo.support.obu.constants.MogoObuComType +import com.mogo.support.obu.constants.MogoObuConstants +import com.mogo.support.obu.constants.MogoObuTopicId +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 org.json.JSONObject + +/** + * + * @author lixiaopeng + * @since 2021/8/23 + * @description 自研OBU 管理 + */ +class MogoPrivateObuNewManager private constructor() { + companion object { + val INSTANCE: MogoPrivateObuNewManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) { + MogoPrivateObuNewManager() + } + } + + private var mContext: Context? = null + private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo() + + + fun connectObu(context: Context, obuIpAddress: String, padIpAddress: String) { + MogoObuManager.getInstance().registerMogoObuListener(mogoObuListener) + + val com = MogoObuCom.newBuilder() + .setLocalIp(padIpAddress) + .setComType(MogoObuComType.UDP) + .setLocalPort(8888) + .setServerIp(obuIpAddress) + .setServerPort(32900) + .build() + + val options: MogoObuOptions = MogoObuOptions.newBuilder() + .setCom(com) + .registerTopic(MogoObuTopicId.HV_BASIC) + .registerTopic(MogoObuTopicId.RV_WARNING) + .registerTopic(MogoObuTopicId.SPAT_WARNING) + .registerTopic(MogoObuTopicId.RSI_WARNING) + .registerTopic(MogoObuTopicId.RSM_WARNING) + .registerTopic(MogoObuTopicId.MAP_MATCH) + .build() + + MogoObuManager.getInstance().connect(options) + } + + private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() { + /** + * 连接状态的改变 + */ + override fun onConnectStatus(connectStatus: Int) { + if (connectStatus == 0) { //断开连接 + CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnectFail ------> ") + mObuStatusInfo.obuStatus = false + mObuStatusInfo.obuHvStatus = false + mObuStatusInfo.obuRvStatus = false + CallerObuListenerManager.invokeListener(mObuStatusInfo) + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) } + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) } + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) } + } else if (connectStatus == 1) { //连接成功 + CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnected ------> ") + mObuStatusInfo.obuStatus = true + CallerObuListenerManager.invokeListener(mObuStatusInfo) + mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) } + } + } + + /** + * HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo + */ + override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) { + if (p0 != null && p0.vehBasicsMsg != null) { + val data = JSONObject() + try { + data.putOpt("lon", p0.vehBasicsMsg.longitude) + data.putOpt("lat", p0.vehBasicsMsg.latitude) + data.putOpt("speed", p0.vehBasicsMsg.speed) + data.putOpt("heading", p0.vehBasicsMsg.heading) + data.putOpt("acceleration", p0.vehBasicsMsg.accFourAxes.accLat) + data.putOpt("yawRate", p0.vehBasicsMsg.accFourAxes.accYaw) + + try { + data.putOpt("systemTime", System.currentTimeMillis()) + } catch (e: Exception) { + e.printStackTrace() + } + try { + data.putOpt("satelliteTime", System.currentTimeMillis()) + } catch (e: Exception) { + e.printStackTrace() + } + + // 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU + if (2 == FunctionBuildConfig.gpsProvider) { + // 同步给MAP地图 + CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data) + // 同步更新经纬度和系统时间至 AutoPilotStatusListener + CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon( + System.currentTimeMillis() / 1000.0, + p0.vehBasicsMsg.longitude.toDouble(), + p0.vehBasicsMsg.latitude.toDouble() + ) + } + } catch (e: Exception) { + e.printStackTrace() + } + } + } + + /** + * v2v预警信息 CvxRvInfoIndInfo CvxV2vThreatIndInfo 他车 + */ + override fun onMogoObuRvWarning(data: MogoObuRvWarningData) { + super.onMogoObuRvWarning(data) + + // 更新数据,远车数据,之前要匹配uuid TODO +// TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let { +// TrafficMarkerDrawer.updateITrafficLocationInfo(it) +// } + + data?.let { + //预警信息,预警类型 threat_level 2、3 + var status = data.status + + data.vehBasicsMsg?.let { + //预警方位 + val direction = getMessageDirection(data.vehBasicsMsg.targetPosition) + //处理预警类型 + val appId = data.vehBasicsMsg.id + var level = -1 + + data.warningMsg?.let { + if (data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) { + level = data.warningMsg.warningData[0].warningLevel + } + } + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxV2vThreatIndInfo target_classification = ${ + getMessageDirection(data.vehBasicsMsg.targetPosition) + } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" + ) + + //拼凑数据 + handleSdkObu(appId, direction, status, level, data) + } + } + } + + /** + * 红绿灯预警信息 CvxIvpThreatIndInfo + */ + override fun onMogoObuSpatWarning(data: MogoObuSpatWarningData) { + super.onMogoObuSpatWarning(data) + if (data != null && data.lights != null + && data.lights.isNotEmpty() + ) { + handlerTrafficLight( + data.warningType, + data.status, + data.lights + ) + } + } + + /** + * RSI预警信息 CvxRtiThreatIndInfo(交通标志预警(前方限速、前方学校等等),交通事件预警(前方拥堵、前方积水等等)) + */ + override fun onMogoObuRsiWarning(data: MogoObuRsiWarningData) { + super.onMogoObuRsiWarning(data) + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onMogoObuRsiWarning ------> $data" + ) + + if (data != null && data.warning_Msg != null && data.warning_Msg.size > 0) { + var alertContent = "" + var ttsContent = "" + var appId = data.warning_Msg[0].sceneType.toString() + val status = data.status + val level = data.warning_Msg[0].warningLevel + val direction = getMessageDirection(data.warning_Msg[0].targetPosition) + + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxRtiThreatIndInfo direction = $direction -- targetPosition = ${data.warning_Msg[0].targetPosition}" + ) + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warning_Msg[0].eventSerialNum} --direction = $direction" + ) + + when (appId) { + // 道路危险情况预警 TODO +// EventTypeEnum.TYPE_USECASE_ID_HLW.poiType, + EventTypeEnum.TYPE_USECASE_ID_IVS.poiType + -> { + when (data.warning_Msg[0].eventSerialNum) { //TODO 没有下面分类 + //施工 + 0x7 -> { + appId = EventTypeEnum.FOURS_ROAD_WORK.poiType + } + //限速 + 0xA -> { + appId = EventTypeEnum.TYPE_USECASE_ID_SLW.poiType + } + //事故 + 0xC -> { + appId = + EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType + } + //拥堵 + 0xD -> { + appId = EventTypeEnum.TYPE_USECASE_ID_TJW.poiType + } + //行人 + 0xF -> { + appId = + EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType + } + //禁止停车 + 0x13 -> { + appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType + } + //学校 + 0x14 -> { + appId = + EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType + } + //桥梁 + 0x17 -> { + appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType + } + } + alertContent = EventTypeEnum.getWarningContent(appId) + ttsContent = EventTypeEnum.getWarningTts(appId) + } + + // 前方拥堵提醒 TODO + EventTypeEnum.TYPE_USECASE_ID_TJW.poiType -> { + ttsContent = EventTypeEnum.getWarningTts(appId) + alertContent = "前方拥堵,减速慢行" + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "ttsContent = $ttsContent --alertContent = $alertContent" + ) + } + } + + when (status) { + // 添加 + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE// 更新 + -> { + //显示警告红边 TODO 需要确定是什么值 +// CallerHmiManager.showWarning(direction) + //显示弹框,语音提示 + CallerHmiManager.showWarningV2X( + appId, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (appId + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 3000L + ) + // 更新数据 + TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)?.let { + TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 移除顶部弹窗 + CallerHmiManager.disableWarningV2X((appId + direction.direction)) + // 更新数据 + TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)?.let { + // 事件结束,还原车辆颜色 + it.threatLevel = 0x01 + TrafficMarkerDrawer.updateITrafficInfo(it) + } + } + } + } + } + + /** + * RSM预警信息 CvxPtcThreatIndInfo CvxPtcInfoIndInfo(主车与弱势交通参与者之间的预警(如:弱势交通参与者碰撞预警)) + */ + override fun onMogoObuRsmWarning(data: MogoObuRsmWarningData?) { + super.onMogoObuRsmWarning(data) + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onMogoObuRsmWarning ------> $data" + ) + // 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu + if (data != null && data.participant != null && (data.participant.ptcType == 1 || data.participant.ptcType == 3)) { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onMogoObuRsmWarning ---status---> ${data.status}" + ) + var v2xType = "" + if (data.participant.ptcType == 1) { //摩托车 + v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType + } else if (data.participant.ptcType == 2) { //行人 + v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType + } + val ttsContent = EventTypeEnum.getWarningTts(v2xType) + val alertContent = EventTypeEnum.getWarningContent(v2xType) + var level = -1 + val direction = getMessageDirection(data.participant.targetPosition) + if (data.m_warning_msg != null && data.m_warning_msg.warningData != null && data.m_warning_msg.warningData.size > 0) { + level = data.m_warning_msg.warningData[0].warningLevel + } + + when (data.status) { + // 添加 + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE// 更新 + -> { +// if (level == 2 || level == 3) { //不考虑level + //显示警告红边 + CallerHmiManager.showWarning(direction) + CallerHmiManager.showWarningV2X( + v2xType, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (v2xType + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 3000L + ) +// } + // 更新数据 + TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)?.let { + TrafficMarkerDrawer.updateITrafficInfo(it) + } + } + + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 更新数据 + TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)?.let { + // 事件结束,还原交通参与者颜色 + it.threatLevel = 0x01 + TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + } + //TODO +// CallerHmiManager.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString()) + } + } + } + } + + /** + * 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道 + */ + override fun onMogoObuMapMath(data: MogoObuMapMathData?) { + super.onMogoObuMapMath(data) + + } + } + + /** + * 获取消息的方位 车辆相关 + */ + private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { + CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_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内容 + * + * @see com.mogo.module.common.enums.EventTypeEnum + */ + private fun handleSdkObu( + appId: String, + direction: WarningDirectionEnum, + status: Int, + level: Int, + info: MogoObuRvWarningData + ) { + // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的 + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status" + ) + var alertContent: String + var ttsContent: String + var changeVisualAngle = false + when (appId) { + // 变道预警,注意左后车辆/注意右后车辆 + EventTypeEnum.TYPE_USECASE_ID_LCW.poiType -> { + alertContent = EventTypeEnum.getWarningContent(appId) + ttsContent = EventTypeEnum.getWarningTts(appId) + 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, "右") + } + } + + //车辆失控预警 + EventTypeEnum.TYPE_USECASE_ID_CLW.poiType -> { + alertContent = EventTypeEnum.getWarningContent(appId) + ttsContent = EventTypeEnum.getWarningTts(appId) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } + + //左转辅助 +// EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> { +// alertContent = EventTypeEnum.getWarningContent(appId) +// ttsContent = EventTypeEnum.getWarningTts(appId) +// } + + //异常车辆提醒 + EventTypeEnum.TYPE_USECASE_ID_AVW.poiType -> { + alertContent = EventTypeEnum.getWarningContent(appId) + ttsContent = EventTypeEnum.getWarningTts(appId) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } + + //盲区预警 + EventTypeEnum.TYPE_USECASE_ID_BSW.poiType -> { + ttsContent = EventTypeEnum.getWarningTts(appId) + alertContent = EventTypeEnum.getWarningContent(appId) + 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 -> { + ttsContent = EventTypeEnum.getWarningTts(appId) + alertContent = EventTypeEnum.getWarningContent(appId) + } + } + + when (status) { + // 添加,更新 add的时候,可能级别是2, + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE -> { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" + ) + if (level == 2 || level == 3) { + //显示弹框,语音提示 + CallerHmiManager.showWarningV2X( + appId, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (appId + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onShow() { + super.onShow() + if (changeVisualAngle) { + CallerVisualAngleManager.changeVisualAngle(TooClose) + } + } + + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + if (changeVisualAngle) { + CallerVisualAngleManager.changeVisualAngle(Default()) + } + } + }, + true, + 3000L + ) + //显示警告红边 + CallerHmiManager.showWarning(direction) + } + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 //TODO UUID不需要匹配了 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 移除顶部弹窗 + CallerHmiManager.disableWarningV2X((appId + direction.direction)) + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + it.threatLevel = 0x01 + TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it) + } + } + } + } + + /** + * 处理红绿灯 + */ + private fun handlerTrafficLight(appId: Int, status: Int, lights: List) { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights " + ) + MogoObuConstants.CONNECT_STATUS.CONNECTED + when (status) { + // 添加 + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE + -> { + changeTrafficLightStatus(appId, lights) + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 移除顶部弹窗 + CallerHmiManager.disableWarningTrafficLight() + CallerHmiManager.disableWarningV2X(appId.toString()) + } + } + } + + private var isRedLight = false + private var isGreenLight = 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_OBU}", + "currentLight = $currentLight ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId" + ) + // 闯红灯预警 + when (appId) { + 0x0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE + } + 0x1 -> {//无违规 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION + CallerHmiManager.disableWarningV2X(appId.toString()) + } + 0x2 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT + ttsContent = EventTypeEnum.getWarningTts(appId.toString()) + alertContent = EventTypeEnum.getWarningContent(appId.toString()) + CallerHmiManager.showWarningV2X( + appId.toString(), alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + appId.toString(), null, true, 3000L + ) + } + 0x3 -> {//闯黄灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_YELLOW_LIGHT + } + } + + when (currentLight.light) { + // 灯光不可用 + 0x0 -> { + CallerHmiManager.showWarningTrafficLight(0, 2) + } + // 红灯 + 0x1 -> { + if (!isRedLight) { + CallerHmiManager.disableWarningV2X(appId.toString()) + isRedLight = true + } + isGreenLight = false + CallerHmiManager.showWarningTrafficLight(1, 2) + + val red = currentLight.countDown + CallerHmiManager.changeCountdownRed(red) + CallerHmiManager.changeCountdownGreen(0) + CallerHmiManager.changeCountdownYellow(0) + } + // 绿灯 + 0x2 -> { + if (!isGreenLight) { + CallerHmiManager.disableWarningV2X(appId.toString()) + isGreenLight = true + } + isRedLight = false + CallerHmiManager.showWarningTrafficLight(3, 2) + val green = currentLight.countDown + CallerHmiManager.changeCountdownGreen(green) + //防止数据出现问题的容错 + CallerHmiManager.changeCountdownRed(0) + CallerHmiManager.changeCountdownYellow(0) + // 拼接建议速度 + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}" + ) + val adviceSpeed = + "${currentLight.suggestMinSpeed} - ${currentLight.suggestMaxSpeed}" + val adviceSpeedTts = + "${currentLight.suggestMinSpeed}到${currentLight.suggestMaxSpeed}" + ttsContent = + String.format( + EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeedTts + ) + alertContent = + String.format( + EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeed + ) + + val maxSpeed = currentLight.suggestMaxSpeed + if (maxSpeed > 0) { + CallerHmiManager.showWarningV2X( + EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + appId.toString(), + null, + true, + 3000L + ) + } + } + // 黄灯 + 0x3 -> { + CallerHmiManager.disableWarningV2X(appId.toString()) + CallerHmiManager.showWarningTrafficLight(2, 2) + val yellow = currentLight.countDown + CallerHmiManager.changeCountdownYellow(yellow) + CallerHmiManager.changeCountdownGreen(0) + CallerHmiManager.changeCountdownRed(0) + } + } + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt index aae4b90480..644de55099 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuRsuTestTriggerReceiver.kt @@ -3,16 +3,16 @@ package com.mogo.eagle.core.function.obu.mogo.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import com.mogo.eagle.core.function.obu.mogo.MogoObuConst -import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU -import com.zhidao.support.obu.constants.ObuConstants -import com.zhidao.support.obu.model.CvxIvpThreatIndInfo -import com.zhidao.support.obu.model.CvxPtcThreatIndInfo -import com.zhidao.support.obu.model.CvxRtiThreatIndInfo -import com.zhidao.support.obu.model.CvxSlwThreatIndInfo -import com.zhidao.support.obu.model.advance.* +//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst +//import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager +//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +//import com.zhidao.support.obu.constants.ObuConstants +//import com.zhidao.support.obu.model.CvxIvpThreatIndInfo +//import com.zhidao.support.obu.model.CvxPtcThreatIndInfo +//import com.zhidao.support.obu.model.CvxRtiThreatIndInfo +//import com.zhidao.support.obu.model.CvxSlwThreatIndInfo +//import com.zhidao.support.obu.model.advance.* /** * @author lixiaopeng @@ -31,90 +31,90 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { mContext = context - val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) - val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) - val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) - val indicator = intent.getIntExtra(MogoObuConst.BROADCAST_LIGHT_LEVEL_EXTRA_KEY, 0) - val pctType = intent.getIntExtra(MogoObuConst.BROADCAST_PTC_INFO_EXTRA_KEY, 0) - val rtiType = intent.getIntExtra(MogoObuConst.BROADCAST_RTI_TYPE_EXTRA_KEY, 0) - - CallerLogger.d( - "$M_OBU$TAG", "obuStatus:$obuStatus phase:$indicator obuType:$obuType obuLevel:$obuLevel" - ) - - when (obuType) { - ObuConstants.USE_CASE_ID.IVP -> { //构建红绿灯数据 - val cvxIvpThreatIndInfo = CvxIvpThreatIndInfo(1, 1, 1L) - - val ivpThreat = IvpThreat(1, obuType, null, 1000, obuLevel, 100) - - cvxIvpThreatIndInfo.threat_info = ivpThreat - - val lightList = listOf( - Light(1, 0x0, 1000, 3000, 6000, 3000, 100, 1000), - Light(1, 0x1, 1000, 3000, 6000, 3000, 100, 1000), - Light(1, 0x2, 1000, 3000, 6000, 3000, 100, 1000), - Light(1, 0x3, 1000, 3000, 6000, 3000, 100, 1000) - ) - val ivpThreatExt = IvpThreatExt(1, 1000, 1000, 0, indicator, lightList) - cvxIvpThreatIndInfo.ext_info = ivpThreatExt - cvxIvpThreatIndInfo.status = obuStatus - cvxIvpThreatIndInfo.link_id = "1" - - MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo) - } - - ObuConstants.USE_CASE_ID.SLW -> { //限速预警 - val cvxSlwThreatIndInfo = CvxSlwThreatIndInfo(1, 1, 1L) - val slwThreatExt = SlwThreatExt(1, 2, 6000, 2000) - - cvxSlwThreatIndInfo.ext_info = slwThreatExt - cvxSlwThreatIndInfo.status = obuStatus - - MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo) - } - - //弱势交通参与者碰撞预警,行人/摩托车碰撞预警 - ObuConstants.USE_CASE_ID.VRUCW -> { - val cvxPtcIndInfo = CvxPtcThreatIndInfo(1, 1, 1) - val position = Position(1, 399739429, 1164115207, 20) - cvxPtcIndInfo.ptc_pos = position - cvxPtcIndInfo.ptc_id = "111" - cvxPtcIndInfo.ptc_type = pctType - cvxPtcIndInfo.status = obuStatus - - val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100) - cvxPtcIndInfo.threat_info = v2vThreat - - MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxPtcThreatIndInfo(cvxPtcIndInfo) - } - - //道路危险情况, 车内标牌, 前方拥堵提醒 - ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, ObuConstants.USE_CASE_ID.TJW -> { - val cvxRtiThreatIndInfo = CvxRtiThreatIndInfo(1, 1, 1L) - val dateTime = DateTime(1, 1, 1, 1, 1, 1, 1, 1) - val rtiThread = RtiThreat(1, obuType, dateTime, 100000, obuLevel, 100) - val extInfo = RtiThreatExt(1, rtiType, 0x02, 100000, 100000) - val position = Position(1, 399739429, 1164115207, 20) - - // 位置围栏 - val zonesInfo = listOf( - ZoneInfo(1, 2000, 2000, listOf(position)) - ) - - cvxRtiThreatIndInfo.rti_id = "123123" - cvxRtiThreatIndInfo.zones_info = zonesInfo - cvxRtiThreatIndInfo.threat_info = rtiThread - cvxRtiThreatIndInfo.ext_info = extInfo - cvxRtiThreatIndInfo.status = obuStatus - - MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo) - } - } +// val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) +// val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) +// val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) +// val indicator = intent.getIntExtra(MogoObuConst.BROADCAST_LIGHT_LEVEL_EXTRA_KEY, 0) +// val pctType = intent.getIntExtra(MogoObuConst.BROADCAST_PTC_INFO_EXTRA_KEY, 0) +// val rtiType = intent.getIntExtra(MogoObuConst.BROADCAST_RTI_TYPE_EXTRA_KEY, 0) +// +// CallerLogger.d( +// "$M_OBU$TAG", "obuStatus:$obuStatus phase:$indicator obuType:$obuType obuLevel:$obuLevel" +// ) +// +// when (obuType) { +// ObuConstants.USE_CASE_ID.IVP -> { //构建红绿灯数据 +// val cvxIvpThreatIndInfo = CvxIvpThreatIndInfo(1, 1, 1L) +// +// val ivpThreat = IvpThreat(1, obuType, null, 1000, obuLevel, 100) +// +// cvxIvpThreatIndInfo.threat_info = ivpThreat +// +// val lightList = listOf( +// Light(1, 0x0, 1000, 3000, 6000, 3000, 100, 1000), +// Light(1, 0x1, 1000, 3000, 6000, 3000, 100, 1000), +// Light(1, 0x2, 1000, 3000, 6000, 3000, 100, 1000), +// Light(1, 0x3, 1000, 3000, 6000, 3000, 100, 1000) +// ) +// val ivpThreatExt = IvpThreatExt(1, 1000, 1000, 0, indicator, lightList) +// cvxIvpThreatIndInfo.ext_info = ivpThreatExt +// cvxIvpThreatIndInfo.status = obuStatus +// cvxIvpThreatIndInfo.link_id = "1" +// +// MogoPrivateObuManager.INSTANCE.getMogoObuListener() +// .onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo) +// } +// +// ObuConstants.USE_CASE_ID.SLW -> { //限速预警 +// val cvxSlwThreatIndInfo = CvxSlwThreatIndInfo(1, 1, 1L) +// val slwThreatExt = SlwThreatExt(1, 2, 6000, 2000) +// +// cvxSlwThreatIndInfo.ext_info = slwThreatExt +// cvxSlwThreatIndInfo.status = obuStatus +// +// MogoPrivateObuManager.INSTANCE.getMogoObuListener() +// .onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo) +// } +// +// //弱势交通参与者碰撞预警,行人/摩托车碰撞预警 +// ObuConstants.USE_CASE_ID.VRUCW -> { +// val cvxPtcIndInfo = CvxPtcThreatIndInfo(1, 1, 1) +// val position = Position(1, 399739429, 1164115207, 20) +// cvxPtcIndInfo.ptc_pos = position +// cvxPtcIndInfo.ptc_id = "111" +// cvxPtcIndInfo.ptc_type = pctType +// cvxPtcIndInfo.status = obuStatus +// +// val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100) +// cvxPtcIndInfo.threat_info = v2vThreat +// +// MogoPrivateObuManager.INSTANCE.getMogoObuListener() +// .onCvxPtcThreatIndInfo(cvxPtcIndInfo) +// } +// +// //道路危险情况, 车内标牌, 前方拥堵提醒 +// ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, ObuConstants.USE_CASE_ID.TJW -> { +// val cvxRtiThreatIndInfo = CvxRtiThreatIndInfo(1, 1, 1L) +// val dateTime = DateTime(1, 1, 1, 1, 1, 1, 1, 1) +// val rtiThread = RtiThreat(1, obuType, dateTime, 100000, obuLevel, 100) +// val extInfo = RtiThreatExt(1, rtiType, 0x02, 100000, 100000) +// val position = Position(1, 399739429, 1164115207, 20) +// +// // 位置围栏 +// val zonesInfo = listOf( +// ZoneInfo(1, 2000, 2000, listOf(position)) +// ) +// +// cvxRtiThreatIndInfo.rti_id = "123123" +// cvxRtiThreatIndInfo.zones_info = zonesInfo +// cvxRtiThreatIndInfo.threat_info = rtiThread +// cvxRtiThreatIndInfo.ext_info = extInfo +// cvxRtiThreatIndInfo.status = obuStatus +// +// MogoPrivateObuManager.INSTANCE.getMogoObuListener() +// .onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo) +// } +// } } } diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerReceiver.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerReceiver.kt index e7c0b2b3ef..de530930bd 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerReceiver.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerReceiver.kt @@ -3,17 +3,17 @@ package com.mogo.eagle.core.function.obu.mogo.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import com.mogo.eagle.core.function.obu.mogo.MogoObuConst -import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU -import com.zhidao.support.obu.constants.ObuConstants -import com.zhidao.support.obu.model.CvxV2vThreatIndInfo -import com.zhidao.support.obu.model.advance.MovingObjectInfo -import com.zhidao.support.obu.model.advance.Position -import com.zhidao.support.obu.model.advance.V2vThreat -import com.zhidao.support.obu.model.advance.V2vThreatExt -import kotlin.random.Random +//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst +//import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager +//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +//import com.zhidao.support.obu.constants.ObuConstants +//import com.zhidao.support.obu.model.CvxV2vThreatIndInfo +//import com.zhidao.support.obu.model.advance.MovingObjectInfo +//import com.zhidao.support.obu.model.advance.Position +//import com.zhidao.support.obu.model.advance.V2vThreat +//import com.zhidao.support.obu.model.advance.V2vThreatExt +//import kotlin.random.Random /** * @author xiaoyuzhou @@ -29,61 +29,61 @@ class ObuTestTriggerReceiver : BroadcastReceiver() { } override fun onReceive(context: Context, intent: Intent) { - mContext = context - /** - * OBU 场景类型 - * @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID - */ - val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) - val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) - val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) - val obuDirection = - intent.getIntExtra(MogoObuConst.BROADCAST_OBU_EVENT_DIRECTION_EXTRA_KEY, 0x11) - CallerLogger.d( - "$M_OBU$TAG", "obuType:$obuType obuStatus:$obuStatus obuDirection$obuDirection" - ) - - when (obuType) { - ObuConstants.USE_CASE_ID.EBW, ObuConstants.USE_CASE_ID.FCW, ObuConstants.USE_CASE_ID.ICW, - ObuConstants.USE_CASE_ID.CLW, ObuConstants.USE_CASE_ID.DNPW, ObuConstants.USE_CASE_ID.AVW, - ObuConstants.USE_CASE_ID.BSW, ObuConstants.USE_CASE_ID.LCW, ObuConstants.USE_CASE_ID.EVW, ObuConstants.USE_CASE_ID.VRUCW, - ObuConstants.USE_CASE_ID.SLW, ObuConstants.USE_CASE_ID.LTA, ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, - ObuConstants.USE_CASE_ID.TJW, ObuConstants.USE_CASE_ID.IVP, ObuConstants.USE_CASE_ID.COC -> { - - // 构建测试数据 - val cvxV2vThreatIndInfo = CvxV2vThreatIndInfo(1, 1, 1L) - - val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100) - cvxV2vThreatIndInfo.threat_info = v2vThreat - - val v2vThreatExt = - V2vThreatExt( - 1, 1, obuDirection, 1, 1 - ) - cvxV2vThreatIndInfo.ext_info = v2vThreatExt - cvxV2vThreatIndInfo.status = obuStatus - cvxV2vThreatIndInfo.vehicle_id = "123321" - - - // 设置位置 - val randomLocation = Random.nextInt(100, 2000) - - val position = Position( - 0, (399739429 + randomLocation).toLong(), - (1164115207 + randomLocation).toLong(), 20 - ) - val movingObjectInfo = MovingObjectInfo( - 0, - position, - 1800 +randomLocation, - 6000 +randomLocation - ) - cvxV2vThreatIndInfo.basic_info = movingObjectInfo - - MogoPrivateObuManager.INSTANCE.getMogoObuListener() - .onCvxV2vThreatIndInfo(cvxV2vThreatIndInfo) - } - } +// mContext = context +// /** +// * OBU 场景类型 +// * @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID +// */ +// val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) +// val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) +// val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) +// val obuDirection = +// intent.getIntExtra(MogoObuConst.BROADCAST_OBU_EVENT_DIRECTION_EXTRA_KEY, 0x11) +// CallerLogger.d( +// "$M_OBU$TAG", "obuType:$obuType obuStatus:$obuStatus obuDirection$obuDirection" +// ) +// +// when (obuType) { +// ObuConstants.USE_CASE_ID.EBW, ObuConstants.USE_CASE_ID.FCW, ObuConstants.USE_CASE_ID.ICW, +// ObuConstants.USE_CASE_ID.CLW, ObuConstants.USE_CASE_ID.DNPW, ObuConstants.USE_CASE_ID.AVW, +// ObuConstants.USE_CASE_ID.BSW, ObuConstants.USE_CASE_ID.LCW, ObuConstants.USE_CASE_ID.EVW, ObuConstants.USE_CASE_ID.VRUCW, +// ObuConstants.USE_CASE_ID.SLW, ObuConstants.USE_CASE_ID.LTA, ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, +// ObuConstants.USE_CASE_ID.TJW, ObuConstants.USE_CASE_ID.IVP, ObuConstants.USE_CASE_ID.COC -> { +// +// // 构建测试数据 +// val cvxV2vThreatIndInfo = CvxV2vThreatIndInfo(1, 1, 1L) +// +// val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100) +// cvxV2vThreatIndInfo.threat_info = v2vThreat +// +// val v2vThreatExt = +// V2vThreatExt( +// 1, 1, obuDirection, 1, 1 +// ) +// cvxV2vThreatIndInfo.ext_info = v2vThreatExt +// cvxV2vThreatIndInfo.status = obuStatus +// cvxV2vThreatIndInfo.vehicle_id = "123321" +// +// +// // 设置位置 +// val randomLocation = Random.nextInt(100, 2000) +// +// val position = Position( +// 0, (399739429 + randomLocation).toLong(), +// (1164115207 + randomLocation).toLong(), 20 +// ) +// val movingObjectInfo = MovingObjectInfo( +// 0, +// position, +// 1800 +randomLocation, +// 6000 +randomLocation +// ) +// cvxV2vThreatIndInfo.basic_info = movingObjectInfo +// +// MogoPrivateObuManager.INSTANCE.getMogoObuListener() +// .onCvxV2vThreatIndInfo(cvxV2vThreatIndInfo) +// } +// } } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerRecognizedReceiver.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerRecognizedReceiver.kt index 6b5a29516c..fa51916e3b 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerRecognizedReceiver.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/receiver/ObuTestTriggerRecognizedReceiver.kt @@ -3,14 +3,14 @@ package com.mogo.eagle.core.function.obu.mogo.receiver import android.content.BroadcastReceiver import android.content.Context import android.content.Intent -import com.mogo.eagle.core.function.obu.mogo.MogoObuConst -import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU -import com.zhidao.support.obu.model.CvxHvInfoIndInfo -import com.zhidao.support.obu.model.advance.MovingObjectInfo -import com.zhidao.support.obu.model.advance.Position -import kotlin.random.Random +//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst +//import com.mogo.eagle.core.function.obu.mogo.MogoPrivateObuManager +//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +//import com.zhidao.support.obu.model.CvxHvInfoIndInfo +//import com.zhidao.support.obu.model.advance.MovingObjectInfo +//import com.zhidao.support.obu.model.advance.Position +//import kotlin.random.Random /** * @author xiaoyuzhou @@ -31,30 +31,30 @@ class ObuTestTriggerRecognizedReceiver : BroadcastReceiver() { * OBU 场景类型 * @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID */ - val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) - val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) - val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) - CallerLogger.d("$M_OBU$TAG", "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel") - - val cvxHvInfoIndInfo = CvxHvInfoIndInfo(0, 1, 2) - - val randomLocation = Random.nextInt(100, 2000) - - val position = Position( - 0, (399739429 + randomLocation).toLong(), - (1164115207 + randomLocation).toLong(), 20 - ) - val movingObjectInfo = MovingObjectInfo( - 0, - position, - 1800 +randomLocation, - 6000 +randomLocation - ) - cvxHvInfoIndInfo.basic_info = movingObjectInfo - - MogoPrivateObuManager.INSTANCE - .getMogoObuListener() - .onCvxHvInfoIndInfo(cvxHvInfoIndInfo) +// val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0) +// val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0) +// val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3) +// CallerLogger.d("$M_OBU$TAG", "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel") +// +// val cvxHvInfoIndInfo = CvxHvInfoIndInfo(0, 1, 2) +// +// val randomLocation = Random.nextInt(100, 2000) +// +// val position = Position( +// 0, (399739429 + randomLocation).toLong(), +// (1164115207 + randomLocation).toLong(), 20 +// ) +// val movingObjectInfo = MovingObjectInfo( +// 0, +// position, +// 1800 +randomLocation, +// 6000 +randomLocation +// ) +// cvxHvInfoIndInfo.basic_info = movingObjectInfo +// +// MogoPrivateObuManager.INSTANCE +// .getMogoObuListener() +// .onCvxHvInfoIndInfo(cvxHvInfoIndInfo) } diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtils.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtils.kt index 8e94bc8bc6..b88ffe939f 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtils.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtils.kt @@ -1,14 +1,14 @@ package com.mogo.eagle.core.function.obu.mogo.utils -import com.mogo.eagle.core.data.traffic.TrafficData -import com.mogo.eagle.core.data.enums.TrafficTypeEnum -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU -import com.zhidao.support.obu.constants.ObuConstants -import com.zhidao.support.obu.model.CvxPtcThreatIndInfo -import com.zhidao.support.obu.model.CvxRtiThreatIndInfo -import com.zhidao.support.obu.model.CvxRvInfoIndInfo -import com.zhidao.support.obu.model.CvxV2vThreatIndInfo +//import com.mogo.eagle.core.data.traffic.TrafficData +//import com.mogo.eagle.core.data.enums.TrafficTypeEnum +//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +//import com.zhidao.support.obu.constants.ObuConstants +//import com.zhidao.support.obu.model.CvxPtcThreatIndInfo +//import com.zhidao.support.obu.model.CvxRtiThreatIndInfo +//import com.zhidao.support.obu.model.CvxRvInfoIndInfo +//import com.zhidao.support.obu.model.CvxV2vThreatIndInfo /** * @author xiaoyuzhou @@ -17,117 +17,117 @@ import com.zhidao.support.obu.model.CvxV2vThreatIndInfo object TrafficDataConvertUtils { val TAG = "TrafficDataConvertUtils" - /** - * OBU 远车 转换交通元素数据 - */ - fun cvxRvInfoIndInfo2TrafficData(info: CvxRvInfoIndInfo): TrafficData? { - if (info.basic_info == null || info.basic_info.position == null) { - CallerLogger.e("$M_OBU$TAG", "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全") - return null - } - val trafficData = TrafficData() - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE - trafficData.uuid = info.vehicle_id - trafficData.lat = info.basic_info.position.latitude - trafficData.lon = info.basic_info.position.longitude - trafficData.heading = info.basic_info.heading - trafficData.speed = info.basic_info.speed - - return trafficData - } - - /** - * OBU RSU道路事件预警信息 转换交通元素数据 - */ - fun cvxRtiThreatIndInfo2TrafficData(info: CvxRtiThreatIndInfo): TrafficData? { - // 这里只处理道路施工 - if(info.ext_info.rti_type != 0x7){ - return null - } - if (info.rti_id == null || info.ext_info == null - || info.zones_info == null || info.zones_info.first() == null - || info.zones_info.first().path_points.first() == null - || info.threat_info == null - ) { - CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") - return null - } - val trafficData = TrafficData() - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG - trafficData.uuid = info.rti_id - - trafficData.lat = info.zones_info.first().path_points.first().latitude - trafficData.lon = info.zones_info.first().path_points.first().longitude - - trafficData.threatLevel = info.threat_info.threat_level - - return trafficData - } - - /** - * OBU 预警事件 转换交通元素数据 - */ - fun cvxV2vThreatIndInfo2TrafficData(info: CvxV2vThreatIndInfo): TrafficData? { - if (info.basic_info == null || info.basic_info.position == null || info.threat_info == null) { - CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") - return null - } - val trafficData = TrafficData() - trafficData.uuid = info.vehicle_id - trafficData.lat = info.basic_info.position.latitude - trafficData.lon = info.basic_info.position.longitude - trafficData.heading = info.basic_info.heading - trafficData.speed = info.basic_info.speed - // 判断车辆V2X预警级别,调整车辆颜色 - trafficData.threatLevel = info.threat_info.threat_level - - if (info.threat_info.app_id == ObuConstants.USE_CASE_ID.EVW) { - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE - } else { - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE - } - - return trafficData - } - - /** - * OBU 弱势交通参与者信息 转换交通元素数据 TODO - */ - fun cvxPtcThreatIndInfo2TrafficData(info: CvxPtcThreatIndInfo): TrafficData? { - if (info.ptc_pos == null || info.threat_info == null) { - CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") - return null - } - val trafficData = TrafficData() - - trafficData.uuid = info.ptc_id - trafficData.lat = info.ptc_pos.latitude - trafficData.lon = info.ptc_pos.longitude -// trafficData.heading = info.ptc_pos.heading -// trafficData.speed = info.ptc_pos.speed - - when (info.ptc_type) { - // 未知 - 0x0 -> { - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI - } - // 非机动车 - 0x1 -> { - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO - } - // 行人 - 0x2 -> { - trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE - } - } - - // 判断车辆V2X预警级别,调整车辆颜色 - if (info.threat_info != null) { - trafficData.threatLevel = info.threat_info.threat_level - } - - return trafficData - } +// /** +// * OBU 远车 转换交通元素数据 +// */ +// fun cvxRvInfoIndInfo2TrafficData(info: CvxRvInfoIndInfo): TrafficData? { +// if (info.basic_info == null || info.basic_info.position == null) { +// CallerLogger.e("$M_OBU$TAG", "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全") +// return null +// } +// val trafficData = TrafficData() +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE +// trafficData.uuid = info.vehicle_id +// trafficData.lat = info.basic_info.position.latitude +// trafficData.lon = info.basic_info.position.longitude +// trafficData.heading = info.basic_info.heading +// trafficData.speed = info.basic_info.speed +// +// return trafficData +// } +// +// /** +// * OBU RSU道路事件预警信息 转换交通元素数据 +// */ +// fun cvxRtiThreatIndInfo2TrafficData(info: CvxRtiThreatIndInfo): TrafficData? { +// // 这里只处理道路施工 +// if(info.ext_info.rti_type != 0x7){ +// return null +// } +// if (info.rti_id == null || info.ext_info == null +// || info.zones_info == null || info.zones_info.first() == null +// || info.zones_info.first().path_points.first() == null +// || info.threat_info == null +// ) { +// CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") +// return null +// } +// val trafficData = TrafficData() +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG +// trafficData.uuid = info.rti_id +// +// trafficData.lat = info.zones_info.first().path_points.first().latitude +// trafficData.lon = info.zones_info.first().path_points.first().longitude +// +// trafficData.threatLevel = info.threat_info.threat_level +// +// return trafficData +// } +// +// /** +// * OBU 预警事件 转换交通元素数据 +// */ +// fun cvxV2vThreatIndInfo2TrafficData(info: CvxV2vThreatIndInfo): TrafficData? { +// if (info.basic_info == null || info.basic_info.position == null || info.threat_info == null) { +// CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") +// return null +// } +// val trafficData = TrafficData() +// trafficData.uuid = info.vehicle_id +// trafficData.lat = info.basic_info.position.latitude +// trafficData.lon = info.basic_info.position.longitude +// trafficData.heading = info.basic_info.heading +// trafficData.speed = info.basic_info.speed +// // 判断车辆V2X预警级别,调整车辆颜色 +// trafficData.threatLevel = info.threat_info.threat_level +// +// if (info.threat_info.app_id == ObuConstants.USE_CASE_ID.EVW) { +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE +// } else { +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE +// } +// +// return trafficData +// } +// +// /** +// * OBU 弱势交通参与者信息 转换交通元素数据 TODO +// */ +// fun cvxPtcThreatIndInfo2TrafficData(info: CvxPtcThreatIndInfo): TrafficData? { +// if (info.ptc_pos == null || info.threat_info == null) { +// CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") +// return null +// } +// val trafficData = TrafficData() +// +// trafficData.uuid = info.ptc_id +// trafficData.lat = info.ptc_pos.latitude +// trafficData.lon = info.ptc_pos.longitude +//// trafficData.heading = info.ptc_pos.heading +//// trafficData.speed = info.ptc_pos.speed +// +// when (info.ptc_type) { +// // 未知 +// 0x0 -> { +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI +// } +// // 非机动车 +// 0x1 -> { +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO +// } +// // 行人 +// 0x2 -> { +// trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE +// } +// } +// +// // 判断车辆V2X预警级别,调整车辆颜色 +// if (info.threat_info != null) { +// trafficData.threatLevel = info.threat_info.threat_level +// } +// +// return trafficData +// } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtilsNew.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtilsNew.kt new file mode 100644 index 0000000000..ff87cc41a8 --- /dev/null +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/utils/TrafficDataConvertUtilsNew.kt @@ -0,0 +1,117 @@ +package com.mogo.eagle.core.function.obu.mogo.utils + +import com.mogo.eagle.core.data.enums.TrafficTypeEnum +import com.mogo.eagle.core.data.traffic.TrafficData +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU +import com.mogo.support.obu.model.MogoObuRsiWarningData +import com.mogo.support.obu.model.MogoObuRsmWarningData +import com.mogo.support.obu.model.MogoObuRvWarningData + +/** + * @description 自研obu数据转换 + * + * @author lixiaopeng + * @since 2022/8/24 + */ +object TrafficDataConvertUtilsNew { + val TAG = "TrafficDataConvertUtilsNew" + + /** + * OBU 远车 转换交通元素数据 + */ + fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? { + if (info.vehBasicsMsg == 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.toDouble() + trafficData.lon = info.vehBasicsMsg.longitude.toDouble() + trafficData.heading = info.vehBasicsMsg.heading.toDouble() + trafficData.speed = info.vehBasicsMsg.speed.toDouble() + + return trafficData + } + + /** + * OBU RSU道路事件预警信息 转换交通元素数据 标牌 为何要显示level + */ + fun cvxRtiThreatIndInfo2TrafficData(info: MogoObuRsiWarningData): TrafficData? { + if (info.warning_Msg == null || info.warning_Msg.size < 1 || info.warning_Msg[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 = "0" //是否需要 TODO + trafficData.lat = info.warning_Msg[0].position.latitude.toDouble() + trafficData.lon = info.warning_Msg[0].position.longitude.toDouble() + trafficData.threatLevel = info.warning_Msg[0].warningLevel + + return trafficData + } + + /** + * OBU 预警事件 转换交通元素数据 他车预警 + */ + fun cvxV2vThreatIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? { + if (info == null || info.vehBasicsMsg == null || info.warningMsg == null || info.warningMsg.warningData == null) { + CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") + return null + } + val trafficData = TrafficData() + trafficData.uuid = info.vehBasicsMsg.id + trafficData.lat = info.vehBasicsMsg.latitude.toDouble() + trafficData.lon = info.vehBasicsMsg.longitude.toDouble() + trafficData.heading = info.vehBasicsMsg.heading.toDouble() + trafficData.speed = info.vehBasicsMsg.speed.toDouble() + // 判断车辆V2X预警级别,调整车辆颜色 + trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel + + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE + + return trafficData + } + + /** + * OBU 弱势交通参与者信息 转换交通元素数据 + */ + fun cvxPtcThreatIndInfo2TrafficData(info: MogoObuRsmWarningData): TrafficData? { + if (info.participant == null) { + CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全") + return null + } + val trafficData = TrafficData() + trafficData.uuid = info.participant.ptcId.toString() + trafficData.lat = info.participant.latitude.toDouble() + trafficData.lon = info.participant.longitude.toDouble() + trafficData.heading = info.participant.heading.toDouble() + trafficData.speed = info.participant.speed.toDouble() + + when (info.participant.ptcType) { + // 未知 + 0x0 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI + } + // 非机动车 + 0x1 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO + } + // 行人 + 0x2 -> { + trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE + } + } + + // 判断车辆V2X预警级别,调整车辆颜色 + if (info.m_warning_msg != null && info.m_warning_msg.warningData != null) { + trafficData.threatLevel = info.m_warning_msg.warningData[0].warningLevel + } + + return trafficData + } + +} \ No newline at end of file diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CommonUtils.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CommonUtils.java index 28f7abfc8f..d5b944f02e 100644 --- a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CommonUtils.java +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/CommonUtils.java @@ -398,7 +398,7 @@ public class CommonUtils { } // 获取本地IP函数 - private static String getLocalIPAddress() { + public static String getLocalIPAddress() { try { Enumeration mEnumeration = NetworkInterface.getNetworkInterfaces(); if (mEnumeration != null) { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt index b491c152dc..ff14933f95 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/enums/EventTypeEnum.kt @@ -2,7 +2,7 @@ package com.mogo.module.common.enums import com.mogo.module.common.R import com.mogo.module.common.utils.CloudPoiManager -import com.zhidao.support.obu.constants.ObuConstants +import com.mogo.support.obu.constants.MogoObuConstants /** * OBU、V2N事件类型枚举类 @@ -16,20 +16,20 @@ enum class EventTypeEnum( //交通检查 TRAFFIC_CHECK( - "10002", "交通检查", "前方交通检查", - R.drawable.v2x_icon_jiaotongjiancha_vr, "前方交通检查", "交通检查" + "10002", "交通检查", "前方交通检查", + R.drawable.v2x_icon_jiaotongjiancha_vr, "前方交通检查", "交通检查" ), //封路 ROAD_CLOSED( - "10003", "封路", "前方封路", R.drawable.v2x_icon_fenglu_vr, - "前方封路", "道路封路" + "10003", "封路", "前方封路", R.drawable.v2x_icon_fenglu_vr, + "前方封路", "道路封路" ), //施工 FOURS_ROAD_WORK( - "10006", "道路施工", "前方施工", R.drawable.icon_warning_v2x_road_construction, - "前方施工", "道路施工" + "10006", "注意施工占道", "注意施工占道", R.drawable.icon_warning_v2x_road_construction, + "注意施工占道", "注意施工占道" ), //施工-AI云下发 @@ -40,62 +40,62 @@ enum class EventTypeEnum( //拥堵 FOURS_BLOCK_UP( - "10007", "道路拥堵", "前方拥堵", R.drawable.icon_warning_v2x_congestion, - "前方道路拥堵", "道路拥堵" + "10007", "道路拥堵", "前方拥堵", R.drawable.icon_warning_v2x_congestion, + "前方道路拥堵", "道路拥堵" ), //积水 FOURS_PONDING( - "10008", "道路积水", "前方道路积水", R.drawable.v2x_icon_jishui_vr, - "前方道路积水", "道路积水" + "10008", "道路积水", "前方道路积水", R.drawable.v2x_icon_jishui_vr, + "前方道路积水", "道路积水" ), //浓雾 FOURS_FOG( - "10010", "出现浓雾", "浓雾预警", R.drawable.v2x_icon_nongwu_vr, - "前方出现浓雾", "出现浓雾" + "10010", "出现浓雾", "浓雾预警", R.drawable.v2x_icon_nongwu_vr, + "前方出现浓雾", "出现浓雾" ), //结冰 FOURS_ICE( - "10011", "路面结冰", "路面结冰", R.drawable.v2x_icon_jiebing_vr, - "前方路面结冰", "路面结冰" + "10011", "路面结冰", "路面结冰", R.drawable.v2x_icon_jiebing_vr, + "前方路面结冰", "路面结冰" ), //事故 FOURS_ACCIDENT( - "10013", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "10013", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //重大事故 FOURS_ACCIDENT_01( - "1001301", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "1001301", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //特大事故 FOURS_ACCIDENT_02( - "1001302", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "1001302", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //较大事故 FOURS_ACCIDENT_03( - "1001303", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "1001303", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //一般事故 FOURS_ACCIDENT_04( - "1001304", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "1001304", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //轻微事故 FOURS_ACCIDENT_05( - "1001305", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, - "前方交通事故", "交通事故" + "1001305", "交通事故", "前方交通事故", R.drawable.v2x_icon_jiaotongshigu_vr, + "前方交通事故", "交通事故" ), //实时路况 @@ -133,228 +133,247 @@ enum class EventTypeEnum( ALERT_ILLEGAL_PARK("99992"), TYPE_USECASE_ID_EBW( - ObuConstants.USE_CASE_ID.EBW.toString(), - "紧急制动预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_emergency_brake, - content = "前车急刹车", - tts = "前车急刹车" + MogoObuConstants.V2X_WARNING_TYPE.EBW.toString(), + "紧急制动预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_emergency_brake, + content = "前车急刹车", + tts = "前车急刹车" ), TYPE_USECASE_ID_FCW( - ObuConstants.USE_CASE_ID.FCW.toString(), - "前向碰撞预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, - content = "前车碰撞预警", - tts = "小心前车" + MogoObuConstants.V2X_WARNING_TYPE.FCW.toString(), + "前向碰撞预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, + content = "前车碰撞预警", + tts = "小心前车" ), TYPE_USECASE_ID_ICW( - ObuConstants.USE_CASE_ID.ICW.toString(), - "交叉路口碰撞预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, - content = "交叉路口碰撞预警", - tts = "注意交叉路口车辆" - ), - TYPE_USECASE_ID_CLW( - ObuConstants.USE_CASE_ID.CLW.toString(), - "车辆失控预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_vehicle_control, - content = "前%s失控预警", - tts = "小心%s失控车辆" - ), - TYPE_USECASE_ID_DNPW( - ObuConstants.USE_CASE_ID.DNPW.toString(), - "逆向超车预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_reverse_overtaking, - content = "逆向超车预警", - tts = "注意对向来车" + MogoObuConstants.V2X_WARNING_TYPE.ICW.toString(), + "交叉路口碰撞预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, + content = "交叉路口碰撞预警", + tts = "注意交叉路口车辆" ), TYPE_USECASE_ID_AVW( - ObuConstants.USE_CASE_ID.AVW.toString(), - "异常车辆提醒", - poiTypeSrcVr = R.drawable.icon_warning_v2x_abnormal_vehicle, - content = "%s车异常", - tts = "小心%s异常车辆" + MogoObuConstants.V2X_WARNING_TYPE.AVW.toString(), + "异常车辆提醒", + poiTypeSrcVr = R.drawable.icon_warning_v2x_abnormal_vehicle, + content = "%s车异常", + tts = "小心%s异常车辆" ), TYPE_USECASE_ID_BSW( - ObuConstants.USE_CASE_ID.BSW.toString(), - "盲区预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_blind_area_collision, - content = "%s后盲区预警", - tts = "注意%s后车辆" + MogoObuConstants.V2X_WARNING_TYPE.BSW.toString(), + "盲区预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_blind_area_collision, + content = "%s后盲区预警", + tts = "注意%s后车辆" ), TYPE_USECASE_ID_LCW( - ObuConstants.USE_CASE_ID.LCW.toString(), - "变道预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_reverse_overtaking, - content = "%s向变道预警", - tts = "注意%s后车辆" + MogoObuConstants.V2X_WARNING_TYPE.LCW.toString(), + "变道预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_reverse_overtaking, + content = "%s向变道预警", + tts = "注意%s后车辆" ),//注意左后车辆/注意右后车辆 TYPE_USECASE_ID_EVW( - ObuConstants.USE_CASE_ID.EVW.toString(), - "紧急车辆提醒", - poiTypeSrcVr = R.drawable.icon_warning_v2x_special_vehicle_access, - content = "注意特种车辆通行", - tts = "请避让特种车辆" + MogoObuConstants.V2X_WARNING_TYPE.EVW.toString(), + "紧急车辆提醒", + poiTypeSrcVr = R.drawable.icon_warning_v2x_special_vehicle_access, + content = "注意特种车辆通行", + tts = "请避让特种车辆" ), + TYPE_USECASE_ID_CLW( + MogoObuConstants.V2X_WARNING_TYPE.CLW.toString(), + "车辆失控预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_vehicle_control, + content = "前%s失控预警", + tts = "小心%s失控车辆" + ), + TYPE_USECASE_ID_DNPW( + MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString(), + "逆向超车预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_reverse_overtaking, + content = "逆向超车预警", + tts = "注意对向来车" + ), + + //TODO TYPE_USECASE_ID_VRUCW_PERSON( - 0X2B0201.toString(), - "弱势交通参与者碰撞预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_pedestrian_crossing, - content = "注意行人", - tts = "注意行人" + 0X2B0201.toString(), + "弱势交通参与者碰撞预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_pedestrian_crossing, + content = "注意行人", + tts = "注意行人" ),//行人/摩托车碰撞预警 TYPE_USECASE_ID_VRUCW_MOTORBIKE( - 0X2B0202.toString(), - "弱势交通参与者碰撞预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_motorcycle_collision, - content = "注意摩托车", - tts = "注意摩托车" + 0X2B0202.toString(), + "弱势交通参与者碰撞预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_motorcycle_collision, + content = "注意摩托车", + tts = "注意摩托车" ),//摩托车碰撞预警 - TYPE_USECASE_ID_SLW( - ObuConstants.USE_CASE_ID.SLW.toString(), - "限速预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_over_speed, - content = "已超速", - tts = "已超速" - ), TYPE_USECASE_ID_LTA( - ObuConstants.USE_CASE_ID.LTA.toString(), - "左转辅助", - poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, - content = "左转碰撞预警", - tts = "注意路口对向来车" + MogoObuConstants.V2X_WARNING_TYPE.LTA.toString(), + "左转辅助", + poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, + content = "左转碰撞预警", + tts = "注意路口对向来车" ), - TYPE_USECASE_ID_HLW( - ObuConstants.USE_CASE_ID.HLW.toString(), - "道路危险情况预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_road_dangerous, - content = "道路危险情况预警", - tts = "前方路况危险,小心行驶" - ),//(如果能给出具体的类别,则播报具体危险类别) + + TYPE_USECASE_ID_IVS( + MogoObuConstants.RSI_SCENE_TYPE.IVS.toString(), + "车内标牌", + poiTypeSrcVr = R.drawable.icon_warning_v2x_road_construction, + content = "车内标牌", + tts = "" + ), + TYPE_USECASE_ID_TJW( + MogoObuConstants.RSI_SCENE_TYPE.TJW.toString(), + "前方拥堵提醒", + poiTypeSrcVr = R.drawable.icon_warning_v2x_congestion, + content = "前方%d米道路拥堵", + tts = "前方拥堵,减速慢行" + ), + + //TODO 不能使用之前obu的定义 ObuConstants.USE_CASE_ID.HLW.toString(), TYPE_USECASE_OPTIMAL_LANE( - ObuConstants.USE_CASE_ID.HLW.toString(), + "111", "最优车道", poiTypeSrcVr = R.drawable.v2x_icon_live_logo, content = "最优车道", tts = "最优车道" ), - TYPE_USECASE_ID_IVS( - ObuConstants.USE_CASE_ID.IVS.toString(), - "车内标牌", - poiTypeSrcVr = R.drawable.icon_warning_v2x_road_construction, - content = "车内标牌", - tts = "" - ), - TYPE_USECASE_ID_TJW( - ObuConstants.USE_CASE_ID.TJW.toString(), - "前方拥堵提醒", - poiTypeSrcVr = R.drawable.icon_warning_v2x_congestion, - content = "前方%d米道路拥堵", - tts = "前方拥堵,减速慢行" - ), + +// TYPE_USECASE_ID_HLW( +// ObuConstants.USE_CASE_ID.HLW.toString(), +// "道路危险情况预警", +// poiTypeSrcVr = R.drawable.icon_warning_v2x_road_dangerous, +// content = "道路危险情况预警", +// tts = "前方路况危险,小心行驶" +// ),//(如果能给出具体的类别,则播报具体危险类别) + TYPE_USECASE_ID_IVP( - ObuConstants.USE_CASE_ID.IVP.toString(), - "闯红灯预警", - poiTypeSrcVr = R.drawable.icon_warning_v2x_traffic_lights_red, - content = "路口红灯,禁止通行", - tts = "路口红灯,禁止通行" + 0x2.toString(), + "闯红灯预警", + poiTypeSrcVr = R.drawable.icon_warning_v2x_traffic_lights_red, + content = "路口红灯,禁止通行", + tts = "路口红灯,禁止通行" ), TYPE_USECASE_ID_IVP_GREEN( - 0x2B091.toString(), - "绿波通行", - poiTypeSrcVr = R.drawable.icon_warning_v2x_traffic_lights_green, - content = "建议车速 %s KM/H", - tts = "建议车速 %s KM/H" + 0x2B091.toString(), + "绿波通行", + poiTypeSrcVr = R.drawable.icon_warning_v2x_traffic_lights_green, + content = "建议车速 %s KM/H", + tts = "建议车速 %s KM/H" ), - TYPE_USECASE_ID_COC( - ObuConstants.USE_CASE_ID.COC.toString(), - "预留", - poiTypeSrcVr = R.drawable.icon_warning_v2x_abnormal_vehicle, - content = "路况预警", - tts = "路况预警" + + //6种智行杯的场景需添加 TODO + TYPE_USECASE_ID_SLW( + "", + "注意超速车辆", + poiTypeSrcVr = R.drawable.icon_warning_v2x_over_speed, + content = "注意超速车辆", + tts = "注意超速车辆" ), + + TYPE_USECASE_ID_BREAKDOWN_WARNING( + "", + "注意故障车辆", + poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, + content = "注意故障车辆", + tts = "注意故障车辆" + ), + + TYPE_USECASE_ID_ROAD_PARKING( + 0x2C10.toString(), + "注意异常停车", + poiTypeSrcVr = R.drawable.icon_warning_v2x_no_parking, + content = "注意异常停车", + tts = "注意异常停车" + ), + + TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE( + 0x2C12.toString(), + "注意逆行车辆", + poiTypeSrcVr = R.drawable.icon_warning_v2x_school, + content = "注意逆行车辆", + tts = "注意逆行车辆" + ), + + TYPE_USECASE_ID_ROAD_BUS_HINT( + 0x2C13.toString(), + "注意公交车站", + poiTypeSrcVr = R.drawable.icon_warning_v2x_school, + content = "注意公交车站", + tts = "注意公交车站" + ), + + //施工占道 + + TYPE_USECASE_ID_ROAD_TRAMCAR( - 0x2C01.toString(), - "前方有轨电车提醒", - poiTypeSrcVr = R.drawable.icon_warning_v2x_tramcar, - content = "注意前方有轨电车", - tts = "注意前方有轨电车驶过" - ), - TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP( - 0x2C02.toString(), - "前方左转急弯", - poiTypeSrcVr = R.drawable.icon_warning_v2x_turn_left_sharp, - content = "注意前方左转急弯", - tts = "前方路口左转急弯,减速慢行", - ), - TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP( - 0x2C03.toString(), - "前方右转急弯", - poiTypeSrcVr = R.drawable.icon_warning_v2x_turn_right_sharp, - content = "注意前方右转急弯", - tts = "前方路口右转急弯,减速慢行" + 0x2C01.toString(), + "前方有轨电车提醒", + poiTypeSrcVr = R.drawable.icon_warning_v2x_tramcar, + content = "注意前方有轨电车", + tts = "注意前方有轨电车驶过" ), + TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING( - 0x2C04.toString(), - "人行横道", - poiTypeSrcVr = R.drawable.icon_warning_v2x_pedestrian_crossing, - content = "注意前方人行横道", - tts = "前方人行横道,减速慢行" + 0x2C04.toString(), + "人行横道", + poiTypeSrcVr = R.drawable.icon_warning_v2x_pedestrian_crossing, + content = "注意前方人行横道", + tts = "前方人行横道,减速慢行" ), TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL( - 0x2C05.toString(), - "学校", - poiTypeSrcVr = R.drawable.icon_warning_v2x_school, - content = "注意前方学校", - tts = "前方学校,减速慢行" + 0x2C05.toString(), + "学校", + poiTypeSrcVr = R.drawable.icon_warning_v2x_school, + content = "注意前方学校", + tts = "前方学校,减速慢行" ), TYPE_USECASE_ID_ROAD_COLLISION_WARNING( - 0x2C06.toString(), - "事故易发路段", - poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, - content = "注意当前路段事故多发", - tts = "当前路段事故多发,请小心驾驶" + 0x2C06.toString(), + "事故易发路段", + poiTypeSrcVr = R.drawable.icon_warning_v2x_collision_warning, + content = "注意当前路段事故多发", + tts = "当前路段事故多发,请小心驾驶" ), TYPE_USECASE_ID_ROAD_ROUNDABOUTPNG( - 0x2C07.toString(), - "环岛行驶", - poiTypeSrcVr = R.drawable.icon_warning_v2x_roundaboutpng, - content = "注意前方驶入环岛", - tts = "即将驶入环岛,减速慢行" + 0x2C07.toString(), + "环岛行驶", + poiTypeSrcVr = R.drawable.icon_warning_v2x_roundaboutpng, + content = "注意前方驶入环岛", + tts = "即将驶入环岛,减速慢行" ), TYPE_USECASE_ID_ROAD_TEST_SECTION( - 0x2C08.toString(), - "驾校考试路段", - poiTypeSrcVr = R.drawable.icon_warning_v2x_test_section, - content = "注意前方驾校考试路段", - tts = "驾校考试路段,请小心驾驶" + 0x2C08.toString(), + "驾校考试路段", + poiTypeSrcVr = R.drawable.icon_warning_v2x_test_section, + content = "注意前方驾校考试路段", + tts = "驾校考试路段,请小心驾驶" ), TYPE_USECASE_ID_ROAD_HUMP_BRIDGE( - 0x2C09.toString(), - "驼峰桥", - poiTypeSrcVr = R.drawable.icon_warning_v2x_hump_bridge, - content = "注意前方驼峰桥", - tts = "注意即将驶入驼峰桥,请小心驾驶" + 0x2C09.toString(), + "驼峰桥", + poiTypeSrcVr = R.drawable.icon_warning_v2x_hump_bridge, + content = "注意前方驼峰桥", + tts = "注意即将驶入驼峰桥,请小心驾驶" ), TYPE_USECASE_ID_ROAD_NO_PARKING( - 0x2C10.toString(), - "禁止停车", - poiTypeSrcVr = R.drawable.icon_warning_v2x_no_parking, - content = "注意当前路段禁止停车", - tts = "当前路段,禁止停车" - ), - TYPE_USECASE_ID_ROAD_GIVE_WAY( - 0x2C11.toString(), - "减速慢行", - poiTypeSrcVr = R.drawable.icon_warning_v2x_give_way, - content = "注意路况复杂,减速慢行", - tts = "路况复杂,减速慢行" + 0x2C10.toString(), + "禁止停车", + poiTypeSrcVr = R.drawable.icon_warning_v2x_no_parking, + content = "注意当前路段禁止停车", + tts = "当前路段,禁止停车" ), + TYPE_ERROR( - ObuConstants.USE_CASE_ID.ERROR.toString(), - "未知/错误/异常", - poiTypeSrcVr = R.drawable.icon_warning_v2x_abnormal_vehicle, - content = "", - tts = "" + MogoObuConstants.RSI_SCENE_TYPE.INVALID.toString(), + "未知/错误/异常", + poiTypeSrcVr = R.drawable.icon_warning_v2x_abnormal_vehicle, + content = "", + tts = "" ), TYPE_VIP_IDENTIFICATION("10022", "", "", R.drawable.icon_warning_v2x_vip_turn_light, "VIP车辆优先通行", "已为您变灯,请优先通行"), @@ -721,15 +740,15 @@ enum class EventTypeEnum( TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType -> TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiTypeSrcVr TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.poiTypeSrcVr TYPE_USECASE_ID_LTA.poiType -> TYPE_USECASE_ID_LTA.poiTypeSrcVr - TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.poiTypeSrcVr +// TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.poiTypeSrcVr TYPE_USECASE_ID_IVS.poiType -> TYPE_USECASE_ID_IVS.poiTypeSrcVr TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.poiTypeSrcVr TYPE_USECASE_ID_IVP.poiType -> TYPE_USECASE_ID_IVP.poiTypeSrcVr TYPE_USECASE_ID_IVP_GREEN.poiType -> TYPE_USECASE_ID_IVP_GREEN.poiTypeSrcVr - TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.poiTypeSrcVr +// TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.poiTypeSrcVr TYPE_USECASE_ID_ROAD_TRAMCAR.poiType -> TYPE_USECASE_ID_ROAD_TRAMCAR.poiTypeSrcVr - TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiTypeSrcVr - TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiTypeSrcVr +// TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiTypeSrcVr +// TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiTypeSrcVr TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiTypeSrcVr TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiTypeSrcVr TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType -> TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiTypeSrcVr @@ -737,7 +756,7 @@ enum class EventTypeEnum( TYPE_USECASE_ID_ROAD_TEST_SECTION.poiType -> TYPE_USECASE_ID_ROAD_TEST_SECTION.poiTypeSrcVr TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType -> TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiTypeSrcVr TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.poiTypeSrcVr - TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.poiTypeSrcVr +// TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.poiTypeSrcVr TYPE_VIP_IDENTIFICATION.poiType -> TYPE_VIP_IDENTIFICATION.poiTypeSrcVr TYPE_ERROR.poiType -> TYPE_ERROR.poiTypeSrcVr TYPE_OPTIMAL_ROUTE_RECOMMEND.poiType -> TYPE_OPTIMAL_ROUTE_RECOMMEND.poiTypeSrcVr @@ -763,15 +782,15 @@ enum class EventTypeEnum( TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType -> TYPE_USECASE_ID_VRUCW_MOTORBIKE.content TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.content TYPE_USECASE_ID_LTA.poiType -> TYPE_USECASE_ID_LTA.content - TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.content +// TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.content TYPE_USECASE_ID_IVS.poiType -> TYPE_USECASE_ID_IVS.content TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.content TYPE_USECASE_ID_IVP.poiType -> TYPE_USECASE_ID_IVP.content TYPE_USECASE_ID_IVP_GREEN.poiType -> TYPE_USECASE_ID_IVP_GREEN.content - TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.content +// TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.content TYPE_USECASE_ID_ROAD_TRAMCAR.poiType -> TYPE_USECASE_ID_ROAD_TRAMCAR.content - TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.content - TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.content +// TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.content +// TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.content TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.content TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.content TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType -> TYPE_USECASE_ID_ROAD_COLLISION_WARNING.content @@ -779,7 +798,7 @@ enum class EventTypeEnum( TYPE_USECASE_ID_ROAD_TEST_SECTION.poiType -> TYPE_USECASE_ID_ROAD_TEST_SECTION.content TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType -> TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.content TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.content - TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.content +// TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.content TYPE_VIP_IDENTIFICATION.poiType -> TYPE_VIP_IDENTIFICATION.content FOURS_ROAD_WORK.poiType -> FOURS_ROAD_WORK.content AI_ROAD_WORK.poiType -> AI_ROAD_WORK.content @@ -806,15 +825,15 @@ enum class EventTypeEnum( TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType -> TYPE_USECASE_ID_VRUCW_MOTORBIKE.tts TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.tts TYPE_USECASE_ID_LTA.poiType -> TYPE_USECASE_ID_LTA.tts - TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.tts +// TYPE_USECASE_ID_HLW.poiType -> TYPE_USECASE_ID_HLW.tts //TODO TYPE_USECASE_ID_IVS.poiType -> TYPE_USECASE_ID_IVS.tts TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.tts TYPE_USECASE_ID_IVP.poiType -> TYPE_USECASE_ID_IVP.tts TYPE_USECASE_ID_IVP_GREEN.poiType -> TYPE_USECASE_ID_IVP_GREEN.tts - TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.tts +// TYPE_USECASE_ID_COC.poiType -> TYPE_USECASE_ID_COC.tts TYPE_USECASE_ID_ROAD_TRAMCAR.poiType -> TYPE_USECASE_ID_ROAD_TRAMCAR.tts - TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.tts - TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.tts +// TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.tts +// TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType -> TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.tts TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.tts TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.tts TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType -> TYPE_USECASE_ID_ROAD_COLLISION_WARNING.tts @@ -822,7 +841,7 @@ enum class EventTypeEnum( TYPE_USECASE_ID_ROAD_TEST_SECTION.poiType -> TYPE_USECASE_ID_ROAD_TEST_SECTION.tts TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType -> TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.tts TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.tts - TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.tts +// TYPE_USECASE_ID_ROAD_GIVE_WAY.poiType -> TYPE_USECASE_ID_ROAD_GIVE_WAY.tts TYPE_VIP_IDENTIFICATION.poiType -> TYPE_VIP_IDENTIFICATION.tts FOURS_ROAD_WORK.poiType -> FOURS_ROAD_WORK.tts AI_ROAD_WORK.poiType -> AI_ROAD_WORK.tts @@ -833,4 +852,5 @@ enum class EventTypeEnum( } } } + } \ No newline at end of file