替换主动获取自动驾驶状态的调用方式

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-02-07 17:12:29 +08:00
parent e787cba3be
commit 8233e69f99
11 changed files with 21 additions and 115 deletions

View File

@@ -1,14 +1,12 @@
package com.mogo.och.bus.fragment;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.CheckedTextView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -24,9 +22,9 @@ import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.mvp.Presenter;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.listener.IMogoMapListener;
import com.mogo.map.uicontroller.VisualAngleMode;
@@ -159,7 +157,7 @@ public abstract class BaseOchBusTabFragment<V extends IView, P extends Presenter
return true;
});
}
onAutopilotStatusChanged(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus(),false);
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState(),false);
// 模拟 不可自动驾驶目前场景是刚开机adas还未和工控机连接
findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
// MogoApisHandler.getInstance().getApis()

View File

@@ -12,6 +12,7 @@ import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -88,9 +89,9 @@ public class OchBusFragment extends BaseOchBusTabFragment< OchBusFragment, OchBu
mPresenter.onAutopilotArriveAtStation(null);
});
Logger.d( TAG, "initView: " + MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() );
Logger.d( TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
// 初始化的时候设置 UI 按钮状态
switch ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus() ) {
switch ( CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ) {
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
hideAutopilotBiz();
break;

View File

@@ -18,6 +18,7 @@ import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
@@ -631,7 +632,7 @@ public class OchBusOrderModel {
if ( lastStopStation <= nextStopStation || nextStopStation <= currentStationIndex ) {
return;
}
if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus()
if ( CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING ) {
// 自动驾驶中动态设置下一个停靠站点/
autoDriveToNextStation( true );

View File

@@ -27,6 +27,7 @@ import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
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.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerSmpManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
@@ -152,7 +153,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
// });
// }
onAutopilotStatusChanged(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
// 模拟 不可自动驾驶目前场景是刚开机adas还未和工控机连接
// findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
@@ -334,7 +335,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
@Override
public void run() {
startOrStopLoadingAnim(false);
onAutopilotStatusChanged(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
}
}, 1000L);
}

View File

@@ -27,6 +27,7 @@ import com.mogo.commons.voice.AIAssist;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
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.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerSmpManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
@@ -150,7 +151,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
// });
// }
onAutopilotStatusChanged(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
// 模拟 不可自动驾驶目前场景是刚开机adas还未和工控机连接
// findViewById(R.id.btnAutopilotDisable).setOnClickListener(view ->
@@ -326,7 +327,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
@Override
public void run() {
startOrStopLoadingAnim(false);
onAutopilotStatusChanged(MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus());
onAutopilotStatusChanged(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
}
}, 1000L);
}

View File

@@ -28,7 +28,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.module.adas.model.AdasServiceModel;
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;
@@ -62,8 +61,6 @@ public class AdasEventManager implements
private int mCurrentAutopilotStatus = -1;
//自动驾驶车速度
private float mCurrentAutopilotSpeed = 0;
//自动驾驶状态
private AutopilotStatusInfo mAutopilotValuesStatus = null;
private AdasEventManager() {
@@ -154,23 +151,12 @@ public class AdasEventManager implements
AdasServiceModel.getInstance().reportSite(lon, lat);
}
public AdasAIDLAutopilotStateModel autopilotStateCall() {
AdasAIDLAutopilotStateModel adasAIDLAutopilotStateModel = new AdasAIDLAutopilotStateModel();
if (mAutopilotValuesStatus != null) {
adasAIDLAutopilotStateModel.setSpeed(mAutopilotValuesStatus.getSpeed());
adasAIDLAutopilotStateModel.setState(mAutopilotValuesStatus.getState());
adasAIDLAutopilotStateModel.setReason(mAutopilotValuesStatus.getReason());
}
return adasAIDLAutopilotStateModel;
}
@Override
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
int state = autoPilotStatusInfo.getState();
float speed = autoPilotStatusInfo.getSpeed();
mCurrentAutopilotStatus = state;
mCurrentAutopilotSpeed = speed;
this.mAutopilotValuesStatus = autoPilotStatusInfo;
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
listener.notifyAutopilotState(autoPilotStatusInfo);
@@ -184,11 +170,6 @@ public class AdasEventManager implements
double lon = autopilotWayArrive.getLon();
double lat = autopilotWayArrive.getLat();
reportSite(lon, lat);
for (IAdasDataListener listener : iAdasEventListeners) {
if (listener != null) {
listener.autopilotArrive(autopilotWayArrive);
}
}
}
}

View File

@@ -7,7 +7,6 @@ import com.alibaba.android.arouter.facade.template.IProvider;
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.common.CupidLogUtils;
@@ -65,7 +64,4 @@ public class AdasProvider implements IProvider {
AdasManager.getInstance().aiCloudToAdasData(msg);
}
public AdasAIDLAutopilotStateModel autopilotStateCall() {
return adasEventManager.autopilotStateCall();
}
}

View File

@@ -1,18 +1,9 @@
package com.mogo.module.adas;
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
public interface IAdasDataListener {
/**
* 自动驾驶到达站点回调接口
*
* @param autopilotWayArrive
*/
default void autopilotArrive(AutopilotStationInfo autopilotWayArrive) {
}
/**
* 自车定位信息

View File

@@ -6,9 +6,9 @@ import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.check.CallerCheckManager;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.service.adas.IMogoAdasOCHCallback;
/**
* @author liujing
@@ -25,14 +25,14 @@ public class VehicleMonitoring implements Handler.Callback {
//非自动驾驶测试数据 后期根据需求做修改
private static final long MANUAL_CHECK_STATUS_DELAY = 30 * 1000;
//自动驾驶状态
private static int AutopilotStatus = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus();
private static int AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState();
public VehicleMonitoring(Context context) {
mContext = context;
}
public void vehicleCheck() {
if (AutopilotStatus == IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING) {
if (AutopilotStatus == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
Log.d(TAG, "自动驾驶中...");
mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY);
} else {
@@ -44,14 +44,14 @@ public class VehicleMonitoring implements Handler.Callback {
@Override
public boolean handleMessage(Message msg) {
AutopilotStatus = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getAutopilotStatus();
AutopilotStatus = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState();
switch (msg.what) {
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_RUNNING:
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING:
vehicleMonitor();
mHandler.sendEmptyMessageDelayed(AutopilotStatus, AUTO_CHECK_STATUS_DELAY);
return true;
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE:
case IMogoAdasOCHCallback.STATUS_AUTOPILOT_ENABLE:
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE:
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
vehicleMonitor();
mHandler.sendEmptyMessageDelayed(AutopilotStatus, MANUAL_CHECK_STATUS_DELAY);
return true;

View File

@@ -33,27 +33,6 @@ public interface IMogoADASController extends IProvider {
*/
void setAdasCarDataCallback(IMogoAdasCarDataCallback carDataCallback);
/**
* 自动驾驶状态通知
*
* @param callback
*/
void addAdasOCHCallback(IMogoAdasOCHCallback callback);
/**
* 移除自动驾驶通知
*/
void removeAdasOCHCallback();
/**
* 获取车辆自动驾驶状态
*
* @return
*/
@Deprecated
int getAutopilotStatus();
/**
* 获取车身的定位纬度
*

View File

@@ -9,7 +9,6 @@ import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotControlCmdParameter;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.network.utils.GsonUtil;
@@ -67,24 +66,6 @@ public class MogoADASController implements IMogoADASController {
if (mAdasDataListener == null) {
mAdasDataListener = new IAdasDataListener() {
@Override
public void autopilotArrive(AutopilotStationInfo autopilotArriveModel) {
if (autopilotArriveModel == null) {
Logger.d(TAG, "autopilotArrive autopilotArriveModel is null");
return;
}
if (!mAdasOCHCallback.isEmpty()) {
for (IMogoAdasOCHCallback cb : mAdasOCHCallback) {
cb.onArriveAt(new AutopilotStationInfo(
autopilotArriveModel.getType(),
autopilotArriveModel.getLon(),
autopilotArriveModel.getLat())
);
}
}
}
@Override
public void ownerCarStateInfo(String ownerCarStateInfo) {
// 接收 adas 定位数据线程
@@ -141,30 +122,6 @@ public class MogoADASController implements IMogoADASController {
mMogoAdasCarDataCallback = carDataCallback;
}
@Override
public void addAdasOCHCallback(IMogoAdasOCHCallback callback) {
if (mAdasOCHCallback.contains(callback)) {
return;
}
mAdasOCHCallback.add(callback);
}
@Override
public void removeAdasOCHCallback() {
mAdasOCHCallback.clear();
}
@Override
public int getAutopilotStatus() {
int status = IMogoAdasOCHCallback.STATUS_AUTOPILOT_DISABLE;
try {
status = adasProvider.autopilotStateCall().getState();
} catch (Exception e) {
e.printStackTrace();
}
return status;
}
}