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 60901c1673..93ad0039a6 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 @@ -2,19 +2,14 @@ package com.mogo.och.common.module.manager; import android.content.Context; +import androidx.annotation.Nullable; + +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener; +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager; import com.mogo.eagle.core.utilcode.mogo.logger.Logger; -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.common.ProtocolStatus; import chassis.Chassis; -import chassis.VehicleStateOuterClass; -import mogo.telematics.pad.MessagePad; -import mogo_msg.MogoReportMsg; -import perception.TrafficLightOuterClass; -import prediction.Prediction; -import record_cache.RecordPanelOuterClass; import system_master.SystemStatusInfo; /** @@ -22,11 +17,10 @@ import system_master.SystemStatusInfo; * 工控机状态信息回调(判断是否能否启动自动驾驶的回调) * 目前定的是3秒回调一次 */ -public class OCHAdasAbilityManager { +public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener { private static final String TAG = OCHAdasAbilityManager.class.getSimpleName(); - private boolean isAutopilotAbility = true; private String autopilotAbilityReason = ""; @@ -52,164 +46,40 @@ public class OCHAdasAbilityManager { private void initListeners() { //2022.10.9 工控机状态信息回调(判断是否能否启动自动驾驶的回调), 目前定的是3秒回调一次 - AdasManager.getInstance().setOnAdasListener(adasListener); + CallerAutopilotActionsListenerManager.INSTANCE.addListener(TAG, this); } private void releaseListeners() { - AdasManager.getInstance().setOnAdasListener(null); + CallerAutopilotActionsListenerManager.INSTANCE.removeListener(this); + } + + @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 (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 = "系统正在关闭"; + } + Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason); } public void release() { releaseListeners(); } - - private final OnAdasListener adasListener = new OnAdasListener() { - @Override - public void onTrajectory(MessagePad.Header header, MessagePad.Trajectory trajectory) { - - } - - @Override - public void onTrackedObjects(MessagePad.Header header, MessagePad.TrackedObjects trackedObjects) { - - } - - @Override - public void onGnssInfo(MessagePad.Header header, MessagePad.GnssInfo gnssInfo) { - - } - - @Override - public void onVehicleState(MessagePad.Header header, VehicleStateOuterClass.VehicleState vehicleState) { - - } - - @Override - public void onAutopilotState(MessagePad.Header header, MessagePad.AutopilotState autopilotState) { - - } - - @Override - public void onReportMessage(MessagePad.Header header, MogoReportMsg.MogoReportMessage mogoReportMessage) { - - } - - @Override - public void onPerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights trafficLights) { - - } - - @Override - public void onPredictionObstacleTrajectory(MessagePad.Header header, Prediction.mPredictionObjects predictionObjects) { - - } - - @Override - public void onPointCloud(byte[] pointCloud) { - - } - - @Override - public void onPlanningObjects(MessagePad.Header header, MessagePad.PlanningObjects planningObjects) { - - } - - @Override - public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) { - - } - - @Override - public void onCarConfigResp(MessagePad.Header header, MessagePad.CarConfigResp carConfigResp) { - - } - - @Override - public void onRecordResult(MessagePad.Header header, RecordPanelOuterClass.RecordPanel recordPanel) { - - } - - @Override - public void onGlobalPathResp(MessagePad.Header header, MessagePad.GlobalPathResp globalPathResp) { - - } - - @Override - public void onWarn(MessagePad.Header header, MessagePad.Warn warn) { - - } - - @Override - public void onArrivalNotification(MessagePad.Header header, MessagePad.ArrivalNotification arrivalNotification) { - - } - - @Override - public void onStatusQueryResp(MessagePad.Header header, SystemStatusInfo.StatusInfo statusInfo) { - - } - - @Override - public void onRecordDataConfigResp(MessagePad.Header header, MessagePad.RecordDataConfig config) { - - } - - @Override - public void onPlanningActionMsg(MessagePad.Header header, MessagePad.PlanningActionMsg planningActionMsg) { - - } - - @Override - public void onError(ProtocolStatus status, byte[] bytes) { - - } - - @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 = "挡位不正常"; - } - 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 = "系统正在关闭"; - } - // 暂时先拦截及提示以上4种异常情况 -// if (isAutopilotAbility) -// if (ability.statusInfo == null) { -// isAutopilotAbility = false; -// autopilotAbilityReason = "系统Topic不正常"; -// } -// 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() + " Topic异常"; -// break; -// } -// } - - Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason); - } - }; } diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt index a9a3e8310b..0402c87379 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -1,7 +1,5 @@ package com.mogo.eagle.core.function.autopilot.adapter -import android.location.Location -import android.util.Log import chassis.VehicleStateOuterClass import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.config.FunctionBuildConfig @@ -37,6 +35,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotGuardian import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotSNRequest import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotStatusRespByQuery +import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager.invokeAutopilotAbility import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager.invokeAutopilotCarConfigData import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager.invokeAutopilotCarStateData import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager @@ -51,7 +50,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger -import com.mogo.map.navi.MogoCarLocationChangedListenerRegister import com.zhidao.support.adas.high.AdasManager import com.zhidao.support.adas.high.OnAdasListener import com.zhidao.support.adas.high.bean.AutopilotAbility @@ -444,5 +442,6 @@ class MoGoAdasListenerImpl : OnAdasListener { * 使用方法查看:app_ipc_monitoring/uiMainActivity/onAutopilotAbility */ override fun onAutopilotAbility(ability: AutopilotAbility?) { + invokeAutopilotAbility(ability) } } \ No newline at end of file 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 new file mode 100644 index 0000000000..ed661bbed4 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotActionsListener.kt @@ -0,0 +1,12 @@ +package com.mogo.eagle.core.function.api.autopilot + +import com.zhidao.support.adas.high.bean.AutopilotAbility + + +interface IMoGoAutopilotActionsListener { + + /** + * pnc actions 决策 驾驶的意图 + */ + fun onAutopilotAbility(ability: AutopilotAbility?) +} \ 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 new file mode 100644 index 0000000000..5310098bda --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotActionsListenerManager.kt @@ -0,0 +1,60 @@ +package com.mogo.eagle.core.function.call.autopilot + +import androidx.annotation.Nullable +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 +import java.util.concurrent.ConcurrentHashMap + + +object CallerAutopilotActionsListenerManager : CallerBase() { + + private val M_AUTOPILOT_ACTIONS_LISTENER: ConcurrentHashMap = + ConcurrentHashMap() + + /** + * 添加监听 + * @param tag 标记,用来注销监听使用 + * @param listener 监听回调 + */ + fun addListener( + @Nullable tag: String, + @Nullable listener: IMoGoAutopilotActionsListener + ) { + if (M_AUTOPILOT_ACTIONS_LISTENER.containsKey(tag)) { + return + } + M_AUTOPILOT_ACTIONS_LISTENER[tag] = listener + } + + /** + * 删除监听 + * @param tag 标记,用来注销监听使用 + */ + fun removeListener(@Nullable tag: String) { + if (!M_AUTOPILOT_ACTIONS_LISTENER.containsKey(tag)) { + return + } + M_AUTOPILOT_ACTIONS_LISTENER.remove(tag) + } + + /** + * 删除自动驾驶按钮选中监听 + * @param listener 要删除的监听对象 + */ + fun removeListener(@Nullable listener: IMoGoAutopilotActionsListener) { + M_AUTOPILOT_ACTIONS_LISTENER.forEach { + if (it.value == listener) { + M_AUTOPILOT_ACTIONS_LISTENER.remove(it.key) + } + } + } + + @Synchronized + fun invokeAutopilotAbility(ability: AutopilotAbility?) { + M_AUTOPILOT_ACTIONS_LISTENER.forEach { + val listener = it.value + listener.onAutopilotAbility(ability) + } + } +} \ No newline at end of file