[2.14.0][adas lib] 1.能否启动自驾检测接口兼容MAP250以下版本;2.获取车机基础信息接口增加多次获取逻辑,目前会尝试3次获取
This commit is contained in:
@@ -23,7 +23,6 @@ import androidx.annotation.Nullable;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.AutopilotReview;
|
||||
import com.zhidao.support.adas.high.common.ByteUtil;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
@@ -34,6 +33,7 @@ import com.zhidao.support.adas.high.common.MessageType;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
|
||||
import com.zhidao.support.adas.high.common.RegexUtils;
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.msg.IMsg;
|
||||
import com.zhidao.support.adas.high.msg.MyMessageFactory;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
@@ -129,6 +129,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
* 乘客屏无法进行注册或取消注册,因为乘客屏无法感知司机屏与工控机连接状态。无法重置已注册或未注册接口列表
|
||||
*/
|
||||
private SubscribeInterface subscribeInterface;
|
||||
private Timer carConfigReqTimer;//车辆基础信息请求 多次请求防止无法收到基础信息情况出现
|
||||
|
||||
public void setOnMultiDeviceListener(OnMultiDeviceListener onMultiDeviceListener) {
|
||||
this.onMultiDeviceListener = onMultiDeviceListener;
|
||||
@@ -519,7 +520,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess(String ipAddress, int port) {
|
||||
sendCarConfigReq();
|
||||
startCarConfigReq();
|
||||
ipcConnectedIp = ipAddress;
|
||||
ipcConnectedPort = port;
|
||||
subscribeInterface = new SubscribeInterface(this);
|
||||
@@ -641,6 +642,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
} else {
|
||||
AutopilotAbilityManager.getInstance().stop();
|
||||
stopCheckCompatibility();
|
||||
stopCarConfigReq();
|
||||
}
|
||||
if (status == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
|
||||
AdasManager.getInstance().setCarConfig(null);
|
||||
@@ -758,6 +760,40 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
CupidLogUtils.setEnableLog(isEnableLog);
|
||||
}
|
||||
|
||||
//车辆基础信息请求
|
||||
private void startCarConfigReq() {
|
||||
if (carConfigReqTimer == null) {
|
||||
carConfigReqTimer = new Timer();
|
||||
carConfigReqTimer.schedule(new TimerTask() {
|
||||
int num = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getIpcConnectionStatus() == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
if (AdasManager.getInstance().getCarConfig() == null) {
|
||||
num++;
|
||||
if (num > 3) {
|
||||
CupidLogUtils.i(TAG, "最后一次也未获取到车机基础信息");
|
||||
stopCarConfigReq();
|
||||
} else {
|
||||
CupidLogUtils.i(TAG, "第" + num + "次获取车机基础信息");
|
||||
sendCarConfigReq();
|
||||
}
|
||||
} else {
|
||||
stopCarConfigReq();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10, 2000L);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void stopCarConfigReq() {
|
||||
if (carConfigReqTimer != null) {
|
||||
carConfigReqTimer.cancel();
|
||||
carConfigReqTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************************************************************/
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOptions;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import chassis.Chassis;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
|
||||
/**
|
||||
* 是否可以启动自动驾驶能力检测 工控机版本>=230&& <250 使用此类
|
||||
* 目前监控了底盘的一些状态和查询节点状态应答的数据
|
||||
* 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知
|
||||
* <p>
|
||||
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
|
||||
*/
|
||||
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;
|
||||
|
||||
public AutopilotAbility230() {
|
||||
}
|
||||
|
||||
|
||||
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
this.chassisStates = chassisStates;
|
||||
}
|
||||
|
||||
private void onCallback() {
|
||||
//金旅、开沃小巴乘客端 不能启动自动驾驶
|
||||
if (AutopilotAbilityManager.getInstance().isBus() && AutopilotAbilityManager.getInstance().isPassenger()) {
|
||||
return;
|
||||
}
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
String unableAutopilotReason = null;//不能启动自动驾驶原因
|
||||
//检测底盘相关
|
||||
if (chassisStates != null) {
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
if (brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "制动踏板被踩下";
|
||||
}
|
||||
}
|
||||
if (isAutopilotAbility) {
|
||||
/**
|
||||
* 档位状态判断 目前判断的车型包括 东风Taxi 红旗Taxi 金旅Bus
|
||||
*/
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
//金旅Bus和清扫车 档位不正常
|
||||
if (AutopilotAbilityManager.getInstance().isBus()) {
|
||||
if (gear == Chassis.GearPosition.GEAR_N || gear == Chassis.GearPosition.GEAR_R) {
|
||||
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 (AutopilotAbilityManager.getInstance().getListener() != null) {
|
||||
AutopilotAbilityManager.getInstance().getListener().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
if (timer == null) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
onCallback();
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
this.chassisStates = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,82 +1,41 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
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 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.ChassisStatesOuterClass;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 是否可以启动自动驾驶能力检测
|
||||
* 是否可以启动自动驾驶能力检测 工控机版本>=250使用此类
|
||||
* 目前监控了底盘的一些状态和查询节点状态应答的数据
|
||||
* 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知
|
||||
* <p>
|
||||
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
|
||||
*/
|
||||
public class AutopilotAbilityManager {
|
||||
private static final String TAG = AutopilotAbilityManager.class.getSimpleName();
|
||||
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 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 int identityMode;
|
||||
|
||||
public interface OnAutopilotAbilityListener {
|
||||
void onStatusQuery();//查询是被调用
|
||||
public AutopilotAbility250() {
|
||||
}
|
||||
|
||||
|
||||
public void setIdentityMode(int identityMode) {
|
||||
this.identityMode = identityMode;
|
||||
}
|
||||
|
||||
public void setOnAdasListener(OnAdasListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) {
|
||||
this.onAutopilotAbilityListener = onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
private AutopilotAbilityManager() {
|
||||
}
|
||||
|
||||
public static AutopilotAbilityManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (AutopilotAbilityManager.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new AutopilotAbilityManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (handler != null) {
|
||||
if (handler.hasMessages(WHAT_TIMEOUT))
|
||||
handler.removeMessages(WHAT_TIMEOUT);
|
||||
if (AutopilotAbilityManager.getInstance().getHandler() != null) {
|
||||
if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT))
|
||||
AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT);
|
||||
}
|
||||
onCallback(statusInfo);
|
||||
}
|
||||
@@ -87,7 +46,7 @@ public class AutopilotAbilityManager {
|
||||
|
||||
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
//金旅、开沃小巴乘客端 不能启动自动驾驶
|
||||
if (isBus(identityMode) && isPassenger(identityMode)) {
|
||||
if (AutopilotAbilityManager.getInstance().isBus() && AutopilotAbilityManager.getInstance().isPassenger()) {
|
||||
return;
|
||||
}
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
@@ -98,20 +57,7 @@ public class AutopilotAbilityManager {
|
||||
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();
|
||||
}
|
||||
}
|
||||
version = AutopilotAbilityManager.getInstance().parseVersion(false, masterVersion);
|
||||
}
|
||||
//如果 maser version 大于1,还需要判断AutoPilotReady字段是否存在,以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
|
||||
if (version > 1 && statusInfo.hasAutoPilotReady()) {
|
||||
@@ -182,7 +128,7 @@ public class AutopilotAbilityManager {
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
//金旅Bus和清扫车 档位不正常
|
||||
if (isBus(identityMode)) {
|
||||
if (AutopilotAbilityManager.getInstance().isBus()) {
|
||||
if (gear == Chassis.GearPosition.GEAR_N || gear == Chassis.GearPosition.GEAR_R) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "挡位不正常";
|
||||
@@ -208,8 +154,8 @@ public class AutopilotAbilityManager {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
if (AutopilotAbilityManager.getInstance().getListener() != null) {
|
||||
AutopilotAbilityManager.getInstance().getListener().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,14 +165,14 @@ public class AutopilotAbilityManager {
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (onAutopilotAbilityListener != null) {
|
||||
onAutopilotAbilityListener.onStatusQuery();
|
||||
if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) {
|
||||
AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery();
|
||||
}
|
||||
AdasManager.getInstance().sendStatusQueryReq();
|
||||
if (handler != null) {
|
||||
if (handler.hasMessages(WHAT_TIMEOUT))
|
||||
handler.removeMessages(WHAT_TIMEOUT);
|
||||
handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
@@ -238,14 +184,9 @@ public class AutopilotAbilityManager {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
handler = null;
|
||||
this.chassisStates = null;
|
||||
}
|
||||
|
||||
public void setHandler(Handler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (msg.what == WHAT_TIMEOUT) {
|
||||
@@ -254,19 +195,4 @@ public class AutopilotAbilityManager {
|
||||
}
|
||||
|
||||
|
||||
private boolean isDriver(int appIdentityMode) {
|
||||
return (appIdentityMode & 0x01) != 0x01;
|
||||
}
|
||||
|
||||
private boolean isPassenger(int appIdentityMode) {
|
||||
return (appIdentityMode & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
private boolean isBus(int appIdentityMode) {
|
||||
return (appIdentityMode & 0xA0) == 0xA0;
|
||||
}
|
||||
|
||||
private boolean isTaxi(int appIdentityMode) {
|
||||
return (appIdentityMode & 0xA0) != 0xA0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.zhidao.support.adas.high.common.autopilot.ability;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
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 java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 是否可以启动自动驾驶能力检测
|
||||
* 目前监控了底盘的一些状态和查询节点状态应答的数据
|
||||
* 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知
|
||||
* <p>
|
||||
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
|
||||
*/
|
||||
public class AutopilotAbilityManager {
|
||||
private static final String TAG = AutopilotAbilityManager.class.getSimpleName();
|
||||
private static volatile AutopilotAbilityManager INSTANCE;
|
||||
private OnAdasListener listener;
|
||||
private final Pattern pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||
private Handler handler;
|
||||
private OnAutopilotAbilityListener onAutopilotAbilityListener;
|
||||
private int dockerVersion = -1;//工控机版本
|
||||
private AutopilotAbility230 autopilotAbility230;
|
||||
private AutopilotAbility250 autopilotAbility250;
|
||||
private Timer startTimer;
|
||||
/**
|
||||
* 身份/车型
|
||||
*/
|
||||
private int identityMode;
|
||||
|
||||
public interface OnAutopilotAbilityListener {
|
||||
void onStatusQuery();//查询是被调用
|
||||
}
|
||||
|
||||
private AutopilotAbilityManager() {
|
||||
}
|
||||
|
||||
public static AutopilotAbilityManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (AutopilotAbilityManager.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new AutopilotAbilityManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public void setIdentityMode(int identityMode) {
|
||||
this.identityMode = identityMode;
|
||||
}
|
||||
|
||||
public void setCarConfig(MessagePad.CarConfigResp carConfig) {
|
||||
if (dockerVersion == -1) {
|
||||
String v = carConfig.getDockVersion();
|
||||
int version = parseVersion(true, v);
|
||||
if (version != -1) {
|
||||
if (startTimer != null) {
|
||||
startTimer.cancel();
|
||||
startTimer = null;
|
||||
}
|
||||
dockerVersion = version;
|
||||
Log.i("dddd", "工控机版本=" + dockerVersion);
|
||||
initAutopilotAbility();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnAdasListener(OnAdasListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public OnAdasListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public void setHandler(Handler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public Handler getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) {
|
||||
this.onAutopilotAbilityListener = onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
public OnAutopilotAbilityListener getOnAutopilotAbilityListener() {
|
||||
return onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
|
||||
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.setStatusInfo(statusInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
if (autopilotAbility230 != null) {
|
||||
autopilotAbility230.setChassisStates(chassisStates);
|
||||
}
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.setChassisStates(chassisStates);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.onHandleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initAutopilotAbility() {
|
||||
if (dockerVersion >= 250) {
|
||||
stop230();
|
||||
if (autopilotAbility250 == null) {
|
||||
autopilotAbility250 = new AutopilotAbility250();
|
||||
autopilotAbility250.start();
|
||||
}
|
||||
} else {
|
||||
stop250();
|
||||
if (autopilotAbility230 == null) {
|
||||
autopilotAbility230 = new AutopilotAbility230();
|
||||
autopilotAbility230.start();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void stop230() {
|
||||
if (autopilotAbility230 != null) {
|
||||
autopilotAbility230.stop();
|
||||
autopilotAbility230 = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void stop250() {
|
||||
if (autopilotAbility250 != null) {
|
||||
autopilotAbility250.stop();
|
||||
autopilotAbility250 = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接工控机成功调用此函数,如果dockerVersion还未获取到将启动最低版本的启动自动驾驶能力检测
|
||||
* 此函数为保险措施 以防无法获取工控机版本时 也能 正常执行逻辑
|
||||
*/
|
||||
public synchronized void start() {
|
||||
if (startTimer == null) {
|
||||
startTimer = new Timer();
|
||||
startTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (dockerVersion == -1 && AdasManager.getInstance().getIpcConnectionStatus() == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
dockerVersion = 230;
|
||||
initAutopilotAbility();
|
||||
}
|
||||
}
|
||||
}, 8000L);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
stop230();
|
||||
stop250();
|
||||
handler = null;
|
||||
dockerVersion = -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 接线板 格式 xxx.xxx.xxx(x的数量不固定)
|
||||
*
|
||||
* @param isUserAll 是否使用全部截取数据 true:表示 12.34.56 截取之后 123456 false:表示12.34.56 截取之后 12
|
||||
* @param ver 版本字符串
|
||||
* @return -1表示解析失败
|
||||
*/
|
||||
public int parseVersion(boolean isUserAll, String ver) {
|
||||
int version = -1;
|
||||
if (!TextUtils.isEmpty(ver)) {
|
||||
try {
|
||||
Matcher matcher = pattern.matcher(ver);
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
if (!TextUtils.isEmpty(group)) {
|
||||
if (isUserAll) {
|
||||
group = group.replace(".", "");
|
||||
} else {
|
||||
group = group.split("\\.")[0];
|
||||
}
|
||||
version = Integer.parseInt(group);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CupidLogUtils.e(TAG, "版本解析失败=" + ver, e);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean isDriver() {
|
||||
return (identityMode & 0x01) != 0x01;
|
||||
}
|
||||
|
||||
public boolean isPassenger() {
|
||||
return (identityMode & 0x01) == 0x01;
|
||||
}
|
||||
|
||||
public boolean isBus() {
|
||||
return (identityMode & 0xA0) == 0xA0;
|
||||
}
|
||||
|
||||
public boolean isTaxi() {
|
||||
return (identityMode & 0xA0) != 0xA0;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
@@ -20,6 +21,7 @@ public class CarConfigRespMessage extends MyAbstractMessageHandler {
|
||||
public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException {
|
||||
MessagePad.CarConfigResp carConfigResp = MessagePad.CarConfigResp.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
|
||||
AdasChannel.calculateTimeConsumingOnDispatchRaw("车机基础信息应答", raw.receiveTime);
|
||||
AutopilotAbilityManager.getInstance().setCarConfig(carConfigResp);
|
||||
AdasManager.getInstance().setCarConfig(carConfigResp);
|
||||
long nowTime = 0;
|
||||
if (CupidLogUtils.isEnableLog())
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.os.SystemClock;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.os.SystemClock;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user