add aiCloudToAdasData
This commit is contained in:
@@ -9,12 +9,18 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.adas.entity.AdasAutoPilotLocReceiverBean;
|
||||
import com.mogo.module.adas.entity.DispatchData;
|
||||
import com.mogo.module.adas.entity.DispatchResult;
|
||||
import com.mogo.module.adas.entity.EndLatLon;
|
||||
import com.mogo.module.adas.entity.StartLatLon;
|
||||
import com.mogo.module.adas.model.AdasServiceModel;
|
||||
import com.mogo.module.adas.model.IDispatch;
|
||||
import com.mogo.module.adas.overlay.LineOverlayManager;
|
||||
import com.mogo.module.adas.view.DispatchRemindDialog;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
|
||||
@@ -43,6 +49,8 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
private DispatchRemindDialog dispatchRemindDialog;
|
||||
private LineOverlayManager lineOverlayManager;
|
||||
private MogoLocation mogoLocation;
|
||||
private IDispatchResultListener dispatchResultListener;
|
||||
private AdasAutoPilotLocReceiverBean receiverBean;
|
||||
|
||||
private AdasAutoPilotManager() {
|
||||
|
||||
@@ -82,6 +90,10 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
dispatchRemindDialog.addIDispatchRemindListener(this);
|
||||
}
|
||||
|
||||
public void addIDispatchResult(IDispatchResultListener listener) {
|
||||
this.dispatchResultListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<AdasAutoPilotLocReceiverBean> target() {
|
||||
return AdasAutoPilotLocReceiverBean.class;
|
||||
@@ -98,6 +110,7 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
Logger.d(TAG, "onMsgReceived 接收到服务端调度信息,但现在已经在自动驾驶状态,下发重复 略过");
|
||||
return;
|
||||
}
|
||||
this.receiverBean = adasAutoPilotLocReceiverBean;
|
||||
Message message = new Message();
|
||||
message.what = MSG_TYPE_SHOW_DIALOG;
|
||||
message.obj = adasAutoPilotLocReceiverBean;
|
||||
@@ -125,13 +138,67 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
|
||||
@Override
|
||||
public void affirm() {
|
||||
AdasServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM);
|
||||
AdasServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (dispatchResultListener != null) {
|
||||
DispatchResult dispatchResult = new DispatchResult(
|
||||
new StartLatLon(mogoLocation.getLatitude(), mogoLocation.getLongitude()),
|
||||
new EndLatLon(receiverBean.getLat(), receiverBean.getLon()));
|
||||
DispatchData dispatchData = new DispatchData("aiCloudToStartAutopilot", dispatchResult);
|
||||
dispatchResultListener.dispatchAffirm(GsonUtil.jsonFromObject(dispatchData));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(boolean manualTrigger) {
|
||||
AdasServiceModel.getInstance().dispatchResultUpload(manualTrigger ?
|
||||
DISPATCH_RESULT_MANUAL_CANCEL : DISPATCH_RESULT_TIMER_CANCEL);
|
||||
DISPATCH_RESULT_MANUAL_CANCEL : DISPATCH_RESULT_TIMER_CANCEL, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location location) {
|
||||
//坐标转换
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
mogoLocation = loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng mogoLatLng) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度指令结果回调
|
||||
*/
|
||||
public interface IDispatchResultListener {
|
||||
//调用确认
|
||||
void dispatchAffirm(String json);
|
||||
}
|
||||
|
||||
public void test() {
|
||||
@@ -158,26 +225,26 @@ public class AdasAutoPilotManager implements IMogoOnMessageListener<AdasAutoPilo
|
||||
}
|
||||
|
||||
public void testDispatchResultUpload() {
|
||||
AdasServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM);
|
||||
AdasServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location location) {
|
||||
//坐标转换
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
mogoLocation = loc;
|
||||
public void testDispatchAutopilot() {
|
||||
DispatchResult dispatchResult = new DispatchResult(
|
||||
new StartLatLon(12.12, 13.13),
|
||||
new EndLatLon(12.12, 13.13));
|
||||
DispatchData dispatchData = new DispatchData("aiCloudToStartAutopilot", dispatchResult);
|
||||
String json = GsonUtil.jsonFromObject(dispatchData);
|
||||
Logger.d(TAG, "testDispatchAutopilot json : " + json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng mogoLatLng) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
|
||||
import adas.Adas;
|
||||
|
||||
|
||||
/**
|
||||
* ADAS 模块
|
||||
@@ -40,6 +42,12 @@ public class AdasProvider implements IProvider {
|
||||
|
||||
private void initAutoPilotBusiness(Context context) {
|
||||
AdasAutoPilotManager.getInstance().initSocket(context);
|
||||
AdasAutoPilotManager.getInstance().addIDispatchResult(new AdasAutoPilotManager.IDispatchResultListener() {
|
||||
@Override
|
||||
public void dispatchAffirm(String json) {
|
||||
AdasManager.getInstance().aiCloudToAdasData(json);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setBasicInfo(){
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
public class DispatchData {
|
||||
|
||||
private String action;
|
||||
private DispatchResult result;
|
||||
|
||||
public DispatchData(String action, DispatchResult result) {
|
||||
this.action = action;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public DispatchResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(DispatchResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DispatchData{" +
|
||||
"action='" + action + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
public class DispatchResult {
|
||||
|
||||
private StartLatLon startLatLon;
|
||||
private EndLatLon endLatLon;
|
||||
|
||||
public DispatchResult(StartLatLon startLatLon, EndLatLon endLatLon) {
|
||||
this.startLatLon = startLatLon;
|
||||
this.endLatLon = endLatLon;
|
||||
}
|
||||
|
||||
public StartLatLon getStartLatLon() {
|
||||
return startLatLon;
|
||||
}
|
||||
|
||||
public void setStartLatLon(StartLatLon startLatLon) {
|
||||
this.startLatLon = startLatLon;
|
||||
}
|
||||
|
||||
public EndLatLon getEndLatLon() {
|
||||
return endLatLon;
|
||||
}
|
||||
|
||||
public void setEndLatLon(EndLatLon endLatLon) {
|
||||
this.endLatLon = endLatLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DispatchResult{" +
|
||||
"startLatLon=" + startLatLon +
|
||||
", endLatLon=" + endLatLon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
public class EndLatLon {
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public EndLatLon(double lat, double lon) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EndLatLon{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.module.adas.entity;
|
||||
|
||||
public class StartLatLon {
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public StartLatLon(double lat, double lon) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StartLatLon{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class AdasServiceModel {
|
||||
*
|
||||
* @param dispatchResultType int
|
||||
*/
|
||||
public void dispatchResultUpload(int dispatchResultType) {
|
||||
public void dispatchResultUpload(int dispatchResultType,IDispatch dispatch) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportDispatchResult reportDispatchResult = new ReportDispatchResult(sn, dispatchResultType);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@@ -139,12 +139,14 @@ public class AdasServiceModel {
|
||||
public void onNext(BaseData o) {
|
||||
super.onNext(o);
|
||||
Logger.d(TAG, "dispatchResultUpload success");
|
||||
dispatch.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG, "dispatchResultUpload error : " + e.getMessage());
|
||||
dispatch.onError(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mogo.module.adas.model;
|
||||
|
||||
public interface IDispatch {
|
||||
|
||||
void onSuccess();
|
||||
|
||||
void onError(String msg);
|
||||
}
|
||||
@@ -47,6 +47,8 @@ public class AdasTestPanelBroadCastReceiver extends BroadcastReceiver {
|
||||
AdasAutoPilotManager.getInstance().testUploadAutopilotRoute();
|
||||
} else if(sceneType == 3){ //验证自动驾驶调度上报接口
|
||||
AdasAutoPilotManager.getInstance().testDispatchResultUpload();
|
||||
} else if(sceneType == 4){ //验证下发给自动驾驶的调用数据
|
||||
AdasAutoPilotManager.getInstance().testDispatchAutopilot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user