[2.13.0] change the host location and fix bug of token problem

This commit is contained in:
zhongchao
2022-11-30 15:22:13 +08:00
parent 573bc5a385
commit 0d6938262c
25 changed files with 56 additions and 367 deletions

View File

@@ -204,7 +204,6 @@ class MoGoAdasListenerImpl : OnAdasListener {
autopilotStatusInfo.camera = autopilotState.camera
autopilotStatusInfo.rtk = autopilotState.rtk
autopilotStatusInfo.radar = autopilotState.radar
autopilotStatusInfo.speed = autopilotState.speed.toFloat()
autopilotStatusInfo.version = AdasManager.getInstance().adasVersion
if (autopilotStatusInfo.connectIP == null) {
autopilotStatusInfo.connectIP = AdasManager.getInstance().ipcConnectedIp
@@ -214,7 +213,6 @@ class MoGoAdasListenerImpl : OnAdasListener {
}
AdasManager.getInstance().carConfig?.let {
autopilotStatusInfo.dockVersion = it.dockVersion
AppConfigInfo.dockerVersion = it.dockVersion
}
CallerLogger.d("Upgrade", "origin = ${autopilotStatusInfo.connectStatus} -----now = ${AppConfigInfo.isConnectAutopilot} ")
AppConfigInfo.isConnectAutopilot = autopilotStatusInfo.connectStatus
@@ -320,9 +318,11 @@ class MoGoAdasListenerImpl : OnAdasListener {
) {
if (carConfigResp != null) {
//todo emArrow startUp时确认数据完整性
AppConfigInfo.dockerVersion = carConfigResp.dockVersion
AppConfigInfo.plateNumber = carConfigResp.plateNumber//车牌号
AppConfigInfo.iPCMacAddress = carConfigResp.macAddress//工控机MAC地址
AppConfigInfo.protocolVersionNumber = carConfigResp.protocolVersionValue//工控机协议版本
AppConfigInfo.isConnectAutopilot = true
invokeAutopilotCarConfigData(carConfigResp)
}
}

View File

@@ -1,13 +1,10 @@
package com.mogo.eagle.core.function.autopilot.adapter
import android.annotation.SuppressLint
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig.*
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
import com.mogo.eagle.core.function.autopilot.network.AdasServiceModel
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
@@ -22,9 +19,6 @@ import com.zhidao.support.adas.high.common.Constants
import com.zhidao.support.adas.high.common.Constants.ENVIRONMENT.*
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DRIVER
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.PASSENGER
import mogo.telematics.pad.MessagePad
import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
/**
* ADAS-SDK与工控机连接状态回调
@@ -33,18 +27,8 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
IMoGoAutopilotStatusListener, IMoGoCloudListener {
private val TAG = "ConnectStatus"
//自动驾驶状态
private var mCurrentAutopilotStatus = -1
//自动驾驶车速度
private var mCurrentAutopilotSpeed = 0f
private var connectStatus = false
private val hasUploadTaskLaunched by lazy { AtomicBoolean(false) }
private val timer = Timer()
init {
CallerCloudListenerManager.registerCloudListener(TAG, this)
}
@@ -65,8 +49,6 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = true
// 同步SN给工控机
syncBasicInfoToAutopilot()
// 开启轮询上传自动驾驶状态
updateDriveStatusTask()
//每次工控机连接成功后,需同步当前设置的美化模式状态
CallerAutoPilotManager.setDemoMode(FunctionBuildConfig.isDemoMode)
//当连接状态是关闭美化模式时,同步给工控机
@@ -89,8 +71,6 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
AdasManager.getInstance().ipcConnectedPort
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = false
//与工控机断开连接,需要重置自动驾驶状态(包括上传至云平台缓存信息),等待连接成功后同步状态信息
mCurrentAutopilotStatus = 0
mCurrentAutopilotSpeed = 0.0f
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state = 0
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().pilotmode = 0
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTING) {
@@ -117,21 +97,6 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
syncBasicInfoToAutopilot()
}
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
if (arrivalNotification != null && arrivalNotification.endLocation != null) {
val lon = arrivalNotification.endLocation.longitude
val lat = arrivalNotification.endLocation.latitude
AdasServiceModel.getInstance().reportSite(lon, lat)
}
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
val state = autoPilotStatusInfo.state
val speed = autoPilotStatusInfo.speed
mCurrentAutopilotStatus = state
mCurrentAutopilotSpeed = speed
}
/**
* 同步SN信息给工控机
*/
@@ -174,23 +139,6 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
}
}
/**
* 上传自动驾驶状态任务
*/
@SuppressLint("CheckResult")
private fun updateDriveStatusTask() {
if (hasUploadTaskLaunched.compareAndSet(false, true)) {
timer.schedule(object : TimerTask() {
override fun run() {
CallerLogger.d("$M_ADAS_IMPL$TAG", "updateDriveStatusTask")
AdasServiceModel.getInstance()
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
}
}, 0, 5000)
}
}
override fun tokenGot(token: String, sn: String) {
syncBasicInfoToAutopilot(sn)
}

View File

@@ -1,41 +0,0 @@
package com.mogo.eagle.core.function.autopilot.entity;
/**
* Created by SuYong on 2021/5/28 16:12
*/
public class AutonomousDriveStatusBean {
private String sn;
private int status;
private float vehicleSpeed;
public AutonomousDriveStatusBean(String sn, int status, float vehicleSpeed) {
this.sn = sn;
this.status = status;
this.vehicleSpeed = vehicleSpeed;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public float getVehicleSpeed() {
return vehicleSpeed;
}
public void setVehicleSpeed(float vehicleSpeed) {
this.vehicleSpeed = vehicleSpeed;
}
}

View File

@@ -1,40 +0,0 @@
package com.mogo.eagle.core.function.autopilot.entity;
/**
* Created by SuYong on 2021/5/31 16:24
*/
public class ReportSiteBean {
private String sn;
private double lon;
private double lat;
public ReportSiteBean(String sn, double lon, double lat) {
this.sn = sn;
this.lon = lon;
this.lat = lat;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
}

View File

@@ -1,95 +0,0 @@
package com.mogo.eagle.core.function.autopilot.network;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.context.ContextHolderUtil;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.function.autopilot.entity.AutonomousDriveStatusBean;
import com.mogo.eagle.core.function.autopilot.entity.ReportSiteBean;
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
import com.mogo.eagle.core.network.RequestOptions;
import com.mogo.eagle.core.network.SubscribeImpl;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.eagle.core.data.constants.HostConst;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* 将自动驾驶状态及站点信息上传给云平台,云平台会根据此数据做路线的绘制
*
* @author dongghongyu
*/
public class AdasServiceModel {
private static final String TAG = "AdasServiceModel";
private static volatile AdasServiceModel instance;
private static final byte[] obj = new byte[0];
private final IAdasApiService mAdasApiService;
private AdasServiceModel() {
this.mAdasApiService = MoGoRetrofitFactory.getInstance(HostConst.DATA_SERVICE_HOST).create(IAdasApiService.class);
}
public static AdasServiceModel getInstance() {
if (instance == null) {
synchronized (obj) {
if (instance == null) {
instance = new AdasServiceModel();
}
}
}
return instance;
}
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
}
});
}
public void reportSite(double lon, double lat) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
}
});
}
}

View File

@@ -1,31 +0,0 @@
package com.mogo.eagle.core.function.autopilot.network;
import com.mogo.eagle.core.data.BaseData;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
public interface IAdasApiService {
/**
* 上传自动驾驶状态接口
* @param requestBody
* @return
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/dataService/autonomousDrive/updateAutonomousDriveStatus")
Observable<BaseData> updateAutonomousDriveStatus(@Body RequestBody requestBody);
/**
* 站点上报 用于网约车业务 云平台绘制路线使用
* @param requestBody
* @return
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/dataService/autonomousDrive/reportSite")
Observable<BaseData> updateReportSite(@Body RequestBody requestBody);
}