[opt2.5.0][mogo-adas] 添加版本解析接口
This commit is contained in:
@@ -55,7 +55,6 @@ import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils
|
||||
import com.zhidao.support.adas.high.common.MessageType
|
||||
import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager
|
||||
import com.zhjt.mogo.adas.data.bean.MogoReport
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
@@ -807,7 +806,7 @@ class MoGoAutopilotControlProvider :
|
||||
if(carConfigResp.dockVersion.isNotEmpty()){
|
||||
if(carConfigResp.dockVersion.contains("taxi")){
|
||||
//修改雨天模式开关默认状态为开启(仅针对taxi320及以上的版本)-sop 215
|
||||
val num = AutopilotAbilityManager.getInstance().parseVersion(true,carConfigResp.dockVersion)
|
||||
val num = AdasManager.getInstance().parseVersion(carConfigResp.dockVersion)
|
||||
if(num >= 320){
|
||||
FunctionBuildConfig.isRainMode = true
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
import com.zhidao.support.adas.high.common.MessageType;
|
||||
import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
|
||||
@@ -14,6 +16,8 @@ import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import bag_manager.BagManagerOuterClass;
|
||||
import chassis.SpecialVehicleTaskCmdOuterClass;
|
||||
@@ -39,6 +43,7 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
private static final int PROTOCOL_VERSION = MessagePad.ProtocolVersion.CurrentVersion.getNumber();
|
||||
private volatile MessagePad.CarConfigResp carConfig;
|
||||
private static final String ADAS_VERSION = BuildConfig.VERSION_NAME;
|
||||
private final Pattern pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+");
|
||||
|
||||
private AdasChannel mChannel;
|
||||
|
||||
@@ -951,4 +956,48 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
public long getTimeoutDetectionTime() {
|
||||
return ReceiveTimeoutManager.getInstance().getTimeout();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析版本 格式 xxx.xxx.xxx(x的数量不固定)
|
||||
* 如果用于比较,仅适用于除个位数非0的字符串,例如:"12.03.04" 解析出为120304可能无法正常对比
|
||||
* 目前已用于DockerVersion和MaserVersion的解析
|
||||
*
|
||||
* @param ver 版本字符串 例如:"MAP-taxi_RoboTaxi_df_2.8.0.3_20220928_test" 解析结果为:280
|
||||
* @return -1表示解析失败
|
||||
*/
|
||||
public int parseVersion(String ver) {
|
||||
return parseVersion(true, ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析版本 格式 xxx.xxx.xxx(x的数量不固定)
|
||||
* 如果用于比较,仅适用于非个位数非0的字符串,例如:"12.03.04" 解析出为120304可能无法正常对比
|
||||
* 目前已用于DockerVersion和MaserVersion的解析
|
||||
*
|
||||
* @param isUseAll 是否使用全部截取数据 true:表示 12.34.56 截取之后 123456 false:表示12.34.56 截取之后 12
|
||||
* @param ver 版本字符串 例如:"MAP-taxi_RoboTaxi_df_2.8.0.3_20220928_test" 解析结果为:280
|
||||
* @return -1表示解析失败
|
||||
*/
|
||||
public int parseVersion(boolean isUseAll, 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 (isUseAll) {
|
||||
group = group.replace(".", "");
|
||||
} else {
|
||||
group = group.split("\\.")[0];
|
||||
}
|
||||
version = Integer.parseInt(group);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CupidLogUtils.e("AdasManager", "版本解析失败=" + ver, e);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AutopilotAbility250 {
|
||||
if (statusInfo.hasMasterVersion()) {
|
||||
//截取Master Version
|
||||
String masterVersion = statusInfo.getMasterVersion();
|
||||
version = AutopilotAbilityManager.getInstance().parseVersion(false, masterVersion);
|
||||
version = AdasManager.getInstance().parseVersion(false, masterVersion);
|
||||
}
|
||||
//如果 maser version 大于1,还需要判断AutoPilotReady字段是否存在,以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行
|
||||
if (version > 1 && statusInfo.hasAutoPilotReady()) {
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -12,8 +11,6 @@ import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import chassis.Chassis;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
@@ -31,7 +28,6 @@ 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;//工控机版本
|
||||
@@ -83,7 +79,7 @@ public class AutopilotAbilityManager {
|
||||
public void setCarConfig(MessagePad.CarConfigResp carConfig) {
|
||||
if (dockerVersion == -1) {
|
||||
String v = carConfig.getDockVersion();
|
||||
int version = parseVersion(true, v);
|
||||
int version = AdasManager.getInstance().parseVersion(v);
|
||||
if (version != -1) {
|
||||
stopTimer();
|
||||
dockerVersion = version;
|
||||
@@ -207,34 +203,4 @@ public class AutopilotAbilityManager {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user