[6.0.0][adas-data][data-centre]能否启动自驾接口修改,加入消息来源字段,以及修改为多条消息同时上报;鹰眼数据中心中修改为事件触发式回调,以及融合域控连接状态原因等;加入主动获取当前状态接口;
This commit is contained in:
@@ -2,36 +2,31 @@ package com.mogo.och.common.module.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatisticsListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
import system_master.SystemStatusInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created on 2022/10/9
|
||||
* 工控机状态信息回调(判断是否能否启动自动驾驶的回调)
|
||||
* 目前定的是3秒回调一次
|
||||
*/
|
||||
public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMoGoAutopilotStatisticsListener, IMoGoAutopilotStatusListener {
|
||||
public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMoGoAutopilotStatisticsListener {
|
||||
|
||||
private static final String TAG = OCHAdasAbilityManager.class.getSimpleName();
|
||||
|
||||
private boolean isAutopilotAbility;
|
||||
private String autopilotAbilityReason = "";
|
||||
private ArrayList<UnableAutopilotReason> unableAutopilotReasons;
|
||||
private String startFailedCode = "";
|
||||
private String startFailedMessage = "";
|
||||
|
||||
@@ -46,7 +41,8 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
ipcConnectStatusChanged();
|
||||
this.isAutopilotAbility = CallerAutopilotActionsListenerManager.INSTANCE.isAutopilotAbility();
|
||||
this.unableAutopilotReasons = CallerAutopilotActionsListenerManager.INSTANCE.getUnableAutopilotReasons();
|
||||
initListeners();
|
||||
}
|
||||
|
||||
@@ -59,7 +55,7 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
|
||||
}
|
||||
|
||||
public String getAutopilotUnAbilityReason(){
|
||||
return autopilotAbilityReason;
|
||||
return unableAutopilotReasons.toString();//TODO 临时toString 需要拼接数据
|
||||
}
|
||||
|
||||
public String getStartFailedCode() {
|
||||
@@ -74,28 +70,20 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
|
||||
//2022.10.9 工控机状态信息回调(判断是否能否启动自动驾驶的回调), 目前定的是3秒回调一次
|
||||
CallerAutopilotActionsListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotStatisticsListenerManager.INSTANCE.addListener(TAG,this);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
CallerAutopilotActionsListenerManager.INSTANCE.removeListener(this);
|
||||
CallerAutopilotStatisticsListenerManager.INSTANCE.removeListener(this);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(this);
|
||||
}
|
||||
|
||||
private void ipcConnectStatusChanged() {
|
||||
this.isAutopilotAbility = CallerAutoPilotControlManager.INSTANCE.isConnected();
|
||||
this.autopilotAbilityReason = isAutopilotAbility ? "" : "未连接自动驾驶系统";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons) {
|
||||
this.isAutopilotAbility = isAutopilotAbility;
|
||||
this.autopilotAbilityReason = unableAutopilotReason;
|
||||
Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason);
|
||||
this.unableAutopilotReasons = unableAutopilotReasons;
|
||||
Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + (unableAutopilotReasons == null ? null : unableAutopilotReasons.toString()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatistics(@Nullable AutopilotStatistics statistics) {
|
||||
if (statistics == null) return;
|
||||
@@ -112,41 +100,4 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
|
||||
public void release() {
|
||||
releaseListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
|
||||
ipcConnectStatusChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(@Nullable MessagePad.ArrivalNotification arrivalNotification) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
}
|
||||
}
|
||||
|
||||
BIN
app_mogo_magic_ring/release/app_mogo_magic_ring-release.apk
Normal file
BIN
app_mogo_magic_ring/release/app_mogo_magic_ring-release.apk
Normal file
Binary file not shown.
1
app_mogo_magic_ring/release/output.json
Normal file
1
app_mogo_magic_ring/release/output.json
Normal file
@@ -0,0 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app_mogo_magic_ring-release.apk","fullName":"release","baseName":"release"},"path":"app_mogo_magic_ring-release.apk","properties":{}}]
|
||||
@@ -53,6 +53,7 @@ import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhjt.mogo.adas.data.bean.AdasParam;
|
||||
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask;
|
||||
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable;
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask;
|
||||
@@ -657,7 +658,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable List<UnableAutopilotReason> unableAutopilotReasons) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import com.zhidao.support.adas.high.OnAdasListener
|
||||
import com.zhjt.mogo.adas.data.bean.AdasParam
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus
|
||||
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
|
||||
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask
|
||||
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask
|
||||
@@ -754,8 +755,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
* 是否可以启动自动驾驶
|
||||
* 使用方法查看:app_ipc_monitoring/uiMainActivity/onAutopilotAbility
|
||||
*/
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?) {
|
||||
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -40,6 +41,7 @@ class MoGoAdasMsgConnectStatusListenerImpl :
|
||||
}
|
||||
|
||||
override fun onConnectionIPCStatus(ipcConnectionStatus: Int, reason: String?) {
|
||||
CallerAutopilotActionsListenerManager.setConnected(ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
|
||||
CallerAutoPilotStatusListenerManager.invokeAutoPilotIPCStatusChanged(
|
||||
ipcConnectionStatus,
|
||||
reason
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.mogo.eagle.core.function.api.autopilot
|
||||
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
|
||||
|
||||
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
* 自动驾驶能力 能否启动自动驾驶
|
||||
*/
|
||||
interface IMoGoAutopilotActionsListener {
|
||||
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
*/
|
||||
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?)
|
||||
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?)
|
||||
}
|
||||
@@ -1,19 +1,103 @@
|
||||
package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isConnected
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
|
||||
|
||||
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
* 能否启动自驾管理类
|
||||
*/
|
||||
object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsListener>() {
|
||||
@Volatile
|
||||
private var isConnected = false
|
||||
private var isAutopilotAbility: Boolean = false
|
||||
private var unableAutopilotReasons: ArrayList<UnableAutopilotReason>? = null
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
init {
|
||||
isConnected = isConnected()
|
||||
isAutopilotAbility = false
|
||||
unableAutopilotReasons = disconnectedReason()
|
||||
printLog("初始化")
|
||||
}
|
||||
|
||||
private fun disconnectedReason(): ArrayList<UnableAutopilotReason> {
|
||||
val list = ArrayList<UnableAutopilotReason>()
|
||||
list.add(UnableAutopilotReason(UnableAutopilotReason.SourceType.LIB, "未连接自动驾驶系统"))
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 能否启动自动驾驶
|
||||
*/
|
||||
fun isAutopilotAbility(): Boolean {
|
||||
return isAutopilotAbility
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不能启动自驾的原因
|
||||
* null:表示没有任何原因证,证明isAutopilotAbility为true
|
||||
*/
|
||||
fun getUnableAutopilotReasons(): ArrayList<UnableAutopilotReason>? {
|
||||
return unableAutopilotReasons
|
||||
}
|
||||
|
||||
fun setConnected(isConnected: Boolean) {
|
||||
if (this.isConnected != isConnected) {
|
||||
this.isConnected = isConnected
|
||||
this.isAutopilotAbility = isConnected
|
||||
unableAutopilotReasons = if (isConnected) null else disconnectedReason()
|
||||
notification()
|
||||
printLog("更新数据 连接状态变更")
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(
|
||||
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
|
||||
) {
|
||||
if (isConnected) {
|
||||
var isEquals: Boolean = true
|
||||
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
|
||||
unableAutopilotReasons.let { onw ->
|
||||
onw.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
this.unableAutopilotReasons?.let { old ->
|
||||
old.sortWith(compareBy(UnableAutopilotReason::hashCode));
|
||||
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
|
||||
Log.i(
|
||||
"ddd",
|
||||
"都不为null时=${isEquals}=${this.isAutopilotAbility} ${(if (this.unableAutopilotReasons == null) null else this.unableAutopilotReasons.toString())}"
|
||||
)
|
||||
}
|
||||
}
|
||||
} else isEquals =
|
||||
!(unableAutopilotReasons != null || this.unableAutopilotReasons != null)
|
||||
Log.i(
|
||||
"ddd",
|
||||
" 两个List是否相同=${isEquals} 新是否能启动自驾=${isAutopilotAbility} 老是否能启动自驾=${this.isAutopilotAbility} 新List是否为空=${unableAutopilotReasons == null} 老List是否为空=${this.unableAutopilotReasons == null}"
|
||||
)
|
||||
if (this.isAutopilotAbility != isAutopilotAbility || !isEquals) {
|
||||
this.isAutopilotAbility = isAutopilotAbility
|
||||
this.unableAutopilotReasons = unableAutopilotReasons
|
||||
notification()
|
||||
printLog("更新数据")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun notification() {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
|
||||
}
|
||||
}
|
||||
|
||||
fun printLog(tag: String) {
|
||||
Log.i(
|
||||
"ddd",
|
||||
"${tag}=${isAutopilotAbility} ${(if (unableAutopilotReasons == null) null else unableAutopilotReasons.toString())}"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zhjt.mogo.adas.data.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 自动驾驶能力 能否启动自动驾驶
|
||||
*/
|
||||
public class UnableAutopilotReason {
|
||||
|
||||
public enum SourceType {
|
||||
LIB,//ADAS庫
|
||||
CHASSIS,//底盤
|
||||
SSM,
|
||||
FSM,
|
||||
}
|
||||
|
||||
/**
|
||||
* 來源
|
||||
*/
|
||||
public final SourceType source;
|
||||
/**
|
||||
* 具體原因
|
||||
*/
|
||||
public final String unableAutopilotReason;
|
||||
|
||||
|
||||
public UnableAutopilotReason(SourceType source, String unableAutopilotReason) {
|
||||
this.source = source;
|
||||
this.unableAutopilotReason = unableAutopilotReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UnableAutopilotReason that = (UnableAutopilotReason) o;
|
||||
return source == that.source && TextUtils.equals(unableAutopilotReason, that.unableAutopilotReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(source, unableAutopilotReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{原因:" + unableAutopilotReason + " 来源:" + source + "}";
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.support.obu.ObuScene;
|
||||
import com.zhjt.mogo.adas.data.AdasConstants;
|
||||
import com.zhidao.support.adas.high.common.MessageType;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhjt.mogo.adas.data.AdasConstants;
|
||||
import com.zhjt.mogo.adas.data.bean.AdasParam;
|
||||
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
|
||||
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
import com.zhjt.mogo.adas.data.sweeper.SweeperCloudTask;
|
||||
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable;
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask;
|
||||
@@ -19,6 +19,9 @@ import com.zhjt.mogo.adas.data.sweeper.task.confirm.SweeperTaskConfirm;
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.status.SweeperTaskStatus;
|
||||
import com.zhjt.mogo.adas.data.sweeper.task.stop.SweeperTaskStop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import bag_manager.BagManagerOuterClass;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import chassis.VehicleStateOuterClass;
|
||||
@@ -263,6 +266,7 @@ public interface OnAdasListener {
|
||||
/**
|
||||
* 后部摄像头视频 10Hz
|
||||
* 目前用于清扫车后摄像头和Taxi右右后摄像头
|
||||
*
|
||||
* @param header 头
|
||||
* @param data 数据
|
||||
*/
|
||||
@@ -418,10 +422,11 @@ public interface OnAdasListener {
|
||||
/**
|
||||
* 是否有能力启动自动驾驶
|
||||
*
|
||||
* @param isAutopilotAbility 是否能启动自动驾驶
|
||||
* @param unableAutopilotReason 不能启动自动驾驶原因
|
||||
* @param isAutopilotAbility 是否能启动自动驾驶
|
||||
* @param unableAutopilotReasons 不能启动自动驾驶原因
|
||||
*/
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason);
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
|
||||
|
||||
|
||||
/**
|
||||
* 启动自动驾驶失败回调
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@@ -15,37 +21,40 @@ import chassis.ChassisStatesOuterClass;
|
||||
*/
|
||||
public class AutopilotAbility230 {
|
||||
private static final String TAG = AutopilotAbility230.class.getSimpleName();
|
||||
private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间
|
||||
private volatile Timer timer;
|
||||
private ChassisStatesOuterClass.ChassisStates chassisStates;
|
||||
private OnAutopilotAbilityListener listener;
|
||||
|
||||
public AutopilotAbility230() {
|
||||
protected interface OnAutopilotAbilityListener {
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
|
||||
}
|
||||
|
||||
protected AutopilotAbility230() {
|
||||
}
|
||||
|
||||
|
||||
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
protected void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
this.chassisStates = chassisStates;
|
||||
}
|
||||
|
||||
|
||||
private void onCallback() {
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
String unableAutopilotReason = null;//不能启动自动驾驶原因
|
||||
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
|
||||
//检测底盘相关
|
||||
if (chassisStates != null) {
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
if (brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "制动踏板被踩下";
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "制动踏板被踩下");
|
||||
}
|
||||
}
|
||||
if (isAutopilotAbility) {
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "档位不正常";
|
||||
}
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "当前档位无法启动自驾");
|
||||
}
|
||||
}
|
||||
//TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段
|
||||
@@ -59,10 +68,13 @@ public class AutopilotAbility230 {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
protected synchronized void start(OnAutopilotAbilityListener listener) {
|
||||
this.listener = listener;
|
||||
if (timer == null) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@@ -70,17 +82,16 @@ public class AutopilotAbility230 {
|
||||
public void run() {
|
||||
onCallback();
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
protected synchronized void stop() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
this.chassisStates = null;
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
import android.os.Message;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -22,36 +24,42 @@ import system_master.SystemStatusInfo;
|
||||
*/
|
||||
public class AutopilotAbility250 {
|
||||
private static final String TAG = AutopilotAbility250.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 volatile Timer timer;
|
||||
private ChassisStatesOuterClass.ChassisStates chassisStates;
|
||||
private int mapVersion = -1;//MAP版本
|
||||
private int masterVersion = -1;//Master版本
|
||||
private OnAutopilotAbilityListener listener;
|
||||
|
||||
public AutopilotAbility250(int mapVersion) {
|
||||
protected interface OnAutopilotAbilityListener {
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
|
||||
|
||||
void onStatusQuery();
|
||||
|
||||
void onSendTimeoutMessages();
|
||||
|
||||
void onRemoveTimeoutMessages();
|
||||
}
|
||||
|
||||
protected AutopilotAbility250(int mapVersion) {
|
||||
this.mapVersion = mapVersion;
|
||||
this.masterVersion = -1;
|
||||
}
|
||||
|
||||
|
||||
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
|
||||
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
|
||||
protected void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (listener != null) {
|
||||
listener.onRemoveTimeoutMessages();
|
||||
}
|
||||
onCallback(statusInfo);
|
||||
}
|
||||
|
||||
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
protected void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
this.chassisStates = chassisStates;
|
||||
}
|
||||
|
||||
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
String unableAutopilotReason = null;//不能启动自动驾驶原因
|
||||
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
|
||||
//检测节点状态相关
|
||||
if (statusInfo != null) {
|
||||
if (masterVersion == -1 && statusInfo.hasMasterVersion()) {
|
||||
@@ -63,7 +71,7 @@ public class AutopilotAbility250 {
|
||||
if (mapVersion >= 30400 && masterVersion > 2 && statusInfo.hasAutoPilotReady() && statusInfo.hasAutoPilotUnreadyReason()) {
|
||||
isAutopilotAbility = statusInfo.getAutoPilotReady();
|
||||
if (!isAutopilotAbility) {
|
||||
unableAutopilotReason = statusInfo.getAutoPilotUnreadyReason();
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, statusInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
} else if (mapVersion >= 21000 && masterVersion > 1 && statusInfo.hasAutoPilotReady()) {//如果 maser version 大于1,还需要判断AutoPilotReady字段是否存在,以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
|
||||
isAutopilotAbility = statusInfo.getAutoPilotReady();
|
||||
@@ -75,15 +83,16 @@ public class AutopilotAbility250 {
|
||||
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]);
|
||||
if (state < AutopilotAbilityManager.NODE_INFO_STATE.length) {
|
||||
builder.append(AutopilotAbilityManager.NODE_INFO_STATE[state]);
|
||||
} else {
|
||||
builder.append("未知异常 ");
|
||||
}
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, builder.toString());
|
||||
builder.setLength(0);
|
||||
}
|
||||
unableAutopilotReason = builder.toString();
|
||||
} else {
|
||||
unableAutopilotReason = "未知异常节点";
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, "未知异常节点");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -91,6 +100,7 @@ public class AutopilotAbility250 {
|
||||
// 目前已知可以下发启动自驾命令的状态: SystemState.SYS_RUNNING、SystemState.PILOT_READY、SystemState.AUTO_PILOT_STARTING、SystemState.AUTO_PILOT_RUNNING
|
||||
if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) {
|
||||
isAutopilotAbility = false;
|
||||
String unableAutopilotReason = null;
|
||||
if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) {
|
||||
unableAutopilotReason = "系统正在启动";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) {
|
||||
@@ -112,30 +122,29 @@ public class AutopilotAbility250 {
|
||||
} else {
|
||||
unableAutopilotReason = "未知系统状态";
|
||||
}
|
||||
if (!isAutopilotAbility) {
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, unableAutopilotReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isAutopilotAbility = false;//是否能启动自动驾驶
|
||||
unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "SSM状态查询超时无响应");
|
||||
}
|
||||
//检测底盘相关
|
||||
if (chassisStates != null) {
|
||||
if (isAutopilotAbility) {
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
if (brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "制动踏板被踩下";
|
||||
}
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
if (brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "制动踏板被踩下");
|
||||
}
|
||||
}
|
||||
if (isAutopilotAbility) {
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "档位不正常";
|
||||
}
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
if (!AutopilotAbilityManager.getInstance().isLaunchAutopilot(gear)) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.CHASSIS, "当前档位无法启动自驾");
|
||||
}
|
||||
}
|
||||
//TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段
|
||||
@@ -149,43 +158,43 @@ public class AutopilotAbility250 {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
protected synchronized void start(OnAutopilotAbilityListener listener) {
|
||||
this.listener = listener;
|
||||
if (timer == null) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) {
|
||||
AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery();
|
||||
if (listener != null) {
|
||||
listener.onStatusQuery();
|
||||
}
|
||||
AdasManager.getInstance().sendStatusQueryReq();
|
||||
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
|
||||
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
|
||||
AutopilotAbilityManager.getInstance().getHandler().sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
if (listener != null) {
|
||||
listener.onSendTimeoutMessages();
|
||||
}
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
protected synchronized void stop() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
this.chassisStates = null;
|
||||
this.masterVersion = -1;
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (msg.what == WHAT_TIMEOUT) {
|
||||
onCallback(null);
|
||||
}
|
||||
protected void onCallTimeout() {
|
||||
onCallback(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -22,29 +26,35 @@ import system_master.SystemStatusInfo;
|
||||
*/
|
||||
public class AutopilotAbility330 {
|
||||
private static final String TAG = AutopilotAbility330.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 volatile Timer timer;
|
||||
|
||||
private volatile FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond;//自动驾驶状态为OFF的原因
|
||||
private int mapVersion = -1;//MAP版本
|
||||
private int masterVersion = -1;//Master版本
|
||||
private OnAutopilotAbilityListener listener;
|
||||
|
||||
public AutopilotAbility330(int mapVersion) {
|
||||
protected interface OnAutopilotAbilityListener {
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons);
|
||||
|
||||
void onStatusQuery();
|
||||
|
||||
void onSendTimeoutMessages();
|
||||
|
||||
void onRemoveTimeoutMessages();
|
||||
}
|
||||
|
||||
protected AutopilotAbility330(int mapVersion) {
|
||||
this.mapVersion = mapVersion;
|
||||
this.masterVersion = -1;
|
||||
}
|
||||
|
||||
public synchronized void setFsmStatusReasonRespond(FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
|
||||
protected synchronized void setFsmStatusReasonRespond(FSMStatusReasonQueryOuterClass.FSMStatusReasonRespond fsmStatusReasonRespond) {
|
||||
this.fsmStatusReasonRespond = fsmStatusReasonRespond;
|
||||
}
|
||||
|
||||
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
|
||||
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
|
||||
protected void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (listener != null) {
|
||||
listener.onRemoveTimeoutMessages();
|
||||
}
|
||||
onCallback(statusInfo);
|
||||
}
|
||||
@@ -52,7 +62,7 @@ public class AutopilotAbility330 {
|
||||
|
||||
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
String unableAutopilotReason = null;//不能启动自动驾驶原因
|
||||
ArrayList<UnableAutopilotReason> unableAutopilotReasons = null;//不能启动自动驾驶原因
|
||||
//检测节点状态相关
|
||||
if (statusInfo != null) {
|
||||
if (masterVersion == -1 && statusInfo.hasMasterVersion()) {
|
||||
@@ -64,7 +74,7 @@ public class AutopilotAbility330 {
|
||||
if (mapVersion >= 30400 && masterVersion > 2 && statusInfo.hasAutoPilotReady() && statusInfo.hasAutoPilotUnreadyReason()) {
|
||||
isAutopilotAbility = statusInfo.getAutoPilotReady();
|
||||
if (!isAutopilotAbility) {
|
||||
unableAutopilotReason = statusInfo.getAutoPilotUnreadyReason();
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, statusInfo.getAutoPilotUnreadyReason());
|
||||
}
|
||||
} else if (mapVersion >= 21000 && masterVersion > 1 && statusInfo.hasAutoPilotReady()) {//如果 maser version 大于1,还需要判断AutoPilotReady字段是否存在,以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
|
||||
isAutopilotAbility = statusInfo.getAutoPilotReady();
|
||||
@@ -76,15 +86,16 @@ public class AutopilotAbility330 {
|
||||
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]);
|
||||
if (state < AutopilotAbilityManager.NODE_INFO_STATE.length) {
|
||||
builder.append(AutopilotAbilityManager.NODE_INFO_STATE[state]);
|
||||
} else {
|
||||
builder.append("未知异常 ");
|
||||
}
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, builder.toString());
|
||||
builder.setLength(0);
|
||||
}
|
||||
unableAutopilotReason = builder.toString();
|
||||
} else {
|
||||
unableAutopilotReason = "未知异常节点";
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, "未知异常节点");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -92,6 +103,7 @@ public class AutopilotAbility330 {
|
||||
// 目前已知可以下发启动自驾命令的状态: SystemState.SYS_RUNNING、SystemState.PILOT_READY、SystemState.AUTO_PILOT_STARTING、SystemState.AUTO_PILOT_RUNNING
|
||||
if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) {
|
||||
isAutopilotAbility = false;
|
||||
String unableAutopilotReason = null;
|
||||
if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) {
|
||||
unableAutopilotReason = "系统正在启动";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) {
|
||||
@@ -113,67 +125,68 @@ public class AutopilotAbility330 {
|
||||
} else {
|
||||
unableAutopilotReason = "未知系统状态";
|
||||
}
|
||||
if (!isAutopilotAbility) {
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.SSM, unableAutopilotReason);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isAutopilotAbility = false;//是否能启动自动驾驶
|
||||
unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "SSM状态查询超时无响应");
|
||||
}
|
||||
if (isAutopilotAbility) {
|
||||
if (fsmStatusReasonRespond != null) {
|
||||
int count = fsmStatusReasonRespond.getFsmStatusReasonRespondCount();
|
||||
StringBuilder builder = null;
|
||||
if (count > 0) {
|
||||
builder = new StringBuilder();
|
||||
isAutopilotAbility = false;
|
||||
for (int i = 0; i < count; i++) {
|
||||
String respond = fsmStatusReasonRespond.getFsmStatusReasonRespond(i);
|
||||
builder.append(respond).append(' ');
|
||||
if (!TextUtils.isEmpty(respond)) {
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.FSM, respond);
|
||||
}
|
||||
}
|
||||
if (unableAutopilotReasons == null || unableAutopilotReasons.isEmpty()) {
|
||||
unableAutopilotReasons = AutopilotAbilityManager.getInstance().addUnableAutopilotReason(unableAutopilotReasons, UnableAutopilotReason.SourceType.LIB, "FSM未给出原因");
|
||||
}
|
||||
}
|
||||
if (builder != null) {
|
||||
isAutopilotAbility = false;
|
||||
builder.deleteCharAt(builder.length() - 1);//删除末尾
|
||||
unableAutopilotReason = builder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
AutopilotAbilityManager.getInstance().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
protected synchronized void start(OnAutopilotAbilityListener listener) {
|
||||
this.listener = listener;
|
||||
if (timer == null) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) {
|
||||
AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery();
|
||||
if (listener != null) {
|
||||
listener.onStatusQuery();
|
||||
}
|
||||
AdasManager.getInstance().sendStatusQueryReq();
|
||||
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
|
||||
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
|
||||
AutopilotAbilityManager.getInstance().getHandler().sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
if (listener != null) {
|
||||
listener.onSendTimeoutMessages();
|
||||
}
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}, 2000L, AutopilotAbilityManager.DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
protected synchronized void stop() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
this.masterVersion = -1;
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (msg.what == WHAT_TIMEOUT) {
|
||||
onCallback(null);
|
||||
}
|
||||
protected void onCallTimeout() {
|
||||
onCallback(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,16 @@ package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -25,8 +30,12 @@ import system_master.SystemStatusInfo;
|
||||
* <p>
|
||||
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
|
||||
*/
|
||||
public class AutopilotAbilityManager {
|
||||
public class AutopilotAbilityManager implements AutopilotAbility230.OnAutopilotAbilityListener, AutopilotAbility250.OnAutopilotAbilityListener, AutopilotAbility330.OnAutopilotAbilityListener {
|
||||
private static final String TAG = AutopilotAbilityManager.class.getSimpleName();
|
||||
protected static final int WHAT_TIMEOUT = 0;
|
||||
protected static final int DEFAULT_TIMEOUT = 2500;
|
||||
protected static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测周期
|
||||
protected static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "};
|
||||
private static volatile AutopilotAbilityManager INSTANCE;
|
||||
private OnAdasListener listener;
|
||||
private Handler handler;
|
||||
@@ -79,6 +88,22 @@ public class AutopilotAbilityManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加不能启动自驾的原因
|
||||
*
|
||||
* @param unableAutopilotReasons 原因列表
|
||||
* @param source 来源
|
||||
* @param unableAutopilotReason 云隐
|
||||
* @return 原因列表
|
||||
*/
|
||||
protected ArrayList<UnableAutopilotReason> addUnableAutopilotReason(ArrayList<UnableAutopilotReason> unableAutopilotReasons, UnableAutopilotReason.SourceType source, String unableAutopilotReason) {
|
||||
if (unableAutopilotReasons == null) {
|
||||
unableAutopilotReasons = new ArrayList<>();
|
||||
}
|
||||
unableAutopilotReasons.add(new UnableAutopilotReason(source, unableAutopilotReason));
|
||||
return unableAutopilotReasons;
|
||||
}
|
||||
|
||||
public void setCarConfig(MessagePad.CarConfigResp carConfig) {
|
||||
mapVersion = carConfig.getMapVersion();
|
||||
isFutianSweeper = carConfig.getIsFutianSweeper();
|
||||
@@ -93,9 +118,33 @@ public class AutopilotAbilityManager {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
@Override
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, @Nullable ArrayList<UnableAutopilotReason> unableAutopilotReasons) {
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReasons);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusQuery() {
|
||||
if (onAutopilotAbilityListener != null) {
|
||||
onAutopilotAbilityListener.onStatusQuery();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendTimeoutMessages() {
|
||||
onRemoveTimeoutMessages();
|
||||
if (handler != null) {
|
||||
handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveTimeoutMessages() {
|
||||
if (handler != null) {
|
||||
if (handler.hasMessages(WHAT_TIMEOUT))
|
||||
handler.removeMessages(WHAT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,18 +152,11 @@ public class AutopilotAbilityManager {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public Handler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) {
|
||||
this.onAutopilotAbilityListener = onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
public OnAutopilotAbilityListener getOnAutopilotAbilityListener() {
|
||||
return onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SSM状态更新
|
||||
@@ -156,8 +198,13 @@ public class AutopilotAbilityManager {
|
||||
}
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.onHandleMessage(msg);
|
||||
if (msg.what == WHAT_TIMEOUT) {
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.onCallTimeout();
|
||||
}
|
||||
if (autopilotAbility330 != null) {
|
||||
autopilotAbility330.onCallTimeout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +216,7 @@ public class AutopilotAbilityManager {
|
||||
stop250();
|
||||
if (autopilotAbility330 == null) {
|
||||
autopilotAbility330 = new AutopilotAbility330(mapVersion);
|
||||
autopilotAbility330.start();
|
||||
autopilotAbility330.start(this);
|
||||
}
|
||||
} else if (mapVersion >= 20500) {
|
||||
CupidLogUtils.i(TAG, "是否可以启动自动驾驶能力检测使用250版本");
|
||||
@@ -177,7 +224,7 @@ public class AutopilotAbilityManager {
|
||||
stop330();
|
||||
if (autopilotAbility250 == null) {
|
||||
autopilotAbility250 = new AutopilotAbility250(mapVersion);
|
||||
autopilotAbility250.start();
|
||||
autopilotAbility250.start(this);
|
||||
}
|
||||
} else {
|
||||
CupidLogUtils.i(TAG, "是否可以启动自动驾驶能力检测使用230版本");
|
||||
@@ -185,7 +232,7 @@ public class AutopilotAbilityManager {
|
||||
stop330();
|
||||
if (autopilotAbility230 == null) {
|
||||
autopilotAbility230 = new AutopilotAbility230();
|
||||
autopilotAbility230.start();
|
||||
autopilotAbility230.start(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user