adas数据获取
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
@@ -11,62 +12,143 @@ 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.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 14:43
|
||||
*/
|
||||
public class AdasListenerManager implements OnAdasListener, OnAdasMsgConnectStatusListener {
|
||||
public class AdasEventManager implements OnAdasListener, OnAdasMsgConnectStatusListener {
|
||||
|
||||
private final String TAG = "AdasEventManager";
|
||||
private ArrayList<AdasListenerAdapter> iAdasEventListeners;
|
||||
private ArrayList<AdasStatusListener> iAdasStatusListeners;
|
||||
|
||||
public void addEventListener(AdasListenerAdapter listener) {
|
||||
Logger.d(TAG,"添加adas事件监听");
|
||||
if (iAdasEventListeners == null) {
|
||||
iAdasEventListeners = new ArrayList<AdasListenerAdapter>();
|
||||
}
|
||||
iAdasEventListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeEventListener(AdasListenerAdapter listener) {
|
||||
Logger.d(TAG,"注销adas事件监听");
|
||||
if (iAdasEventListeners != null && iAdasEventListeners.contains(listener)) {
|
||||
iAdasEventListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void addStatusListener(AdasStatusListener listener) {
|
||||
Logger.d(TAG,"添加adas状态事件监听");
|
||||
if (iAdasStatusListeners == null) {
|
||||
iAdasStatusListeners = new ArrayList<AdasStatusListener>();
|
||||
}
|
||||
iAdasStatusListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeStatusListener(AdasStatusListener listener) {
|
||||
Logger.d(TAG,"注销adas状态事件监听");
|
||||
if (iAdasEventListeners != null && iAdasEventListeners.contains(listener)) {
|
||||
iAdasEventListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
|
||||
Logger.d(TAG,"onWarnMessage");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onWarnMessage(warnMessageInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSize(int width, int height) {
|
||||
|
||||
Logger.d(TAG,"onVideoSize");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onVideoSize(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
|
||||
Logger.d(TAG,"onRectData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onRectData(rectInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarStateData(CarStateInfo carStateInfo) {
|
||||
|
||||
Logger.d(TAG,"onCarStateData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onCarStateData(carStateInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightStateData(LightStatueInfo lightStatueInfo) {
|
||||
|
||||
Logger.d(TAG,"onLightStateData");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onLightStateData(lightStatueInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
|
||||
|
||||
Logger.d(TAG,"onObstaclesInfo");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onObstaclesInfo(obstaclesInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
|
||||
|
||||
Logger.d(TAG,"onCarLaneInfo");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onCarLaneInfo(carLaneInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotStatus(AutopilotStatus autopilotStatus) {
|
||||
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.autopilotStatus(autopilotStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
|
||||
|
||||
Logger.d(TAG,"autopilotArrive");
|
||||
for (AdasListenerAdapter listener:iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.autopilotArrive(autopilotWayArrive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess() {
|
||||
|
||||
Logger.d(TAG,"websocket连接成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectFailed() {
|
||||
|
||||
Logger.d(TAG,"websocket连接失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 16:52
|
||||
*/
|
||||
public abstract class AdasListenerAdapter implements OnAdasListener {
|
||||
|
||||
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
|
||||
|
||||
};
|
||||
|
||||
public void onVideoSize(int width, int height) {
|
||||
|
||||
};
|
||||
|
||||
public void onRectData(RectInfo rectInfo) {
|
||||
|
||||
};
|
||||
|
||||
public void onCarStateData(CarStateInfo carStateInfo){
|
||||
|
||||
};
|
||||
|
||||
public void onLightStateData(LightStatueInfo lightStatueInfo){
|
||||
|
||||
};
|
||||
|
||||
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
|
||||
|
||||
};
|
||||
|
||||
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
|
||||
|
||||
};
|
||||
|
||||
public void autopilotStatus(AutopilotStatus autopilotStatus) {
|
||||
|
||||
};
|
||||
|
||||
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
|
||||
/**
|
||||
* ADAS 模块
|
||||
@@ -17,10 +18,40 @@ import com.mogo.service.MogoServicePaths;
|
||||
@Route(path = MogoServicePaths.PATH_ADAS)
|
||||
public class AdasProvider implements IProvider {
|
||||
private final String TAG = "AdasProvider";
|
||||
private AdasEventManager adasEventManager;
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Log.d(TAG, "初始化 ADAS 模块");
|
||||
Logger.d(TAG, "初始化 ADAS 模块");
|
||||
|
||||
adasEventManager = new AdasEventManager();
|
||||
initAdas(context, adasEventManager);
|
||||
}
|
||||
|
||||
private void initAdas(Context context, AdasEventManager adasEventManager) {
|
||||
AdasManager.getInstance().create(context);
|
||||
AdasManager.getInstance().setOnAdasListener(adasEventManager);
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
|
||||
}
|
||||
|
||||
public void addAdasEventListener(AdasListenerAdapter listener) {
|
||||
adasEventManager.addEventListener(listener);
|
||||
}
|
||||
|
||||
public void removeAdasEventListener(AdasListenerAdapter listener) {
|
||||
adasEventManager.removeEventListener(listener);
|
||||
}
|
||||
|
||||
public void addAdaStatusListener(AdasStatusListener listener) {
|
||||
adasEventManager.addStatusListener(listener);
|
||||
}
|
||||
|
||||
public void removeAdasStatusListener(AdasStatusListener listener) {
|
||||
adasEventManager.removeStatusListener(listener);
|
||||
}
|
||||
|
||||
public void sendWsMessage(String msg) {
|
||||
AdasManager.getInstance().aiCloudToAdasData(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 4/28/21 16:19
|
||||
*/
|
||||
public abstract class AdasStatusListener {
|
||||
|
||||
public void onServiceConnected() {
|
||||
|
||||
};
|
||||
public void onServiceDisconnected() {
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/4/25 16:52
|
||||
*/
|
||||
public class IAdasEventListener {
|
||||
}
|
||||
Reference in New Issue
Block a user