From 7992613d729a6c672c2eb895691aed36ba3c49a3 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Thu, 2 Feb 2023 23:28:47 +0800 Subject: [PATCH 01/10] opt trafic light --- .../datacenter/obu/MogoObuDcCombineManager.kt | 14 +- .../obu/MogoPrivateObuNewManager.kt | 757 +++++++++--------- 2 files changed, 365 insertions(+), 406 deletions(-) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt index ac8b07b2ff..de0079b86c 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoObuDcCombineManager.kt @@ -538,8 +538,6 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener } } - private var isRedLight = false - private var isGreenLight = false private var isShowGreenWave = false private var isShowRunRedLight = false @@ -662,11 +660,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener } // 红灯 - 2, 3 -> { //todo 小鹏 - if (!isRedLight) { - isRedLight = true - } - isGreenLight = false + 2, 3 -> { CallerTrafficLightListenerManager.showTrafficLight( TrafficLightEnum.RED, DataSourceType.TELEMATIC @@ -676,11 +670,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener } // 绿灯 - 4, 5, 6 -> { //todo 小鹏 - if (!isGreenLight) { - isGreenLight = true - } - isRedLight = false + 4, 5, 6 -> { CallerTrafficLightListenerManager.showTrafficLight( TrafficLightEnum.GREEN, DataSourceType.TELEMATIC diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 7d75b06c6c..7781bab8d8 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -635,382 +635,322 @@ class MogoPrivateObuNewManager private constructor() { } } -} + } -/** - * 获取消息的方位 车辆相关 - */ -private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { - // CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification") - return when (targetClassification) { - MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE, - MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 + /** + * 获取消息的方位 车辆相关 + */ + private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { + // CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification") + return when (targetClassification) { + MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE, + MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 - MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 + MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方 - MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 + MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方 - MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方 + 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_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.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_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.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT, + -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方 - MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 - else -> WarningDirectionEnum.ALERT_WARNING_ALL - } -} - -/** - * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 - * - * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截 - * - * @see com.mogo.module.common.enums.EventTypeEnum - */ -private fun handleSdkObu( - appId: String, - direction: WarningDirectionEnum, - status: Int, - level: Int, - info: MogoObuRvWarningData -) { - // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 - var alertContent: String = "" - var ttsContent: String = "" - var changeVisualAngle = false - when (appId) { - //交叉路口碰撞预警 - MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) - } - - //交叉路口碰撞预警 - MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) - } - - //左转辅助预警 - MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) - } - - //盲区预警 - MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> { - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) - if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT - ) { //左后 - changeVisualAngle = true - ttsContent = String.format(ttsContent, "左") - alertContent = String.format(alertContent, "左") - } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT - ) { //右后 - changeVisualAngle = true - ttsContent = String.format(ttsContent, "右") - alertContent = String.format(alertContent, "右") - } - } - - // 变道预警,注意左后车辆/注意右后车辆 - MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) - if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT - ) { - ttsContent = String.format(ttsContent, "左") - alertContent = String.format(alertContent, "左") - } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT - ) { - ttsContent = String.format(ttsContent, "右") - alertContent = String.format(alertContent, "右") - } - } - - //逆向超车预警 - MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) - } - - //紧急制动预警 - MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) - } - - //异常车辆提醒 - MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - - //车辆失控预警 - MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) - alertContent = String.format(alertContent, direction.desc) - ttsContent = String.format(ttsContent, direction.desc) - } - //车辆失控预警 - MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> { - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) - } - - // 这里处理固定的提示信息,包括了<紧急车辆提醒> - else -> { //TODO -// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString()) -// alertContent = EventTypeEnumNew.getWarningContent(appId.toString()) + MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知 + else -> WarningDirectionEnum.ALERT_WARNING_ALL } } - when (status) { - // 添加,更新 add的时候,可能级别是2, - MogoObuConstants.STATUS.ADD, - MogoObuConstants.STATUS.UPDATE -> { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" - ) - if (level == 2 || level == 3) { - //不显示弹框,其它保留 - CallerMsgBoxManager.saveMsgBox( - MsgBoxBean( - MsgBoxType.V2X, - V2XMsg( - appId, - alertContent, - ttsContent - ) - ).apply { - sourceType = DataSourceType.OBU - } - ) - CallerHmiManager.warningV2X( - appId, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - object : IMoGoWarningStatusListener { - override fun onShow() { - super.onShow() - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(TooClose) - } - } - - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) - if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(Default()) - } - } - } - ) - //显示警告红边 - CallerHmiManager.showWarning(direction) + /** + * 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示 + * + * @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截 + * + * @see com.mogo.module.common.enums.EventTypeEnum + */ + private fun handleSdkObu( + appId: String, + direction: WarningDirectionEnum, + status: Int, + level: Int, + info: MogoObuRvWarningData + ) { + // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 + var alertContent: String = "" + var ttsContent: String = "" + var changeVisualAngle = false + when (appId) { + //交叉路口碰撞预警 + MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) } - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了 - TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) + + //交叉路口碰撞预警 + MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + } + + //左转辅助预警 + MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + } + + //盲区预警 + MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> { + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + if ( + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + ) { //左后 + changeVisualAngle = true + ttsContent = String.format(ttsContent, "左") + alertContent = String.format(alertContent, "左") + } else if ( + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + ) { //右后 + changeVisualAngle = true + ttsContent = String.format(ttsContent, "右") + alertContent = String.format(alertContent, "右") + } + } + + // 变道预警,注意左后车辆/注意右后车辆 + MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) + if ( + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + ) { + ttsContent = String.format(ttsContent, "左") + alertContent = String.format(alertContent, "左") + } else if ( + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + ) { + ttsContent = String.format(ttsContent, "右") + alertContent = String.format(alertContent, "右") + } + } + + //逆向超车预警 + MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + } + + //紧急制动预警 + MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + } + + //异常车辆提醒 + MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } + + //车辆失控预警 + MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) + alertContent = String.format(alertContent, direction.desc) + ttsContent = String.format(ttsContent, direction.desc) + } + //车辆失控预警 + MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> { + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + } + + // 这里处理固定的提示信息,包括了<紧急车辆提醒> + else -> { //TODO + // ttsContent = EventTypeEnumNew.getWarningTts(appId.toString()) + // alertContent = EventTypeEnumNew.getWarningContent(appId.toString()) } } - // 删除 - MogoObuConstants.STATUS.DELETE -> { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - // 移除顶部弹窗 - // CallerHmiManager.disableWarningV2X((appId + direction.direction)) - //更新周边车辆进行预警颜色变换,车辆实时移动和变色 - TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { - it.threatLevel = 0x01 - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) - } - } - } -} -/** - * 处理红绿灯 - */ -private fun handlerTrafficLight(appId: Int, status: Int, lights: List) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId" - ) - when (status) { - // 添加 - MogoObuConstants.STATUS.ADD, - MogoObuConstants.STATUS.UPDATE - -> { - if (lights != null && lights.isNotEmpty()) { - changeTrafficLightStatus(appId, lights) - } - } - // 删除 - MogoObuConstants.STATUS.DELETE -> { - // 移除顶部弹窗 - CallerTrafficLightListenerManager.disableTrafficLight() - isShowGreenWave = false - isShowRunRedLight = false - isYellowLight = false -// lightCountDownRed = 1 -// lightCountDownGreen = 1 -// lightCountDownYellow = 1 - } - } -} - -private var isRedLight = false -private var isGreenLight = false -private var isYellowLight = false -private var isShowGreenWave = false -private var isShowRunRedLight = false - -// private var lightCountDownRed : Int = 1 -// private var lightCountDownGreen : Int = 1 -// private var lightCountDownYellow : Int = 1 - - -/** - * 修改红绿灯 - */ -@Synchronized -private fun changeTrafficLightStatus( - appId: Int, - lights: List -) { - var ttsContent = "" - var alertContent = "" - //这里需要根据真实数据确定 index 取值方式 - val currentLight = lights[0] - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}" - ) - // 闯红灯预警,绿波通行和闯红灯是互斥的 - when (appId) { - 0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效 - - } - 1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次 - if (!isShowRunRedLight) { - isShowRunRedLight = true + when (status) { + // 添加,更新 add的时候,可能级别是2, + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE -> { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "changeTrafficLightStatus 闯红灯 --------> " + "new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" ) - ttsContent = - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) - alertContent = - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) - CallerMsgBoxManager.saveMsgBox( - MsgBoxBean( - MsgBoxType.V2X, - V2XMsg( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, - alertContent, - ttsContent - ) - ).apply { - sourceType = DataSourceType.OBU - } - ) - - CallerHmiManager.warningV2X( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, - alertContent, - ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 - ) - } - } - - 2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候 - if (!isShowGreenWave) { - isShowGreenWave = true - - var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6) - var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6) - if (minSpeedTemp == maxSpeedTemp) { - minSpeedTemp -= 5 - } - - val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp" - val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp" - -// val adviceSpeed = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} - ${Math.round(currentLight.suggestMaxSpeed*3.6)}" -// val adviceSpeedTts = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} 到 ${Math.round(currentLight.suggestMaxSpeed*3.6)}" - - ttsContent = - String.format( - EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeedTts - ) - alertContent = - String.format( - EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeed - ) - - val maxSpeed = currentLight.suggestMaxSpeed - if (maxSpeed > 0) { + if (level == 2 || level == 3) { + //不显示弹框,其它保留 CallerMsgBoxManager.saveMsgBox( MsgBoxBean( MsgBoxType.V2X, V2XMsg( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + appId, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.OBU + } + ) + CallerHmiManager.warningV2X( + appId, + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + object : IMoGoWarningStatusListener { + override fun onShow() { + super.onShow() + if (changeVisualAngle) { + CallerVisualAngleManager.changeVisualAngle(TooClose) + } + } + + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) + if (changeVisualAngle) { + CallerVisualAngleManager.changeVisualAngle(Default()) + } + } + } + ) + //显示警告红边 + CallerHmiManager.showWarning(direction) + } + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + // 移除顶部弹窗 + // CallerHmiManager.disableWarningV2X((appId + direction.direction)) + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 + TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let { + it.threatLevel = 0x01 + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + } + } + } + + /** + * 处理红绿灯 + */ + private fun handlerTrafficLight(appId: Int, status: Int, lights: List) { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId" + ) + when (status) { + // 添加 + MogoObuConstants.STATUS.ADD, + MogoObuConstants.STATUS.UPDATE + -> { + if (lights != null && lights.isNotEmpty()) { + changeTrafficLightStatus(appId, lights) + } + } + // 删除 + MogoObuConstants.STATUS.DELETE -> { + // 移除顶部弹窗 + CallerTrafficLightListenerManager.disableTrafficLight() + isShowGreenWave = false + isShowRunRedLight = false + } + } + } + + + private var isYellowLight = false + private var isShowGreenWave = false + private var isShowRunRedLight = false + + + + /** + * 修改红绿灯 + */ + @Synchronized + private fun changeTrafficLightStatus( + appId: Int, + lights: List + ) { + var ttsContent = "" + var alertContent = "" + //这里需要根据真实数据确定 index 取值方式 + val currentLight = lights[0] + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}" + ) + // 闯红灯预警,绿波通行和闯红灯是互斥的 + when (appId) { + 0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效 + + } + 1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次 + if (!isShowRunRedLight) { + isShowRunRedLight = true + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "changeTrafficLightStatus 闯红灯 --------> " + ) + ttsContent = + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + alertContent = + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType) + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent ) @@ -1020,51 +960,80 @@ private fun changeTrafficLightStatus( ) CallerHmiManager.warningV2X( - EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 ) } } + + 2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候 + if (!isShowGreenWave) { + isShowGreenWave = true + + var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6) + var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6) + if (minSpeedTemp == maxSpeedTemp) { + minSpeedTemp -= 5 + } + + val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp" + val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp" + + ttsContent = + String.format( + EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeedTts + ) + alertContent = + String.format( + EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeed + ) + + val maxSpeed = currentLight.suggestMaxSpeed + if (maxSpeed > 0) { + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.V2X, + V2XMsg( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent + ) + ).apply { + sourceType = DataSourceType.OBU + } + ) + + CallerHmiManager.warningV2X( + EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType, + alertContent, + ttsContent// 只有第一次才tts,防止更新的时候不断的提醒 + ) + } + } + } + } + + when (currentLight.light) { + // 灯光不可用 + 0 -> { + CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK) + } + // 红灯 + 2, 3 -> { + CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED) + } + + // 绿灯 + 4, 5, 6 -> { + CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN) + } + + // 黄灯 + 7, 8 -> { + CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW) + } } } - - when (currentLight.light) { - // 灯光不可用 - 0 -> { - CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK) - } - // 红灯 - 2, 3 -> { - if (!isRedLight) { //todo 小鹏 - isRedLight = true - } - isGreenLight = false - isYellowLight = false - CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED) - val red = currentLight.countDown.toInt() - } - - // 绿灯 - 4, 5, 6 -> { //todo 小鹏 - if (!isGreenLight) { - isGreenLight = true - } - isRedLight = false - isYellowLight = false - CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN) - val green = currentLight.countDown.toInt() - } - - // 黄灯 - 7, 8 -> { - if (!isYellowLight) { - isYellowLight = true - } - isRedLight = false - isGreenLight = false - CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW) - val yellow = currentLight.countDown.toInt() - } - } -} From 21d6c665f3982bb2d47103b7803bcce2032cdfa8 Mon Sep 17 00:00:00 2001 From: renwj Date: Fri, 3 Feb 2023 17:31:45 +0800 Subject: [PATCH 02/10] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0][leakfix]?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=B1=E4=BA=8E=E5=8C=BF=E5=90=8DRunnable?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E5=BC=95=E7=94=A8=E5=A4=96=E9=83=A8=E7=B1=BB?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E9=80=A0=E6=88=90=E7=9A=84=E5=86=85=E5=AD=98?= =?UTF-8?q?=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 3 + .../com/mogo/launcher/lancet/MemoryLeakFix.kt | 94 +++++++++++++++++++ build.gradle | 2 +- config.gradle | 2 +- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt diff --git a/app/build.gradle b/app/build.gradle index 71abf1ea14..e70a3c65ef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,9 @@ if (!isAndroidTestBuild()) { crash_fix { enable true } + memory_leak { + enable true + } } } } diff --git a/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt b/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt new file mode 100644 index 0000000000..4b9374ed5f --- /dev/null +++ b/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt @@ -0,0 +1,94 @@ +package com.mogo.launcher.lancet + +import android.app.Activity +import android.app.Dialog +import android.content.Context +import android.view.View +import androidx.annotation.* +import androidx.core.view.ViewCompat +import androidx.fragment.app.* +import com.knightboost.lancet.api.* +import com.knightboost.lancet.api.annotations.* +import com.knightboost.lancet.api.annotations.Weaver +import com.mogo.eagle.core.utilcode.kotlin.* +import java.lang.ref.* +import java.lang.reflect.Modifier +import java.util.concurrent.ConcurrentHashMap + +@Keep +@Weaver +@Group("memory_leak") +class MemoryLeakFix { + + @Insert + @ImplementedInterface("java.lang.Runnable") + @TargetMethod(methodName = "run") + fun runProxy() { + if (AccessSyntheticUtils.isTargetAlive(This.get())) { + Origin.callVoid() + } + } +} + +internal class AccessSyntheticUtils { + + companion object { + + private val fields = ConcurrentHashMap>() + + @JvmStatic + fun isTargetAlive(obj: Any): Boolean { + try { + val clazz = obj.javaClass + if (!clazz.isAnonymousClass) { + return true + } + val key = clazz.name + return (fields[key] ?: clazz.declaredFields.find { + it.isSynthetic && + ((it.modifiers and Modifier.STATIC) == 0) && + (View::class.java.isAssignableFrom(it.type) or + Context::class.java.isAssignableFrom(it.type) or + Fragment::class.java.isAssignableFrom(it.type) or + android.app.Fragment::class.java.isAssignableFrom(it.type) or + Dialog::class.java.isAssignableFrom(it.type) + ) + }?.let { + it.isAccessible = true + val wf = WeakReference(it.get(obj), ReferenceQueue()) + fields[key] = wf + wf + })?.also { + if (it.isEnqueued) { + //对像被垃圾回收了 + fields.remove(key) + } + }?.get()?.let { t -> + when(t) { + is View -> { + ViewCompat.isAttachedToWindow(t) + } + is Activity -> { + !t.isFinishing && !t.isDestroyed + } + is Fragment -> { + !t.isDetached + } + is android.app.Fragment -> { + !t.isDetached + } + is Dialog -> { + t.window?.decorView?.let { v -> ViewCompat.isAttachedToWindow(v) } ?: false + } + else -> { + true + } + } + } ?: true + } catch (t: Throwable) { + t.printStackTrace() + } + return true + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 66ec9a72f2..cbd64fba4f 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ buildscript { classpath 'com.mogo.cloud:systrace:1.0.1' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' classpath 'com.mogo.sticky:service:1.0.8' - classpath 'io.github.knight-zxw:lancet-plugin:0.0.1' + classpath 'io.github.knight-zxw:lancet-plugin:0.0.4' // classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true } } diff --git a/config.gradle b/config.gradle index 2ee5bb5335..d073b6b0a7 100644 --- a/config.gradle +++ b/config.gradle @@ -220,7 +220,7 @@ ext { //========================= LancetX =================== - lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.1", + lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4", //========================= autosize ====================== androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1', From efe80d9ea8aecd5c6f808368a26488b09f9bded5 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 3 Feb 2023 17:37:51 +0800 Subject: [PATCH 03/10] =?UTF-8?q?[Opt]=E9=AB=98=E5=BE=B7=E7=9A=84=E5=B0=8F?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=B0=81=E8=A3=85=E5=88=B0View=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/smp/view/SmallMapView.kt | 350 ++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt new file mode 100644 index 0000000000..de31b43cd3 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/view/SmallMapView.kt @@ -0,0 +1,350 @@ +package com.mogo.eagle.core.function.smp.view + +import android.content.Context +import android.graphics.Color +import android.os.Bundle +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.RelativeLayout +import androidx.annotation.UiThread +import com.amap.api.maps.* +import com.amap.api.maps.model.* +import com.mogo.cloud.commons.utils.CoordinateUtils +import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.map.MogoLatLng +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener +import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager +import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.map.R +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import mogo.telematics.pad.MessagePad +import java.util.* +import kotlin.math.floor + +class SmallMapView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener, + IMoGoPlanningRottingListener, + IMoGoAutopilotStatusListener { + + private var mAMapNaviView: TextureMapView? = null + private var mAMap: AMap? = null + private var mCarMarker: Marker? = null + private var mStartMarker: Marker? = null + private var mEndMarker: Marker? = null + private val zoomLevel = 15 + private val mCoordinatesLatLng: MutableList = ArrayList() + private var mPolyline: Polyline? = null + private var mCameraUpdate: CameraUpdate? = null + private var mContext: Context? = null + private var mLocation: MogoLocation? = null + + private var autoPilotStatus = 0 + + companion object { + const val TAG = "SmallMapView" + } + + init { + try { + initView(context) + } catch (e: Exception) { + e.printStackTrace() + } + } + + // =================必须通知高德地图生命周期的变化================= + fun onCreateView(savedInstanceState: Bundle?) { + if (mAMapNaviView != null) { + mAMapNaviView!!.onCreate(savedInstanceState) + } + } + + fun onResume() { + if (mAMapNaviView != null) { + mAMapNaviView!!.onResume() + } + } + + fun onPause() { + if (mAMapNaviView != null) { + mAMapNaviView!!.onPause() + } + } + + fun onDestroy() { + if (mAMapNaviView != null) { + mAMapNaviView!!.onDestroy() + } + } + // =================必须通知高德地图生命周期的变化================= + + fun convert(coordinates: List) { + mCoordinatesLatLng.clear() + val latLngs = coordinateConverterFrom84ForList(mContext, coordinates) + mCoordinatesLatLng.addAll(latLngs) + } + + @UiThread + fun drawablePolyline() { + clearPolyline() + if (mAMap != null) { + if (mCoordinatesLatLng.size > 2) { + // 设置开始结束Marker位置 + mStartMarker!!.position = mCoordinatesLatLng[0] + mEndMarker!!.position = mCoordinatesLatLng[mCoordinatesLatLng.size - 1] + mStartMarker!!.setToTop() + mStartMarker!!.isVisible = true + mEndMarker!!.isVisible = true + mEndMarker!!.setToTop() + + + //存放所有点的经纬度 + val boundsBuilder = LatLngBounds.Builder() + for (i in mCoordinatesLatLng.indices) { + //把所有点都include进去(LatLng类型) + boundsBuilder.include(mCoordinatesLatLng[i]) + } + //第二个参数为四周留空宽度 + mAMap!!.animateCamera( + CameraUpdateFactory.newLatLngBounds( + boundsBuilder.build(), + 30 + ) + ) + // 绘制线 + mPolyline = mAMap!!.addPolyline( + PolylineOptions() + .addAll(mCoordinatesLatLng) + .color(Color.argb(255, 31, 127, 255)) + .width(12f) + ) + } + } + } + + @UiThread + fun clearPolyline() { + if (mPolyline != null) { + mPolyline!!.remove() + } + if (mStartMarker != null) { + mStartMarker!!.isVisible = false + } + if (mEndMarker != null) { + mEndMarker!!.isVisible = false + } + } + + private fun initView(context: Context) { + mContext = context + val smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this) + mAMapNaviView = smpView.findViewById(R.id.aMapNaviView) + initAMapView() + + // 注册定位监听 + CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this) + CallerPlanningRottingListenerManager.addListener(TAG, this) + CallerAutoPilotStatusListenerManager.addListener(TAG, this) + startTask() + } + + private fun initAMapView() { + mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel.toFloat()) + mAMap = mAMapNaviView!!.map + // 关闭地图文字标注 + mAMap?.showMapText(false) + // 设置导航地图模式,aMap是地图控制器对象。 + mAMap?.mapType = AMap.MAP_TYPE_NIGHT + // 关闭显示实时路况图层,aMap是地图控制器对象。 + mAMap?.isTrafficEnabled = false + // 设置 锚点 图标 + mCarMarker = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon)) + .anchor(0.5f, 0.5f) + ) + } else { + mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon)) + .anchor(0.5f, 0.5f) + ) + } + mStartMarker = mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)) + ) + mEndMarker = mAMap?.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)) + ) + // 加载自定义样式 + val customMapStyleOptions = CustomMapStyleOptions() + .setEnable(true) + .setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data")) + .setStyleExtraData( + MapAssetStyleUtils.getAssetsExtraStyle( + context, + "over_view_style_extra.data" + ) + ) + // 设置自定义样式 + mAMap?.setCustomMapStyle(customMapStyleOptions) + //设置希望展示的地图缩放级别 + mAMap?.moveCamera(mCameraUpdate) + // 设置地图的样式 + val uiSettings = mAMap?.uiSettings + uiSettings?.isZoomControlsEnabled = false // 地图缩放级别的交换按钮 + uiSettings?.setAllGesturesEnabled(false) // 所有手势 + uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮 + uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可 + mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener { + CallerLogger.d( + SceneConstant.M_MAP + TAG, + "smp---onMapLoaded" + ) + // 加载自定义样式 + val customMapStyleOptions1 = CustomMapStyleOptions() + .setEnable(true) + .setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data")) + .setStyleExtraData( + MapAssetStyleUtils.getAssetsExtraStyle( + context, + "over_view_style_extra.data" + ) + ) + // 设置自定义样式 + mAMap?.setCustomMapStyle(customMapStyleOptions1) + mAMapNaviView!!.map.setPointToCenter( + mAMapNaviView!!.width / 2, + mAMapNaviView!!.height / 2 + ) + }) + } + + private fun startTask() { + val mTimer = Timer() + mTimer.schedule(UpdateLocationTask(), 1000, 200) + } + + private inner class UpdateLocationTask : TimerTask() { + override fun run() { + if (mLocation != null) { + if (mCarMarker == null) { + mCarMarker = mAMap!!.addMarker( + MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo)) + .anchor(0.5f, 0.5f) + ) + } + if (mCarMarker == null) { + return + } + val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude) + val bearing = floor(mLocation!!.heading).toFloat() + //更新车辆位置 + mCarMarker!!.position = currentLatLng + if (mCoordinatesLatLng.size > 1) { + // 结束位置 + val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1] + val calculateDistance = CoordinateUtils.calculateLineDistance( + endLatLng.latitude, endLatLng.longitude, + currentLatLng.latitude, currentLatLng.longitude + ) + CallerLogger.d( + SceneConstant.M_MAP + TAG, + "calculateDistance=$calculateDistance" + ) + if (calculateDistance <= 5) { + clearPolyline() + mCoordinatesLatLng.clear() + } + } + val cameraPosition: CameraPosition = + CameraPosition.Builder().target(mCarMarker!!.position).tilt(0f).bearing(bearing) + .zoom(zoomLevel.toFloat()).build() + mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)) + } + } + } + + private fun coordinateConverterFrom84(mContext: Context?, mogoLatLng: MogoLatLng): LatLng { + val mCoordinateConverter = CoordinateConverter(mContext) + mCoordinateConverter.from(CoordinateConverter.CoordType.GPS) + mCoordinateConverter.coord(LatLng(mogoLatLng.lat, mogoLatLng.lon)) + return mCoordinateConverter.convert() + } + + private fun coordinateConverterFrom84ForList( + mContext: Context?, + mogoLatLngList: List + ): List { + val list: MutableList = ArrayList() + for (m in mogoLatLngList) { + val mogoLatLng = coordinateConverterFrom84(mContext, m) + list.add(mogoLatLng) + } + return list + } + + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + if (mogoLocation == null) { + return + } + mLocation = mogoLocation + } + + override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { + val tempStatus = autoPilotStatusInfo.pilotmode + if (tempStatus != 1) { + UiThreadHandler.post { + clearPolyline() + } + } else if (tempStatus == 1 && autoPilotStatus == 0) { + getGlobalPath() + } + autoPilotStatus = tempStatus + } + + override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { + if (globalPathResp == null || globalPathResp.wayPointsList.size == 0) { + return + } + val latLngList: MutableList = ArrayList() + for (routeModel in globalPathResp.wayPointsList) { + latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude)) + } + if (latLngList.size > 0) { + UiThreadHandler.post { + convert(latLngList) + drawablePolyline() + } + } else { + UiThreadHandler.post { + clearPolyline() + } + } + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + // 注册定位监听 + CallerChassisLocationGCJ20ListenerManager.removeListener(TAG) + CallerPlanningRottingListenerManager.removeListener(TAG) + CallerAutoPilotStatusListenerManager.removeListener(TAG) + } +} \ No newline at end of file From 390aa3ef9ed19ee4824f1dc488d04ff2ae27583a Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 6 Feb 2023 12:03:38 +0800 Subject: [PATCH 04/10] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0][leakfix]?= =?UTF-8?q?=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E5=AF=B9=E8=B1=A1=E9=94=80?= =?UTF-8?q?=E6=AF=81=E6=97=B6=EF=BC=8C=E7=9B=B4=E6=8E=A5=E5=B0=86=E5=8C=BF?= =?UTF-8?q?=E5=90=8D=E5=86=85=E9=83=A8=E7=B1=BB=E5=BC=95=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=BD=AEnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/launcher/lancet/MemoryLeakFix.kt | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt b/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt index 4b9374ed5f..5357e485f6 100644 --- a/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt +++ b/app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt @@ -7,10 +7,14 @@ import android.view.View import androidx.annotation.* import androidx.core.view.ViewCompat import androidx.fragment.app.* +import androidx.lifecycle.* +import androidx.lifecycle.Lifecycle.Event +import androidx.lifecycle.Lifecycle.Event.ON_DESTROY import com.knightboost.lancet.api.* import com.knightboost.lancet.api.annotations.* import com.knightboost.lancet.api.annotations.Weaver import com.mogo.eagle.core.utilcode.kotlin.* +import io.netty.util.internal.ConcurrentSet import java.lang.ref.* import java.lang.reflect.Modifier import java.util.concurrent.ConcurrentHashMap @@ -35,6 +39,7 @@ internal class AccessSyntheticUtils { companion object { private val fields = ConcurrentHashMap>() + private val observers = ConcurrentSet() @JvmStatic fun isTargetAlive(obj: Any): Boolean { @@ -64,31 +69,72 @@ internal class AccessSyntheticUtils { fields.remove(key) } }?.get()?.let { t -> - when(t) { + var lifecycle: Lifecycle? = null + val ret = when (t) { is View -> { + lifecycle = t.lifecycleOwner.lifecycle ViewCompat.isAttachedToWindow(t) } is Activity -> { + lifecycle = t.findViewById(android.R.id.content)?.lifecycleOwner?.lifecycle !t.isFinishing && !t.isDestroyed } is Fragment -> { + lifecycle = t.lifecycle !t.isDetached } is android.app.Fragment -> { + lifecycle = t.view?.lifecycleOwner?.lifecycle !t.isDetached } is Dialog -> { - t.window?.decorView?.let { v -> ViewCompat.isAttachedToWindow(v) } ?: false + t.window?.decorView?.let { + v -> + lifecycle = v.lifecycleOwner.lifecycle + ViewCompat.isAttachedToWindow(v) + } ?: false } else -> { true } } + if (!ret) { + assignFinalFieldNull(obj, t.javaClass) + } else { + val l = lifecycle + if (l != null && !observers.contains(key)) { + observers.add(key) + l.addObserver(object : LifecycleEventObserver { + override fun onStateChanged(source: LifecycleOwner, event: Event) { + if (event == ON_DESTROY) { + assignFinalFieldNull(obj, t.javaClass) + observers.remove(key) + } + } + }) + } + } + ret } ?: true } catch (t: Throwable) { t.printStackTrace() } return true } + + @JvmStatic + private fun assignFinalFieldNull(obj: Any, fieldType: Class<*>) { + try { + obj.javaClass.declaredFields.find { + it.isSynthetic && + ((it.modifiers and Modifier.STATIC) == 0) && it.type == fieldType + }?.also { + it.isAccessible = true + it.set(obj, null) + } + } catch (t: Throwable) { + t.printStackTrace() + } + } } } \ No newline at end of file From 3b07d19df51c7cc06906f9e2272a1767b9ba4690 Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 6 Feb 2023 14:44:07 +0800 Subject: [PATCH 05/10] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/v2x/events/V2XEventManager.kt | 2 +- .../core/function/v2x/events/consts/V2XConst.java | 11 ----------- .../events/scenario/impl/V2XScenarioManager.java | 4 ---- .../events/scenario/scene/airoad/AiRoadMarker.kt | 2 -- .../core/function/v2x/events/test/TestConsts.kt | 14 ++++++++++++++ .../function/v2x/events/test/TestV2XReceiver.java | 2 +- 6 files changed, 16 insertions(+), 19 deletions(-) create mode 100644 core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestConsts.kt diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt index 11db596df0..841bd6796a 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt @@ -94,7 +94,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, V2XManager.init(V2XConfig.Builder().also { it.aiCloudConfig(MoGoAiCloudClientConfig.getInstance()) it.context(context) - it.loggable(true) + it.loggable(false) it.distanceForTriggerRefresh(200f) //行驶超过200(包含)米,刷新道路周边信息(短链请求) it.durationForTriggerRefresh( 60, diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/consts/V2XConst.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/consts/V2XConst.java index bcc9d0ecf7..b6dee1cb0f 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/consts/V2XConst.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/consts/V2XConst.java @@ -16,17 +16,6 @@ public class V2XConst { public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast"; public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity"; - /** - * V2X 测试控制面板广播Action - */ - public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType"; - - public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast"; - - - public static final String V2X_ROAD_PRODUCE = "v2x_road_produce"; - - public static final String LAUNCHER_ICON_CLICK = "Launcher_Icon_Click"; /** * V2X预警日志tag diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java index 1f43cac2e9..d9d77b72df 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/impl/V2XScenarioManager.java @@ -57,10 +57,6 @@ public class V2XScenarioManager implements IV2XScenarioManager { ThreadUtils.runOnUiThread(() -> { // 提取之前存储的场景 if (v2XMessageEntity != null) { - // 广播给应用内部其它模块 - Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION); - intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity); - LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent); // 如果没有拿到之前的,根据类型分发 switch (v2XMessageEntity.getType()) { case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING: diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index e1eb7d8be3..2568063852 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -38,8 +38,6 @@ class AiRoadMarker { private val marker by lazy { AtomicReference() } - private val carLocation by lazy { AtomicReference>() } - private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager( AbsMogoApplication.getApp() diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestConsts.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestConsts.kt new file mode 100644 index 0000000000..98e85df379 --- /dev/null +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestConsts.kt @@ -0,0 +1,14 @@ +package com.mogo.eagle.core.function.v2x.events.test + +class TestConsts { + + + companion object { + + /** + * V2X 测试控制面板广播Action + */ + @JvmField + val BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType" + } +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestV2XReceiver.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestV2XReceiver.java index 70c5eae7c3..2c5e50edc7 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestV2XReceiver.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/test/TestV2XReceiver.java @@ -29,7 +29,7 @@ public class TestV2XReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { try { this.mContext = context; - int sceneType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0); + int sceneType = intent.getIntExtra(TestConsts.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0); // 分发场景 dispatchSceneTest(sceneType); From a613dcd2592223be0d5e302a5ad17d86f272e933 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Mon, 6 Feb 2023 16:17:17 +0800 Subject: [PATCH 06/10] =?UTF-8?q?[adas=20lib]=E8=83=BD=E5=90=A6=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=87=AA=E9=A9=BE=E4=BB=A5=E5=8F=8A=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E4=B8=8B=E5=8F=91=E5=90=8E=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=88=96=E5=A4=B1=E8=B4=A5=E7=BB=9F=E8=AE=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/manager/OCHAdasAbilityManager.java | 37 +-- .../adas/client/adapter/ConfigAdapter.java | 5 +- .../zhidao/adas/client/base/BaseAdapter.java | 4 + .../com/zhidao/adas/client/bean/Config.java | 17 +- .../zhidao/adas/client/ui/MainActivity.java | 56 +---- .../adas/client/ui/VersionFragment.java | 37 +++ .../zhidao/adas/client/utils/RandomColor.java | 29 +++ .../src/main/res/values/colors.xml | 7 +- .../zhidao/adas/magic/ui/MainActivity.java | 10 +- .../autopilot/MoGoAutopilotControlProvider.kt | 3 + .../autopilot/adapter/MoGoAdasListenerImpl.kt | 5 +- .../IMoGoAutopilotActionsListener.kt | 4 +- .../CallerAutopilotActionsListenerManager.kt | 5 +- ...llerRoboBusJinlvM1StatesListenerManager.kt | 2 +- .../zhidao/support/adas/high/AdasChannel.java | 28 ++- .../zhidao/support/adas/high/AdasOptions.java | 17 ++ .../support/adas/high/OnAdasListener.java | 6 +- .../adas/high/bean/AutopilotAbility.java | 41 ---- .../adas/high/bean/AutopilotStatistics.java | 6 +- .../high/common/AutopilotAbilityManager.java | 229 ++++++++++++++++-- .../adas/high/common/AutopilotReview.java | 28 --- .../support/adas/high/common/Constants.java | 4 - .../support/adas/high/common/Define.java | 3 +- .../support/adas/high/common/MogoReport.java | 43 +--- .../adas/high/msg/ChassisStatesMessage.java | 2 + .../support/adas/high/msg/ReportMessage.java | 26 +- .../adas/high/msg/VehicleStateMessage.java | 115 ++++----- .../adas/high/thread/DispatchHandler.java | 46 ++-- 28 files changed, 493 insertions(+), 322 deletions(-) create mode 100644 app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/RandomColor.java delete mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotAbility.java diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHAdasAbilityManager.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHAdasAbilityManager.java index 245989a8f2..e5b39d9b9d 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHAdasAbilityManager.java +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/manager/OCHAdasAbilityManager.java @@ -12,12 +12,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsList import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; -import com.zhidao.support.adas.high.bean.AutopilotAbility; import com.zhidao.support.adas.high.bean.AutopilotStatistics; -import chassis.Chassis; -import system_master.SystemStatusInfo; - /** * Created on 2022/10/9 * 工控机状态信息回调(判断是否能否启动自动驾驶的回调) @@ -78,36 +74,9 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo } @Override - public void onAutopilotAbility(@Nullable AutopilotAbility ability) { - isAutopilotAbility = true; - autopilotAbilityReason = null; - if (ability.gear == null || ability.gear == Chassis.GearPosition.GEAR_P || - ability.gear == Chassis.GearPosition.GEAR_R) { - isAutopilotAbility = false; - autopilotAbilityReason = "挡位不正常"; - } - - if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && - ability.gear == Chassis.GearPosition.GEAR_N){ //bus档位不正常 - isAutopilotAbility = false; - autopilotAbilityReason = "挡位不正常"; - } - - if (isAutopilotAbility) - if (ability.brake > 0) { - isAutopilotAbility = false; - autopilotAbilityReason = "制动踏板被踩下"; - } - if (isAutopilotAbility) - if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_STARTING) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统正在启动"; - } - if (isAutopilotAbility) - if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_EXITING) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统正在关闭"; - } + public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) { + this.isAutopilotAbility = isAutopilotAbility; + this.autopilotAbilityReason = unableAutopilotReason; Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason); } diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/adapter/ConfigAdapter.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/adapter/ConfigAdapter.java index 7381bc5116..fa494393dc 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/adapter/ConfigAdapter.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/adapter/ConfigAdapter.java @@ -36,7 +36,10 @@ public class ConfigAdapter extends BaseAdapter } viewHolder.name.setText(data.name); viewHolder.value.setText(data.value); - + if (data.color == -1) { + data.color = R.color.colorSlateGray; + } + viewHolder.value.setTextColor(mContext.getResources().getColor(data.color)); } @Override diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/base/BaseAdapter.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/base/BaseAdapter.java index 333d6198e1..ca5e419fc4 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/base/BaseAdapter.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/base/BaseAdapter.java @@ -48,6 +48,10 @@ public abstract class BaseAdapter extends Recycler notifyDataSetChanged(); } + public List getData() { + return mDatas; + } + public void setOnItemClickListener(OnItemClickListener listener) { mItemClick = listener; } diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/Config.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/Config.java index 9f18c1fd2b..960c40a65c 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/Config.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/bean/Config.java @@ -1,11 +1,26 @@ package com.zhidao.adas.client.bean; +import java.util.Objects; + public class Config { public final String name; - public final String value; + public String value; + public int color = -1; public Config(String name, String value) { this.name = name; this.value = value; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Config config = (Config) o; + return Objects.equals(name, config.name); + } + + public void cover(Config config) { + this.value = config.value; + } } diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java index 4057298775..bc9235444e 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/MainActivity.java @@ -98,7 +98,6 @@ import com.zhidao.support.adas.high.AdasOptions; import com.zhidao.support.adas.high.OnAdasConnectStatusListener; import com.zhidao.support.adas.high.OnAdasListener; import com.zhidao.support.adas.high.OnMultiDeviceListener; -import com.zhidao.support.adas.high.bean.AutopilotAbility; import com.zhidao.support.adas.high.bean.AutopilotStatistics; import com.zhidao.support.adas.high.bean.VersionCompatibility; import com.zhidao.support.adas.high.common.ByteUtil; @@ -121,7 +120,6 @@ import java.util.Locale; import java.util.concurrent.ScheduledExecutorService; import bag_manager.BagManagerOuterClass; -import chassis.Chassis; import chassis.ChassisStatesOuterClass; import chassis.VehicleStateOuterClass; import function_state_management.FunctionStates; @@ -184,8 +182,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas private ListPopupWindow listPopupWindow; private FloatWindow floatWindow; private View include_title; - private boolean isAutopilotAbility = true; - private String autopilotAbilityReason; private List specialVehicleBeanList;//特种车辆 private long errorDataUpdateTime = 0; // @Override @@ -860,47 +856,12 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas } @Override - public void onAutopilotAbility(AutopilotAbility ability) { - isAutopilotAbility = true; - autopilotAbilityReason = null; - if (ability.gear == null || ability.gear == Chassis.GearPosition.GEAR_P || ability.gear == Chassis.GearPosition.GEAR_R) { - isAutopilotAbility = false; - autopilotAbilityReason = "挡位不正常"; + public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) { + if (fromFragment instanceof VersionFragment) { + VersionFragment fragment = (VersionFragment) fromFragment; + fragment.autopilotAbility(isAutopilotAbility, unableAutopilotReason); } - if (isAutopilotAbility) - if (ability.brake > 0) { - isAutopilotAbility = false; - autopilotAbilityReason = "制动踏板被踩下"; - } - if (isAutopilotAbility) - if (ability.statusInfo == null) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统Topic不正常"; - } - if (isAutopilotAbility) - if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_STARTING) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统正在启动"; - } - if (isAutopilotAbility) - if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_EXITING) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统正在关闭"; - } - if (isAutopilotAbility) - if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_FAULT) { - isAutopilotAbility = false; - autopilotAbilityReason = "系统异常"; - } - if (isAutopilotAbility) - for (SystemStatusInfo.HealthInfo healthInfo : ability.statusInfo.getHealthInfoList()) { - if (healthInfo.getState() == SystemStatusInfo.HealthState.FAULT) { - isAutopilotAbility = false; - autopilotAbilityReason = healthInfo.getName() + " 节点异常"; - break; - } - } - Log.i(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason); + Log.i(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + unableAutopilotReason); } @Override @@ -1012,7 +973,12 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas BasicInfoReq info = new BasicInfoReq(header, basicInfoReq, sdf); DataDistribution.getInstance().addData(info); AdasManager.getInstance().sendBasicInfoResp("", 0, com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG); - showToastCenter("收到车机基础信息请求:" + info.toString()); + runOnUiThread(new Runnable() { + @Override + public void run() { + showToastCenter("收到车机基础信息请求:" + info.toString()); + } + }); } @Override diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/VersionFragment.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/VersionFragment.java index 23e8c12b62..7b4abdaad1 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/VersionFragment.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/ui/VersionFragment.java @@ -30,6 +30,7 @@ import com.zhidao.adas.client.adapter.InterfaceAdapter; import com.zhidao.adas.client.base.BaseFragment; import com.zhidao.adas.client.bean.Config; import com.zhidao.adas.client.bean.InterfaceModel; +import com.zhidao.adas.client.utils.RandomColor; import com.zhidao.support.adas.high.AdasManager; import com.zhidao.support.adas.high.bean.VersionCompatibility; import com.zhidao.support.adas.high.common.Constants; @@ -211,11 +212,47 @@ public class VersionFragment extends BaseFragment { VersionCompatibility versionCompatibility = AdasManager.getInstance().getVersionCompatibility(); list.add(new Config("版本兼容性:", versionCompatibility == null ? null : versionCompatibility.toString())); } + list.add(new Config("ADAS LIB版本:", AdasManager.getInstance().getAdasVersion())); list.add(new Config("APP构建时间:", BuildConfig.BUILD_TIME)); + list.add(getAutopilotAbilityConfig("")); adapter.setData(list); } + private Config getAutopilotAbilityConfig(String value) { + return new Config("能否启动自动驾驶:", value); + } + + public void autopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) { + List list = adapter.getData(); + if (list != null) { + Config temp = getAutopilotAbilityConfig(isAutopilotAbility + ",原因:" + unableAutopilotReason); + int index = list.indexOf(temp); + if (index < 0) { + list.add(temp); + if (getActivity() != null) + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + adapter.notifyItemInserted(list.size() - 1); + } + }); + } else { + Config config = list.get(index); + config.cover(temp); + config.color = RandomColor.randomColor(); + if (getActivity() != null) + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + adapter.notifyItemChanged(index); + } + }); + } + } + + + } @Override protected void onRefreshView() { diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/RandomColor.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/RandomColor.java new file mode 100644 index 0000000000..1b36a27c04 --- /dev/null +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/utils/RandomColor.java @@ -0,0 +1,29 @@ +package com.zhidao.adas.client.utils; + +import com.zhidao.adas.client.R; + +import java.util.Random; + + +public class RandomColor { + //随机颜色,且不与上一次重复 + private static Random randomColor; + private static int tempColorIndex; + private static int[] colors = {R.color.color1, R.color.color2, R.color.color3, R.color.color4, R.color.color5}; + + public static int randomColor() { + randomColorTemp(); + return colors[tempColorIndex]; + } + + private static void randomColorTemp() { + if (randomColor == null) + randomColor = new Random(); + int colorInt = randomColor.nextInt(colors.length); + if (tempColorIndex == colorInt) { + randomColorTemp(); + } else { + tempColorIndex = colorInt; + } + } +} diff --git a/app_ipc_monitoring/src/main/res/values/colors.xml b/app_ipc_monitoring/src/main/res/values/colors.xml index bfe52b115c..fc88f479a4 100644 --- a/app_ipc_monitoring/src/main/res/values/colors.xml +++ b/app_ipc_monitoring/src/main/res/values/colors.xml @@ -15,6 +15,11 @@ #32CD32 #DC143C #FF00FF - #DAA520 + #3333FF #1E90FF + #FFC0CB + #FF8F00 + #FFE500 + #B9ED3E + #2EEDEB diff --git a/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java b/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java index 8b6703a50e..43df01c887 100644 --- a/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java +++ b/app_mogo_magic_ring/src/main/java/com/zhidao/adas/magic/ui/MainActivity.java @@ -45,7 +45,6 @@ import com.zhidao.support.adas.high.AdasManager; import com.zhidao.support.adas.high.AdasOptions; import com.zhidao.support.adas.high.OnAdasConnectStatusListener; import com.zhidao.support.adas.high.OnAdasListener; -import com.zhidao.support.adas.high.bean.AutopilotAbility; import com.zhidao.support.adas.high.bean.AutopilotStatistics; import com.zhidao.support.adas.high.bean.VersionCompatibility; import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS; @@ -587,6 +586,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas } + @Override + public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) { + + } + private void initAdas() { CupidLogUtils.e(TAG, "--->初始化"); @@ -855,10 +859,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas } } - @Override - public void onAutopilotAbility(AutopilotAbility ability) { - - } @Override public void onStartAutopilotFailed(MogoReportMsg.MogoReportMessage message) { diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt index 6758d9458f..8143b8158c 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt @@ -105,6 +105,7 @@ class MoGoAutopilotControlProvider : .setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION) .setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext)) .setClient(false) + .setIdentityMode(FunctionBuildConfig.appIdentityMode) // .setSubscribeInterfaceOptions(subscribeInterfaceOptions)// .build() @@ -195,6 +196,7 @@ class MoGoAutopilotControlProvider : val options = AdasOptions .Builder() .setClient(true) + .setIdentityMode(FunctionBuildConfig.appIdentityMode) .build() AdasManager.getInstance() .create(options, MoGoAdasMsgConnectStatusListenerImpl()) @@ -222,6 +224,7 @@ class MoGoAutopilotControlProvider : .setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION) .setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext)) .setClient(false)// 乘客端直连工控机改为false + .setIdentityMode(FunctionBuildConfig.appIdentityMode) .build() AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl()) //////////////////////////////////注意先后顺序,AdasManager.getInstance().create后才可以设置监听///////////////////////////////////////////// diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index 9b737d7fbb..5e817bc880 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -59,7 +59,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.support.obu.ObuScene import com.zhidao.support.adas.high.AdasManager import com.zhidao.support.adas.high.OnAdasListener -import com.zhidao.support.adas.high.bean.AutopilotAbility import com.zhidao.support.adas.high.bean.AutopilotStatistics import com.zhidao.support.adas.high.common.ProtocolStatus import com.zhjt.service.chain.ChainLog @@ -608,8 +607,8 @@ class MoGoAdasListenerImpl : OnAdasListener { * 是否可以启动自动驾驶 * 使用方法查看:app_ipc_monitoring/uiMainActivity/onAutopilotAbility */ - override fun onAutopilotAbility(ability: AutopilotAbility?) { - invokeAutopilotAbility(ability) + override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) { + invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason) } /** diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotActionsListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotActionsListener.kt index 89d1015067..5a97424e03 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotActionsListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotActionsListener.kt @@ -1,7 +1,5 @@ package com.mogo.eagle.core.function.api.autopilot -import com.zhidao.support.adas.high.bean.AutopilotAbility - /** * pnc actions 决策 驾驶的意图 @@ -11,5 +9,5 @@ interface IMoGoAutopilotActionsListener { /** * pnc actions 决策 驾驶的意图 */ - fun onAutopilotAbility(ability: AutopilotAbility?) + fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotActionsListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotActionsListenerManager.kt index 38c7a83260..b03db15a32 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotActionsListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotActionsListenerManager.kt @@ -2,7 +2,6 @@ package com.mogo.eagle.core.function.call.autopilot import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener import com.mogo.eagle.core.function.call.base.CallerBase -import com.zhidao.support.adas.high.bean.AutopilotAbility /** @@ -11,10 +10,10 @@ import com.zhidao.support.adas.high.bean.AutopilotAbility object CallerAutopilotActionsListenerManager : CallerBase() { @Synchronized - fun invokeAutopilotAbility(ability: AutopilotAbility?) { + fun invokeAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) { M_LISTENERS.forEach { val listener = it.value - listener.onAutopilotAbility(ability) + listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason) } } } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerRoboBusJinlvM1StatesListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerRoboBusJinlvM1StatesListenerManager.kt index b961321d8e..c23647ca96 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerRoboBusJinlvM1StatesListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerRoboBusJinlvM1StatesListenerManager.kt @@ -11,7 +11,7 @@ import com.mogo.eagle.core.function.call.base.CallerBase object CallerRoboBusJinlvM1StatesListenerManager : CallerBase() { /** - * 电池管理系统 + * 金旅M1 */ fun invokeRoboBusJinlvM1States(states: VehicleStateOuterClass.RoboBusJinlvM1State) { M_LISTENERS.forEach { diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java index c53588b041..9ef9c6deb1 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java @@ -12,6 +12,8 @@ import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_ADAS; import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_LOG_CONNECT_STATUS; import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT; +import android.os.Handler; +import android.os.Message; import android.os.SystemClock; import android.text.TextUtils; @@ -79,6 +81,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec private RawUnpack rawUnpack;//业务数据拆包 private RawPack rawPack;//数据打包 private DispatchHandler defaultDispatchHandler;//默认分发线程分发 + private DispatchHandler statusQueryRespDispatchHandler;//状态查询应答分发线程分发 private final Map dispatchHandlers = new HashMap<>();//其他分发线程 private Timer checkCompatibilityTimer;//检查版本兼容性定时器 连接成功后5秒内等待工控机发送配置信息 private int seqSpecialVehicle = 0;//特种车辆命令发送次数 @@ -181,6 +184,12 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec //启用线程分发 defaultDispatchHandler = new DispatchHandler(MessagePad.MessageType.MsgTypeDefault, this);//默认分发线程 不要添加到Map中 initOtherDispatchHandler(); + AutopilotAbilityManager.getInstance().setOnAutopilotAbilityListener(new AutopilotAbilityManager.OnAutopilotAbilityListener() { + @Override + public void onStatusQuery() { + statusQueryRespDispatchHandler.start(); + } + }); } /** @@ -234,8 +243,9 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec // dispatchHandlers.put(MessagePad.MessageType.MsgTypeWarn, new DispatchHandler(MessagePad.MessageType.MsgTypeWarn, this)); //到站提醒 // dispatchHandlers.put(MessagePad.MessageType.MsgTypeArrivalNotification, new DispatchHandler(MessagePad.MessageType.MsgTypeArrivalNotification, this)); - //状态查询应答 -// dispatchHandlers.put(MessagePad.MessageType.MsgTypeStatusQueryResp, new DispatchHandler(MessagePad.MessageType.MsgTypeStatusQueryResp, this)); + //状态查询应答 TODO 此线程更新频率目前为3秒,但是由于会在此接口中做一些其他数据处理,所以单独开启线程 + statusQueryRespDispatchHandler = new DispatchHandler(MessagePad.MessageType.MsgTypeStatusQueryResp, this); + dispatchHandlers.put(MessagePad.MessageType.MsgTypeStatusQueryResp, statusQueryRespDispatchHandler); //数据采集配置 // dispatchHandlers.put(MessagePad.MessageType.MsgTypeRecordDataConfigResp, new DispatchHandler(MessagePad.MessageType.MsgTypeRecordDataConfigResp, this)); //Planning决策状态 @@ -412,6 +422,20 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec } } + @Override + public void onHandler(MessagePad.MessageType type, Handler handler) { + if (type == MessagePad.MessageType.MsgTypeStatusQueryResp) { + AutopilotAbilityManager.getInstance().setHandler(handler); + } + } + + @Override + public void onHandleMessage(MessagePad.MessageType type, Message msg) { + if (type == MessagePad.MessageType.MsgTypeStatusQueryResp) { + AutopilotAbilityManager.getInstance().onHandleMessage(msg); + } + } + /** * 分发和解析 * diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java index a3b82d5391..9caee97d94 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java @@ -1,5 +1,6 @@ package com.zhidao.support.adas.high; +import com.zhidao.support.adas.high.common.AutopilotAbilityManager; import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOptions; import java.util.HashSet; @@ -124,6 +125,17 @@ public class AdasOptions { return this; } + /** + * 身份/车型 + * + * @param identityMode 车型 + * @return + */ + public Builder setIdentityMode(String identityMode) { + options.setIdentityMode(identityMode); + return this; + } + public AdasOptions build() { return options; } @@ -141,6 +153,7 @@ public class AdasOptions { options.ipcAssignIP = null; options.ipcFixationIP = null; options.subscribeInterfaceOptions = null; + options.setIdentityMode(""); return options; } @@ -183,4 +196,8 @@ public class AdasOptions { public void setSubscribeInterfaceOptions(SubscribeInterfaceOptions subscribeInterfaceOptions) { this.subscribeInterfaceOptions = subscribeInterfaceOptions; } + + public void setIdentityMode(String identityMode) { + AutopilotAbilityManager.getInstance().setIdentityMode(identityMode); + } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java index 2613f4e95e..91cfec766c 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java @@ -1,7 +1,6 @@ package com.zhidao.support.adas.high; import com.mogo.support.obu.ObuScene; -import com.zhidao.support.adas.high.bean.AutopilotAbility; import com.zhidao.support.adas.high.bean.AutopilotStatistics; import com.zhidao.support.adas.high.common.ProtocolStatus; @@ -263,9 +262,10 @@ public interface OnAdasListener { /** * 是否有能力启动自动驾驶 * - * @param ability 是否可以启动自动驾驶 + * @param isAutopilotAbility 是否能启动自动驾驶 + * @param unableAutopilotReason 不能启动自动驾驶原因 */ - void onAutopilotAbility(AutopilotAbility ability); + void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason); /** * 启动自动驾驶失败回调 diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotAbility.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotAbility.java deleted file mode 100644 index c9e3dc9fa1..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotAbility.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.zhidao.support.adas.high.bean; - -import chassis.Chassis; -import system_master.SystemStatusInfo; - -/** - * 自动驾驶能力 能否启动自动驾驶 - * 未赋值表示接口通讯异常或者工控机相关节点异常 如果回调持续都是未赋值的状态表示此问题是持久性的 - */ -public class AutopilotAbility { - /** - * 刹车踏板开度 0~100 - * -1表示未赋值 - * 值为0时表示 制动踏板未踩下 - */ - public final float brake; - /** - * 挡位 - * null表示未赋值 - * 挡位处于P挡和R挡时不能启动自动驾驶 - */ - public final Chassis.GearPosition gear; - /** - * 状态查询结果 - * null表示未赋值 - * 不能启动自动驾驶的判断 - * statusInfo.getHealthInfoList().get().getState()== SystemStatusInfo.HealthState.FAULT - * statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_STARTING - * statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_EXITING - * statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_FAULT - */ - public final SystemStatusInfo.StatusInfo statusInfo; - - public AutopilotAbility(float brake, Chassis.GearPosition gear, SystemStatusInfo.StatusInfo statusInfo) { - this.brake = brake; - this.gear = gear; - this.statusInfo = statusInfo; - - - } -} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatistics.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatistics.java index 763311b16c..cba060b13e 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatistics.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatistics.java @@ -15,7 +15,6 @@ public class AutopilotStatistics { * 0 成功 * 1 失败 * 2 取消 - * 3 超时 * {@link com.zhidao.support.adas.high.common.Constants.AUTOPILOT_START_STATUS} */ @Define.AutopilotStartStatus @@ -37,10 +36,7 @@ public class AutopilotStatistics { */ public final MogoReportMsg.MogoReportMessage failedMessage; - public AutopilotStatistics(@Define.AutopilotStartStatus int status, - long usedTime, - MessagePad.SetAutopilotModeReq req, - MogoReportMsg.MogoReportMessage failedMessage) { + public AutopilotStatistics(@Define.AutopilotStartStatus int status, long usedTime, MessagePad.SetAutopilotModeReq req, MogoReportMsg.MogoReportMessage failedMessage) { this.status = status; this.usedTime = usedTime; this.req = req; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java index 02d90a102d..26d38467f5 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java @@ -1,37 +1,88 @@ package com.zhidao.support.adas.high.common; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; + import com.zhidao.support.adas.high.AdasManager; import com.zhidao.support.adas.high.OnAdasListener; -import com.zhidao.support.adas.high.bean.AutopilotAbility; +import java.util.List; import java.util.Timer; import java.util.TimerTask; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import chassis.Chassis; -import chassis.VehicleStateOuterClass; +import chassis.ChassisStatesOuterClass; import system_master.SystemStatusInfo; /** * 是否可以启动自动驾驶能力检测 * 目前监控了底盘的一些状态和查询节点状态应答的数据 * 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知 - * + *

* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态 */ public class AutopilotAbilityManager { private static final String TAG = AutopilotAbilityManager.class.getSimpleName(); + private static final int WHAT_TIMEOUT = 0; + private static final int DEFAULT_TIMEOUT = 1500; private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间 + private static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "}; private static volatile AutopilotAbilityManager INSTANCE; - private OnAdasListener listener; private volatile Timer timer; + private final Pattern pattern = Pattern.compile("\\d+.\\d+.\\d+"); + private ChassisStatesOuterClass.ChassisStates chassisStates; + private Handler handler; + private OnAutopilotAbilityListener onAutopilotAbilityListener; + /** + * 身份/车型 + */ + private String identityMode; - private VehicleStateOuterClass.VehicleState vehicleState; + public interface OnAutopilotAbilityListener { + void onStatusQuery();//查询是被调用 + } + + /** + * 身份规则定义根据app/productFlavors/README.md + * * taxi司机屏 Taxi_Driver_Base (东风、红旗司机端) + * * taxi乘客屏 Taxi_Passenger_Base (东风、红旗乘客端) + * * bus司机屏 Bus_Driver_Base (金旅小巴司机端) + * * Bus_Driver_Van (开沃小巴司机端) + * * bus乘客屏 Bus_Passenger_Base (金旅、开沃小巴乘客端) + * * Bus_Passenger_M1 (M1小巴乘客端) + * * Bus_Passenger_M2 (M2小巴乘客端) + * * 清扫车 Sweeper_Driver_FT (福田清扫车司机端) + *

+ * 此定义不区分角色,只区分业务线和车型 + */ + private interface IDENTITY_MODE { + String TAXI_DRIVER_BASE = "Taxi_Driver_Base";//(东风、红旗司机端) + String TAXI_PASSENGER_BASE = "Taxi_Passenger_Base";//(东风、红旗乘客端) + String BUS_DRIVER_BASE = "Bus_Driver_Base";//(金旅小巴司机端) + String BUS_DRIVER_VAN = "Bus_Driver_Van";//(开沃小巴司机端) + String BUS_PASSENGER_BASE = "Bus_Passenger_Base";//(金旅、开沃小巴乘客端) + String BUS_PASSENGER_M1 = "Bus_Passenger_M1";//(M1小巴乘客端) + String BUS_PASSENGER_M2 = "Bus_Passenger_M2";//(M2小巴乘客端) + String SWEEPER_DRIVER_FT = "Sweeper_Driver_FT";//(福田清扫车司机端) + } + + + public void setIdentityMode(String identityMode) { + this.identityMode = identityMode; + } public void setOnAdasListener(OnAdasListener listener) { this.listener = listener; } + public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) { + this.onAutopilotAbilityListener = onAutopilotAbilityListener; + } + private AutopilotAbilityManager() { } @@ -47,19 +98,147 @@ public class AutopilotAbilityManager { } public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) { - if (listener != null) { - float brake = -1; - Chassis.GearPosition gear = null; - if (vehicleState != null) { - brake = vehicleState.getBrake(); - gear = vehicleState.getGear(); - } - listener.onAutopilotAbility(new AutopilotAbility(brake, gear, statusInfo)); + if (handler != null) { + if (handler.hasMessages(WHAT_TIMEOUT)) + handler.removeMessages(WHAT_TIMEOUT); } + onCallback(statusInfo); } - public void setVehicleState(VehicleStateOuterClass.VehicleState vehicleState) { - this.vehicleState = vehicleState; + public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) { + this.chassisStates = chassisStates; + } + + private void onCallback(SystemStatusInfo.StatusInfo statusInfo) { + //金旅、开沃小巴乘客端 不能启动自动驾驶 + if (IDENTITY_MODE.BUS_PASSENGER_BASE.equalsIgnoreCase(identityMode)) { + return; + } + boolean isAutopilotAbility = true;//是否能启动自动驾驶 + String unableAutopilotReason = null;//不能启动自动驾驶原因 + //检测节点状态相关 + if (statusInfo != null) { + int version = -1; + if (statusInfo.hasMasterVersion()) { + //截取Master Version + String masterVersion = statusInfo.getMasterVersion(); + if (!TextUtils.isEmpty(masterVersion)) { + try { + Matcher matcher = pattern.matcher(masterVersion); + if (matcher.find()) { + String group = matcher.group(); + if (!TextUtils.isEmpty(group)) { + String v = group.split("\\.")[0]; + version = Integer.parseInt(v); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + if (version > 1) { + isAutopilotAbility = statusInfo.getAutoPilotReady(); + if (!isAutopilotAbility) { + SystemStatusInfo.NodeFaultList nodeFaultList = statusInfo.getAutoPilotUnreadyList(); + if (nodeFaultList.getSum() > 0) { + List list = nodeFaultList.getNodeList(); + StringBuilder builder = new StringBuilder(); + for (SystemStatusInfo.NodeInfo info : list) { + builder.append(info.getNodeName()); + int state = info.getState(); + if (state < NODE_INFO_STATE.length) { + builder.append(NODE_INFO_STATE[state]); + } else { + builder.append("未知 "); + } + } + unableAutopilotReason = builder.toString(); + } else { + unableAutopilotReason = "未知"; + } + } + } else { + SystemStatusInfo.SystemState systemState = statusInfo.getSysState(); + if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) { + isAutopilotAbility = false; + if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) { + unableAutopilotReason = "系统正在启动"; + } else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) { + unableAutopilotReason = "系统正在关闭"; + } else if (systemState == SystemStatusInfo.SystemState.SYS_FAULT) { + unableAutopilotReason = "系统异常"; + } else if (systemState == SystemStatusInfo.SystemState.AUTO_PILOT_STARTING) { + unableAutopilotReason = "正在开始自动驾驶"; + } else if (systemState == SystemStatusInfo.SystemState.AUTO_PILOT_RUNNING) { + unableAutopilotReason = "自动驾驶运行中"; + } else if (systemState == SystemStatusInfo.SystemState.REMOTE_PILOT_STARTING) { + unableAutopilotReason = "平行驾驶启动中"; + } else if (systemState == SystemStatusInfo.SystemState.REMOTE_PILOT_RUNNING) { + unableAutopilotReason = "平行驾驶运行中"; + } else { + unableAutopilotReason = "未知"; + } + } + } + } else { + isAutopilotAbility = false;//是否能启动自动驾驶 + unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因 + } + //检测底盘相关 + if (chassisStates != null) { + if (isAutopilotAbility) { + if (chassisStates.hasBrakeSystemStates()) { + float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition(); + if (brake > 0) { + isAutopilotAbility = false; + unableAutopilotReason = "制动踏板被踩下"; + } + } + } + if (isAutopilotAbility) { + /** + * 档位状态判断 目前判断的车型包括 东风Taxi 红旗Taxi 金旅Bus 金旅M1 金旅M1 福田清扫车 开沃 + * TODO 如果 identityMode 未赋值以及目前已知其他车型判断逻辑跟东风Taxi和红旗 走 + */ + if (chassisStates.hasGearSystemStates()) { + Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition(); + if (TextUtils.isEmpty(identityMode)) { + identityMode = ""; + } + //开沃任何档位都能启动自驾 + if (!IDENTITY_MODE.BUS_DRIVER_VAN.equalsIgnoreCase(identityMode)) { + //金旅Bus和清扫车 档位不正常 + if (IDENTITY_MODE.BUS_DRIVER_BASE.equalsIgnoreCase(identityMode) || IDENTITY_MODE.SWEEPER_DRIVER_FT.equalsIgnoreCase(identityMode)) { + if (gear == Chassis.GearPosition.GEAR_N) { + isAutopilotAbility = false; + unableAutopilotReason = "挡位不正常"; + } + } else { + //东风Taxi和红旗 司机端和乘客端 档位不正常 + if (gear == Chassis.GearPosition.GEAR_P || gear == Chassis.GearPosition.GEAR_R) { + isAutopilotAbility = false; + unableAutopilotReason = "挡位不正常"; + } + } + } + } + } + + //TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段 +// if (isAutopilotAbility) { +// //电子驻车制动系统 +// if (chassisStates.hasEpbSystemStates()) { +// ChassisStatesOuterClass.EPBSystemStates epb = chassisStates.getEpbSystemStates(); +// if (epb.hasEpbEnableState()){ +// epb.getEpbWorkState(); +// } +// } +// } + } + if (listener != null) { + listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason); + } } public synchronized void start() { @@ -68,7 +247,15 @@ public class AutopilotAbilityManager { timer.schedule(new TimerTask() { @Override public void run() { + if (onAutopilotAbilityListener != null) { + onAutopilotAbilityListener.onStatusQuery(); + } AdasManager.getInstance().sendStatusQueryReq(); + if (handler != null) { + if (handler.hasMessages(WHAT_TIMEOUT)) + handler.removeMessages(WHAT_TIMEOUT); + handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT); + } } }, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步 } @@ -79,8 +266,18 @@ public class AutopilotAbilityManager { timer.cancel(); timer = null; } - this.vehicleState = null; + handler = null; + this.chassisStates = null; + } + + public void setHandler(Handler handler) { + this.handler = handler; } + public void onHandleMessage(Message msg) { + if (msg.what == WHAT_TIMEOUT) { + onCallback(null); + } + } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotReview.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotReview.java index c1825605ab..16f62686fd 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotReview.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotReview.java @@ -16,13 +16,6 @@ import mogo_msg.MogoReportMsg; * 自动驾驶状态检查/统计 */ public class AutopilotReview { - /** - * 默认启动自驾超时时间 - */ - private static final long DEFAULT_TIMEOUT = 15 * 1000L; - - - private Timer timer; /** * 下发的启动自动驾驶命令 */ @@ -45,7 +38,6 @@ public class AutopilotReview { } private void onCallback(@Define.AutopilotStartStatus int status) { - stopTimer(); long usedTime = SystemClock.elapsedRealtime() - startTime; if (listener != null) { listener.onReview(new AutopilotStatistics(status, usedTime, startReq, failedMessage)); @@ -56,25 +48,6 @@ public class AutopilotReview { } - private void startTimer() { - if (timer == null) { - timer = new Timer(); - timer.schedule(new TimerTask() { - @Override - public void run() { - //超时 - onCallback(Constants.AUTOPILOT_START_STATUS.TIMEOUT); - } - }, DEFAULT_TIMEOUT); - } - } - - private void stopTimer() { - if (timer != null) { - timer.cancel(); - timer = null; - } - } /** * 自动驾命令 @@ -86,7 +59,6 @@ public class AutopilotReview { //启动自动驾驶 startReq = req; startTime = SystemClock.elapsedRealtime(); - startTimer(); } else { onCallback(Constants.AUTOPILOT_START_STATUS.CANCEL); } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java index 2063e46474..2591484ac9 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java @@ -126,10 +126,6 @@ public class Constants { * 取消 */ int CANCEL = 2; - /** - * 超时 - */ - int TIMEOUT = 3; } /** diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Define.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Define.java index 4ea9eec593..4ef4b6830c 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Define.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Define.java @@ -49,8 +49,7 @@ public final class Define { @IntDef(flag = true, value = {Constants.AUTOPILOT_START_STATUS.SUCCESSFUL, Constants.AUTOPILOT_START_STATUS.FAILED, - Constants.AUTOPILOT_START_STATUS.CANCEL, - Constants.AUTOPILOT_START_STATUS.TIMEOUT}) + Constants.AUTOPILOT_START_STATUS.CANCEL}) @Retention(RetentionPolicy.SOURCE) public @interface AutopilotStartStatus { } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java index 0ba915d384..dcc7a49aa5 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java @@ -2,7 +2,7 @@ package com.zhidao.support.adas.high.common; /** * 监控事件报告中定义的事件以及解释 - * 根据MAP2.10.0消息定义编写 + * 根据MAP2.11.0消息定义编写 */ public class MogoReport { public static final String RESULT_AUTOPILOT_SYSTEM_UNSTARTED = "RESULT_AUTOPILOT_SYSTEM_UNSTARTED"; @@ -12,33 +12,17 @@ public class MogoReport { public static final String RESULT_REMOTEPILOT_INFERIOR = "RESULT_REMOTEPILOT_INFERIOR"; public static final String RESULT_SHOW_WARNING = "RESULT_SHOW_WARNING"; -// private static final String RESULT_DISCONNECTED_WITH_PAD = "RESULT_DISCONNECTED_WITH_PAD"; -// private static final String RESULT_PAD_CANNOT_CONNECT_TELEMATICS = "RESULT_PAD_CANNOT_CONNECT_TELEMATICS"; -// private static final String RESULT_PAD_INFO_LOST = "RESULT_PAD_INFO_LOST"; -// private static final String RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS = "RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS"; -// private static final String RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS = "RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS"; -// private static final String RESULT_PAD_CANNOT_GET_OBSTACLE_INFO = "RESULT_PAD_CANNOT_GET_OBSTACLE_INFO"; -// private static final String RESULT_NO_CONNECTION_TO_AICLOUD = "RESULT_NO_CONNECTION_TO_AICLOUD"; -// private static final String RESULT_AICLOUD_INFO_LOST = "RESULT_AICLOUD_INFO_LOST"; -// private static final String RESULT_CANNOT_CHANGE_LIGHT = "RESULT_CANNOT_CHANGE_LIGHT"; + public enum Result { AUTOPILOT_SYSTEM_UNSTARTED(RESULT_AUTOPILOT_SYSTEM_UNSTARTED, "自动驾驶系统启动过程中出错,pad可能无法连接,云端监控可能无法上报"), AUTOPILOT_DISABLE(RESULT_AUTOPILOT_DISABLE, "无法启动自动驾驶"), - AUTOPILOT_INFERIOR(RESULT_AUTOPILOT_INFERIOR, "自动驾驶部分功能受影响,演示模式可以考虑强行启动,需联系人员排查问题。\n例如定位偏移,camera无数据,算法严重丢帧,属于自动驾驶可以启动,但是效果受影响。"), + AUTOPILOT_INFERIOR(RESULT_AUTOPILOT_INFERIOR, "自动驾驶部分功能受严重影响,演示模式可以考虑强行启动,非演示模式下建议停止自动驾驶,联系人员排查问题。\n例如定位偏移,camera无数据,算法非常严重的丢帧,属于自动驾驶可以启动,但是效果受影响。"), REMOTEPILOT_DISABLE(RESULT_REMOTEPILOT_DISABLE, "无法启动远程驾驶"), REMOTEPILOT_INFERIOR(RESULT_REMOTEPILOT_INFERIOR, "远程驾驶部分功能受影响。例如网络高延迟"), SHOW_WARNING(RESULT_SHOW_WARNING, "一般为过渡状态,存在不确定因素,有可能对自动驾驶有微弱影响,需要在pad端显示为黄色告警。\n如果偶尔上报该result可忽略,如果频繁上报需联系人员进行排查。 目前仅有RTK无法确认状态事件。"); -// DISCONNECTED_WITH_PAD(RESULT_DISCONNECTED_WITH_PAD, "未检测到来自pad的链接,如果只报了这个result,可以通过后台/远程驾驶启动自动驾驶"), -// PAD_CANNOT_CONNECT_TELEMATICS(RESULT_PAD_INFO_LOST, "Pad无法连接到工控机"), -// PAD_INFO_LOST(RESULT_PAD_CANNOT_CONNECT_TELEMATICS, "Pad工控机之间指令信息丢失"), -// PAD_CANNOT_GET_AUTOPILOT_STATUS(RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS, "Pad端无法拿到自动驾驶状态信息"), -// PAD_CANNOT_GET_GNS_CHASSIS_STATUS(RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS, "Pad端无法拿到自车状态和底盘状态信息"), -// PAD_CANNOT_GET_OBSTACLE_INFO(RESULT_PAD_CANNOT_GET_OBSTACLE_INFO, "Pad端无法拿到障碍物信息"), -// NO_CONNECTION_TO_AICLOUD(RESULT_NO_CONNECTION_TO_AICLOUD, "无法和云端通信"), -// AICLOUD_INFO_LOST(RESULT_AICLOUD_INFO_LOST, "云端工控机之间信息丢失"), -// CANNOT_CHANGE_LIGHT(RESULT_CANNOT_CHANGE_LIGHT, "变灯失败"); + /** * 消息result code @@ -69,25 +53,6 @@ public class MogoReport { return REMOTEPILOT_INFERIOR.desc; case RESULT_SHOW_WARNING: return SHOW_WARNING.desc; - -// case RESULT_DISCONNECTED_WITH_PAD: -// return DISCONNECTED_WITH_PAD.desc; -// case RESULT_PAD_CANNOT_CONNECT_TELEMATICS: -// return PAD_CANNOT_CONNECT_TELEMATICS.desc; -// case RESULT_PAD_INFO_LOST: -// return PAD_INFO_LOST.desc; -// case RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS: -// return PAD_CANNOT_GET_AUTOPILOT_STATUS.desc; -// case RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS: -// return PAD_CANNOT_GET_GNS_CHASSIS_STATUS.desc; -// case RESULT_PAD_CANNOT_GET_OBSTACLE_INFO: -// return PAD_CANNOT_GET_OBSTACLE_INFO.desc; -// case RESULT_NO_CONNECTION_TO_AICLOUD: -// return NO_CONNECTION_TO_AICLOUD.desc; -// case RESULT_AICLOUD_INFO_LOST: -// return AICLOUD_INFO_LOST.desc; -// case RESULT_CANNOT_CHANGE_LIGHT: -// return CANNOT_CHANGE_LIGHT.desc; default: return resultCode; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java index 1fb5af656b..081a1a9a58 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java @@ -2,6 +2,7 @@ package com.zhidao.support.adas.high.msg; import com.google.protobuf.InvalidProtocolBufferException; import com.zhidao.support.adas.high.OnAdasListener; +import com.zhidao.support.adas.high.common.AutopilotAbilityManager; import com.zhidao.support.adas.high.protocol.RawData; import chassis.ChassisStatesOuterClass; @@ -14,6 +15,7 @@ public class ChassisStatesMessage extends MyAbstractMessageHandler { @Override public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException { ChassisStatesOuterClass.ChassisStates chassisStates = ChassisStatesOuterClass.ChassisStates.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue()); + AutopilotAbilityManager.getInstance().setChassisStates(chassisStates); if (adasListener != null) { adasListener.onChassisStates(raw.getHeader(), chassisStates); } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java index 7baa2838cd..e146fca77c 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java @@ -10,7 +10,8 @@ import com.zhidao.support.adas.high.common.CupidLogUtils; import com.zhidao.support.adas.high.common.MogoReport; import com.zhidao.support.adas.high.protocol.RawData; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import mogo_msg.MogoReportMsg; @@ -19,9 +20,28 @@ import mogo_msg.MogoReportMsg; */ public class ReportMessage extends MyAbstractMessageHandler { private final AutopilotReview autopilotReview; + private final Set startAutopilotFailCode = new HashSet();//启动自驾失败Code public ReportMessage(AutopilotReview autopilotReview) { this.autopilotReview = autopilotReview; + initStartAutopilotFailCode(); + } + + private void initStartAutopilotFailCode() { + //ssm_master的失败事件 + startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.AUTOPILOT_FAILED);//在尝试启动自动驾驶,但是超过指定时间后底盘未进入,会发送此事件 + startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.ROUTING_REQ_TIMEOUT);//算路请求响应超时或轨迹加载超时 + startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.PLANNING_CHANGE_FAILIED);//planning切换失败(仅df hq有此事件) + startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.CHECK_TRAJECTORY_FAILURE);//轨迹下载检查不可用 + //controller的失败事件 EMAP_ENTRY_AUTOPILOT_XXX 底盘启动失败 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_CANADAPTER_TIMEOUT);//can_adapter消息超时未进入自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_PLANNING_TIMEOUT);//PLANNING消息超时未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_LOCATION_TIMEOUT);//定位消息超时未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_BRAKE);//制动踏板干预未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_ACCEL);//加速踏板干预未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_STEER);//方向盘干预未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_GEAR_SWITCH);//档位切换干预未进自驾 + startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_OTHER_CTL);//其他干预未进自驾,请检查仪表盘和开关项(如双闪,制动灯灯等 可在msg中补充原因信息) } @Override @@ -36,8 +56,8 @@ public class ReportMessage extends MyAbstractMessageHandler { } AdasChannel.calculateTimeConsumingBusiness("监控事件报告", nowTime); //分发自动驾驶启动失败相关回调 - List results = mogoReportMessage.getResultList(); - if (!results.isEmpty() && results.contains(MogoReport.RESULT_AUTOPILOT_DISABLE)) { + String code = mogoReportMessage.getCode(); + if (startAutopilotFailCode.contains(code)) { if (adasListener != null) { adasListener.onStartAutopilotFailed(mogoReportMessage);//启动自动驾驶失败回调 } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java index 941a28beec..0b3575b12a 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java @@ -23,13 +23,13 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException { VehicleStateOuterClass.VehicleState vehicleState = VehicleStateOuterClass.VehicleState.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue()); AdasChannel.calculateTimeConsumingOnDispatchRaw("底盘信息", raw.receiveTime); - AutopilotAbilityManager.getInstance().setVehicleState(vehicleState); long nowTime = 0; if (CupidLogUtils.isEnableLog()) nowTime = SystemClock.elapsedRealtime(); + ChassisStatesOuterClass.ChassisStates chassisStates = compatibility(adasListener, raw, vehicleState); if (adasListener != null) { - //TODO 暂时关闭新老兼容 - //compatibility(adasListener, raw, vehicleState); + //TODO 暂时关闭老底盘转发 后期 会删除 onVehicleState + //adasListener.onChassisStates(raw.getHeader(), chassisStates); adasListener.onVehicleState(raw.getHeader(), vehicleState); } AdasChannel.calculateTimeConsumingBusiness("底盘信息", nowTime); @@ -46,15 +46,12 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { * fuel_value robo_taxi_state robo_bus_state * robo_bus_jinlv_m1_state */ - private void compatibility(OnAdasListener adasListener, RawData raw, VehicleStateOuterClass.VehicleState vehicleState) throws InvalidProtocolBufferException { + private ChassisStatesOuterClass.ChassisStates compatibility(OnAdasListener adasListener, RawData raw, VehicleStateOuterClass.VehicleState vehicleState) throws InvalidProtocolBufferException { /**************老地盘转换成新地盘PB***************/ ChassisStatesOuterClass.ChassisStates.Builder builder = ChassisStatesOuterClass.ChassisStates.newBuilder(); //工控机所用Header if (vehicleState.hasHeader()) { - HeaderOuterClass.Header outHeader = vehicleState.getHeader(); - if (outHeader != null) { - builder.setHeader(HeaderOuterClass.Header.parseFrom(vehicleState.getHeader().toByteArray())); - } + builder.setHeader(HeaderOuterClass.Header.parseFrom(vehicleState.getHeader().toByteArray())); } setBCMSystemStates(builder, vehicleState); setSteerSystemStates(builder, vehicleState); @@ -66,45 +63,41 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { //电子驻车制动系统 if (vehicleState.hasEpb()) { Chassis.EPBWorkStatus old = vehicleState.getEpb(); - if (old != null) { - ChassisStatesOuterClass.EPBWorkStates epb = null; - if (old == Chassis.EPBWorkStatus.EPBSTATUS_NONE) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_NONE; - } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED; - } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASED) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASED; - } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED_FAIL) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED_FAIL; - } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASE_FAIL) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASE_FAIL; - } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_FAULT) { - epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_FAULT; - } - if (epb != null) { - builder.setEpbSystemStates(ChassisStatesOuterClass.EPBSystemStates.newBuilder() - .setEpbWorkState(epb)); - } + ChassisStatesOuterClass.EPBWorkStates epb = null; + if (old == Chassis.EPBWorkStatus.EPBSTATUS_NONE) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_NONE; + } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED; + } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASED) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASED; + } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED_FAIL) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED_FAIL; + } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASE_FAIL) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASE_FAIL; + } else if (old == Chassis.EPBWorkStatus.EPBSTATUS_FAULT) { + epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_FAULT; + } + if (epb != null) { + builder.setEpbSystemStates(ChassisStatesOuterClass.EPBSystemStates.newBuilder() + .setEpbWorkState(epb)); } } // 整车故障状态 if (vehicleState.hasVehiclefaultlevel()) { Chassis.VehicleFaultLevel vehicleFaultLevel = vehicleState.getVehiclefaultlevel(); - if (vehicleFaultLevel != null) { - ChassisStatesOuterClass.VehicleFaultLevels vehicleFaultLevels = null; - if (vehicleFaultLevel == Chassis.VehicleFaultLevel.None_Fault) { - vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.NONE_FAULT; - } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.General_Fault) { - vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.GENERAL_FAULT; - } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Serious_Fault) { - vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.SERIOUS_FAULT; - } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Critical_Fault) { - vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.CRITICAL_FAULT; - } - if (vehicleFaultLevels != null) { - builder.setVehicleChassisFaultInformation(ChassisStatesOuterClass.VehicleChassisFaultInformation.newBuilder() - .setVehiclefaultlevel(vehicleFaultLevels)); - } + ChassisStatesOuterClass.VehicleFaultLevels vehicleFaultLevels = null; + if (vehicleFaultLevel == Chassis.VehicleFaultLevel.None_Fault) { + vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.NONE_FAULT; + } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.General_Fault) { + vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.GENERAL_FAULT; + } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Serious_Fault) { + vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.SERIOUS_FAULT; + } else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Critical_Fault) { + vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.CRITICAL_FAULT; + } + if (vehicleFaultLevels != null) { + builder.setVehicleChassisFaultInformation(ChassisStatesOuterClass.VehicleChassisFaultInformation.newBuilder() + .setVehiclefaultlevel(vehicleFaultLevels)); } } //电量 @@ -113,25 +106,21 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { } //清扫车(福田)清扫控制系统状态 if (vehicleState.hasSweeperFutianCleanSystemState()) { - VehicleStateOuterClass.SweeperFuTianCleanSystemState sweeperFuTianCleanSystemState = vehicleState.getSweeperFutianCleanSystemState(); - if (sweeperFuTianCleanSystemState != null) { - byte[] bytes = sweeperFuTianCleanSystemState.toByteArray(); - builder.setTaskSystemStates(ChassisStatesOuterClass.TaskSystemStates.newBuilder() - .setSweeperFutianTaskSystemStates(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates.parseFrom(bytes)));//鹰眼已用 清扫车专用 - } + byte[] bytes = vehicleState.getSweeperFutianCleanSystemState().toByteArray(); + builder.setTaskSystemStates(ChassisStatesOuterClass.TaskSystemStates.newBuilder() + .setSweeperFutianTaskSystemStates(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates.parseFrom(bytes)));//鹰眼已用 清扫车专用 } - adasListener.onChassisStates(raw.getHeader(), builder.build()); + ChassisStatesOuterClass.ChassisStates chassisStates = builder.build(); + AutopilotAbilityManager.getInstance().setChassisStates(chassisStates); + return chassisStates; } private void setChassisAutopilotAssistanceInformation(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) { ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.Builder chassisAutopilotAssistanceInformation = null; if (vehicleState.hasPilotMode()) { - Chassis.PilotMode pilotMode = vehicleState.getPilotMode(); - if (pilotMode != null) { - chassisAutopilotAssistanceInformation = ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.newBuilder(); - chassisAutopilotAssistanceInformation.setChassisPilotModeState(pilotMode); - } + chassisAutopilotAssistanceInformation = ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.newBuilder(); + chassisAutopilotAssistanceInformation.setChassisPilotModeState(vehicleState.getPilotMode()); } if (vehicleState.hasEmergencyStopSwitch()) { if (chassisAutopilotAssistanceInformation == null) { @@ -151,12 +140,9 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { private void setGearSystemStates(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) { ChassisStatesOuterClass.GearSystemStates.Builder gearSystemStates = null; if (vehicleState.hasGear()) { - Chassis.GearPosition gear = vehicleState.getGear(); - if (gear != null) { - gearSystemStates = ChassisStatesOuterClass.GearSystemStates.newBuilder(); - //挂挡档位数据 - gearSystemStates.setGearPosition(gear);//鹰眼已用 - } + gearSystemStates = ChassisStatesOuterClass.GearSystemStates.newBuilder(); + //挂挡档位数据 + gearSystemStates.setGearPosition(vehicleState.getGear());//鹰眼已用 } if (vehicleState.hasGearSwitchInference()) { if (gearSystemStates == null) { @@ -278,12 +264,9 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { private void setBCMSystemStates(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) { ChassisStatesOuterClass.BCMSystemStates.Builder bcmSystemStates = null; if (vehicleState.hasLight()) { - Chassis.LightSwitch light = vehicleState.getLight(); - if (light != null) { - bcmSystemStates = ChassisStatesOuterClass.BCMSystemStates.newBuilder(); - //转向灯数据 - bcmSystemStates.setTurnLightState(light);//鹰眼已用 - } + bcmSystemStates = ChassisStatesOuterClass.BCMSystemStates.newBuilder(); + //转向灯数据 + bcmSystemStates.setTurnLightState(vehicleState.getLight());//鹰眼已用 } if (vehicleState.hasBrakeLightStatus()) { if (bcmSystemStates == null) { diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/DispatchHandler.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/DispatchHandler.java index b33334ba03..0ed67b9cc9 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/DispatchHandler.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/DispatchHandler.java @@ -22,11 +22,16 @@ import mogo.telematics.pad.MessagePad; public class DispatchHandler { private final MessagePad.MessageType messageType; private final OnDispatchHandlerListener listener; + private static final int WHAT_DISPATCH = 999999; private HandlerThread mThread; private BaseHandler mBaseHandler; public interface OnDispatchHandlerListener { - void onDispatchRaw(MessagePad.MessageType name, RawData raw); + void onHandler(MessagePad.MessageType type, Handler handler); + + void onHandleMessage(MessagePad.MessageType type, Message msg); + + void onDispatchRaw(MessagePad.MessageType type, RawData raw); } @@ -35,6 +40,16 @@ public class DispatchHandler { this.messageType = messageType; } + public void start() { + if (mThread == null) { + String name = "Dispatch-" + messageType.name().replace("MsgType", ""); + mThread = new HandlerThread(name); + mThread.start(); + initHandler(mThread.getLooper()); + listener.onHandler(messageType, mBaseHandler); + } + } + public void stop() { if (mBaseHandler != null) { mBaseHandler.removeCallbacksAndMessages(null); @@ -47,14 +62,10 @@ public class DispatchHandler { } public void sendRawMessage(RawData raw) { - if (mThread == null) { - String name = "Dispatch-" + messageType.name().replace("MsgType", ""); - mThread = new HandlerThread(name); - mThread.start(); - initHandler(mThread.getLooper()); - } + start(); Message msg = Message.obtain(); msg.obj = raw; + msg.what = WHAT_DISPATCH; mBaseHandler.sendMessage(msg); } @@ -67,16 +78,19 @@ public class DispatchHandler { * @param msg */ protected void handleMessage(Message msg) { - //TODO 计算耗时 临时测试 - if (CupidLogUtils.isEnableLog()) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (mThread != null) { - MessageQueue queue = mThread.getLooper().getQueue(); - CupidLogUtils.i("TimeConsuming", mThread.getName() + " 当前消息队列是否处于空闲状态=" + queue.isIdle()); + if (msg.what == WHAT_DISPATCH) { + //TODO 计算耗时 临时测试 + if (CupidLogUtils.isEnableLog()) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (mThread != null) { + MessageQueue queue = mThread.getLooper().getQueue(); + CupidLogUtils.i("TimeConsuming", mThread.getName() + " 当前消息队列是否处于空闲状态=" + queue.isIdle()); + } } - - } - listener.onDispatchRaw(messageType, (RawData) msg.obj); + listener.onDispatchRaw(messageType, (RawData) msg.obj); + } else { + listener.onHandleMessage(messageType, msg); + } } /** From 9fc90622302ce04d68a678025d41218e1670426e Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Mon, 6 Feb 2023 16:26:19 +0800 Subject: [PATCH 07/10] =?UTF-8?q?[=E5=B7=A5=E6=8E=A7=E6=9C=BA=E7=9B=91?= =?UTF-8?q?=E6=8E=A7]=E6=8F=90=E7=A4=BA=E9=94=99=E8=AF=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zhidao/adas/client/DataDistribution.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java index 5f9055ed09..838fd8d895 100644 --- a/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java +++ b/app_ipc_monitoring/src/main/java/com/zhidao/adas/client/DataDistribution.java @@ -181,7 +181,7 @@ public class DataDistribution { public String cutDown(String str) { if (isCutDown && str.length() > 650) { - str = str.substring(0, 650) + "\n(已缩短。如需查看完整数据,请勾选日志存储复选框)"; + str = str.substring(0, 650) + "\n(已缩短。如需查看完整数据,请勾选日志缩短复选框)"; } return str; } From 0b8faa797e43430e89d79a42bcdbfd7c06fc8b64 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Mon, 6 Feb 2023 18:29:25 +0800 Subject: [PATCH 08/10] =?UTF-8?q?[1.0.0]=20[m1]=20[dialogFragment=20?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=BA=95=E9=83=A8bar=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/BusPassengerFunctionFragment.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionFragment.kt b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionFragment.kt index 91ca752e7d..133b0b38c7 100644 --- a/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionFragment.kt +++ b/OCH/mogo-och-bus-passenger/src/m1/java/com/mogo/och/bus/passenger/ui/BusPassengerFunctionFragment.kt @@ -2,6 +2,8 @@ package com.mogo.och.bus.passenger.ui import android.os.Bundle import android.util.Log +import android.view.View +import android.view.WindowManager import android.widget.CompoundButton import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment @@ -16,6 +18,7 @@ import com.mogo.och.bus.passenger.R import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionPresenter import kotlinx.android.synthetic.m1.bus_p_function_fragment.* + /** * @author: yangyakun * @date: 2023/1/28 @@ -72,10 +75,21 @@ class BusPassengerFunctionFragment : override fun getTagName(): String = TAG override fun initViews() { + + //dialog?.setCancelable(false) + } + + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) dialog?.window?.let { BarUtils.hideStatusBarAndSticky(it) + it.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) + dialog?.setOnShowListener { _ -> + it.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) + BarUtils.hideStatusBarAndSticky(it) + } } - //dialog?.setCancelable(false) } private val videoListener = CompoundButton.OnCheckedChangeListener { _, isChecked -> @@ -140,7 +154,7 @@ class BusPassengerFunctionFragment : override fun show(manager: FragmentManager, tag: String?) { try { var cls = this.javaClass.superclass ?: return - while (cls != null) { + while (true) { if (cls.name == "java.lang.Object") { break } From 2ce02f2a5bfecf208ba9f09e09bcdc358803d553 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Mon, 6 Feb 2023 16:17:17 +0800 Subject: [PATCH 09/10] =?UTF-8?q?[ADAS=20LIB][opt3.0]=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/adas/high/common/MogoReport.java | 110 +++++++++++++++--- 1 file changed, 93 insertions(+), 17 deletions(-) diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java index dcc7a49aa5..3365f70734 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MogoReport.java @@ -13,7 +13,6 @@ public class MogoReport { public static final String RESULT_SHOW_WARNING = "RESULT_SHOW_WARNING"; - public enum Result { AUTOPILOT_SYSTEM_UNSTARTED(RESULT_AUTOPILOT_SYSTEM_UNSTARTED, "自动驾驶系统启动过程中出错,pad可能无法连接,云端监控可能无法上报"), AUTOPILOT_DISABLE(RESULT_AUTOPILOT_DISABLE, "无法启动自动驾驶"), @@ -23,7 +22,6 @@ public class MogoReport { SHOW_WARNING(RESULT_SHOW_WARNING, "一般为过渡状态,存在不确定因素,有可能对自动驾驶有微弱影响,需要在pad端显示为黄色告警。\n如果偶尔上报该result可忽略,如果频繁上报需联系人员进行排查。 目前仅有RTK无法确认状态事件。"); - /** * 消息result code */ @@ -69,6 +67,7 @@ public class MogoReport { public static final String ACTION_CHECK_GEAR = "ACTION_CHECK_GEAR"; public static final String ACTION_CHECK_NETWORK = "ACTION_CHECK_NETWORK"; public static final String ACTION_TRY_AGAIN_LATER = "ACTION_TRY_AGAIN_LATER"; + public static final String ACTION_REMOTEPILOT_REQUEST = "ACTION_REMOTEPILOT_REQUEST"; public enum Action { @@ -79,7 +78,8 @@ public class MogoReport { REBOOT_VEHICLE(ACTION_REBOOT_VEHICLE, "重启车辆"), CHECK_GEAR(ACTION_CHECK_GEAR, "检查车辆档位等影响自动驾驶的因素"), CHECK_NETWORK(ACTION_CHECK_NETWORK, "检查网络连接和路由器等影响通信的因素"), - TRY_AGAIN_LATER(ACTION_TRY_AGAIN_LATER, "请稍后重试"); + TRY_AGAIN_LATER(ACTION_TRY_AGAIN_LATER, "请稍后重试"), + REMOTEPILOT_REQUEST(ACTION_REMOTEPILOT_REQUEST, "请求远程驾驶"); /** * 消息Action code @@ -268,6 +268,20 @@ public class MogoReport { String TASK_CONFIG_EMPTY = "ERECORD_TASK_CONFIG_EMPTY";//配置为空 String TASK_QUEUE_EMPTY = "ERECORD_TASK_QUEUE_EMPTY";//数据队列为空 } + + /** + * 平行驾驶相关异常 + */ + interface EPARALLEL { + String AICLOUD_CONNECTION_ERROR = "EPARALLEL_AICLOUD_CONNECTION_ERROR";//平行驾驶长连接异常 + } + + /** + * 车辆处于困境,等待平行驾驶接管 + */ + interface EVEHICLE { + String IN_TROUBLE = "EVEHICLE_IN_TROUBLE";//planning 检测到车处于困境,把困境状态汇报给 SSM,ssm 发出该事件,等待驾舱端开始平行驾驶 + } } /** @@ -309,9 +323,10 @@ public class MogoReport { } /** - * 系统状态 常规信息 + * 系统状态 */ interface ISYS { + /*******常规信息*******/ String STARTING = "ISYS_STARTING";//系统启动中 String RUNNING = "ISYS_RUNNING";//所有Xavier启动完成 String EXITING = "ISYS_EXITING";//系统退出中 @@ -327,19 +342,14 @@ public class MogoReport { String SYSTEM_IN_IDLE = "ISYS_SYSTEM_IN_IDLE";//系统进入空闲状态 String SYSTEM_OUT_IDLE = "ISYS_SYSTEM_OUT_IDLE";//系统退出空闲状态 - String FUNC_YY_START = "ISYS_FUNC_YY_START";//产品状态检查开始 - String FUNC_YY_FINISH = "ISYS_FUNC_YY_FINISH";//产品状态达成(第一次ready) - String FUNC_YY_TIMEOUT = "ISYS_FUNC_YY_TIMEOUT";//产品状态检查超时 - String FUNC_YY_ABORT = "ISYS_FUNC_YY_ABORT";//产品状态检查中止 - String FUNC_YY_UNREADY = "ISYS_FUNC_YY_UNREADY";//产品状态未就绪 - String FUNC_YY_READY = "ISYS_FUNC_YY_READY";//产品状态就绪 - + /*******轨迹下载相关*******/ String INIT_TRAJECTORY_START = "ISYS_INIT_TRAJECTORY_START";//轨迹管理_轨迹开始下载 String INIT_TRAJECTORY_SUCCESS = "ISYS_INIT_TRAJECTORY_SUCCESS";//轨迹管理_轨迹下载成功 String INIT_TRAJECTORY_FAILURE = "ISYS_INIT_TRAJECTORY_FAILURE";//轨迹管理_轨迹下载失败,本地无对应轨迹 String INIT_TRAJECTORY_WARNING = "ISYS_INIT_TRAJECTORY_WARNING";//轨迹管理_轨迹下载失败,本地有对应轨迹,认为成功 String INIT_TRAJECTORY_TIMEOUT = "ISYS_INIT_TRAJECTORY_TIMEOUT";//轨迹管理_轨迹下载超时 + /*******配置更新相关*******/ String CONFIG_UPDATE_HADMAP = "ISYS_CONFIG_UPDATE_HADMAP";//需要重启升级高精地图 String CONFIG_UPDATE_AI_MODEL = "ISYS_CONFIG_UPDATE_AI_MODEL";//需要重启升级AI模型 String CONFIG_UPDATE_SLAM_MAP = "ISYS_CONFIG_UPDATE_SLAM_MAP";//需要重启升级SLAM地图 @@ -355,13 +365,65 @@ public class MogoReport { interface ISSM { String INIT = "ISSM_INIT";//SSM系统上电初始化 String RESTARTED = "ISSM_RESTARTED";//SSM系统发生重启 - String MODE_XX_START = "ISSM_MODE_XX_START";//SSM变更模式开始 - String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成(第一次ready - String MODE_XX_ABORT = "ISSM_MODE_XX_ABORT";//SSM变更模式中止 - String MODE_XX_TIMEOUT = "ISSM_MODE_XX_TIMEOUT";//SSM变更模式超时 - String MODE_XX_READY = "ISSM_MODE_XX_READY";//SSM模式就绪 - String MODE_XX_UNREADY = "ISSM_MODE_XX_UNREADY";//SSM未就绪 +// String MODE_XX_START = "ISSM_MODE_XX_START";//SSM变更模式开始 +// String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成(第一次ready +// String MODE_XX_ABORT = "ISSM_MODE_XX_ABORT";//SSM变更模式中止 +// String MODE_XX_TIMEOUT = "ISSM_MODE_XX_TIMEOUT";//SSM变更模式超时 +// String MODE_XX_READY = "ISSM_MODE_XX_READY";//SSM模式就绪 +// String MODE_XX_UNREADY = "ISSM_MODE_XX_UNREADY";//SSM未就绪 + + //以上6组被注释掉的字段 中的MODE_XX分别替换成MODE_RUN、MODE_IDLE、MODE_STOP + + String MODE_RUN_START = "ISSM_MODE_RUN_START";//SSM变更模式开始 + String MODE_RUN_FINISH = "ISSM_MODE_RUN_FINISH";//SSM变更模式完成(第一次ready + String MODE_RUN_ABORT = "ISSM_MODE_RUN_ABORT";//SSM变更模式中止 + String MODE_RUN_TIMEOUT = "ISSM_MODE_RUN_TIMEOUT";//SSM变更模式超时 + String MODE_RUN_READY = "ISSM_MODE_RUN_READY";//SSM模式就绪 + String MODE_RUN_UNREADY = "ISSM_MODE_RUN_UNREADY";//SSM未就绪 + + String MODE_IDLE_START = "ISSM_MODE_IDLE_START";//SSM变更模式开始 + String MODE_IDLE_FINISH = "ISSM_MODE_IDLE_FINISH";//SSM变更模式完成(第一次ready + String MODE_IDLE_ABORT = "ISSM_MODE_IDLE_ABORT";//SSM变更模式中止 + String MODE_IDLE_TIMEOUT = "ISSM_MODE_IDLE_TIMEOUT";//SSM变更模式超时 + String MODE_IDLE_READY = "ISSM_MODE_IDLE_READY";//SSM模式就绪 + String MODE_IDLE_UNREADY = "ISSM_MODE_IDLE_UNREADY";//SSM未就绪 + + String MODE_STOP_START = "ISSM_MODE_STOP_START";//SSM变更模式开始 + String MODE_STOP_FINISH = "ISSM_MODE_STOP_FINISH";//SSM变更模式完成(第一次ready + String MODE_STOP_ABORT = "ISSM_MODE_STOP_ABORT";//SSM变更模式中止 + String MODE_STOP_TIMEOUT = "ISSM_MODE_STOP_TIMEOUT";//SSM变更模式超时 + String MODE_STOP_READY = "ISSM_MODE_STOP_READY";//SSM模式就绪 + String MODE_STOP_UNREADY = "ISSM_MODE_STOP_UNREADY";//SSM未就绪 + +// String FUNC_YY_START = "ISSM_FUNC_YY_START";//产品状态检查开始 +// String FUNC_YY_FINISH = "ISSM_FUNC_YY_FINISH";//产品状态达成(第一次ready) +// String FUNC_YY_TIMEOUT = "ISSM_FUNC_YY_TIMEOUT";//产品状态检查超时 +// String FUNC_YY_ABORT = "ISSM_FUNC_YY_ABORT";//产品状态检查中止 +// String FUNC_YY_UNREADY = "ISSM_FUNC_YY_UNREADY";//产品状态未就绪 +// String FUNC_YY_READY = "ISSM_FUNC_YY_READY";//产品状态就绪 + + //以上6组被注释掉的字段 中的FUNC_YY分别替换成FUNC_COLD_START、FUNC_AUTO_PILOT、FUNC_REMOTE_PILOT + String FUNC_COLD_START_START = "ISSM_FUNC_COLD_START_START";//产品状态检查开始 + String FUNC_COLD_START_FINISH = "ISSM_FUNC_COLD_START_FINISH";//产品状态达成(第一次ready) + String FUNC_COLD_START_TIMEOUT = "ISSM_FUNC_COLD_START_TIMEOUT";//产品状态检查超时 + String FUNC_COLD_START_ABORT = "ISSM_FUNC_COLD_START_ABORT";//产品状态检查中止 + String FUNC_COLD_START_UNREADY = "ISSM_FUNC_COLD_START_UNREADY";//产品状态未就绪 + String FUNC_COLD_START_READY = "ISSM_FUNC_COLD_START_READY";//产品状态就绪 + + String FUNC_AUTO_PILOT_START = "ISSM_FUNC_AUTO_PILOT_START";//产品状态检查开始 + String FUNC_AUTO_PILOT_FINISH = "ISSM_FUNC_AUTO_PILOT_FINISH";//产品状态达成(第一次ready) + String FUNC_AUTO_PILOT_TIMEOUT = "ISSM_FUNC_AUTO_PILOT_TIMEOUT";//产品状态检查超时 + String FUNC_AUTO_PILOT_ABORT = "ISSM_FUNC_AUTO_PILOT_ABORT";//产品状态检查中止 + String FUNC_AUTO_PILOT_UNREADY = "ISSM_FUNC_AUTO_PILOT_UNREADY";//产品状态未就绪 + String FUNC_AUTO_PILOT_READY = "ISSM_FUNC_AUTO_PILOT_READY";//产品状态就绪 + + String FUNC_REMOTE_PILOT_START = "ISSM_FUNC_REMOTE_PILOT_START";//产品状态检查开始 + String FUNC_REMOTE_PILOT_FINISH = "ISSM_FUNC_REMOTE_PILOT_FINISH";//产品状态达成(第一次ready) + String FUNC_REMOTE_PILOT_TIMEOUT = "ISSM_FUNC_REMOTE_PILOT_TIMEOUT";//产品状态检查超时 + String FUNC_REMOTE_PILOT_ABORT = "ISSM_FUNC_REMOTE_PILOT_ABORT";//产品状态检查中止 + String FUNC_REMOTE_PILOT_UNREADY = "ISSM_FUNC_REMOTE_PILOT_UNREADY";//产品状态未就绪 + String FUNC_REMOTE_PILOT_READY = "ISSM_FUNC_REMOTE_PILOT_READY";//产品状态就绪 } interface IAGENT { @@ -392,6 +454,20 @@ public class MogoReport { String TASK_AUTO = "IRECORDER_TASK_AUTO";//自动录包任务创建 String TASK_CMD = "IRECORDER_TASK_CMD";//指令录包任务创建 } + + /** + * 平行驾驶相关 + */ + interface IPARALLEL { + String AICLOUD_CONNECTION_OK = "IPARALLEL_AICLOUD_CONNECTION_OK";//长连接连接恢复后, 5s 内如果长连状态一直 ok 的话,会触发该事件 建议鹰眼展示该事件 + } + + /** + * 车辆处于困境相关 + */ + interface IVEHICLE { + String NOT_IN_TROUBLE = "IVEHICLE_NOT_IN_TROUBLE";//车辆脱离困境,恢复正常,可继续开始自动驾驶了 触发频率:处于困境中,触发一次; 脱困后,触发一次 云端驾舱会接入该事件 建议鹰眼也接入,展示困境状态/脱困状态 + } } } } From 2c6684b6170ee7ab7be5e9b6681bea988d06b63a Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Mon, 6 Feb 2023 18:45:30 +0800 Subject: [PATCH 10/10] =?UTF-8?q?[Opt]=E5=85=A8=E8=A7=88=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?View=E5=92=8C=E4=B8=9A=E5=8A=A1=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo-core-function-biz/build.gradle | 3 + .../eagle/function/biz/FuncBizProvider.kt | 15 + .../biz/v2x}/overview/OverViewDataManager.kt | 66 +-- .../biz/v2x}/overview/db/OverviewDao.kt | 2 +- .../biz/v2x}/overview/db/OverviewDb.kt | 2 +- .../overview/remote/OverViewServiceApi.kt | 2 +- .../biz/v2x/overview/remote/V2XEventResult.kt | 20 + .../core/function/hmi/ui/MoGoHmiFragment.kt | 50 +- .../function/main/MainMoGoApplication.java | 4 +- .../eagle/core/function/map/MapFragment.kt | 10 - .../function/overview/InfStructureManager.kt | 51 -- .../core/function/overview/ViewModelExt.kt | 13 - .../function/overview/ViewModelFactory.kt | 41 -- .../function/overview/view/OverMapView.kt | 70 ++- .../function/overview/vm/OverViewModel.kt | 141 ----- .../core/function/smp/AMapCustomView.java | 550 ------------------ .../function/smp/OverviewMapFragment.java | 163 ------ .../layout/module_overview_map_fragment.xml | 14 - .../com/mogo/eagle/core/data/v2x/V2XEvent.kt} | 16 +- .../function/api/biz/IMoGoFuncBizProvider.kt | 7 + .../core/function/api/v2x/IFuncBizProvider.kt | 16 + .../call/biz/CallerFuncBizListenerManager.kt | 33 ++ .../function/call/map/CallerSmpManager.kt | 24 +- 23 files changed, 206 insertions(+), 1107 deletions(-) rename core/function-impl/{mogo-core-function-map/src/main/java/com/mogo/eagle/core/function => mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x}/overview/OverViewDataManager.kt (74%) rename core/function-impl/{mogo-core-function-map/src/main/java/com/mogo/eagle/core/function => mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x}/overview/db/OverviewDao.kt (91%) rename core/function-impl/{mogo-core-function-map/src/main/java/com/mogo/eagle/core/function => mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x}/overview/db/OverviewDb.kt (95%) rename core/function-impl/{mogo-core-function-map/src/main/java/com/mogo/eagle/core/function => mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x}/overview/remote/OverViewServiceApi.kt (83%) create mode 100644 core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/V2XEventResult.kt delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelExt.kt delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelFactory.kt delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java delete mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java delete mode 100644 core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml rename core/{function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/V2XEventResult.kt => mogo-core-data/src/main/java/com/mogo/eagle/core/data/v2x/V2XEvent.kt} (77%) create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IFuncBizProvider.kt create mode 100644 core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/biz/CallerFuncBizListenerManager.kt diff --git a/core/function-impl/mogo-core-function-biz/build.gradle b/core/function-impl/mogo-core-function-biz/build.gradle index d03c91e88d..7ca8ee96d9 100644 --- a/core/function-impl/mogo-core-function-biz/build.gradle +++ b/core/function-impl/mogo-core-function-biz/build.gradle @@ -57,6 +57,9 @@ dependencies { kapt rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.rxandroid + implementation rootProject.ext.dependencies.androidxroomruntime + kapt rootProject.ext.dependencies.androidxroomcompiler + implementation rootProject.ext.dependencies.androidxroomktx implementation project(':foudations:mogo-commons') implementation project(':core:mogo-core-data') diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt index d0831a75ef..cd99899059 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt @@ -2,6 +2,7 @@ package com.mogo.eagle.function.biz import android.content.Context import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.eagle.core.data.camera.CameraEntity import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider @@ -10,6 +11,8 @@ import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.d import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager +import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager +import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb import com.mogo.eagle.function.biz.v2x.speedlimit.SpeedLimitDispatcher import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightDispatcher @@ -68,6 +71,18 @@ class FuncBizProvider : IMoGoFuncBizProvider { cronTaskManager.clear() } + override fun fetchInfStructures() { + OverViewDataManager.fetchInfStructures() + } + + override fun getAllV2XEvents() { + OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn) + } + + override fun initOverViewDb(context: Context) { + OverviewDb.getDb(context) + } + override fun onDestroy() { noticeSocketManager.release() dispatchAutoPilotManager.release() diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/OverViewDataManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt similarity index 74% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/OverViewDataManager.kt rename to core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt index 1bd7910759..eef88f1602 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/OverViewDataManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/OverViewDataManager.kt @@ -1,21 +1,23 @@ -package com.mogo.eagle.core.function.overview +package com.mogo.eagle.function.biz.v2x.overview import androidx.lifecycle.* import com.mogo.commons.AbsMogoApplication import com.mogo.commons.constants.HostConst import com.mogo.eagle.core.data.map.Infrastructure import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager -import com.mogo.eagle.core.function.overview.db.OverviewDb -import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi -import com.mogo.eagle.core.function.overview.remote.V2XEvent +import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb +import com.mogo.eagle.function.biz.v2x.overview.remote.OverViewServiceApi import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import java.util.concurrent.TimeUnit object OverViewDataManager { @@ -26,37 +28,8 @@ object OverViewDataManager { OverviewDb.getDb(AbsMogoApplication.getApp()).overviewDao() } - private val _infStructures = MutableLiveData>() - private val _V2XEvents = MutableLiveData>() private var disposable: Disposable? = null - val infStructures - get() = _infStructures - - private val _infStructuresMap = _infStructures - .switchMap { infStructures -> - liveData { - val map = HashMap>() - infStructures.forEach { - val geoHash = it.geoHash - if (geoHash == null) { - return@forEach - } else { - if (!map.containsKey(geoHash)) { - val list = ArrayList() - list.add(it) - map[geoHash] = list - } else { - map[geoHash]?.add(it) - } - } - } - emit(map) - } - } - val infStructuresMap - get() = _infStructuresMap - fun fetchInfStructures() { ProcessLifecycleOwner.get().lifecycleScope.launch { val data = try { @@ -67,8 +40,27 @@ object OverViewDataManager { e.printStackTrace() null } - data?.let { - _infStructures.value = it + data?.let { infStructures -> + withContext(Dispatchers.Default) { + val map = HashMap>() + infStructures.forEach { + val geoHash = it.geoHash + if (geoHash == null) { + return@forEach + } else { + if (!map.containsKey(geoHash)) { + val list = ArrayList() + list.add(it) + map[geoHash] = list + } else { + map[geoHash]?.add(it) + } + } + } + withContext(Dispatchers.Main) { + CallerFuncBizListenerManager.invokeInfStructures(map) + } + } } } } @@ -113,13 +105,11 @@ object OverViewDataManager { .observeOn(AndroidSchedulers.mainThread()) .subscribe { it?.apply { - _V2XEvents.value = this + CallerFuncBizListenerManager.invokeV2XEvents(this) } } } - fun getV2XEventLiveData() = _V2XEvents - fun stopQueryV2XEvents() { disposable?.dispose() } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDao.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDao.kt similarity index 91% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDao.kt rename to core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDao.kt index 4398041c9e..dd45f481ad 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDao.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDao.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.function.overview.db +package com.mogo.eagle.function.biz.v2x.overview.db import androidx.room.Dao import androidx.room.Query diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDb.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDb.kt similarity index 95% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDb.kt rename to core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDb.kt index 596c282697..c788baa5b4 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/db/OverviewDb.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/db/OverviewDb.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.function.overview.db +package com.mogo.eagle.function.biz.v2x.overview.db import android.content.Context import androidx.room.Database diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/OverViewServiceApi.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/OverViewServiceApi.kt similarity index 83% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/OverViewServiceApi.kt rename to core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/OverViewServiceApi.kt index 64b96e4c72..365f5f0d29 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/OverViewServiceApi.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/OverViewServiceApi.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.function.overview.remote +package com.mogo.eagle.function.biz.v2x.overview.remote import io.reactivex.Observable import retrofit2.http.GET diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/V2XEventResult.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/V2XEventResult.kt new file mode 100644 index 0000000000..0650d29817 --- /dev/null +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/overview/remote/V2XEventResult.kt @@ -0,0 +1,20 @@ +package com.mogo.eagle.function.biz.v2x.overview.remote + +import androidx.annotation.Keep + +import com.google.gson.annotations.SerializedName +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.v2x.V2XEvent + + +@Keep +data class V2XEventResult ( + @SerializedName("result") + var result: Result? +): BaseData() + +@Keep +data class Result( + @SerializedName("eventList") + var v2XEventList: List? +) \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index e0f9474b10..8fe0b50495 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -343,34 +343,34 @@ class MoGoHmiFragment : MvpFragment(), } override fun showSmallFragment() { - // 加载全览模式图层 - val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) - .navigation() as BaseFragment - activity?.supportFragmentManager?.beginTransaction() - ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply { - if (!fragmentOverview.isAdded) { - add( - R.id.module_main_id_smp_fragment, - fragmentOverview, - fragmentOverview.tagName - ) - } else { - show(fragmentOverview) - }.commitAllowingStateLoss() - } - CallerDevaToolsManager.hideStatusBar() +// // 加载全览模式图层 +// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) +// .navigation() as BaseFragment +// activity?.supportFragmentManager?.beginTransaction() +// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply { +// if (!fragmentOverview.isAdded) { +// add( +// R.id.module_main_id_smp_fragment, +// fragmentOverview, +// fragmentOverview.tagName +// ) +// } else { +// show(fragmentOverview) +// }.commitAllowingStateLoss() +// } +// CallerDevaToolsManager.hideStatusBar() } override fun hideSmallFragment() { - val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) - .navigation() as BaseFragment - activity?.supportFragmentManager?.beginTransaction() - ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply { - if (fragmentOverview.isVisible) { - hide(fragmentOverview) - } - } - ?.commitAllowingStateLoss() +// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) +// .navigation() as BaseFragment +// activity?.supportFragmentManager?.beginTransaction() +// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply { +// if (fragmentOverview.isVisible) { +// hide(fragmentOverview) +// } +// } +// ?.commitAllowingStateLoss() } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index 36e777c379..684940db25 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -22,12 +22,12 @@ import com.mogo.eagle.core.data.constants.MoGoConfig; import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.function.api.chat.biz.ChatConsts; import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener; +import com.mogo.eagle.core.function.call.biz.CallerFuncBizManager; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager; import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb; -import com.mogo.eagle.core.function.overview.db.OverviewDb; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; @@ -194,7 +194,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { } private void initOverviewDb() { - OverviewDb.Companion.getDb(this); + CallerFuncBizManager.getBizProvider().initOverViewDb(this); } /** diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt index 4b2daf1c8e..275fe4851d 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.kt @@ -11,7 +11,6 @@ import com.mogo.eagle.core.data.map.CenterLine import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener -import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener import com.mogo.eagle.core.function.business.MapPointCloudSubscriber @@ -20,20 +19,11 @@ import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager import com.mogo.eagle.core.function.call.map.CallerHDMapManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager -import com.mogo.eagle.core.function.overview.InfStructureManager -import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData -import com.mogo.eagle.core.function.overview.obtainViewModel -import com.mogo.eagle.core.function.overview.vm.OverViewModel -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr -import com.mogo.eagle.core.utilcode.util.Utils import com.mogo.map.IMogoMap import com.mogo.map.MogoMapView import com.mogo.map.uicontroller.IMogoMapUIController diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt deleted file mode 100644 index b355165c92..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.mogo.eagle.core.function.overview - -import com.mogo.eagle.core.data.map.Infrastructure -import mogo.telematics.pad.MessagePad - -/** - * 本地数据库查询出来的红绿灯、摄像头等数据 - */ -object InfStructureManager { - - // 每个GeoHash网格对应的新基建Bean - private val _infMap by lazy { - HashMap>() - } - - // 全局路径规划中所有点的GeoHash网格对应的新基建数据集合 - private val _pathMap by lazy { - HashMap>() - } - - private val _planningList by lazy { - ArrayList() - } - - fun saveData(map: HashMap>) { - if (_infMap.isNotEmpty()) { - _infMap.clear() - } - _infMap.putAll(map) - } - - fun getData(): Map> = _infMap - - fun savePathData(map: HashMap>) { - if (_pathMap.isNotEmpty()) { - _pathMap.clear() - } - _pathMap.putAll(map) - } - - fun getPathData(): Map> = _pathMap - - fun savePlanningData(planningList: List) { - if (_planningList.isNotEmpty()) { - _planningList.clear() - } - _planningList.addAll(planningList) - } - - fun getPlanningData() = _planningList -} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelExt.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelExt.kt deleted file mode 100644 index ec414fe02f..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelExt.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.mogo.eagle.core.function.overview - -import androidx.appcompat.app.AppCompatActivity -import androidx.fragment.app.Fragment -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProviders -import com.mogo.commons.AbsMogoApplication - -fun AppCompatActivity.obtainViewModel(viewModelClass: Class) = - ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass) - -fun Fragment.obtainViewModel(viewModelClass: Class) = - ViewModelProviders.of(this, ViewModelFactory.getInstance(AbsMogoApplication.getApp())).get(viewModelClass) \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelFactory.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelFactory.kt deleted file mode 100644 index 0418a667e6..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/ViewModelFactory.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.mogo.eagle.core.function.overview - -import android.annotation.SuppressLint -import android.app.Application -import androidx.annotation.VisibleForTesting -import androidx.lifecycle.ViewModel -import androidx.lifecycle.ViewModelProvider -import com.mogo.eagle.core.function.overview.db.OverviewDao -import com.mogo.eagle.core.function.overview.db.OverviewDb -import com.mogo.eagle.core.function.overview.vm.OverViewModel - -class ViewModelFactory private constructor( - private val overviewDao: OverviewDao -) : ViewModelProvider.NewInstanceFactory() { - - override fun create(modelClass: Class) = - with(modelClass) { - when { - isAssignableFrom(OverViewModel::class.java) -> - OverViewModel(overviewDao) - else -> - throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}") - } - } as T - - companion object { - @SuppressLint("StaticFieldLeak") - @Volatile private var INSTANCE: ViewModelFactory? = null - - fun getInstance(application: Application) = - INSTANCE ?: synchronized(ViewModelFactory::class.java) { - INSTANCE ?: ViewModelFactory( - OverviewDb.getDb(application).overviewDao()) - .also { INSTANCE = it } - } - - @VisibleForTesting fun destroyInstance() { - INSTANCE = null - } - } -} diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/view/OverMapView.kt index ac8567895b..ff8745ffd9 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/view/OverMapView.kt @@ -20,17 +20,16 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.Infrastructure import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.data.v2x.V2XEvent import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener +import com.mogo.eagle.core.function.api.v2x.IFuncBizProvider import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager +import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showVideoDialog import com.mogo.eagle.core.function.map.R -import com.mogo.eagle.core.function.overview.InfStructureManager -import com.mogo.eagle.core.function.overview.InfStructureManager.getData -import com.mogo.eagle.core.function.overview.OverViewDataManager -import com.mogo.eagle.core.function.overview.remote.V2XEvent import com.mogo.eagle.core.function.smp.MakerWithCount import com.mogo.eagle.core.function.smp.MarkerDrawerManager import com.mogo.eagle.core.function.smp.MarkerDrawerManager.callback @@ -40,7 +39,6 @@ import com.mogo.eagle.core.function.smp.MarkerDrawerManager.planningPoints import com.mogo.eagle.core.function.smp.MarkerDrawerManager.startLoopCalCarLocation import com.mogo.eagle.core.function.smp.MarkerDrawerManager.updateRoutePoints import com.mogo.eagle.core.function.smp.V2XMarkerView -import com.mogo.eagle.core.utilcode.kotlin.lifecycleOwner import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler @@ -69,6 +67,8 @@ class OverMapView @JvmOverloads constructor( private val pathMap: MutableMap?> = HashMap() private val posInfMap: MutableMap?> = HashMap() + private var geoHashInfMap: HashMap>? = null + // =============绘制轨迹线相关============= private var mCarMarker: Marker? = null private var mCompassMarker: Marker? = null @@ -189,18 +189,17 @@ class OverMapView @JvmOverloads constructor( override fun onAttachedToWindow() { super.onAttachedToWindow() - OverViewDataManager.infStructuresMap.observe(lifecycleOwner) { list -> - InfStructureManager.saveData(list) - } - // 查询本地数据库中的摄像头数据 - OverViewDataManager.fetchInfStructures() + CallerFuncBizListenerManager.addListener(TAG, object : IFuncBizProvider { + override fun onInfStructures(map: HashMap>?) { + geoHashInfMap = map + } + + override fun onV2XEvents(v2xEvents: List?) { + showV2XEventMarkers(v2xEvents) + } + }) // 主动查一次全局路径规划的数据 getGlobalPath() - // 定时查询V2X事件 - OverViewDataManager.getV2XEventLiveData().observe(lifecycleOwner) { - showV2XEventMarkers(it) - } - OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn) } private fun setUpMap() { @@ -297,32 +296,45 @@ class OverMapView @JvmOverloads constructor( } } startLoopCalCarLocation() - UiThreadHandler.post { drawInfrastructureMarkers(locationList) } + UiThreadHandler.post { + if (geoHashInfMap.isNullOrEmpty()) { + UiThreadHandler.postDelayed({ + drawInfrastructureMarkers(locationList) + }, 1000) + } else { + drawInfrastructureMarkers(locationList) + } + } } /** * 显示V2X事件的Marker */ - fun showV2XEventMarkers(v2XEvents: List?) { + private fun showV2XEventMarkers(v2XEvents: List?) { if (v2XEvents == null || v2XEvents.isEmpty()) return clearV2XMarkers() val markerOptionsList = ArrayList() - for ((_, _, _, center, _, _, poiType, coordinateType) in v2XEvents) { + for (v2xEvent in v2XEvents) { + val center = v2xEvent.center if (center != null) { - center.lon val markerOption = MarkerOptions() - var latLng: LatLng = if (coordinateType == null || coordinateType == 0) { - LatLng(center.lat, center.lon) - } else { - // wgs84坐标系需转成高德坐标系 - coordinateConverterWgsToGcj(mContext!!, center.lat, center.lon) - } + var latLng: LatLng = + if (v2xEvent.coordinateType == null || v2xEvent.coordinateType == 0) { + LatLng(center.lat, center.lon) + } else { + // wgs84坐标系需转成高德坐标系 + coordinateConverterWgsToGcj( + mContext!!, + center.lat, + center.lon + ) + } markerOption.position(latLng) markerOption.anchor(0.13f, 1f) markerOption.icon( BitmapDescriptorFactory.fromBitmap( getV2XBitmap( - poiType + v2xEvent.poiType ) ) ) @@ -364,7 +376,6 @@ class OverMapView @JvmOverloads constructor( // 注册定位监听 CallerChassisLocationGCJ20ListenerManager.removeListener(TAG) CallerPlanningRottingListenerManager.removeListener(TAG) - OverViewDataManager.stopQueryV2XEvents() } override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { @@ -386,7 +397,8 @@ class OverMapView @JvmOverloads constructor( * @param locationList */ private fun drawInfrastructureMarkers(locationList: List?) { - if (locationList == null) return + val infMap = geoHashInfMap + if (locationList == null || infMap.isNullOrEmpty()) return if (pathMap.isNotEmpty()) { pathMap.clear() } @@ -399,7 +411,7 @@ class OverMapView @JvmOverloads constructor( // 网格内的轨迹点只取一次s if (!pathMap.containsKey(geoHash)) { // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 - infList = getData()[geoHash] + infList = infMap[geoHash] if (infList != null) { pathMap[geoHash] = infList } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt deleted file mode 100644 index 8b1237a6c6..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/vm/OverViewModel.kt +++ /dev/null @@ -1,141 +0,0 @@ -package com.mogo.eagle.core.function.overview.vm - -import androidx.lifecycle.* -import com.mogo.commons.constants.HostConst -import com.mogo.eagle.core.data.map.Infrastructure -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo -import com.mogo.eagle.core.function.overview.db.OverviewDao -import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi -import com.mogo.eagle.core.function.overview.remote.V2XEvent -import com.mogo.eagle.core.network.MoGoRetrofitFactory -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import io.reactivex.Observable -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.disposables.Disposable -import io.reactivex.schedulers.Schedulers -import kotlinx.coroutines.launch -import java.util.concurrent.TimeUnit - -class OverViewModel( - private val overviewDao: OverviewDao -) : ViewModel() { - private val _infStructures = MutableLiveData>() - private val _V2XEvents = MutableLiveData>() - private var disposable: Disposable? = null - - companion object { - const val TAG = "OverViewModel" - } - - val infStructures - get() = _infStructures - - private val _infStructuresMap = _infStructures - .switchMap { infStructures -> - liveData { - val map = HashMap>() - infStructures.forEach { - val geoHash = it.geoHash - if (geoHash == null) { - return@forEach - } else { - if (!map.containsKey(geoHash)) { - val list = ArrayList() - list.add(it) - map[geoHash] = list - } else { - map[geoHash]?.add(it) - } - } - } - emit(map) - } - } - val infStructuresMap - get() = _infStructuresMap - - fun fetchInfStructures() { - viewModelScope.launch { - val data = try { - // 只查找摄像头 - overviewDao.listInfStructures(0) -// overviewDao.listAllInfStructures() - } catch (e: Exception) { - e.printStackTrace() - null - } - data?.let { - _infStructures.value = it - } - } - } - - fun updateGeoHash(id: Int, geoHash: String) { - viewModelScope.launch { - try { - overviewDao.updateGeoHash(id, geoHash) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - fun getAllV2XEventsByLineId(sn: String) { - if (disposable != null && !disposable!!.isDisposed) { - disposable!!.dispose() - } - - // 1分钟查询一次 - disposable = Observable.interval(2000, 60000, TimeUnit.MILLISECONDS) - .flatMap { - val lineId = getLineId() - if (lineId > 0) { - MoGoRetrofitFactory.getInstance(HostConst.getHost()) - .create(OverViewServiceApi::class.java) - .queryAllV2XEventsByLineId(lineId.toString(), sn) - .map { - if (it.code == 200 || it.code == 0) { - CallerLogger.d(SceneConstant.M_MAP + TAG, "请求成功,size为:${it.result?.v2XEventList?.size}") - return@map it.result?.v2XEventList - } else { - CallerLogger.d(SceneConstant.M_MAP + TAG, "请求失败,code为:${it.code}") - return@map ArrayList() - } - } - } else { - Observable.just(ArrayList()) - } - } - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe { - it?.apply { - _V2XEvents.value = this - } - } - } - - fun getV2XEventLiveData() = _V2XEvents - - fun stopQueryV2XEvents() { - disposable?.dispose() - } - - private fun getLineId(): Long { - var lineId: Long = -1 - val parameter = getAutoPilotStatusInfo() - .autopilotControlParameters - if (parameter != null) { - if (parameter.autoPilotLine != null) { - lineId = parameter.autoPilotLine!!.lineId - CallerLogger.d(SceneConstant.M_MAP + TAG, "lineId为:$lineId") - } else { - CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter.autoPilotLine为null") - } - } else { - CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter为null") - } - return lineId - } -} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java deleted file mode 100644 index 033d1d3828..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ /dev/null @@ -1,550 +0,0 @@ -package com.mogo.eagle.core.function.smp; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.os.Bundle; -import android.util.AttributeSet; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.amap.api.maps.AMap; -import com.amap.api.maps.CameraUpdate; -import com.amap.api.maps.CameraUpdateFactory; -import com.amap.api.maps.TextureMapView; -import com.amap.api.maps.UiSettings; -import com.amap.api.maps.model.BitmapDescriptor; -import com.amap.api.maps.model.BitmapDescriptorFactory; -import com.amap.api.maps.model.CameraPosition; -import com.amap.api.maps.model.CustomMapStyleOptions; -import com.amap.api.maps.model.LatLng; -import com.amap.api.maps.model.LatLngBounds; -import com.amap.api.maps.model.Marker; -import com.amap.api.maps.model.MarkerOptions; -import com.amap.api.maps.model.Polyline; -import com.amap.api.maps.model.PolylineOptions; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.map.Infrastructure; -import com.mogo.eagle.core.data.map.MogoLocation; -import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; -import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager; -import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; -import com.mogo.eagle.core.function.map.R; -import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.function.overview.remote.Center; -import com.mogo.eagle.core.function.overview.remote.V2XEvent; -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; -import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import ch.hsr.geohash.GeoHash; -import kotlin.Pair; -import me.jessyan.autosize.utils.AutoSizeUtils; -import mogo.telematics.pad.MessagePad; - -/** - * 小地图的方向View - * 监听自动驾驶路径结束,结束高德地图导航 - * - * @author donghongyu - * @date 12/14/20 4:40 PM - */ -public class AMapCustomView - extends RelativeLayout - implements IMoGoChassisLocationGCJ02Listener { - public static final String TAG = "AMapCustomView"; - private TextureMapView mAMapView; - private AMap mAMap; - private int zoomLevel = 15; - private CameraUpdate mCameraUpdate; - private Context mContext; - private float mTilt = 60f; - private TextView overLayerView; - private boolean calculate = false; - - // 全局路径规划中的GeoHash网格 - private Map> pathMap = new HashMap(); - private Map> posInfMap = new HashMap(); - - // =============绘制轨迹线相关============= - private Marker mCarMarker; - private Marker mCompassMarker; - private Marker mStartMarker; - private Marker mEndMarker; - private Polyline mBottomPolyline; - private Polyline mCoveredPolyline; - // 计算索引并设置对应的Bitmap - BitmapDescriptor arrivedBitmap; - BitmapDescriptor unArrivedBitmap; - // 绘制轨迹线的集合 - private List textureList = new ArrayList<>(); - private List texIndexList = new ArrayList<>(); - - private MogoLocation mLocation; - private boolean isFirstLocation = true; - CustomMapStyleOptions mCustomMapStyleOptions; - - ArrayList currMarkerList; - - public AMapCustomView(Context context) { - this(context, null); - } - - public AMapCustomView(Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public AMapCustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - try { - initView(context); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void initView(Context context) { - mContext = context; - View smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this); - mAMapView = smpView.findViewById(R.id.aMapView); - overLayerView = findViewById(R.id.overLayer); - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset)); - arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived); - unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive); - } else { - overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset_bus)); - arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img); - unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route); - } - CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); - initAMapView(context); - // 注册定位监听 - CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this); - //设置全览模式 - overLayerView.setOnClickListener(v -> { - displayCustomOverView(); - }); - } - - private void initAMapView(Context context) { - Log.d(TAG, "initAMapView"); - mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel); - mAMap = mAMapView.getMap(); - mCustomMapStyleOptions = new CustomMapStyleOptions(); - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data")); - mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data")); - } else { - mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data")); - mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data")); - } - mAMap.setOnMapLoadedListener(() -> { - Log.d(TAG, "---onMapLoaded---"); - if (mCustomMapStyleOptions != null) { - // 加载自定义样式 - mCustomMapStyleOptions.setEnable(true); - // 设置自定义样式 - mAMap.setCustomMapStyle(mCustomMapStyleOptions); - } - // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 - mAMap.setTrafficEnabled(false); - }); - setUpMap(); - customOptions(); - } - - private void setUpMap() { - // 地图文字标注 - mAMap.showMapText(true); - //设置希望展示的地图缩放级别 - mAMap.moveCamera(mCameraUpdate); - //设置地图的样式 - UiSettings uiSettings = mAMap.getUiSettings(); - //地图缩放级别的交换按钮 - uiSettings.setZoomControlsEnabled(false); - //所有手势 - uiSettings.setAllGesturesEnabled(true); - //隐藏指南针 - uiSettings.setCompassEnabled(false); - //设置倾斜手势是否可用。 - uiSettings.setTiltGesturesEnabled(true); - //隐藏默认的定位按钮 - uiSettings.setMyLocationButtonEnabled(false); - //设置Logo下边界距离屏幕底部的边距,设置为负值即可 - uiSettings.setLogoBottomMargin(-150); - Log.d(TAG, "before onMapLoaded"); - } - - /** - * 自定义导航View和路况状态 - */ - private void customOptions() { - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - mCarMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon)) - .anchor(0.5f, 0.5f)); - mCompassMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_corner)) - .anchor(0.5f, 0.5f)); - } else { - mCarMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon)) - .anchor(0.5f, 0.5f)); - mCompassMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_corner)) - .anchor(0.5f, 0.5f)); - } - - mStartMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))); - mEndMarker = mAMap.addMarker(new MarkerOptions() - .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))); - } - - private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { - - /** - * 根据全路径获取起始点和经停点进行导航路线绘制 - * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 - * 室内某个bag包自动驾驶启动8s后返回 - */ - @Override - public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) { - Log.d(TAG, "onAutopilotRotting"); - if (globalPathResp != null) { - handlePlanningData(globalPathResp.getWayPointsList()); - } - } - }; - - public void handlePlanningData(List locationList) { - if (locationList == null || locationList.size() == 0) return; - List list = locationList; - // 转成高德坐标系并存储 - MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext); - List planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints(); - UiThreadHandler.post(() -> { - displayCustomOverView(); - drawStartAndEndMarker(planningPointList); - }); - MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> { - // 每1s刷新一下轨迹线 - UiThreadHandler.post(() -> { - if (points.size() > 0) { - drawPolyline(points, locIndex); - } - }); - }); - MarkerDrawerManager.INSTANCE.startLoopCalCarLocation(); - UiThreadHandler.post(() -> { - drawInfrastructureMarkers(locationList); - }); - } - - public void showV2XEventMarkers(List v2XEvents) { - if (v2XEvents == null || v2XEvents.size() <= 0) return; - clearV2XMarkers(); - ArrayList markerOptionsList = new ArrayList<>(); - for (V2XEvent event : v2XEvents) { - Center center = event.getCenter(); - if (center != null) { - center.getLon(); - MarkerOptions markerOption = new MarkerOptions(); - LatLng latLng; - if (event.getCoordinateType() == null || event.getCoordinateType() == 0) { - latLng = new LatLng(center.getLat(), center.getLon()); - } else { - // wgs84坐标系需转成高德坐标系 - latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, center.getLat(), center.getLon()); - } - markerOption.position(latLng); - markerOption.anchor(0.13f, 1f); - markerOption.icon(BitmapDescriptorFactory.fromBitmap(getV2XBitmap(event.getPoiType()))); - markerOptionsList.add(markerOption); - } - } - if (markerOptionsList.size() > 0) { - drawV2XMarkers(markerOptionsList); - } - } - - public void drawV2XMarkers(ArrayList markerOptionsList) { - currMarkerList = mAMap.addMarkers(markerOptionsList, false); - } - - private Bitmap getV2XBitmap(String poiType) { - V2XMarkerView marker = new V2XMarkerView(getContext(), null, 0, poiType); - marker.measure(View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 229), View.MeasureSpec.EXACTLY), - View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 96), View.MeasureSpec.EXACTLY)); - marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight()); - Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888); - marker.draw(new Canvas(bitmap)); - return bitmap; - } - - public void clearV2XMarkers() { - if (currMarkerList != null) { - for (Marker marker : currMarkerList) { - marker.destroy(); - } - currMarkerList = null; - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - // 注册定位监听 - CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG); - CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG); - } - - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - return false; - } - - public void onCreateView(Bundle savedInstanceState) { - if (mAMapView != null) { - mAMapView.onCreate(savedInstanceState); - } - } - - public void onResume() { - if (mAMapView != null) { - mAMapView.onResume(); - } - } - - public void onPause() { - if (mAMapView != null) { - mAMapView.onPause(); - } - } - - public void onDestroy() { - if (mAMapView != null) { - mAMapView.onDestroy(); - } - - if (mAMapView != null) { - mAMapView.onDestroy(); - } - } - - public void clearCustomPolyline() { - if (mBottomPolyline != null) { - mBottomPolyline.remove(); - } - if (mCoveredPolyline != null) { - mCoveredPolyline.remove(); - } - } - - /** - * 绘制新基建Markers(比如:摄像头) - * - * @param locationList - */ - private void drawInfrastructureMarkers(List locationList) { - if (locationList == null) return; - if (!pathMap.isEmpty()) { - pathMap.clear(); - } - String geoHash; - ArrayList infList; - for (int i = 0; i < locationList.size(); i++) { - LatLng latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, locationList.get(i)); - geoHash = GeoHash.withCharacterPrecision(latLng.latitude, latLng.longitude, 7).toBase32(); - // 网格内的轨迹点只取一次s - if (!pathMap.containsKey(geoHash)) { - // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 - infList = InfStructureManager.INSTANCE.getData().get(geoHash); - if (infList != null) { - pathMap.put(geoHash, infList); - } - } - } - drawInfMarkers(pathMap); - } - - //todo 扶风 需重构此处,封装至 全览 - public void drawInfMarkers(Map> infStruMap) { - // 绘制新基建数据 - if (!posInfMap.isEmpty()) { - posInfMap.clear(); - } - ArrayList markerOptionsList = new ArrayList(); - for (ArrayList structureList : infStruMap.values()) { - // 每个GeoHash内根据坐标系象限分散开摄像头icon显示 - - MarkerOptions markerOption = new MarkerOptions(); - LatLng latLng = new LatLng(Double.valueOf(structureList.get(0).getLat()), - Double.valueOf(structureList.get(0).getLon())); - markerOption.position(latLng); - Bitmap bitmap = getBitmap(structureList.size()); - markerOption.icon(BitmapDescriptorFactory.fromBitmap( - bitmap - )); - markerOption.zIndex(2f); - posInfMap.put(latLng, structureList); - markerOptionsList.add(markerOption); - } - mAMap.addMarkers(markerOptionsList, false); - mAMap.setOnMarkerClickListener(marker -> { - List infList = posInfMap.get(marker.getPosition()); - // 如果是摄像头 - if (infList != null) { - CallerHmiManager.INSTANCE.showVideoDialog(infList); - return true; - } - return false; - }); - } - - private Bitmap getBitmap(int count) { - MakerWithCount marker = new MakerWithCount(getContext()); - marker.setCount(count); - - marker.measure(View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY), - View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY)); - marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight()); - Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888); - marker.draw(new Canvas(bitmap)); - return bitmap; - } - - /** - * 进入自定义全览模式 - */ - private void displayCustomOverView() { - ArrayList linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints(); - if (linePointsLatLng.size() > 1) { - //圈定地图显示范围 - //存放经纬度 - LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); - for (int i = 0; i < linePointsLatLng.size(); i++) { - boundsBuilder.include(linePointsLatLng.get(i)); - } - LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude()); - boundsBuilder.include(currentLatLng); - - CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build(); - //第二个参数为四周留空宽度 - mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)); - mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); - } else { - //设置希望展示的地图缩放级别 - CameraPosition cameraPosition = new CameraPosition.Builder() - .target(mCarMarker.getPosition()).tilt(0).zoom(zoomLevel).build(); - mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); - } - } - - /** - * 绘制自车 - * - * @param location - */ - private void drawCarMarker(MogoLocation location) { - if (location == null) return; - if (mCarMarker != null) { - LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); - mCarMarker.setRotateAngle((float) (360 - location.getHeading())); - mCarMarker.setPosition(currentLatLng); - mCarMarker.setToTop(); - if (mCompassMarker != null) { - mCompassMarker.setRotateAngle((float) (360 - location.getHeading())); - mCompassMarker.setPosition(currentLatLng); - } - } - } - - /** - * 绘制起始点、终点 - */ - private void drawStartAndEndMarker(List coordinates) { - if (mStartMarker != null) { - mStartMarker.setVisible(false); - } - if (mEndMarker != null) { - mEndMarker.setVisible(false); - } - if (coordinates.size() > 2) { - // 设置开始结束Marker位置 - - LatLng startLatLng = coordinates.get(0); - LatLng endLatLng = coordinates.get(coordinates.size() - 1); - - mStartMarker.setPosition(startLatLng); - mEndMarker.setPosition(endLatLng); - mStartMarker.setVisible(true); - mEndMarker.setVisible(true); - } - } - - /** - * 绘制轨迹线 - * - * @param coordinates - * @param locIndex - */ - private void drawPolyline(List coordinates, int locIndex) { - if (textureList.size() > 0) { - textureList.clear(); - } - if (texIndexList.size() > 0) { - texIndexList.clear(); - } - for (int i = 0; i < coordinates.size(); i++) { - if (i <= locIndex) { - // 已走过的置灰 - textureList.add(arrivedBitmap); - } else { - // 未走过的纹理 - textureList.add(unArrivedBitmap); - } - texIndexList.add(i); - } - if (mAMap != null && coordinates.size() > 2) { - //设置线段纹理 - PolylineOptions polylineOptions = new PolylineOptions(); - polylineOptions.addAll(coordinates); - polylineOptions.width(14); //线段宽度 - polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound); - polylineOptions.setCustomTextureList(textureList); - polylineOptions.setCustomTextureIndex(texIndexList); - // 绘制线 - mBottomPolyline = mCoveredPolyline; - mCoveredPolyline = mAMap.addPolyline(polylineOptions); - if (mBottomPolyline != null) { - mBottomPolyline.remove(); - } - } - } - - @Override - public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) { - mLocation = gnssInfo; - MarkerDrawerManager.INSTANCE.setLonLat(new Pair(gnssInfo.getLongitude(), gnssInfo.getLatitude())); - drawCarMarker(gnssInfo); - if (isFirstLocation) { - displayCustomOverView(); - isFirstLocation = false; - } - } -} diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java deleted file mode 100644 index 3c4123621f..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.mogo.eagle.core.function.smp; - -import android.content.Context; -import android.os.Bundle; -import android.view.View; - -import androidx.annotation.Nullable; - -import com.alibaba.android.arouter.facade.annotation.Route; -import com.mogo.cloud.passport.MoGoAiCloudClientConfig; -import com.mogo.commons.mvp.BaseFragment; -import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; -import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; -import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager; -import com.mogo.eagle.core.function.map.R; -import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.function.overview.ViewModelExtKt; -import com.mogo.eagle.core.function.overview.vm.OverViewModel; - -import java.util.List; - -/** - * @author donghongyu - * @date 2021/5/19 10:50 上午 - * 全览模式Fragment - */ -@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) -public class OverviewMapFragment extends BaseFragment - implements IMogoSmallMapProvider { - private final String TAG = "OverviewMapFragment"; - protected AMapCustomView mAMapCustomView; - private OverViewModel mViewModel; - - @Override - public void onAttach(Context context) { - super.onAttach(context); - } - - @Override - protected int getLayoutId() { - return R.layout.module_overview_map_fragment; - } - - @Override - public String getTagName() { - return TAG; - } - - @Override - protected void initViews() { - - } - - @Override - protected void initViews(Bundle savedInstanceState) { - super.initViews(savedInstanceState); - mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView); - mAMapCustomView.onCreateView(savedInstanceState); - } - - @Override - public void showPanel() { - if (mAMapCustomView != null) { - mAMapCustomView.setVisibility(View.VISIBLE); - } - } - - @Override - public void hidePanel() { - if (mAMapCustomView != null) { - mAMapCustomView.setVisibility(View.GONE); - } - } - - @Override - public void startQueryV2XEvents() { - if (isAdded()) { - if (mViewModel != null) { - mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn()); - } - } - } - - @Override - public void clearV2XMarkers() { - if (isAdded()) { - if (mAMapCustomView != null) { - mAMapCustomView.clearV2XMarkers(); - } - if (mViewModel != null) { - mViewModel.stopQueryV2XEvents(); - } - } - } - - @Override - public void drawablePolyline(List coordinates) { - } - - @Override - public void clearPolyline() { - } - - @Override - public void onResume() { - super.onResume(); - if (mAMapCustomView != null) { - mAMapCustomView.onResume(); - } - mAMapCustomView.handlePlanningData(InfStructureManager.INSTANCE.getPlanningData()); - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - // 主动查一次全局路径规划的数据 - CallerAutoPilotControlManager.INSTANCE.getGlobalPath(); - queryV2XEvents(); - } - - private void queryV2XEvents() { - mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class); - mViewModel.getV2XEventLiveData().observe(this.getViewLifecycleOwner(), v2XEvents -> { - mAMapCustomView.showV2XEventMarkers(v2XEvents); - }); - mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn()); - } - - /** - * @return Taxi的下发的轨迹id - */ - private long getLineId() { - long lineId = -1; - AutopilotControlParameters parameter = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo() - .getAutopilotControlParameters(); - if (parameter != null) { - if (parameter.autoPilotLine != null) { - lineId = parameter.autoPilotLine.getLineId(); - } - } - return lineId; - } - - @Override - public void onPause() { - super.onPause(); - if (mAMapCustomView != null) { - mAMapCustomView.onPause(); - } - - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (mAMapCustomView != null) { - mAMapCustomView.onDestroy(); - } - } -} diff --git a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml b/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml deleted file mode 100644 index 8ed1c15374..0000000000 --- a/core/function-impl/mogo-core-function-map/src/main/res/layout/module_overview_map_fragment.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/V2XEventResult.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/v2x/V2XEvent.kt similarity index 77% rename from core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/V2XEventResult.kt rename to core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/v2x/V2XEvent.kt index e9138cb04e..c9c1bbb61e 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/remote/V2XEventResult.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/v2x/V2XEvent.kt @@ -1,22 +1,8 @@ -package com.mogo.eagle.core.function.overview.remote +package com.mogo.eagle.core.data.v2x import androidx.annotation.Keep import com.google.gson.annotations.SerializedName -import com.mogo.eagle.core.data.BaseData - - -@Keep -data class V2XEventResult ( - @SerializedName("result") - var result: Result? -): BaseData() - -@Keep -data class Result( - @SerializedName("eventList") - var v2XEventList: List? -) @Keep data class V2XEvent( diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt index 3914299c8d..774812ef84 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt @@ -1,5 +1,6 @@ package com.mogo.eagle.core.function.api.biz +import android.content.Context import com.mogo.eagle.core.data.camera.CameraEntity import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider @@ -51,4 +52,10 @@ interface IMoGoFuncBizProvider : IMoGoFunctionServerProvider { */ fun closeCameraLive() + /*----------------------------------------全览模式----------------------------------------*/ + fun fetchInfStructures() + + fun getAllV2XEvents() + + fun initOverViewDb(context: Context) } \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IFuncBizProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IFuncBizProvider.kt new file mode 100644 index 0000000000..d25c01434a --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/v2x/IFuncBizProvider.kt @@ -0,0 +1,16 @@ +package com.mogo.eagle.core.function.api.v2x + +import com.mogo.eagle.core.data.map.Infrastructure +import com.mogo.eagle.core.data.v2x.V2XEvent + +interface IFuncBizProvider { + /** + * 查询衡阳所有的摄像头数据 + */ + fun onInfStructures(map: HashMap>?) {} + + /** + * 根据lineId获取整条道路的V2X事件 + */ + fun onV2XEvents(v2xEvents: List?) {} +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/biz/CallerFuncBizListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/biz/CallerFuncBizListenerManager.kt new file mode 100644 index 0000000000..6131b746c6 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/biz/CallerFuncBizListenerManager.kt @@ -0,0 +1,33 @@ +package com.mogo.eagle.core.function.call.biz + +import androidx.annotation.MainThread +import com.mogo.eagle.core.data.map.Infrastructure +import com.mogo.eagle.core.data.v2x.V2XEvent +import com.mogo.eagle.core.function.api.v2x.IFuncBizProvider +import com.mogo.eagle.core.function.call.base.CallerBase + +object CallerFuncBizListenerManager: CallerBase() { + + private var map: HashMap>? = null + + override fun doSomeAfterAddListener(tag: String, listener: IFuncBizProvider) { + listener.onInfStructures(map) + } + + @MainThread + fun invokeInfStructures(map: HashMap>) { + this.map = map + M_LISTENERS.forEach { + val listener = it.value + listener.onInfStructures(map) + } + } + + @MainThread + fun invokeV2XEvents(v2xEvents: List?) { + M_LISTENERS.forEach { + val listener = it.value + listener.onV2XEvents(v2xEvents) + } + } +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerSmpManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerSmpManager.kt index 16fbe0a4e9..77198d5fa6 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerSmpManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerSmpManager.kt @@ -20,9 +20,9 @@ object CallerSmpManager : CallerBase() { get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP) .navigation() as IMogoSmallMapProvider - private val mogoOverViewMapProvider: IMogoSmallMapProvider - get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) - .navigation() as IMogoSmallMapProvider +// private val mogoOverViewMapProvider: IMogoSmallMapProvider +// get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) +// .navigation() as IMogoSmallMapProvider private val v2xProvider: IV2XEventProvider get() = ARouter.getInstance().build(MogoServicePaths.PATH_V2X_MODULE) @@ -65,22 +65,22 @@ object CallerSmpManager : CallerBase() { if (Thread.currentThread() !== Looper.getMainLooper().thread) { UiThreadHandler.post { v2xProvider.queryWholeRoadEvents() - mogoOverViewMapProvider.startQueryV2XEvents() +// mogoOverViewMapProvider.startQueryV2XEvents() } } else { v2xProvider.queryWholeRoadEvents() - mogoOverViewMapProvider.startQueryV2XEvents() +// mogoOverViewMapProvider.startQueryV2XEvents() } } @JvmStatic fun clearV2XMarkers() { - if (Thread.currentThread() !== Looper.getMainLooper().thread) { - UiThreadHandler.post { - mogoOverViewMapProvider.clearV2XMarkers() - } - } else { - mogoOverViewMapProvider.clearV2XMarkers() - } +// if (Thread.currentThread() !== Looper.getMainLooper().thread) { +// UiThreadHandler.post { +// mogoOverViewMapProvider.clearV2XMarkers() +// } +// } else { +// mogoOverViewMapProvider.clearV2XMarkers() +// } } } \ No newline at end of file