[Delete]
整理adas控制接口 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 2021/5/28 15:24
|
||||
*/
|
||||
public class AdasConstant {
|
||||
public static final String MODULE_TAG = "AdasConstant";
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
|
||||
@@ -30,6 +31,7 @@ import com.mogo.module.common.drawer.IdentifyDataDrawer;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
import com.zhidao.support.obu.ami.AmiClientManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -56,7 +58,6 @@ public class AdasEventManager implements
|
||||
|
||||
private final Gson gson;
|
||||
private final ArrayList<IAdasDataListener> iAdasEventListeners = new ArrayList<>();
|
||||
private final ArrayList<IAdasStatusListener> iAdasStatusListeners = new ArrayList<>();
|
||||
//自动驾驶状态
|
||||
private int mCurrentAutopilotStatus = -1;
|
||||
//自动驾驶车速度
|
||||
@@ -64,7 +65,6 @@ public class AdasEventManager implements
|
||||
//自动驾驶状态
|
||||
private AutopilotStatusInfo mAutopilotValuesStatus = null;
|
||||
|
||||
private IAdasProviderBizListener providerBizListener;
|
||||
|
||||
private AdasEventManager() {
|
||||
gson = GsonUtil.getGson();
|
||||
@@ -98,32 +98,19 @@ public class AdasEventManager implements
|
||||
iAdasEventListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addStatusListener(IAdasStatusListener listener) {
|
||||
Logger.d(TAG, "添加adas状态事件监听");
|
||||
if (iAdasStatusListeners.contains(listener)) {
|
||||
return;
|
||||
}
|
||||
iAdasStatusListeners.add(listener);
|
||||
/**
|
||||
* 同步SN信息给工控机
|
||||
*/
|
||||
public void syncBasicInfoToAutopilot() {
|
||||
Logger.d(TAG, "同步PAD的SN给工控机……");
|
||||
BasicInfo info = new BasicInfo();
|
||||
info.setSn(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
AdasManager.getInstance().setBasicInfo(info);
|
||||
}
|
||||
|
||||
public void removeStatusListener(IAdasStatusListener listener) {
|
||||
Logger.d(TAG, "注销adas状态事件监听");
|
||||
iAdasStatusListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void removeStatusListener() {
|
||||
Logger.d(TAG, "注销adas状态事件监听");
|
||||
iAdasStatusListeners.clear();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
if (providerBizListener != null) {
|
||||
providerBizListener.getDeviceSn();
|
||||
} else {
|
||||
Logger.e(TAG, "onAutopilotSNRequest providerBizListener is null");
|
||||
}
|
||||
syncBasicInfoToAutopilot();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,9 +121,11 @@ public class AdasEventManager implements
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(true);
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
for (IAdasStatusListener listener : iAdasStatusListeners) {
|
||||
listener.onServiceConnected();
|
||||
}
|
||||
|
||||
// 同步SN给工控机
|
||||
syncBasicInfoToAutopilot();
|
||||
|
||||
// 开启轮训上传自动驾驶状态
|
||||
updateDriveStatusTask();
|
||||
}
|
||||
|
||||
@@ -146,9 +135,6 @@ public class AdasEventManager implements
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectIP(AdasManager.getInstance().getAdasConfig().getAddress());
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().setConnectStatus(false);
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
|
||||
for (IAdasStatusListener listener : iAdasStatusListeners) {
|
||||
listener.onServiceDisconnected();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDriveStatusTask() {
|
||||
@@ -178,10 +164,6 @@ public class AdasEventManager implements
|
||||
return adasAIDLAutopilotStateModel;
|
||||
}
|
||||
|
||||
public void setProviderBizListener(IAdasProviderBizListener listener) {
|
||||
providerBizListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
int state = autoPilotStatusInfo.getState();
|
||||
@@ -218,12 +200,15 @@ public class AdasEventManager implements
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//can数据转发
|
||||
AutopilotCarStateInfo.ValuesBean bean = autoPilotCarStateInfo.getValues();
|
||||
if (bean != null) {
|
||||
int turn_light = bean.getTurn_light(); //转向灯状态 0是正常 1是左转 2是右转
|
||||
AmiClientManager.getInstance().setTurnLightState(turn_light);
|
||||
// 获取的自动驾驶车辆信息不是空的时候
|
||||
if (autoPilotCarStateInfo != null) {
|
||||
//can数据转发
|
||||
AutopilotCarStateInfo.ValuesBean bean = autoPilotCarStateInfo.getValues();
|
||||
if (bean != null) {
|
||||
//转向灯状态 0是正常 1是左转 2是右转
|
||||
int turnLight = bean.getTurn_light();
|
||||
AmiClientManager.getInstance().setTurnLightState(turnLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,24 +233,12 @@ public class AdasEventManager implements
|
||||
|
||||
@Override
|
||||
public void onAutopilotWarnMessage(@Nullable AutopilotWarnMessage autopilotWarnMessage) {
|
||||
Logger.d(TAG, "onWarnMessage " + autopilotWarnMessage);
|
||||
//报警model
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onWarnMessage(autopilotWarnMessage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(ArrayList<ADASTrajectoryInfo> trajectoryInfo) {
|
||||
if (trajectoryInfo != null && trajectoryInfo.size() > 0) {
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onAutopilotTrajectory(trajectoryInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -276,12 +249,6 @@ public class AdasEventManager implements
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecordResult(AutoPilotRecordResult result) {
|
||||
if (result != null) {
|
||||
for (IAdasDataListener listener : iAdasEventListeners) {
|
||||
if (listener != null) {
|
||||
listener.onAutopilotRecordResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,22 +24,22 @@ object AdasObjectUtils {
|
||||
|
||||
fun fromAutopilotGuardianInfo(autopilotGuardianInfo: AutopilotGuardianInfo): AutopilotGuardianStatusInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(autopilotGuardianInfo),
|
||||
AutopilotGuardianStatusInfo::class.java
|
||||
GsonUtil.jsonFromObject(autopilotGuardianInfo),
|
||||
AutopilotGuardianStatusInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
fun fromAdasAutopilotRoute(carStateInfo: AutopilotRoute): AutopilotRouteInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotRouteInfo::class.java
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotRouteInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
fun fromAdasCarStateInfoObject(carStateInfo: CarStateInfo): AutopilotCarStateInfo? {
|
||||
return GsonUtil.objectFromJson(
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotCarStateInfo::class.java
|
||||
GsonUtil.jsonFromObject(carStateInfo),
|
||||
AutopilotCarStateInfo::class.java
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ object AdasObjectUtils {
|
||||
if (info == null) {
|
||||
return null
|
||||
}
|
||||
val warnMessage =
|
||||
AutopilotWarnMessage()
|
||||
val warnMessage = AutopilotWarnMessage()
|
||||
warnMessage.content = info.content
|
||||
warnMessage.level = info.level
|
||||
try {
|
||||
|
||||
@@ -4,13 +4,11 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
|
||||
@@ -31,18 +29,6 @@ public class AdasProvider implements IProvider {
|
||||
Logger.d(TAG, "初始化 AdasProvider 模块");
|
||||
adasEventManager = AdasEventManager.getInstance();
|
||||
initAdas(context, adasEventManager);
|
||||
addAdasStatusListener(new IAdasStatusListener() {
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
Logger.d(TAG, "adas statusListener connected & send sn");
|
||||
setBasicInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected() {
|
||||
Logger.d(TAG, "adas statuslistener disconnected");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initAdas(Context context, AdasEventManager adasEventManager) {
|
||||
@@ -65,13 +51,6 @@ public class AdasProvider implements IProvider {
|
||||
}
|
||||
AdasManager.getInstance().setOnAdasListener(new OnAdasListenerAdapter());
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(adasEventManager);
|
||||
adasEventManager.setProviderBizListener(this::setBasicInfo);
|
||||
}
|
||||
|
||||
public void setBasicInfo() {
|
||||
BasicInfo info = new BasicInfo();
|
||||
info.setSn(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
AdasManager.getInstance().setBasicInfo(info);
|
||||
}
|
||||
|
||||
public void addAdasEventListener(IAdasDataListener listener) {
|
||||
@@ -82,14 +61,6 @@ public class AdasProvider implements IProvider {
|
||||
adasEventManager.removeEventListener(listener);
|
||||
}
|
||||
|
||||
public void addAdasStatusListener(IAdasStatusListener listener) {
|
||||
adasEventManager.addStatusListener(listener);
|
||||
}
|
||||
|
||||
public void removeAdasStatusListener() {
|
||||
adasEventManager.removeStatusListener();
|
||||
}
|
||||
|
||||
public void sendWsMessage(String msg) {
|
||||
AdasManager.getInstance().aiCloudToAdasData(msg);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,11 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface IAdasDataListener {
|
||||
|
||||
default void sendMsg(String msg) {
|
||||
|
||||
}
|
||||
|
||||
default void onWarnMessage(AutopilotWarnMessage autopilotWarnMessage) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自动驾驶到达站点回调接口
|
||||
*
|
||||
@@ -46,18 +30,4 @@ public interface IAdasDataListener {
|
||||
default void notifyAutopilotState(AutopilotStatusInfo autopilotStatus) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 车前引导路径回调
|
||||
* @param trajectory
|
||||
*/
|
||||
default void onAutopilotTrajectory(ArrayList<ADASTrajectoryInfo> trajectory) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务结果回调
|
||||
* @param record 结果数据
|
||||
*/
|
||||
default void onAutopilotRecordResult(AutoPilotRecordResult record) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
public interface IAdasProviderBizListener {
|
||||
|
||||
void getDeviceSn();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.mogo.module.adas;
|
||||
|
||||
/**
|
||||
* Created by XuYong on 4/28/21 16:19
|
||||
*/
|
||||
public interface IAdasStatusListener {
|
||||
|
||||
void onServiceConnected();
|
||||
|
||||
void onServiceDisconnected();
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.mogo.module.adas.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.adas.AdasProvider;
|
||||
|
||||
public class AdasTestPanelBroadCastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "AdasTestPanelBroadCastReceiver";
|
||||
|
||||
/**
|
||||
* Adas测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
Logger.d(TAG, "sceneType=" + sceneType);
|
||||
if(sceneType == 6){ //测试发送sn
|
||||
AdasProvider adasProvider = ARouter.getInstance().navigation(AdasProvider.class);
|
||||
adasProvider.setBasicInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user