更改升级接口

This commit is contained in:
xinfengkun
2022-01-20 11:34:20 +08:00
parent de0fdbdac1
commit 0776ea0b6e
6 changed files with 160 additions and 195 deletions

View File

@@ -6,7 +6,6 @@ import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
import com.zhidao.support.adas.high.bean.SSHResult;
import com.zhidao.support.adas.high.bean.IPCUpgradePatchDownloadStatusInfo;
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
import com.zhidao.support.adas.high.bean.LightStatueInfo;
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
@@ -146,11 +145,5 @@ public interface OnAdasListener {
*/
void onUpgradeStateInfo(IPCUpgradeStateInfo info);
/**
* 升级包下载进度 0%~100%
*
* @param info
*/
void onUpgradePatchDownloadStatus(IPCUpgradePatchDownloadStatusInfo info);
}

View File

@@ -1,120 +0,0 @@
package com.zhidao.support.adas.high.bean;
import com.google.gson.annotations.SerializedName;
/**
* 工控机升级包下载
*/
public class IPCUpgradePatchDownloadStatusInfo extends BaseInfo<IPCUpgradePatchDownloadStatusInfo.Values> {
/**
* 状态
*/
public enum Status {
/**
* 下载完成
*/
FINISHED(0, "完成"),
/**
* 正在下载
*/
DOWNLOADING(1, "正在下载"),
/**
* 下载失败
*/
FAILED(2, "下载失败");
public final int code;
public final String describe;
private Status(int code, String describe) {
this.code = code;
this.describe = describe;
}
public static Status getStatus(int code) {
switch (code) {
default:
case 0:
return FINISHED;
case 1:
return DOWNLOADING;
case 2:
return FAILED;
}
}
}
public IPCUpgradePatchDownloadStatusInfo(String action) {
super(action);
}
/**
* 下载进度
*
* @return
*/
public int getDownloadProgress() {
if (values == null) {
//数据解析出错
return -1;
} else {
return values.downloadProgress;
}
}
/**
* 下载状态
*
* @return {@link Status}
*/
public int getDownloadStatus() {
if (values == null) {
//数据解析出错
return -1;
} else {
return values.downloadStatus;
}
}
/**
* 下载版本
*/
public String getDownloadVersion() {
if (values == null) {
//数据解析出错
return null;
} else {
return values.downloadVersion;
}
}
public static class Values {
/**
* 下载进度
*/
@SerializedName("progress")
private int downloadProgress;
/**
* 是否下载完成 0完成 1正在下载 2下载失败
*/
@SerializedName("status")
private int downloadStatus;
/**
* 下载版本
*/
@SerializedName("version")
private String downloadVersion;
public void setDownloadProgress(int downloadProgress) {
this.downloadProgress = downloadProgress;
}
public void setDownloadStatus(int downloadStatus) {
this.downloadStatus = downloadStatus;
}
public void setDownloadVersion(String downloadVersion) {
this.downloadVersion = downloadVersion;
}
}
}

View File

@@ -1,36 +1,81 @@
package com.zhidao.support.adas.high.bean;
import com.google.gson.annotations.SerializedName;
/**
* 工控机升级状态
* 工控机升级
*/
public class IPCUpgradeStateInfo extends BaseInfo<IPCUpgradeStateInfo.Values> {
/**
* 状态
* 下载状态
*/
public enum Status {
public enum DownloadStatus {
/**
* 成功
* 30:开始下载
* 31:下载完成
* 32:下载失败
*/
SUCCESSFUL(0, "升级成功"),
/**
* 失败
*/
FAILED(1, "升级失败");
START(30, "开始下载"),
FINISH(31, "下载完成"),
FAILED(32, "下载失败");
public final int code;
public final String describe;
private Status(int code, String describe) {
private DownloadStatus(int code, String describe) {
this.code = code;
this.describe = describe;
}
public static Status getStatus(int code) {
public static DownloadStatus getStatus(int code) {
switch (code) {
default:
case 0:
case 30:
return START;
case 31:
return FINISH;
case 32:
return FAILED;
case 1:
return SUCCESSFUL;
}
}
}
/**
* 下载状态
*/
public enum UpgradeStatus {
/**
* 60:是否升级
* 61:升级成功
* 62:升级失败
* 63:用户确认
* 64:用户取消
*/
AFFIRM(60, "是否升级"),
SUCCEED(61, "升级成功"),
FAILED(62, "升级失败"),
USER_AFFIRM(63, "用户确认"),
USER_CANCEL(64, "用户取消");
public final int code;
public final String describe;
private UpgradeStatus(int code, String describe) {
this.code = code;
this.describe = describe;
}
public static UpgradeStatus getStatus(int code) {
switch (code) {
default:
case 60:
return AFFIRM;
case 61:
return SUCCEED;
case 62:
return FAILED;
case 63:
return USER_AFFIRM;
case 64:
return USER_CANCEL;
}
}
}
@@ -39,32 +84,117 @@ public class IPCUpgradeStateInfo extends BaseInfo<IPCUpgradeStateInfo.Values> {
super(action);
}
/**
* 获取升级包下载进度
*
* @return
*/
public Values.Progress getProgress() {
if (this.values == null) return null;//数据或解析异常
return this.values.progress;
}
/**
* 获取下载状态
*
* @return
*/
public int getDownloadStatus() {
if (this.values == null) return -1;//数据或解析异常
return this.values.downloadStatus;
}
/**
* 获取升级状态
*
* @return @ {@link Status}
* @return
*/
public int getUpgradeStatus() {
if (values == null) {
return 1;
} else {
return values.status;
}
if (this.values == null) return -1;//数据或解析异常
return this.values.upgradeStatus;
}
/**
* 获取版本号
*
* @return
*/
public String getImages() {
if (this.values == null) return null;//数据或解析异常
return this.values.images;
}
public static class Values {
private Progress progress;
/**
* 0 升级不成功
* 1 升级成功
* int 类型, 下载状态, 如果下载完成,下载进度会为空
*/
private int status;
@SerializedName("download_status")
private int downloadStatus;
/**
* int 类型, 升级状态
*/
@SerializedName("upgrade_status")
private int upgradeStatus;
/**
* string 类型,版本号
*/
private String images;
public int getStatus() {
return status;
}
public static class Progress {
/**
* total : 307405010
* current : 1071793
*/
/**
* int 类型 ,包总大小,字节
*/
private int total;
/**
* int 类型 ,包已经下载大小,字节
*/
private int current;
public void setStatus(int status) {
this.status = status;
public int getTotal() {
return total;
}
public int getCurrent() {
return current;
}
@Override
public String toString() {
return "{" +
"total=" + total +
", current=" + current +
'}';
}
}
}
}
/**
* download_status:
* 30:开始下载
* 31:下载完成
* 32:下载失败
* upgrade_status:
* 60:是否升级
* 61:升级成功
* 62:升级失败
* 63:用户确认
* 64:用户取消
* {
* "action": "ipc_upgrade_status",
* "values": {
* "progress": {
* "total": 307405010, //int 类型 ,包总大小,字节
* "current": 1071793 //int 类型 ,包已经下载大小,字节
* },
* "download_status": 31, //int 类型, 下载状态, 如果下载完成,下载进度会为空
* "upgrade_status": 61, //int 类型, 升级状态
* "images": "mogohub.tencentcloudcr.com/autocar/df:RoboTaxi_MAP-taxi_2.1.3.1_20211214_huzhengming" //string 类型,版本号* }
* <p>
* }
*/

View File

@@ -98,11 +98,7 @@ public enum ActionTypeReceive {
*/
ACTION_WS_AUTOPILOT_ROUTES("route_list", 0x104, "轨迹列表"),
/**
* 工控机升级包下载状态
*/
ACTION_WS_AUTOPILOT_UPGRADE_PATCH_DOWNLOAD_STATUS("ipc_upgrade_patch_download_status", -1, "IPC升级包下载状态"),
/**
* 工控机升级进度
* 工控机升级状态
*/
ACTION_WS_AUTOPILOT_UPGRADE_STATUS("ipc_upgrade_status", -1, "IPC升级状态");

View File

@@ -80,10 +80,7 @@ public class MyMessageFactory implements IMyMessageFactory {
* car dock 基础信息
*/
private IMsg autopilotConfig;
/**
* 工控机升级进度
*/
private IMsg autopilotUpgradePatchDownloadStatusMessage;
@Override
@@ -184,12 +181,6 @@ public class MyMessageFactory implements IMyMessageFactory {
autopilotUpgradeStatusMessage = new WsAutopilotUpgradeStatusMessage();
}
return autopilotUpgradeStatusMessage;
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_UPGRADE_PATCH_DOWNLOAD_STATUS.getmActionType())) {
//ws 工控机升级进度
if (autopilotUpgradePatchDownloadStatusMessage == null) {
autopilotUpgradePatchDownloadStatusMessage = new WsAutopilotUpgradePatchDownloadStatusMessage();
}
return autopilotUpgradePatchDownloadStatusMessage;
}
if (nuImplMessage == null) {

View File

@@ -1,25 +0,0 @@
package com.zhidao.support.adas.high.msg;
import com.google.gson.Gson;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.IPCUpgradePatchDownloadStatusInfo;
/**
* @des 工控机升级包下载状态
* @date 2020/3/12
*/
public class WsAutopilotUpgradePatchDownloadStatusMessage extends MyAbstractMessageHandler {
@Override
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
IPCUpgradePatchDownloadStatusInfo autopilotStatus = gson.fromJson(msg, IPCUpgradePatchDownloadStatusInfo.class);
if (adasListener != null) {
adasListener.onUpgradePatchDownloadStatus(autopilotStatus);
}
}
@Override
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
}
}