adas数据通路完善
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
|
||||
@@ -10,11 +14,47 @@ import com.zhidao.support.adas.high.bean.ObstaclesInfo;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 16:52
|
||||
*/
|
||||
public abstract class AdasListenerAdapter implements OnAdasListener {
|
||||
public abstract class AdasDataListener {
|
||||
public void sendMsg( String msg ) {
|
||||
|
||||
}
|
||||
|
||||
public void cameraEyeDetectResult( String detectResult ) {
|
||||
}
|
||||
|
||||
public void selectCarModelUrl( String carStyleUrl ) {
|
||||
}
|
||||
|
||||
public void requestGetCarModelListInfo() {
|
||||
}
|
||||
|
||||
public void clickSettingBack() {
|
||||
}
|
||||
|
||||
public void showToast( String msg ) {
|
||||
|
||||
}
|
||||
|
||||
public void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
|
||||
}
|
||||
|
||||
public void ownerCarStateInfo( String ownerCarStateInfo ) {
|
||||
}
|
||||
|
||||
public void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
|
||||
}
|
||||
|
||||
public void notifyAutopilotState( AdasAIDLAutopilotStateModel autopilotStateModel ) {
|
||||
}
|
||||
|
||||
public void notifyOwnerCarRect( List<AdasAIDLOwnerCarRectModel> ownerCarStateRectList ) {
|
||||
}
|
||||
/*
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
|
||||
};
|
||||
@@ -49,5 +89,5 @@ public abstract class AdasListenerAdapter implements OnAdasListener {
|
||||
|
||||
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
|
||||
|
||||
};
|
||||
};*/
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
@@ -11,6 +15,7 @@ import com.zhidao.support.adas.high.bean.LightStatueInfo;
|
||||
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.common.MsgActionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -20,18 +25,25 @@ import java.util.ArrayList;
|
||||
public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusListener {
|
||||
|
||||
private final String TAG = "AdasEventManager";
|
||||
private ArrayList<AdasListenerAdapter> iAdasEventListeners;
|
||||
|
||||
private Gson gson;
|
||||
|
||||
private ArrayList<AdasDataListener> iAdasEventListeners;
|
||||
private ArrayList<AdasStatusListener> iAdasStatusListeners;
|
||||
|
||||
public void addEventListener(AdasListenerAdapter listener) {
|
||||
public AdasEventManager() {
|
||||
gson = GsonUtil.getGson();
|
||||
}
|
||||
|
||||
public void addEventListener(AdasDataListener listener) {
|
||||
Logger.d(TAG,"添加adas事件监听");
|
||||
if (iAdasEventListeners == null) {
|
||||
iAdasEventListeners = new ArrayList<AdasListenerAdapter>();
|
||||
iAdasEventListeners = new ArrayList<AdasDataListener>();
|
||||
}
|
||||
iAdasEventListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeEventListener(AdasListenerAdapter listener) {
|
||||
public void removeEventListener(AdasDataListener listener) {
|
||||
Logger.d(TAG,"注销adas事件监听");
|
||||
if (iAdasEventListeners != null && iAdasEventListeners.contains(listener)) {
|
||||
iAdasEventListeners.remove(listener);
|
||||
@@ -56,9 +68,16 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
Logger.d(TAG,"onWarnMessage");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
//报警model
|
||||
WarnMessageModel warnMessageModel = null;
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onWarnMessage(warnMessageInfo);
|
||||
if (warnMessageModel == null) {
|
||||
warnMessageModel = new WarnMessageModel();
|
||||
warnMessageModel.setAction(MsgActionType.ACTION_WS_MSG_WARNING_TYPE.getmActionType());
|
||||
}
|
||||
warnMessageModel.setValues(warnMessageInfo);
|
||||
listener.cameraEyeDetectResult(gson.toJson(warnMessageModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,9 +85,8 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onVideoSize(int width, int height) {
|
||||
Logger.d(TAG,"onVideoSize");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onVideoSize(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,9 +94,10 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
Logger.d(TAG,"onRectData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onRectData(rectInfo);
|
||||
listener.cameraEyeDetectResult(gson.toJson(rectInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,9 +105,9 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onCarStateData(CarStateInfo carStateInfo) {
|
||||
Logger.d(TAG,"onCarStateData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onCarStateData(carStateInfo);
|
||||
listener.ownerCarStateInfo(gson.toJson(carStateInfo));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,9 +115,8 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onLightStateData(LightStatueInfo lightStatueInfo) {
|
||||
Logger.d(TAG,"onLightStateData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onLightStateData(lightStatueInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,9 +124,8 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
|
||||
Logger.d(TAG,"onObstaclesInfo");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onObstaclesInfo(obstaclesInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,28 +133,54 @@ public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusL
|
||||
@Override
|
||||
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
|
||||
Logger.d(TAG,"onCarLaneInfo");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onCarLaneInfo(carLaneInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotStatus(AutopilotStatus autopilotStatus) {
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.autopilotStatus(autopilotStatus);
|
||||
AutopilotStatus.ValuesBean autopilotStatusValues = autopilotStatus.getValues();
|
||||
AutopilotStatus.ValuesBean mAutopilotStatus;
|
||||
|
||||
|
||||
if (autopilotStatusValues != null) {
|
||||
AdasAIDLAutopilotStateModel adasAIDLAutopilotStateModel=new AdasAIDLAutopilotStateModel();
|
||||
adasAIDLAutopilotStateModel.setReason(autopilotStatusValues.getReason());
|
||||
mAutopilotStatus = autopilotStatusValues;
|
||||
int state = autopilotStatusValues.getState();
|
||||
float speed = autopilotStatusValues.getSpeed();
|
||||
adasAIDLAutopilotStateModel.setState(state);
|
||||
adasAIDLAutopilotStateModel.setSpeed(speed);
|
||||
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.notifyAutopilotState(adasAIDLAutopilotStateModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
|
||||
Logger.d(TAG,"autopilotArrive");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.autopilotArrive(autopilotWayArrive);
|
||||
if (autopilotWayArrive != null) {
|
||||
AutopilotWayArrive.ResultBean result = autopilotWayArrive.getResult();
|
||||
if (result != null) {
|
||||
AutopilotWayArrive.ResultBean.EndLatLonBean endLatLon = result.getEndLatLon();
|
||||
if (endLatLon != null) {
|
||||
AdasAIDLAutopilotArriveModel adasAIDLAutopilotArriveModel = new AdasAIDLAutopilotArriveModel();
|
||||
adasAIDLAutopilotArriveModel.setCarType(result.getCarType());
|
||||
adasAIDLAutopilotArriveModel.setLat(endLatLon.getLat());
|
||||
adasAIDLAutopilotArriveModel.setLon(endLatLon.getLon());
|
||||
for (AdasDataListener listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.autopilotArrive(adasAIDLAutopilotArriveModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
|
||||
|
||||
/**
|
||||
* ADAS 模块
|
||||
*
|
||||
@@ -22,7 +23,7 @@ public class AdasProvider implements IProvider {
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "初始化 ADAS 模块");
|
||||
Logger.d(TAG, "初始化 AdasProvider 模块");
|
||||
|
||||
adasEventManager = new AdasEventManager();
|
||||
initAdas(context, adasEventManager);
|
||||
@@ -34,11 +35,11 @@ public class AdasProvider implements IProvider {
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
|
||||
}
|
||||
|
||||
public void addAdasEventListener(AdasListenerAdapter listener) {
|
||||
public void addAdasEventListener(AdasDataListener listener) {
|
||||
adasEventManager.addEventListener(listener);
|
||||
}
|
||||
|
||||
public void removeAdasEventListener(AdasListenerAdapter listener) {
|
||||
public void removeAdasEventListener(AdasDataListener listener) {
|
||||
adasEventManager.removeEventListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2020/10/22
|
||||
*/
|
||||
public class WarnMessageModel {
|
||||
|
||||
private String action;
|
||||
|
||||
private WarnMessageInfo values;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public WarnMessageInfo getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(WarnMessageInfo values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user