[dev2.15.0][adas]添加添加参数获取应答回调解析方法
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.zhidao.adas.client.bean;
|
||||
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
import com.google.protobuf.TextFormat;
|
||||
import com.zhidao.adas.client.R;
|
||||
import com.zhidao.support.adas.high.bean.AdasParam;
|
||||
import com.zhidao.support.adas.high.common.ByteUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class AdasParamReceiveData extends BaseInfo {
|
||||
public final GeneratedMessageV3 bean;
|
||||
private final AdasParam adasParam;
|
||||
|
||||
public AdasParamReceiveData(MessagePad.Header header, GeneratedMessageV3 bean, AdasParam adasParam, SimpleDateFormat sdf) {
|
||||
super("接收", bean.getSerializedSize(), header, sdf);
|
||||
this.bean = bean;
|
||||
this.adasParam = adasParam;
|
||||
}
|
||||
|
||||
public String toString(int resId) {
|
||||
String srt = "";
|
||||
if (resId == R.id.rb_analysis) {
|
||||
srt = TextFormat.printer().shortDebugString(bean);
|
||||
} else if (resId == R.id.rb_original) {
|
||||
srt = "Payload原始数据:" + ByteUtil.byteArrToHex(bean.toByteArray());
|
||||
} else if (resId == R.id.rb_all) {
|
||||
srt = "Payload原始数据:" + ByteUtil.byteArrToHex(bean.toByteArray()) + '\n' + TextFormat.printer().shortDebugString(bean);
|
||||
}
|
||||
return super.toString(resId) + srt + "\n原始数据翻译:\n" + adasParam.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import com.zhidao.adas.client.adapter.InfoTitleAdapter;
|
||||
import com.zhidao.adas.client.base.BaseActivity;
|
||||
import com.zhidao.adas.client.base.BaseAdapter;
|
||||
import com.zhidao.adas.client.base.BaseFragment;
|
||||
import com.zhidao.adas.client.bean.AdasParamReceiveData;
|
||||
import com.zhidao.adas.client.bean.ErrorData;
|
||||
import com.zhidao.adas.client.bean.IPCConnectState;
|
||||
import com.zhidao.adas.client.bean.ObuMap;
|
||||
@@ -84,6 +85,7 @@ 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.AdasParam;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
@@ -1279,8 +1281,8 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetParamResp(@NonNull MessagePad.Header header, @NonNull MessagePad.SetParamReq getParamResp) {
|
||||
ReceiveData base = new ReceiveData(header, getParamResp, sdf);
|
||||
public void onGetParamResp(@NonNull MessagePad.Header header, @NonNull MessagePad.SetParamReq getParamResp, @NonNull AdasParam adasParam) {
|
||||
AdasParamReceiveData base = new AdasParamReceiveData(header, getParamResp, adasParam, sdf);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.mogo.support.obu.ObuScene;
|
||||
import com.zhidao.support.adas.high.bean.AdasParam;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
|
||||
|
||||
@@ -292,8 +293,9 @@ public interface OnAdasListener {
|
||||
*
|
||||
* @param header 头
|
||||
* @param getParamResp 配置参数
|
||||
* @param adasParam 解析后的配置参数
|
||||
*/
|
||||
void onGetParamResp(@NotNull MessagePad.Header header, @NotNull MessagePad.SetParamReq getParamResp);
|
||||
void onGetParamResp(@NotNull MessagePad.Header header, @NotNull MessagePad.SetParamReq getParamResp, @NotNull AdasParam adasParam);
|
||||
|
||||
/**
|
||||
* 是否有能力启动自动驾驶
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* 工控机配置参数
|
||||
* -1表示未知,说明没有这个param或者get失败
|
||||
*/
|
||||
public class AdasParam {
|
||||
/**
|
||||
* 绕障类功能开关
|
||||
* -1:未知 0:关闭 1:开启
|
||||
*/
|
||||
public final int detouringCmd;
|
||||
/**
|
||||
* 变道绕障的目标障碍物速度阈值
|
||||
* -1:未知
|
||||
*/
|
||||
public final double detouringSpeed;
|
||||
/**
|
||||
* AEB开关
|
||||
* -1:未知 0:关闭自动紧急制动功能 1:启用自动紧急制动功能
|
||||
*/
|
||||
public final int aebCmd;
|
||||
/**
|
||||
* 限制绕障开关
|
||||
* -1:未知 0(默认):正常绕障 1:限制绕障
|
||||
*/
|
||||
public final int laneChangeRestrainValid;
|
||||
/**
|
||||
* 停车让行线前避让等待开关
|
||||
* -1:未知 0(默认):停车让行线前无需等待 1:停车让行线前需要等待
|
||||
*/
|
||||
public final int stopYieldValid;
|
||||
/**
|
||||
* 地图限速功能开关
|
||||
* -1:未知 0(默认):不使用地图限速功能 1:使用地图限速功能
|
||||
*/
|
||||
public final int hadmapSpeedLimitValid;
|
||||
/**
|
||||
* 环岛模式开关
|
||||
* -1:未知 0(默认):普通模式 1:环岛模式
|
||||
*/
|
||||
public final int rampThetaValid;
|
||||
/**
|
||||
* 弱网减速停车策略开关
|
||||
* -1:未知 0:关闭弱网减速停车策略 1(默认):使用弱网减速停车策略
|
||||
*/
|
||||
public final int weakNetSlowDown;
|
||||
|
||||
public AdasParam(MessagePad.SetParamReq param) {
|
||||
int detouringCmd = -1;
|
||||
double detouringSpeed = -1.0;
|
||||
int aebCmd = -1;
|
||||
int laneChangeRestrainValid = -1;
|
||||
int stopYieldValid = -1;
|
||||
int hadmapSpeedLimitValid = -1;
|
||||
int rampThetaValid = -1;
|
||||
int weakNetSlowDown = -1;
|
||||
if (param != null) {
|
||||
int size = param.getReqsCount();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
MessagePad.SetOneParam oneParam = param.getReqs(i);
|
||||
int type = oneParam.getType();
|
||||
String value = oneParam.getValue();
|
||||
if (type == Constants.PARAM_TYPE.DETOURING) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
detouringCmd = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.DETOURING_SPEED) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
detouringSpeed = Double.parseDouble(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.AEB) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
aebCmd = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.LANE_CHANGE_RESTRAIN_VALID) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
laneChangeRestrainValid = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.STOP_YIELD_VALID) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
stopYieldValid = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.HADMAP_SPEED_LIMIT_VALID) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
hadmapSpeedLimitValid = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.RAMP_THETA_VALID) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
rampThetaValid = Integer.parseInt(value);
|
||||
}
|
||||
} else if (type == Constants.PARAM_TYPE.WEAK_NET_SLOW_DOWN) {
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
weakNetSlowDown = Integer.parseInt(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.detouringCmd = detouringCmd;
|
||||
this.detouringSpeed = detouringSpeed;
|
||||
this.aebCmd = aebCmd;
|
||||
this.laneChangeRestrainValid = laneChangeRestrainValid;
|
||||
this.stopYieldValid = stopYieldValid;
|
||||
this.hadmapSpeedLimitValid = hadmapSpeedLimitValid;
|
||||
this.rampThetaValid = rampThetaValid;
|
||||
this.weakNetSlowDown = weakNetSlowDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "绕障类功能开关=" + (detouringCmd == -1 ? "未知" : detouringCmd == 0 ? "关" : "开") +
|
||||
"\n变道绕障的目标障碍物速度阈值=" + (detouringSpeed == -1 ? "未知" : detouringSpeed + "m/s") +
|
||||
"\nAEB开关=" + (aebCmd == -1 ? "未知" : aebCmd == 0 ? "关" : "开") +
|
||||
"\n限制绕障开关=" + (laneChangeRestrainValid == -1 ? "未知" : laneChangeRestrainValid == 0 ? "正常绕障" : "限制绕障") +
|
||||
"\n停车让行线前避让等待开关=" + (stopYieldValid == -1 ? "未知" : stopYieldValid == 0 ? "无需等待" : "等待") +
|
||||
"\n地图限速功能开关=" + (hadmapSpeedLimitValid == -1 ? "未知" : hadmapSpeedLimitValid == 0 ? "不使用" : "使用") +
|
||||
"\n环岛模式开关=" + (rampThetaValid == -1 ? "未知" : rampThetaValid == 0 ? "普通模式" : "环岛模式") +
|
||||
"\n弱网减速停车策略开关=" + (weakNetSlowDown == -1 ? "未知" : weakNetSlowDown == 0 ? "关闭" : "使用");
|
||||
}
|
||||
}
|
||||
@@ -5,6 +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.bean.AdasParam;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class GetParamRespMessage extends MyAbstractMessageHandler {
|
||||
if (CupidLogUtils.isEnableLog())
|
||||
nowTime = SystemClock.elapsedRealtime();
|
||||
if (adasListener != null) {
|
||||
adasListener.onGetParamResp(raw.getHeader(), getParamResp);
|
||||
adasListener.onGetParamResp(raw.getHeader(), getParamResp, new AdasParam(getParamResp));
|
||||
}
|
||||
AdasChannel.calculateTimeConsumingBusiness("参数获取应答", nowTime);
|
||||
// CupidLogUtils.e("到站提醒--->" + arrivalNotification.toString());
|
||||
|
||||
Reference in New Issue
Block a user