Merge branch 'dev_robotaxi-d_230612_3.3.0' into dev_saasbus-d_230607_from3.2.0
# Conflicts: # gradle.properties
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.bus.passenger.callback;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,7 +9,7 @@ import java.util.List;
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public interface IBusPassengerAutopilotPlanningCallback {
|
||||
void routeResult(List<LatLng> models,int haveArrivedIndex);
|
||||
void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location);
|
||||
void routePlanningToNextStationChanged(long meters, long timeInSecond);
|
||||
void updateTotalDistance();
|
||||
}
|
||||
|
||||
@@ -1,685 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.model;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.QUERY_BUS_P_STATION_DELAY;
|
||||
import static com.mogo.och.bus.passenger.constant.BusPassengerConst.STATION_STATUS_STOPPED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener;
|
||||
import com.mogo.commons.module.intent.IntentManager;
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.commons.module.status.StatusDescriptor;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult;
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback;
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager;
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager;
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg;
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType;
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager;
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst;
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.PinYinUtil;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
public class BusPassengerModel {
|
||||
private static final String TAG = BusPassengerModel.class.getSimpleName();
|
||||
|
||||
private List<MogoLocation> mRoutePoints = new ArrayList<>();
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final BusPassengerModel INSTANCE = new BusPassengerModel();
|
||||
}
|
||||
|
||||
public static BusPassengerModel getInstance() {
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private IBusPassengerADASStatusCallback mADASStatusCallback; //Model->Presenter:自动驾驶状态相关
|
||||
private IBusPassengerAutopilotPlanningCallback mAutopilotPlanningCallback; //Model->Presenter:自动驾驶线路规划
|
||||
private Map<String, IBusPassengerControllerStatusCallback> mControllerStatusCallbackMap = new ConcurrentHashMap<>();
|
||||
|
||||
private IBusPassegerDriverStatusCallback mDriverStatusCallback; //出车收车状态
|
||||
private IBusPassengerRouteLineInfoCallback mRouteLineInfoCallback; // bus路线信息更新
|
||||
|
||||
private MogoLocation mLocation = null;
|
||||
|
||||
private BusPassengerRoutesResult routesResult = null;
|
||||
|
||||
List<BusPassengerStation> mStations = new ArrayList<>();
|
||||
private int mNextStationIndex = 0;// 要到达站的index
|
||||
private final List<MogoLocation> mTwoStationsRouts = new ArrayList<>();
|
||||
private int mPreRouteIndex = 0;
|
||||
private int mWipePreIndex = 0;
|
||||
|
||||
private static final int MSG_QUERY_BUS_P_STATION = 1001;
|
||||
private final Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if ( msg.what == MSG_QUERY_BUS_P_STATION ) {
|
||||
queryDriverOperationStatus();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
private BusPassengerModel() {
|
||||
}
|
||||
|
||||
public void init( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
initListeners();
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus();
|
||||
startOrStopOrderLoop(true);
|
||||
}
|
||||
|
||||
public void setDriverStatusCallback(IBusPassegerDriverStatusCallback callback){
|
||||
this.mDriverStatusCallback = callback;
|
||||
}
|
||||
|
||||
public void setRouteLineInfoCallback(IBusPassengerRouteLineInfoCallback callback){
|
||||
this.mRouteLineInfoCallback = callback;
|
||||
}
|
||||
|
||||
private void queryDriverOperationDelay() {
|
||||
handler.sendEmptyMessageDelayed( MSG_QUERY_BUS_P_STATION, QUERY_BUS_P_STATION_DELAY );
|
||||
}
|
||||
|
||||
private void queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerOperationStatusResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerOperationStatusResponse data) {
|
||||
if (data == null || data.data == null) return;
|
||||
if (mDriverStatusCallback != null) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverOperationStatus = %s", data.data.plateNumber );
|
||||
mDriverStatusCallback.changeOperationStatus(data.data.driverStatus == 1);
|
||||
mDriverStatusCallback.updatePlateNumber(data.data.plateNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
||||
}
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
//延迟3s再次查询
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryDriverSiteByCoordinate(){
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(mContext
|
||||
, new OchCommonServiceCallback<BusPassengerRoutesResponse>() {
|
||||
@Override
|
||||
public void onSuccess(BusPassengerRoutesResponse data) {
|
||||
if ( data == null || data.getResult() == null) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = null");
|
||||
if (routesResult != null) {
|
||||
routesResult = null;
|
||||
mNextStationIndex = 0;
|
||||
}
|
||||
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.showNoTaskView();
|
||||
}
|
||||
|
||||
mRoutePoints.clear();
|
||||
|
||||
return;
|
||||
}
|
||||
if (routesResult != null && data.getResult().equals(routesResult)){
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = not update");
|
||||
return;
|
||||
}
|
||||
routesResult = data.getResult();
|
||||
updatePassengerRouteInfo(data.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg
|
||||
+ ", sn = " +BusPassengerServiceManager.INSTANCE.getDriverAppSn());
|
||||
if (code == 1003){
|
||||
queryDriverOperationDelay();
|
||||
}
|
||||
if (BusPassengerServiceManager.INSTANCE.getDriverAppSn().isEmpty()){
|
||||
//此处拦截是为了防止过程中乘客屏和司机端断连,拿不到司机端sn, 造成请求失败去刷新了界面
|
||||
return;
|
||||
}
|
||||
if (code == 1003){
|
||||
routesResult = null;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updatePassengerRouteInfo(BusPassengerRoutesResult result) {
|
||||
if (mRouteLineInfoCallback != null){
|
||||
mRouteLineInfoCallback.updateLineInfo(result.getName(),result.getRunningDur());
|
||||
mRouteLineInfoCallback.hideNoTaskView();
|
||||
if (result.getSites() != null){
|
||||
List<BusPassengerStation> stations = result.getSites();
|
||||
mStations.clear();
|
||||
mStations.addAll(stations);
|
||||
for (int i = 0; i< stations.size(); i++){
|
||||
BusPassengerStation station = stations.get(i);
|
||||
if (station.getDrivingStatus() == STATION_STATUS_STOPPED && station.isLeaving() && i+1 < stations.size()){ //离站
|
||||
mRouteLineInfoCallback.updateStationsInfo(stations,i+1,false);
|
||||
if(mNextStationIndex != i+1){
|
||||
mTwoStationsRouts.clear();
|
||||
startRemainRouteInfo();
|
||||
}
|
||||
mNextStationIndex = i+1;
|
||||
|
||||
updateAutopilotControlParameters(result,i);
|
||||
return;
|
||||
}else if (station.getDrivingStatus() == STATION_STATUS_STOPPED && !station.isLeaving()){ //到站
|
||||
if (i == 0){
|
||||
startOrStopRouteAndWipe(false);
|
||||
}
|
||||
mPreRouteIndex = 0;
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
mRouteLineInfoCallback.updateStationsInfo(stations,i,true);
|
||||
clearAutopilotControlParameters();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateAutopilotControlParameters(BusPassengerRoutesResult busRoutesResult,
|
||||
int leaveIndex) {
|
||||
|
||||
AutopilotControlParameters parameters = initAutopilotControlParameters(busRoutesResult,leaveIndex);
|
||||
if (null == parameters) {
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG, "AutopilotControlParameters is empty.");
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "AutopilotControlParameters is update.");
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters);
|
||||
}
|
||||
|
||||
private void clearAutopilotControlParameters() {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "AutopilotControlParameters is clear.");
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null);
|
||||
}
|
||||
|
||||
private AutopilotControlParameters initAutopilotControlParameters(BusPassengerRoutesResult busRoutesResult,
|
||||
int leaveIndex) {
|
||||
if (busRoutesResult.getSites() == null){ return null ;}
|
||||
List<BusPassengerStation> stations = busRoutesResult.getSites();
|
||||
if (leaveIndex + 1 > stations.size() - 1) {
|
||||
CallerLogger.INSTANCE.e(M_BUS_P + TAG, "行程日志-mismatch condition1.");
|
||||
return null;
|
||||
}
|
||||
BusPassengerStation currentStation = stations.get(leaveIndex);
|
||||
BusPassengerStation nextStation = stations.get(leaveIndex + 1);
|
||||
|
||||
AutopilotControlParameters parameters = new AutopilotControlParameters();
|
||||
parameters.routeID = busRoutesResult.getLineId();
|
||||
parameters.routeName = busRoutesResult.getName();
|
||||
parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName());
|
||||
parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName());
|
||||
parameters.startLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(currentStation.getLat(), currentStation.getLon());
|
||||
parameters.endLatLon = new AutopilotControlParameters
|
||||
.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
|
||||
parameters.vehicleType = 10;
|
||||
if (parameters.autoPilotLine == null) {
|
||||
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
|
||||
busRoutesResult.getLineId(),
|
||||
busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime, busRoutesResult.carModel,
|
||||
busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP,
|
||||
busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP,
|
||||
busRoutesResult.contrailSaveTimeDPQP);
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void release() {
|
||||
releaseListeners();
|
||||
startOrStopCalculateRouteInfo(false);
|
||||
startOrStopOrderLoop(false);
|
||||
}
|
||||
|
||||
public void setMoGoAutopilotPlanningListener(IBusPassengerAutopilotPlanningCallback
|
||||
moGoAutopilotPlanningCallback) {
|
||||
this.mAutopilotPlanningCallback = moGoAutopilotPlanningCallback;
|
||||
}
|
||||
|
||||
public void setADASStatusCallback(IBusPassengerADASStatusCallback callback) {
|
||||
this.mADASStatusCallback = callback;
|
||||
}
|
||||
|
||||
public void setControllerStatusCallback(String tag, IBusPassengerControllerStatusCallback callback) {
|
||||
if (tag == null || "".equals(tag)) return;
|
||||
|
||||
if (callback == null) {
|
||||
mControllerStatusCallbackMap.remove(tag);
|
||||
return;
|
||||
}
|
||||
|
||||
mControllerStatusCallbackMap.put(tag,callback);
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
// 2021.11.1重构自动驾驶 实现接口 IMoGoAutopilotStatusListener 注册监听 替换IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener);
|
||||
IntentManager.getInstance().registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener );
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener );
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener);
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG,moGoAutopilotPlanningListener);
|
||||
|
||||
//监听司机端消息
|
||||
CallerTelematicListenerManager.INSTANCE.addListener(TAG,mReceivedMsgListener);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
// 注销定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterLifecycleListener(10010);
|
||||
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(mGoAutopilotStatusListener);
|
||||
CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener);
|
||||
CallerTelematicListenerManager.INSTANCE.removeListener(TAG);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
}
|
||||
|
||||
private final IReceivedMsgListener mReceivedMsgListener = new IReceivedMsgListener() {
|
||||
@Override
|
||||
public void onReceivedServerSn(@Nullable String sn) {
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedServerSn = "+sn);
|
||||
if (mDriverStatusCallback != null) {
|
||||
mDriverStatusCallback.updateDriverSn(sn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedMsg(int type, @NonNull byte[] byteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type){
|
||||
|
||||
BaseDPMsg baseMsg = GsonUtils.fromJson(new String(byteArray), BaseDPMsg.class);
|
||||
Logger.d(SceneConstant.M_BUS_P+TAG,"onReceivedMsg = "+GsonUtils.toJson(baseMsg));
|
||||
|
||||
if (baseMsg != null && baseMsg.getType() == DPMsgType.TYPE_COMMON.getType()){
|
||||
AppConnectMsg msg = GsonUtils.fromJson(new String(byteArray), AppConnectMsg.class);
|
||||
if (msg.isViewShow()){ //消息盒子显示内容
|
||||
OCHSocketMessageManager.INSTANCE.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),msg.getMsg(),
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private final IMogoIntentListener mNetWorkIntentListener = new IMogoIntentListener() {
|
||||
@Override
|
||||
public void onIntentReceived( String intentStr, Intent intent ) {
|
||||
CallerLogger.INSTANCE.d( M_BUS_P + TAG, "onIntentReceived = %s", intentStr );
|
||||
if ( ConnectivityManager.CONNECTIVITY_ACTION.equals( intentStr ) ) {
|
||||
if ( NetworkUtils.isConnected( mContext ) ) {
|
||||
queryDriverOperationStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// VR mode变更回调
|
||||
private final IMogoStatusChangedListener mMogoStatusChangedListener = (descriptor, isTrue) -> {
|
||||
if (StatusDescriptor.VR_MODE == descriptor) {
|
||||
if (mControllerStatusCallbackMap.size() > 0) {
|
||||
for (IBusPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){
|
||||
callback.onVRModeChanged(isTrue);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final IMoGoChassisLocationGCJ02Listener mMapLocationListener = new IMoGoChassisLocationGCJ02Listener() {
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (null == gnssInfo) return;
|
||||
mLocation = gnssInfo;
|
||||
for (IBusPassengerControllerStatusCallback callback :mControllerStatusCallbackMap.values()){
|
||||
callback.onCarLocationChanged(gnssInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private volatile int mPreAutoStatus = -1;
|
||||
|
||||
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotRouteLineId(long lineId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
|
||||
|
||||
}
|
||||
|
||||
private boolean arriveAtEnd = false; //乘客app专用字段
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
if (autopilotStatusInfo == null) return;
|
||||
int state = autopilotStatusInfo.getState();
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning();
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotEnable();
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotDisable();
|
||||
}else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING){
|
||||
if(state != mPreAutoStatus){
|
||||
mTwoStationsRouts.clear();
|
||||
}
|
||||
if (mADASStatusCallback != null) mADASStatusCallback.onAutopilotRunning();
|
||||
}
|
||||
mPreAutoStatus = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(@Nullable MessagePad.ArrivalNotification arrivalNotification) {
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
arriveAtEnd = true;
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31
|
||||
if (DebugConfig.isDebug()) {
|
||||
// ToastUtils.showShort("到达目的地");
|
||||
}
|
||||
if (mADASStatusCallback != null){
|
||||
mADASStatusCallback.onAutopilotArriveEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener(){
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp routeList) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onAutopilotRotting = "
|
||||
+ GsonUtil.jsonFromObject(routeList));
|
||||
List<MessagePad.Location> routePoints = routeList.getWayPointsList();
|
||||
if (null != routePoints && routePoints.size() > 0){
|
||||
updateRoutePoints(routePoints);
|
||||
startToRouteAndWipe();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void updateRoutePoints(List<MessagePad.Location> routePoints){
|
||||
mRoutePoints.clear();
|
||||
List<MogoLocation> latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(mContext,routePoints);
|
||||
mRoutePoints.addAll(latLngModels);
|
||||
calculateTwoStationsRoute();
|
||||
}
|
||||
|
||||
private void calculateTwoStationsRoute(){
|
||||
//找出前往站对应的轨迹点,拿出两站点的集合
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size());
|
||||
if (mRoutePoints.size() > 0) {
|
||||
if (mStations.size() > 1){ //两个站点及以上要计算两个站点间的轨迹路线
|
||||
if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex - 1 >=0){
|
||||
mTwoStationsRouts.clear();
|
||||
BusPassengerStation stationNext = mStations.get(mNextStationIndex);
|
||||
BusPassengerStation stationCur = mStations.get(mNextStationIndex - 1);
|
||||
//当前站在轨迹中对应的点
|
||||
int currentRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(0
|
||||
,mRoutePoints
|
||||
,stationCur.getGcjLon(),stationCur.getGcjLat());
|
||||
//要前往的站在轨迹中对应的点
|
||||
int nextRouteIndex = CoordinateCalculateRouteUtil.getArrivedPointIndexNew(currentRouteIndex
|
||||
,mRoutePoints
|
||||
,stationNext.getGcjLon(),stationNext.getGcjLat());
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==currentRouteIndex = " + currentRouteIndex
|
||||
+ ", nextRouteIndex = " + nextRouteIndex);
|
||||
if (currentRouteIndex < nextRouteIndex){ //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(mRoutePoints.subList(currentRouteIndex,nextRouteIndex + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
// else { //只有两个站点的时候整个路线就是两个站点之间的轨迹
|
||||
// mTwoStationsRouts.clear();
|
||||
// mTwoStationsRouts.addAll(mRoutePoints);
|
||||
// }
|
||||
if (mTwoStationsRouts.size() > 0){
|
||||
float sumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(mTwoStationsRouts);
|
||||
SharedPrefsMgr.getInstance(mContext).putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS,(int) sumLength);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.updateTotalDistance();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
//计算当前位置和下一站的剩余点集合
|
||||
//计算剩余点总里程和时间
|
||||
if (mTwoStationsRouts.size() == 0){
|
||||
calculateTwoStationsRoute();
|
||||
}
|
||||
if (mTwoStationsRouts.size() > 0 && mLocation != null){
|
||||
Map<Integer,List<MogoLocation>> lastPointsMap = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompareNew(mPreRouteIndex,mTwoStationsRouts,mLocation);
|
||||
for (int index: lastPointsMap.keySet()) {
|
||||
mPreRouteIndex = index;
|
||||
break;
|
||||
}
|
||||
|
||||
for (List<MogoLocation> lastPoints: lastPointsMap.values()){
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastPoints.size() = " + lastPoints.size());
|
||||
float lastSumLength = 0;
|
||||
if (lastPoints.size() == 1){ //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
if (mNextStationIndex <= mStations.size()-1 && mNextStationIndex >= 0){
|
||||
BusPassengerStation stationNext = mStations.get(mNextStationIndex);
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
stationNext.getGcjLon(), stationNext.getGcjLat(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude());
|
||||
}else {
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude());
|
||||
}
|
||||
|
||||
}else {
|
||||
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
}
|
||||
|
||||
double lastTime = lastSumLength / getAverageSpeed() * 3.6 ; //秒
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "轨迹排查==lastSumLength = " + lastSumLength);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
mAutopilotPlanningCallback.routePlanningToNextStationChanged((long)lastSumLength,(long) lastTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getAverageSpeed(){
|
||||
return BusPassengerConst.BUS_AVERAGE_SPEED;
|
||||
}
|
||||
|
||||
public void startRemainRouteInfo() {
|
||||
//开启实时计算剩余距离,剩余时间,预计时间
|
||||
startOrStopCalculateRouteInfo(true);
|
||||
}
|
||||
|
||||
public void startToRouteAndWipe() {
|
||||
startOrStopRouteAndWipe(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时轨迹擦除
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopRouteAndWipe(boolean isStart){
|
||||
if (isStart){
|
||||
BusPassengerModelLoopManager.getInstance().startOrStopRouteAndWipe();
|
||||
}else {
|
||||
mWipePreIndex = 0;
|
||||
BusPassengerModelLoopManager.getInstance().stopOrStopRouteAndWipe();
|
||||
}
|
||||
}
|
||||
|
||||
public void loopRouteAndWipe() {
|
||||
if (mRoutePoints != null && mRoutePoints.size() > 0 && mLocation != null){
|
||||
int haveArrivedIndex = CoordinateCalculateRouteUtil
|
||||
.getArrivedPointIndexNew(mWipePreIndex,
|
||||
mRoutePoints,
|
||||
mLocation);
|
||||
|
||||
mWipePreIndex = haveArrivedIndex;
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "thread = "+ Thread.currentThread().getName()+" haveArrivedIndex== " + haveArrivedIndex);
|
||||
if (mAutopilotPlanningCallback != null){
|
||||
List<LatLng> routePoints = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext,mRoutePoints);
|
||||
mAutopilotPlanningCallback.routeResult(routePoints,haveArrivedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始轮询计算剩余里程和时间
|
||||
* @param isStart
|
||||
*/
|
||||
public void startOrStopCalculateRouteInfo(boolean isStart) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopCalculateRouteInfo() " + isStart);
|
||||
if (isStart) {
|
||||
BusPassengerModelLoopManager.getInstance().startCalculateRouteInfoLoop();
|
||||
} else {
|
||||
mTwoStationsRouts.clear();
|
||||
BusPassengerModelLoopManager.getInstance().stopCalculateRouteInfLoop();
|
||||
}
|
||||
}
|
||||
|
||||
private void startOrStopOrderLoop(boolean start) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "startOrStopOrderLoop() " + start);
|
||||
if (start) {
|
||||
BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop();
|
||||
} else {
|
||||
BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,607 @@
|
||||
package com.mogo.och.bus.passenger.model
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.os.Handler
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.module.intent.IMogoIntentListener
|
||||
import com.mogo.commons.module.intent.IntentManager
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.commons.module.status.StatusDescriptor
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.addListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isPassenger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerOperationStatusResponse
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResponse
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerRoutesResult
|
||||
import com.mogo.och.bus.passenger.bean.BusPassengerStation
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassegerDriverStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerADASStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerAutopilotPlanningCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerControllerStatusCallback
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerRouteLineInfoCallback
|
||||
import com.mogo.och.bus.passenger.constant.BusPassengerConst
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.network.BusPassengerServiceManager.driverAppSn
|
||||
import com.mogo.och.common.module.bean.dpmsg.AppConnectMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
import com.mogo.och.common.module.bean.dpmsg.DPMsgType
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager
|
||||
import com.mogo.och.common.module.biz.common.socketmessage.OCHSocketMessageManager.pushAppOperationalMsgBox
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager.startLoopAbnormalFactors
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager.stopLoopAbnormalFactors
|
||||
import com.mogo.och.common.module.manager.distancemamager.IDistanceListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.ITrajectoryListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.addDistanceListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.addTrajectoryListener
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.setStationPoint
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.suspendCalculate
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.calculateRouteSumLength
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjLocations
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.getArrivedPointIndexNew
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.PinYinUtil
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.ArrivalNotification
|
||||
import mogo.telematics.pad.MessagePad.GlobalPathResp
|
||||
import system_master.SystemStatusInfo
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* Created on 2022/3/31
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object BusPassengerModel{
|
||||
|
||||
private val TAG = BusPassengerModel::class.java.simpleName
|
||||
private const val MSG_QUERY_BUS_P_STATION = 1001
|
||||
|
||||
private val mRoutePoints: MutableList<MogoLocation> = ArrayList()
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var mADASStatusCallback //Model->Presenter:自动驾驶状态相关
|
||||
: IBusPassengerADASStatusCallback? = null
|
||||
private var mAutopilotPlanningCallback //Model->Presenter:自动驾驶线路规划
|
||||
: IBusPassengerAutopilotPlanningCallback? = null
|
||||
private val mControllerStatusCallbackMap: MutableMap<String, IBusPassengerControllerStatusCallback> =
|
||||
ConcurrentHashMap()
|
||||
private var mDriverStatusCallback //出车收车状态
|
||||
: IBusPassegerDriverStatusCallback? = null
|
||||
private var mRouteLineInfoCallback // bus路线信息更新
|
||||
: IBusPassengerRouteLineInfoCallback? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
private var routesResult: BusPassengerRoutesResult? = null
|
||||
var mStations: MutableList<BusPassengerStation> = ArrayList()
|
||||
private var mNextStationIndex = 0 // 要到达站的index
|
||||
private val mTwoStationsRouts: MutableList<MogoLocation> = ArrayList()
|
||||
private val handler = Handler(Handler.Callback { msg ->
|
||||
if (msg.what == MSG_QUERY_BUS_P_STATION) {
|
||||
queryDriverOperationStatus()
|
||||
return@Callback true
|
||||
}
|
||||
false
|
||||
})
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context.applicationContext
|
||||
initListeners()
|
||||
// TODO: 2022/3/31
|
||||
queryDriverOperationStatus()
|
||||
startOrStopOrderLoop(true)
|
||||
}
|
||||
|
||||
fun setDriverStatusCallback(callback: IBusPassegerDriverStatusCallback?) {
|
||||
mDriverStatusCallback = callback
|
||||
}
|
||||
|
||||
fun setRouteLineInfoCallback(callback: IBusPassengerRouteLineInfoCallback?) {
|
||||
mRouteLineInfoCallback = callback
|
||||
}
|
||||
|
||||
private fun queryDriverOperationDelay() {
|
||||
handler.sendEmptyMessageDelayed(
|
||||
MSG_QUERY_BUS_P_STATION,
|
||||
BusPassengerConst.QUERY_BUS_P_STATION_DELAY
|
||||
)
|
||||
}
|
||||
|
||||
private fun queryDriverOperationStatus() {
|
||||
BusPassengerServiceManager.queryDriverOperationStatus(
|
||||
mContext!!, object : OchCommonServiceCallback<BusPassengerOperationStatusResponse> {
|
||||
override fun onSuccess(data: BusPassengerOperationStatusResponse?) {
|
||||
if (data?.data == null) return
|
||||
if (mDriverStatusCallback != null) {
|
||||
d(
|
||||
M_BUS_P + TAG,
|
||||
"queryDriverOperationStatus = %s",
|
||||
data.data.plateNumber
|
||||
)
|
||||
mDriverStatusCallback!!.changeOperationStatus(data.data.driverStatus == 1)
|
||||
mDriverStatusCallback!!.updatePlateNumber(data.data.plateNumber)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.network_error_tip))
|
||||
} else {
|
||||
ToastUtils.showShort(mContext!!.getString(R.string.request_error_tip))
|
||||
}
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
//延迟3s再次查询
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun queryDriverSiteByCoordinate() {
|
||||
BusPassengerServiceManager.queryDriverSiteByCoordinate(
|
||||
mContext!!, object : OchCommonServiceCallback<BusPassengerRoutesResponse> {
|
||||
override fun onSuccess(data: BusPassengerRoutesResponse) {
|
||||
if (data.result == null) {
|
||||
d(M_BUS_P + TAG, "order = queryDriverSiteByCoordinate = null")
|
||||
if (routesResult != null) {
|
||||
routesResult = null
|
||||
mNextStationIndex = 0
|
||||
}
|
||||
cleanStation()
|
||||
if (mRouteLineInfoCallback != null) {
|
||||
mRouteLineInfoCallback!!.showNoTaskView()
|
||||
}
|
||||
mRoutePoints.clear()
|
||||
return
|
||||
}
|
||||
if (routesResult != null && data.result == routesResult) {
|
||||
d(M_BUS_P + TAG, "order = queryDriverSiteByCoordinate = not update")
|
||||
return
|
||||
}
|
||||
routesResult = data.result
|
||||
updatePassengerRouteInfo(data.result)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
d(
|
||||
M_BUS_P + TAG, "queryDriverSiteByCoordinate = %s", msg
|
||||
+ ", sn = " + driverAppSn
|
||||
)
|
||||
if (code == 1003) {
|
||||
queryDriverOperationDelay()
|
||||
}
|
||||
if (driverAppSn.isEmpty()) {
|
||||
//此处拦截是为了防止过程中乘客屏和司机端断连,拿不到司机端sn, 造成请求失败去刷新了界面
|
||||
return
|
||||
}
|
||||
if (code == 1003) {
|
||||
routesResult = null
|
||||
cleanStation()
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updatePassengerRouteInfo(result: BusPassengerRoutesResult) {
|
||||
if (mRouteLineInfoCallback != null) {
|
||||
Logger.d(M_BUS_P + TAG, "order = BusPassengerRoutesResult= " +GsonUtil.jsonFromObject(result))
|
||||
mRouteLineInfoCallback!!.updateLineInfo(result.name, result.runningDur)
|
||||
mRouteLineInfoCallback!!.hideNoTaskView()
|
||||
if (result.sites != null) {
|
||||
val stations = result.sites
|
||||
mStations.clear()
|
||||
mStations.addAll(stations)
|
||||
for (i in stations.indices) {
|
||||
val station = stations[i]
|
||||
if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && station.isLeaving && i + 1 < stations.size) { //离站
|
||||
Logger.d(M_BUS_P + TAG, "order = station= leave")
|
||||
mRouteLineInfoCallback!!.updateStationsInfo(stations, i + 1, false)
|
||||
if (mNextStationIndex != i + 1) {
|
||||
mTwoStationsRouts.clear()
|
||||
val startStation = mStations[i]
|
||||
val endStation = mStations[i + 1]
|
||||
setTrajectoryStation(startStation, endStation, result.lineId)
|
||||
}
|
||||
mNextStationIndex = i + 1
|
||||
updateAutopilotControlParameters(result, i)
|
||||
return
|
||||
} else if (station.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !station.isLeaving) { //到站
|
||||
if (i == stations.size - 1) {
|
||||
cleanStation()
|
||||
}
|
||||
suspendCalculate()
|
||||
|
||||
Logger.d(M_BUS_P + TAG, "order = station= arrive")
|
||||
|
||||
mRouteLineInfoCallback!!.updateStationsInfo(stations, i, true)
|
||||
clearAutopilotControlParameters()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAutopilotControlParameters(
|
||||
busRoutesResult: BusPassengerRoutesResult,
|
||||
leaveIndex: Int
|
||||
) {
|
||||
val parameters = initAutopilotControlParameters(busRoutesResult, leaveIndex)
|
||||
if (null == parameters) {
|
||||
e(M_BUS_P + TAG, "AutopilotControlParameters is empty.")
|
||||
return
|
||||
}
|
||||
d(M_BUS_P + TAG, "AutopilotControlParameters is update.")
|
||||
updateAutopilotControlParameters(parameters)
|
||||
}
|
||||
|
||||
private fun clearAutopilotControlParameters() {
|
||||
d(M_BUS_P + TAG, "AutopilotControlParameters is clear.")
|
||||
updateAutopilotControlParameters(null)
|
||||
}
|
||||
|
||||
private fun initAutopilotControlParameters(
|
||||
busRoutesResult: BusPassengerRoutesResult,
|
||||
leaveIndex: Int
|
||||
): AutopilotControlParameters? {
|
||||
if (busRoutesResult.sites == null) {
|
||||
return null
|
||||
}
|
||||
val stations = busRoutesResult.sites
|
||||
if (leaveIndex + 1 > stations.size - 1) {
|
||||
e(M_BUS_P + TAG, "行程日志-mismatch condition1.")
|
||||
return null
|
||||
}
|
||||
val currentStation = stations[leaveIndex]
|
||||
val nextStation = stations[leaveIndex + 1]
|
||||
val parameters = AutopilotControlParameters()
|
||||
parameters.routeID = busRoutesResult.lineId
|
||||
parameters.routeName = busRoutesResult.name
|
||||
parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.name)
|
||||
parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.name)
|
||||
parameters.startLatLon = AutoPilotLonLat(currentStation.lat, currentStation.lon)
|
||||
parameters.endLatLon = AutoPilotLonLat(nextStation.lat, nextStation.lon)
|
||||
parameters.vehicleType = 10
|
||||
if (parameters.autoPilotLine == null) {
|
||||
parameters.autoPilotLine = AutoPilotLine(
|
||||
busRoutesResult.lineId.toLong(),
|
||||
busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5,
|
||||
busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5,
|
||||
busRoutesResult.contrailSaveTime, busRoutesResult.carModel,
|
||||
busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP,
|
||||
busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP,
|
||||
busRoutesResult.contrailSaveTimeDPQP
|
||||
)
|
||||
}
|
||||
return parameters
|
||||
}
|
||||
|
||||
fun release() {
|
||||
releaseListeners()
|
||||
cleanStation()
|
||||
startOrStopOrderLoop(false)
|
||||
}
|
||||
|
||||
fun setMoGoAutopilotPlanningListener(moGoAutopilotPlanningCallback: IBusPassengerAutopilotPlanningCallback?) {
|
||||
mAutopilotPlanningCallback = moGoAutopilotPlanningCallback
|
||||
}
|
||||
|
||||
fun setADASStatusCallback(callback: IBusPassengerADASStatusCallback?) {
|
||||
mADASStatusCallback = callback
|
||||
}
|
||||
|
||||
fun setControllerStatusCallback(
|
||||
tag: String?,
|
||||
callback: IBusPassengerControllerStatusCallback?
|
||||
) {
|
||||
if (tag == null || "" == tag) return
|
||||
if (callback == null) {
|
||||
mControllerStatusCallbackMap.remove(tag)
|
||||
return
|
||||
}
|
||||
mControllerStatusCallbackMap[tag] = callback
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
|
||||
// 2021.11.1重构自动驾驶 实现接口 IMoGoAutopilotStatusListener 注册监听 替换IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mGoAutopilotStatusListener)
|
||||
IntentManager.getInstance()
|
||||
.registerIntentListener(ConnectivityManager.CONNECTIVITY_ACTION, mNetWorkIntentListener)
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.VR_MODE,
|
||||
mMogoStatusChangedListener
|
||||
)
|
||||
// 定位监听
|
||||
addListener(TAG, 10, mMapLocationListener)
|
||||
|
||||
//2021.11.1 自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
|
||||
|
||||
//监听司机端消息
|
||||
CallerTelematicListenerManager.addListener(TAG, mReceivedMsgListener)
|
||||
startLoopAbnormalFactors(mContext!!)
|
||||
addDistanceListener(TAG, distanceListener)
|
||||
addTrajectoryListener(TAG, trajectoryListener)
|
||||
}
|
||||
|
||||
private fun releaseListeners() {
|
||||
MogoStatusManager.getInstance().unregisterStatusChangedListener(
|
||||
TAG,
|
||||
StatusDescriptor.VR_MODE,
|
||||
mMogoStatusChangedListener
|
||||
)
|
||||
|
||||
// 注销定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterLifecycleListener(10010)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(mGoAutopilotStatusListener)
|
||||
CallerPlanningRottingListenerManager.removeListener(moGoAutopilotPlanningListener)
|
||||
CallerTelematicListenerManager.removeListener(TAG)
|
||||
stopLoopAbnormalFactors()
|
||||
}
|
||||
|
||||
private val distanceListener: IDistanceListener = object : IDistanceListener {
|
||||
override fun distanceCallback(distance: Float) {
|
||||
val lastTime: Double = distance / BusPassengerConst.BUS_AVERAGE_SPEED * 3.6 //秒
|
||||
d(M_BUS_P + TAG, "轨迹排查==lastSumLength = $distance")
|
||||
for (site in routesResult!!.sites) {
|
||||
if (site.drivingStatus == BusPassengerConst.STATION_STATUS_STOPPED && !site.isLeaving) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback!!.routePlanningToNextStationChanged(
|
||||
distance.toLong(),
|
||||
lastTime.toLong()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val trajectoryListener: ITrajectoryListener =
|
||||
object : ITrajectoryListener {
|
||||
override fun trajectoryCallback(
|
||||
routeArrivied: MutableList<MogoLocation>,
|
||||
routeArriving: MutableList<MogoLocation>,
|
||||
location: MogoLocation
|
||||
) {
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
val routeArriviedTemp: MutableList<LatLng> = ArrayList()
|
||||
val routeArrivingTemp: MutableList<LatLng> = ArrayList()
|
||||
var temp: LatLng
|
||||
for (mogoLocation in routeArrivied) {
|
||||
temp = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
routeArriviedTemp.add(temp)
|
||||
}
|
||||
for (mogoLocation in routeArriving) {
|
||||
temp = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
routeArrivingTemp.add(temp)
|
||||
}
|
||||
mAutopilotPlanningCallback!!.routeResult(
|
||||
routeArriviedTemp,
|
||||
routeArrivingTemp,
|
||||
location
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mReceivedMsgListener: IReceivedMsgListener = object : IReceivedMsgListener {
|
||||
override fun onReceivedServerSn(sn: String?) {
|
||||
Logger.d(M_BUS_P + TAG, "onReceivedServerSn = $sn")
|
||||
if (mDriverStatusCallback != null) {
|
||||
mDriverStatusCallback!!.updateDriverSn(sn)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
if (OchCommonConst.BUSINESS_STRING == type) {
|
||||
val baseMsg = GsonUtils.fromJson(String(byteArray), BaseDPMsg::class.java)
|
||||
Logger.d(
|
||||
M_BUS_P + TAG,
|
||||
"onReceivedMsg = " + GsonUtils.toJson(baseMsg)
|
||||
)
|
||||
if (baseMsg != null && baseMsg.type == DPMsgType.TYPE_COMMON.type) {
|
||||
val (isViewShow, _, msg1) = GsonUtils.fromJson(
|
||||
String(byteArray),
|
||||
AppConnectMsg::class.java
|
||||
)
|
||||
if (isViewShow) { //消息盒子显示内容
|
||||
pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(), msg1,
|
||||
OCHSocketMessageManager.OPERATION_SYSTEM
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听网络变化,避免启动机器时无网导致无法更新订单信息
|
||||
private val mNetWorkIntentListener = IMogoIntentListener { intentStr, intent ->
|
||||
d(M_BUS_P + TAG, "onIntentReceived = %s", intentStr)
|
||||
if (ConnectivityManager.CONNECTIVITY_ACTION == intentStr) {
|
||||
if (NetworkUtils.isConnected(mContext)) {
|
||||
queryDriverOperationStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VR mode变更回调
|
||||
private val mMogoStatusChangedListener =
|
||||
IMogoStatusChangedListener { descriptor: StatusDescriptor, isTrue: Boolean ->
|
||||
if (StatusDescriptor.VR_MODE == descriptor) {
|
||||
if (mControllerStatusCallbackMap.isNotEmpty()) {
|
||||
for (callback in mControllerStatusCallbackMap.values) {
|
||||
callback.onVRModeChanged(isTrue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mMapLocationListener: IMoGoChassisLocationGCJ02Listener =
|
||||
object : IMoGoChassisLocationGCJ02Listener {
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (null == mogoLocation) return
|
||||
mLocation = mogoLocation
|
||||
for (callback in mControllerStatusCallbackMap.values) {
|
||||
callback.onCarLocationChanged(mogoLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
private var arriveAtEnd = false //乘客app专用字段
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotRunning()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotEnable()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotDisable()
|
||||
} else if (state == IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
|
||||
mTwoStationsRouts.clear()
|
||||
if (mADASStatusCallback != null) mADASStatusCallback!!.onAutopilotRunning()
|
||||
}
|
||||
}
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: ArrivalNotification?) {
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& isPassenger(FunctionBuildConfig.appIdentityMode)
|
||||
) {
|
||||
arriveAtEnd = true
|
||||
}
|
||||
|
||||
// TODO: 2022/3/31
|
||||
if (DebugConfig.isDebug()) {
|
||||
// ToastUtils.showShort("到达目的地");
|
||||
}
|
||||
if (mADASStatusCallback != null) {
|
||||
mADASStatusCallback!!.onAutopilotArriveEnd()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {}
|
||||
}
|
||||
private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener =
|
||||
object : IMoGoPlanningRottingListener {
|
||||
override fun onAutopilotRotting(globalPathResp: GlobalPathResp?) {
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
if (it.size > 0) {
|
||||
d(M_BUS_P + TAG, "收到轨迹:${it.size}--第一个点${it[0]}--最后一个点:${it.last()}")
|
||||
updateRoutePoints(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
|
||||
mRoutePoints.clear()
|
||||
val latLngModels: List<MogoLocation> = coordinateConverterWgsToGcjLocations(mContext, routePoints)
|
||||
mRoutePoints.addAll(latLngModels)
|
||||
calculateTwoStationsRoute()
|
||||
}
|
||||
|
||||
private fun calculateTwoStationsRoute() {
|
||||
//找出前往站对应的轨迹点,拿出两站点的集合
|
||||
d(M_BUS_P + TAG, "mRoutePoints.size() = " + mRoutePoints.size)
|
||||
if (mRoutePoints.size > 0) {
|
||||
if (mStations.size > 1) { //两个站点及以上要计算两个站点间的轨迹路线
|
||||
if (mNextStationIndex <= mStations.size - 1 && mNextStationIndex - 1 >= 0) {
|
||||
mTwoStationsRouts.clear()
|
||||
val stationNext = mStations[mNextStationIndex]
|
||||
val stationCur = mStations[mNextStationIndex - 1]
|
||||
//当前站在轨迹中对应的点
|
||||
val currentRouteIndex = getArrivedPointIndexNew(
|
||||
0, mRoutePoints, stationCur.gcjLon, stationCur.gcjLat
|
||||
)
|
||||
//要前往的站在轨迹中对应的点
|
||||
val nextRouteIndex = getArrivedPointIndexNew(
|
||||
currentRouteIndex, mRoutePoints, stationNext.gcjLon, stationNext.gcjLat
|
||||
)
|
||||
d(
|
||||
M_BUS_P + TAG,
|
||||
"轨迹排查==currentRouteIndex = " + currentRouteIndex
|
||||
+ ", nextRouteIndex = " + nextRouteIndex
|
||||
)
|
||||
if (currentRouteIndex < nextRouteIndex) { //如果找到的next在起点的轨迹前面,直接舍弃这个轨迹,不显示
|
||||
mTwoStationsRouts.addAll(
|
||||
mRoutePoints.subList(
|
||||
currentRouteIndex,
|
||||
nextRouteIndex + 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mTwoStationsRouts.size > 0) {
|
||||
val sumLength = calculateRouteSumLength(mTwoStationsRouts)
|
||||
SharedPrefsMgr.getInstance(mContext!!)
|
||||
.putInt(BusPassengerConst.BUS_SP_KEY_ORDER_SUM_DIS, sumLength.toInt())
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback!!.updateTotalDistance()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startOrStopOrderLoop(start: Boolean) {
|
||||
d(M_BUS_P + TAG, "startOrStopOrderLoop() $start")
|
||||
if (start) {
|
||||
BusPassengerModelLoopManager.getInstance().startQueryDriverLineLoop()
|
||||
} else {
|
||||
BusPassengerModelLoopManager.getInstance().stopQueryDriverLineLoop()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setTrajectoryStation(
|
||||
startStationInfo: BusPassengerStation,
|
||||
endStationInfo: BusPassengerStation,
|
||||
lineId: Int
|
||||
) {
|
||||
val startStation = MogoLocation()
|
||||
startStation.longitude = startStationInfo.gcjLon
|
||||
startStation.latitude = startStationInfo.gcjLat
|
||||
val endStation = MogoLocation()
|
||||
endStation.longitude = endStationInfo.gcjLon
|
||||
endStation.latitude = endStationInfo.gcjLat
|
||||
setStationPoint(startStation, endStation, lineId.toLong())
|
||||
}
|
||||
|
||||
fun cleanStation() {
|
||||
setStationPoint(null, null, -1L)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,45 +37,6 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
|
||||
private Disposable mQueryLineDisposable; //心跳轮询
|
||||
private CompositeDisposable mRouteWipeDisposable;
|
||||
private CompositeDisposable mCalculateRouteDisposable; //每隔2s计算一次剩余里程和时间
|
||||
|
||||
public void startOrStopRouteAndWipe() {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startOrStopRouteWipe()");
|
||||
if (mRouteWipeDisposable != null) return;
|
||||
if (mRouteWipeDisposable == null){
|
||||
mRouteWipeDisposable = new CompositeDisposable();
|
||||
}
|
||||
Disposable disposable = startLoopRouteAndWipe()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_1S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mRouteWipeDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopOrStopRouteAndWipe() {
|
||||
if (mRouteWipeDisposable != null) {
|
||||
mRouteWipeDisposable.dispose();
|
||||
mRouteWipeDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void startQueryDriverLineLoop() {
|
||||
if (mQueryLineDisposable != null && !mQueryLineDisposable.isDisposed()) {
|
||||
@@ -87,7 +48,7 @@ public class BusPassengerModelLoopManager {
|
||||
.map((aLong -> aLong + 1))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aLong -> BusPassengerModel.getInstance().queryDriverSiteByCoordinate());
|
||||
.subscribe(aLong -> BusPassengerModel.INSTANCE.queryDriverSiteByCoordinate());
|
||||
}
|
||||
|
||||
public void stopQueryDriverLineLoop() {
|
||||
@@ -98,63 +59,4 @@ public class BusPassengerModelLoopManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void startCalculateRouteInfoLoop() {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "startCalculateRouteInfoLoop()");
|
||||
if (mCalculateRouteDisposable != null) return;
|
||||
if (mCalculateRouteDisposable == null){
|
||||
mCalculateRouteDisposable = new CompositeDisposable();
|
||||
}
|
||||
Disposable disposable = startLoopCalculateRouteInfo()
|
||||
.doOnSubscribe(new Consumer<Disposable>() {
|
||||
@Override
|
||||
public void accept(Disposable disposable) throws Exception {
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@Override
|
||||
public void accept(Throwable throwable) throws Exception {
|
||||
}
|
||||
})
|
||||
.delay(LOOP_LINE_2S, TimeUnit.MILLISECONDS, true) // 设置delayError为true,表示出现错误的时候也需要延迟5s进行通知,达到无论是请求正常还是请求失败,都是5s后重新订阅,即重新请求。
|
||||
.subscribeOn(Schedulers.io())
|
||||
.repeat() // repeat保证请求成功后能够重新订阅。
|
||||
.retry() // retry保证请求失败后能重新订阅
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Integer>() {
|
||||
@Override
|
||||
public void accept(Integer integer) throws Exception {
|
||||
}
|
||||
});
|
||||
mCalculateRouteDisposable.add(disposable);
|
||||
}
|
||||
|
||||
public void stopCalculateRouteInfLoop() {
|
||||
if (mCalculateRouteDisposable != null) {
|
||||
CallerLogger.INSTANCE.i(M_BUS_P + TAG, "stopCalculateRouteInfLoop()");
|
||||
mCalculateRouteDisposable.dispose();
|
||||
mCalculateRouteDisposable = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopRouteAndWipe(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().loopRouteAndWipe();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable<Integer> startLoopCalculateRouteInfo(){
|
||||
return Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
if (emitter.isDisposed()) return;
|
||||
BusPassengerModel.getInstance().dynamicCalculateRouteInfo();
|
||||
emitter.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
|
||||
public BaseBusPassengerPresenter(BusPassengerRouteFragment view) {
|
||||
super(view);
|
||||
BusPassengerModel.getInstance().init(AbsMogoApplication.getApp());
|
||||
BusPassengerModel.INSTANCE.init(AbsMogoApplication.getApp());
|
||||
initListeners();
|
||||
}
|
||||
|
||||
@@ -50,23 +50,23 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
super.onDestroy( owner );
|
||||
|
||||
releaseListeners();
|
||||
BusPassengerModel.getInstance().release();
|
||||
BusPassengerModel.INSTANCE.release();
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
BusPassengerModel.getInstance().setADASStatusCallback(this);
|
||||
BusPassengerModel.getInstance().setControllerStatusCallback(TAG, this);
|
||||
BusPassengerModel.getInstance().setDriverStatusCallback(this);
|
||||
BusPassengerModel.getInstance().setRouteLineInfoCallback(this);
|
||||
BusPassengerModel.getInstance().setMoGoAutopilotPlanningListener(this);
|
||||
BusPassengerModel.INSTANCE.setADASStatusCallback(this);
|
||||
BusPassengerModel.INSTANCE.setControllerStatusCallback(TAG, this);
|
||||
BusPassengerModel.INSTANCE.setDriverStatusCallback(this);
|
||||
BusPassengerModel.INSTANCE.setRouteLineInfoCallback(this);
|
||||
BusPassengerModel.INSTANCE.setMoGoAutopilotPlanningListener(this);
|
||||
}
|
||||
|
||||
private void releaseListeners() {
|
||||
BusPassengerModel.getInstance().setADASStatusCallback(null);
|
||||
BusPassengerModel.getInstance().setControllerStatusCallback(TAG, null);
|
||||
BusPassengerModel.getInstance().setDriverStatusCallback(null);
|
||||
BusPassengerModel.getInstance().setRouteLineInfoCallback(null);
|
||||
BusPassengerModel.getInstance().setMoGoAutopilotPlanningListener(null);
|
||||
BusPassengerModel.INSTANCE.setADASStatusCallback(null);
|
||||
BusPassengerModel.INSTANCE.setControllerStatusCallback(TAG, null);
|
||||
BusPassengerModel.INSTANCE.setDriverStatusCallback(null);
|
||||
BusPassengerModel.INSTANCE.setRouteLineInfoCallback(null);
|
||||
BusPassengerModel.INSTANCE.setMoGoAutopilotPlanningListener(null);
|
||||
}
|
||||
|
||||
private void runOnUIThread( Runnable executor ) {
|
||||
@@ -152,10 +152,8 @@ public class BaseBusPassengerPresenter extends Presenter<BusPassengerRouteFragme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "routeResult:" + models.size()
|
||||
+ " haveArrivedIndex = "+haveArrivedIndex);
|
||||
runOnUIThread(() ->mView.routeResult(models,haveArrivedIndex));
|
||||
public void routeResult(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
runOnUIThread(() ->mView.routeResult(routeArrivied,routeArriving,location));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,9 @@ import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.data.multidisplay.TelematicConstant;
|
||||
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener;
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView;
|
||||
import com.mogo.eagle.core.function.view.MapBizView;
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,7 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
|
||||
private MapBizView mapBizView;
|
||||
private FrameLayout flContainer;
|
||||
private RomaPassengerView romaPView;
|
||||
|
||||
protected AppCompatImageView videoSwitch;
|
||||
|
||||
@@ -45,13 +48,14 @@ public abstract class BusPassengerBaseFragment<V extends IView, P extends Presen
|
||||
protected void initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView);
|
||||
videoSwitch = findViewById(R.id.video_switch_iv);
|
||||
romaPView = findViewById(R.id.romaPView);
|
||||
if(DeviceUtils.isLenovoModel() || DeviceUtils.isEB5Model()){
|
||||
romaPView.setVisibility(View.VISIBLE);
|
||||
}else{
|
||||
romaPView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
videoSwitch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openOrCloseLiveVideo();
|
||||
}
|
||||
});
|
||||
videoSwitch.setOnClickListener(v -> openOrCloseLiveVideo());
|
||||
|
||||
CallerTelematicListenerManager.INSTANCE.addListener(TAG, new IReceivedMsgListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,352 +0,0 @@
|
||||
package com.mogo.och.bus.passenger.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS_P;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.bus.passenger.R;
|
||||
import com.mogo.och.bus.passenger.callback.IBusPassengerMapViewCallback;
|
||||
import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
public class BusPassengerMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener,
|
||||
IBusPassengerMapDirectionView,
|
||||
AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TPMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>(); //轨迹坐标数据
|
||||
private List<LatLng> mLineStationLatLng = new ArrayList<>();//站点坐标数据
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
private int mHaveArrivedIndex = 0;
|
||||
|
||||
private List<Marker> mLineMarkers = new ArrayList<>();
|
||||
|
||||
// private IBusPassengerMapViewCallback mIBusPassengerMapViewCallback;
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
public BusPassengerMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public BusPassengerMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// public void setTaxiPassengerMapViewCallback(IBusPassengerMapViewCallback iBusPassengerMapViewCallback) {
|
||||
// this.mIBusPassengerMapViewCallback = iBusPassengerMapViewCallback;
|
||||
// }
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.bus_p_line_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
// mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
// mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(BusPassengerMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "onCarLocationChanged2 :" + location.getLatitude() + ":" + location.getLongitude());
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_BUS_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
//圈定地图显示范围
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 0){
|
||||
//存放经纬度
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++) {
|
||||
boundsBuilder.include(mCoordinatesLatLng.get(i));
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
}else if (mLineStationLatLng.size() > 0){
|
||||
for (int i = 0; i< mLineStationLatLng.size();i++){
|
||||
boundsBuilder.include(mLineStationLatLng.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
boundsBuilder.include(currentLatLng);
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),100,100,100,100));
|
||||
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, "mLinePointsLatLng.size() = " +mLineStationLatLng.size()
|
||||
+" mCoordinatesLatLng.size()= " + mCoordinatesLatLng.size());
|
||||
if (mLineStationLatLng.size() >= 2 && mCoordinatesLatLng.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.width(14); //线段宽度
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.colorValues(colorList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
|
||||
}
|
||||
|
||||
public void clearCoordinatesLatLng(){
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
mCoordinatesLatLng.clear();
|
||||
mLineStationLatLng.clear();
|
||||
CallerLogger.INSTANCE.d(M_BUS_P + TAG, " mCoordinatesLatLng.clear " );
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs,int haveArrivedIndex) {
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
public void clearLineMarkers(){
|
||||
for (int i =0; i< mLineMarkers.size();i++){
|
||||
mLineMarkers.get(i).setVisible(false);
|
||||
mLineMarkers.get(i).remove();
|
||||
}
|
||||
mLineMarkers.clear();
|
||||
}
|
||||
|
||||
public void setLinePointMarkerAndDraw(List<LatLng> mLineStationsList, int currentIndex) {
|
||||
clearLineMarkers();
|
||||
mLineStationLatLng.clear();
|
||||
mLineStationLatLng.addAll(mLineStationsList);
|
||||
|
||||
if (mLineStationsList.size() > 0){
|
||||
for (int i = 0; i < mLineStationsList.size(); i++) {
|
||||
if (currentIndex == i){
|
||||
Marker mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_end_point)));
|
||||
mEndMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mEndMarker);
|
||||
}else {
|
||||
Marker mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_view_dir_way_point)));
|
||||
mStartMarker.setPosition(mLineStationsList.get(i));
|
||||
mLineMarkers.add(i,mStartMarker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
// mIBusPassengerMapViewCallback.onCameraChange(cameraPosition.bearing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package com.mogo.och.bus.passenger.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import com.amap.api.maps.AMap
|
||||
import com.amap.api.maps.CameraUpdateFactory
|
||||
import com.amap.api.maps.TextureMapView
|
||||
import com.amap.api.maps.model.BitmapDescriptor
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory
|
||||
import com.amap.api.maps.model.CameraPosition
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.amap.api.maps.model.LatLngBounds
|
||||
import com.amap.api.maps.model.Marker
|
||||
import com.amap.api.maps.model.MarkerOptions
|
||||
import com.amap.api.maps.model.Polyline
|
||||
import com.amap.api.maps.model.PolylineOptions
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.utils.BusPassengerMapAssetStyleUtil
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
class BusPassengerMapDirectionView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
IBusPassengerMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
companion object {
|
||||
//小地图名称
|
||||
const val TAG = "BusPassengerMapDirectionView"
|
||||
}
|
||||
|
||||
private lateinit var mAMapNaviView: TextureMapView
|
||||
private lateinit var mAMap: AMap
|
||||
private var mPolyline: Polyline? = null
|
||||
private val mLineMarkers: MutableList<Marker> = ArrayList()
|
||||
private lateinit var mCarMarker: Marker
|
||||
|
||||
private val mLineStationLatLng: MutableList<LatLng> = ArrayList() //站点坐标数据
|
||||
var textureList: MutableList<BitmapDescriptor?> = ArrayList()
|
||||
var texIndexList: MutableList<Int> = ArrayList()
|
||||
private var mArrivedRes: BitmapDescriptor? = null
|
||||
private var mUnArrivedRes: BitmapDescriptor? = null
|
||||
|
||||
private val routeArrivied: MutableList<LatLng> = ArrayList()
|
||||
private val routeArriving: MutableList<LatLng> = ArrayList()
|
||||
private var location: MogoLocation? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
initView(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
d(M_BUS_P + TAG, "initView")
|
||||
val smpView = LayoutInflater.from(context).inflate(R.layout.bus_p_map_view, this)
|
||||
mAMapNaviView = smpView.findViewById<View>(R.id.bus_p_line_amap_view) as TextureMapView
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 10, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
mAMap = mAMapNaviView.map
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.mapType = AMap.MAP_TYPE_NIGHT
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.isTrafficEnabled = false
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_car)).anchor(0.5f, 0.5f))
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_arrived)
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrow_un_arrive)
|
||||
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsStyle(
|
||||
context, "map_style.data"
|
||||
)
|
||||
)
|
||||
.setStyleExtraData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context, "map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions)
|
||||
|
||||
// 设置地图的样式
|
||||
mAMap.uiSettings.apply {
|
||||
isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
setAllGesturesEnabled(true) // 所有手势
|
||||
isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
}
|
||||
|
||||
mAMap.setOnMapLoadedListener {
|
||||
d(M_BUS_P + TAG, "smp---onMapLoaded")
|
||||
// 加载自定义样式
|
||||
val options = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsStyle(
|
||||
context, "map_style.data"
|
||||
)
|
||||
)
|
||||
.setStyleExtraData(
|
||||
BusPassengerMapAssetStyleUtil.getAssetsExtraStyle(
|
||||
context, "map_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(options)
|
||||
mAMapNaviView.map.setPointToCenter(
|
||||
mAMapNaviView.width / 2,
|
||||
mAMapNaviView.height / 2
|
||||
)
|
||||
}
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this)
|
||||
}
|
||||
|
||||
// override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
// return true
|
||||
// }
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
val currentLatLng = LatLng(mogoLocation.latitude, mogoLocation.longitude)
|
||||
|
||||
//更新车辆位置
|
||||
mCarMarker.rotateAngle = (360 - mogoLocation.heading).toFloat()
|
||||
mCarMarker.position = currentLatLng
|
||||
mCarMarker.setToTop()
|
||||
try {
|
||||
//圈定地图显示范围
|
||||
val boundsBuilder = LatLngBounds.Builder()
|
||||
routeArrivied.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
routeArriving.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
mLineStationLatLng.forEach {
|
||||
boundsBuilder.include(it)
|
||||
}
|
||||
boundsBuilder.include(currentLatLng)
|
||||
mAMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngBoundsRect(
|
||||
boundsBuilder.build(),
|
||||
100,
|
||||
100,
|
||||
100,
|
||||
100
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawablePolyline() {
|
||||
if (routeArrivied.isEmpty() && routeArriving.isEmpty()) {
|
||||
d(SceneConstant.M_TAXI + TAG, "没有点")
|
||||
return
|
||||
}
|
||||
texIndexList.clear()
|
||||
val allPoints = ArrayList(routeArrivied)
|
||||
for (i in routeArrivied.indices) {
|
||||
if (routeArrivied.size > 1 && i < routeArrivied.size - 1) {
|
||||
texIndexList.add(0)
|
||||
}
|
||||
}
|
||||
texIndexList.add(0)
|
||||
allPoints.add(LatLng(location!!.latitude, location!!.longitude))
|
||||
allPoints.addAll(routeArriving)
|
||||
for (ignored in routeArrivied) {
|
||||
texIndexList.add(1)
|
||||
}
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.points = allPoints
|
||||
mPolyline!!.options.customTextureIndex = texIndexList
|
||||
return
|
||||
}
|
||||
if(textureList.isEmpty()) {
|
||||
textureList.add(mArrivedRes)
|
||||
textureList.add(mUnArrivedRes)
|
||||
}
|
||||
//设置线段纹理
|
||||
val polylineOptions = PolylineOptions().apply {
|
||||
addAll(allPoints)
|
||||
isUseTexture = true
|
||||
width(15f)
|
||||
lineCapType(PolylineOptions.LineCapType.LineCapRound)
|
||||
customTextureList = textureList
|
||||
customTextureIndex = texIndexList
|
||||
}
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions)
|
||||
}
|
||||
|
||||
override fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
mPolyline = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLineMarker() {}
|
||||
|
||||
fun clearCoordinatesLatLng() {
|
||||
textureList.clear()
|
||||
texIndexList.clear()
|
||||
routeArrivied.clear()
|
||||
routeArriving.clear()
|
||||
mLineStationLatLng.clear()
|
||||
d(M_BUS_P + TAG, " mCoordinatesLatLng.clear ")
|
||||
}
|
||||
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
mAMapNaviView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
mAMapNaviView.onResume()
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
mAMapNaviView.onPause()
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mAMapNaviView.onDestroy()
|
||||
}
|
||||
|
||||
fun setCoordinatesLatLng(
|
||||
routeArrivied: List<LatLng>?,
|
||||
routeArriving: List<LatLng>?,
|
||||
location: MogoLocation?
|
||||
) {
|
||||
this.routeArrivied.clear()
|
||||
this.routeArrivied.addAll(routeArrivied!!)
|
||||
this.routeArriving.clear()
|
||||
this.routeArriving.addAll(routeArriving!!)
|
||||
this.location = location
|
||||
}
|
||||
|
||||
fun clearLineMarkers() {
|
||||
for (i in mLineMarkers.indices) {
|
||||
mLineMarkers[i].isVisible = false
|
||||
mLineMarkers[i].remove()
|
||||
}
|
||||
mLineMarkers.clear()
|
||||
}
|
||||
|
||||
fun setLinePointMarkerAndDraw(mLineStationsList: List<LatLng>, currentIndex: Int) {
|
||||
clearLineMarkers()
|
||||
mLineStationLatLng.clear()
|
||||
mLineStationLatLng.addAll(mLineStationsList)
|
||||
if (mLineStationsList.isNotEmpty()) {
|
||||
// 起点marker, 终点marker, 过站marker, 未过站marker
|
||||
val size = mLineStationsList.size
|
||||
val mStartMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_start_point))
|
||||
)
|
||||
val mEndMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_end_point))
|
||||
)
|
||||
mStartMarker.position = mLineStationsList[0]
|
||||
mLineMarkers.add(0, mStartMarker)
|
||||
for (i in mLineStationsList.indices) {
|
||||
if (currentIndex <= i && i < size - 1 && i > 0) { //未到达
|
||||
val unArrivedMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_unarrived_point))
|
||||
)
|
||||
unArrivedMarker.position = mLineStationsList[i]
|
||||
mLineMarkers.add(i, unArrivedMarker)
|
||||
} else if (i in 1 until currentIndex) {
|
||||
val arrivedMarker = mAMap.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bus_p_map_arrived_point))
|
||||
)
|
||||
arrivedMarker.position = mLineStationsList[i]
|
||||
mLineMarkers.add(i, arrivedMarker)
|
||||
}
|
||||
}
|
||||
mEndMarker.position = mLineStationsList[size - 1]
|
||||
mLineMarkers.add(size - 1, mEndMarker)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCameraChange(cameraPosition: CameraPosition) {
|
||||
}
|
||||
|
||||
override fun onCameraChangeFinish(cameraPosition: CameraPosition) {}
|
||||
|
||||
}
|
||||
@@ -240,9 +240,9 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
public void routeResult(List<LatLng> latLngList,int haveArrivedIndex) {
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolyline(latLngList,haveArrivedIndex);
|
||||
public void routeResult(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
if (routeArrivied.size() > 0||routeArriving.size()>0) {
|
||||
drawablePolyline(routeArrivied,routeArriving,location);
|
||||
} else {
|
||||
clearMapView();
|
||||
}
|
||||
@@ -253,15 +253,10 @@ public class BusPassengerRouteFragment extends
|
||||
*
|
||||
* @param coordinates
|
||||
*/
|
||||
private void drawablePolyline(List<LatLng> coordinates,int haveArrivedIndex) {
|
||||
private void drawablePolyline(List<LatLng> routeArrivied,List<LatLng> routeArriving,MogoLocation location) {
|
||||
if (mMapDirectionView != null) {
|
||||
mMapDirectionView.setCoordinatesLatLng(coordinates,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
mMapDirectionView.setCoordinatesLatLng(routeArrivied,routeArriving,location);
|
||||
UiThreadHandler.post(() -> mMapDirectionView.drawablePolyline());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,10 +285,7 @@ public class BusPassengerRouteFragment extends
|
||||
}
|
||||
|
||||
public void changeOperationStatus(boolean status) {
|
||||
if (status) {
|
||||
mNoLineInfoView.setVisibility(View.GONE);
|
||||
mRouteInfoView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (!status) {
|
||||
emptyTv.setText(getString(R.string.bus_p_no_out));
|
||||
mNoLineInfoView.setVisibility(View.VISIBLE);
|
||||
mRouteInfoView.setVisibility(View.GONE);
|
||||
|
||||
@@ -48,9 +48,7 @@ public class BPRouteDataTestUtils {
|
||||
builder.setLongitude(s.getDouble("longitude_"));
|
||||
list.add(builder.build());
|
||||
}
|
||||
BusPassengerModel.getInstance().updateRoutePoints(list);
|
||||
BusPassengerModel.getInstance().startRemainRouteInfo();
|
||||
BusPassengerModel.getInstance().startToRouteAndWipe();
|
||||
BusPassengerModel.INSTANCE.updateRoutePoints(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 628 B |
@@ -27,7 +27,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.RomaPassengerView
|
||||
android:id="@+id/ivMoGoLogo"
|
||||
android:id="@+id/romaPView"
|
||||
android:layout_width="@dimen/dp_120"
|
||||
android:layout_height="@dimen/dp_120"
|
||||
android:background="@drawable/roma_bus_p_bg_selector"
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -62,6 +63,8 @@ import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.distancemamager.ITrajectoryListener;
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
@@ -94,8 +97,6 @@ public class OrderModel {
|
||||
private int backgroundCurrentStationIndex = 0;//A->B 此处值是A站点索引
|
||||
|
||||
private static volatile OrderModel sInstance;
|
||||
public double mLongitude = 0;
|
||||
public double mLatitude = 0;
|
||||
private Context mContext;
|
||||
private final List<BusStationBean> stationList = new ArrayList<>();
|
||||
private BusRoutesResult busRoutesResult = null;
|
||||
@@ -153,7 +154,7 @@ public class OrderModel {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
loginService = (LoginService) ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation();
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, mMapLocationListener);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG,10, mMapLocationListener);
|
||||
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
@@ -173,6 +174,8 @@ public class OrderModel {
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addTrajectoryListener(TAG,trajectoryListener);
|
||||
|
||||
//2022.1.28
|
||||
// 调用Disposable.dispose() 时候会出现InterruptedException 导致出现崩溃
|
||||
// The exception could not be delivered to the consumer because it has already canceled/disposed
|
||||
@@ -268,6 +271,12 @@ public class OrderModel {
|
||||
this.mControllerStatusCallback = callback;
|
||||
}
|
||||
|
||||
private final ITrajectoryListener trajectoryListener = new ITrajectoryListener() {
|
||||
@Override
|
||||
public void trajectoryCallback(@NonNull List<MogoLocation> routeArrivied, @NonNull List<MogoLocation> routeArriving, @NonNull MogoLocation location) {
|
||||
|
||||
}
|
||||
};
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
|
||||
|
||||
@Override
|
||||
@@ -347,6 +356,8 @@ public class OrderModel {
|
||||
OCHSocketMessageManager.msgWriteOffPassengerType);
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.stopLoopAbnormalFactors();
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
@@ -382,8 +393,6 @@ public class OrderModel {
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (null == gnssInfo) return;
|
||||
mLongitude = gnssInfo.getLongitude();
|
||||
mLatitude = gnssInfo.getLatitude();
|
||||
if (mControllerStatusCallback != null) {
|
||||
mControllerStatusCallback.onCarLocationChanged(gnssInfo);
|
||||
}
|
||||
@@ -410,10 +419,26 @@ public class OrderModel {
|
||||
startLon, startLat,
|
||||
location.getLongitude(), location.getLatitude());
|
||||
|
||||
if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) {
|
||||
if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) {//1、当前位置和站点围栏15m内
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance
|
||||
+ " to " + upcomingStation.getName());
|
||||
onArriveAt(null); //无自动驾驶到站信息传null
|
||||
|
||||
//2、开始计算当前位置和站点的向量角度 < 90度 未经过 >90度 经过
|
||||
double stationAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
location.getLongitude(),
|
||||
location.getLatitude(),
|
||||
startLon,
|
||||
startLat,
|
||||
(int) location.getHeading());
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "judgeArrivedStation() stationAngle = " + stationAngle);
|
||||
|
||||
//3、刚过站且过站距离在15m内, 提交到站
|
||||
if (stationAngle > 90 && distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE){
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "judgeArrivedStation() = 刚过站且在15m内");
|
||||
onArriveAt(null); //无自动驾驶到站信息传null
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -601,12 +626,13 @@ public class OrderModel {
|
||||
, nextStation
|
||||
, isLastStop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void onStartAutopilot(int leaveIndex) {
|
||||
//开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启
|
||||
isGoingToNextStation = true;
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
startAutopilot(false, leaveIndex);
|
||||
} else {
|
||||
@@ -743,16 +769,24 @@ public class OrderModel {
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "leaveStation-backgroundCurrentStationIndex = " + backgroundCurrentStationIndex);
|
||||
String nextStationName = "";
|
||||
String nextStationNameKr = "";
|
||||
MogoLocation nextStationPoint = new MogoLocation();
|
||||
if (backgroundCurrentStationIndex < stationList.size() - 1) {
|
||||
nextStationName = stationList.get(backgroundCurrentStationIndex + 1).getName();
|
||||
nextStationNameKr = stationList.get(backgroundCurrentStationIndex + 1).getNameKr();
|
||||
BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1);
|
||||
nextStationName = nextStation.getName();
|
||||
nextStationNameKr = nextStation.getNameKr();
|
||||
nextStationPoint.setLongitude(nextStation.getGcjLon());
|
||||
nextStationPoint.setLatitude(nextStation.getGcjLat());
|
||||
}
|
||||
final String currentStationName = stationList.get(backgroundCurrentStationIndex).getName();
|
||||
BusStationBean busStationBean = stationList.get(backgroundCurrentStationIndex);
|
||||
final String currentStationName = busStationBean.getName();
|
||||
String finalNextStationName = nextStationName;
|
||||
String finalNextStationNameKr = nextStationNameKr;
|
||||
MogoLocation currentStationPoint = new MogoLocation();
|
||||
currentStationPoint.setLongitude(busStationBean.getGcjLon());
|
||||
currentStationPoint.setLatitude(busStationBean.getGcjLat());
|
||||
OrderServiceManager.leaveStation(mContext,
|
||||
stationList.get(backgroundCurrentStationIndex).getSeq(),
|
||||
stationList.get(backgroundCurrentStationIndex).getSiteId(),
|
||||
busStationBean.getSeq(),
|
||||
busStationBean.getSiteId(),
|
||||
currentTaskId,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -764,6 +798,7 @@ public class OrderModel {
|
||||
queryBusRoutes();
|
||||
leaveStationSuccess(backgroundCurrentStationIndex, currentStationName,
|
||||
finalNextStationName,finalNextStationNameKr);
|
||||
setTrajectoryStation(currentStationPoint,nextStationPoint, (long) currentLineId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1019,7 +1054,7 @@ public class OrderModel {
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束====");
|
||||
CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot();
|
||||
|
||||
setTrajectoryStation(null,null,-1L);
|
||||
endTask();
|
||||
}
|
||||
|
||||
@@ -1090,6 +1125,10 @@ public class OrderModel {
|
||||
String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5);
|
||||
String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-dataLatitude = "+ latitude+
|
||||
", dataLongitude = " + longitude + "; arriveLat = " + arriveLat +
|
||||
", arriveLon = " +arriveLon);
|
||||
|
||||
if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) {
|
||||
CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致");
|
||||
return;
|
||||
@@ -1113,6 +1152,8 @@ public class OrderModel {
|
||||
|
||||
// 车机端上传心跳数据(只在出车状态时上传)
|
||||
public void runCarHeartbeat() {
|
||||
double mLatitude = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLatitude();
|
||||
double mLongitude =CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLongitude();
|
||||
OrderServiceManager.runCarHeartbeat(mContext, mLongitude, mLatitude,
|
||||
new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
@@ -1138,6 +1179,8 @@ public class OrderModel {
|
||||
|
||||
// 登出
|
||||
public void logout() {
|
||||
double mLatitude = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLatitude();
|
||||
double mLongitude =CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02().getLongitude();
|
||||
loginService.loginOut(mLatitude, mLongitude);
|
||||
}
|
||||
|
||||
@@ -1232,4 +1275,8 @@ public class OrderModel {
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setTrajectoryStation(MogoLocation startStation,MogoLocation endStation,Long lineId){
|
||||
TrajectoryAndDistanceManager.INSTANCE.setStationPoint(startStation,endStation,lineId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class BusConst {
|
||||
const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L
|
||||
|
||||
//围栏到站 暂定10米
|
||||
const val ARRIVE_AT_END_STATION_DISTANCE = 10
|
||||
const val ARRIVE_AT_END_STATION_DISTANCE = 15
|
||||
|
||||
// 轮询
|
||||
const val LOOP_PASSENGER_5S = 5 * 1000L
|
||||
|
||||
@@ -158,7 +158,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
});
|
||||
|
||||
initListener();
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
ctvAutopilotStatus.setOnClickListener(new OnPreventFastClickListener() {
|
||||
|
||||
@Override
|
||||
@@ -301,9 +301,6 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
@Override
|
||||
public void onAutopilotRecordResult(@Nullable RecordPanelOuterClass.RecordPanel recordPanel) {
|
||||
// if (!HmiBuildConfig.isShowBadCaseView && recordPanel != null && recordPanel.getType() == 1 && recordPanel.getStat() == 100) {
|
||||
// CallerDevaToolsManager.INSTANCE.onReceiveBadCaseRecord(recordPanel);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -448,7 +445,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
|
||||
public void stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,7 +519,7 @@ public abstract class BaseBusTabFragment<V extends IView, P extends Presenter<V>
|
||||
public void run() { //未启动成功做处理
|
||||
if (isAnimateRunning) {// 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation();
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
}
|
||||
}
|
||||
}, TIMER_START_AUTOPILOT_INTERVAL);
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.constraintlayout.widget.Group;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.temp.EventLogout;
|
||||
@@ -108,7 +107,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
groupStationsPanel = findViewById(R.id.group_stations_panel);
|
||||
noDataView = findViewById(R.id.no_line_data_view);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState());
|
||||
CallerLogger.INSTANCE.d(M_BUS + TAG, "initView: " + CallerAutoPilotStatusListenerManager.INSTANCE.getState());
|
||||
// 初始化的时候设置 UI 按钮状态
|
||||
showAutopilotBiz();
|
||||
|
||||
@@ -455,7 +454,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
}
|
||||
|
||||
//清除鹰眼右下角小地图轨迹
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_MAP, "clearBusStationsMarkers --------->");
|
||||
CallerLogger.INSTANCE.d(SceneConstant.M_BUS, "clearBusStationsMarkers --------->");
|
||||
smallMapView.clearPolyline();
|
||||
}
|
||||
|
||||
@@ -532,7 +531,7 @@ public class BusFragment extends BaseBusTabFragment<BusFragment, BusPresenter>
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.switch_line_btn) {//切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线
|
||||
//本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState()
|
||||
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
ToastUtils.showLong(getResources().getString(R.string.bus_switch_line_btn_warning1));
|
||||
return;
|
||||
|
||||
@@ -34,8 +34,6 @@ import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.voice.VoiceNotice;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -45,8 +43,6 @@ import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 网约车小巴
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class BusPresenter extends Presenter<BusFragment>
|
||||
implements IRefreshBusStationsCallback, ISlidePannelHideCallback
|
||||
@@ -54,8 +50,8 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
private static final String TAG = "BusPresenter";
|
||||
|
||||
private int currentAutopilotStatus = -1;
|
||||
private List<BusStationBean> mStationList = new ArrayList<>();
|
||||
private volatile int currentAutopilotStatus = -1;
|
||||
private final List<BusStationBean> mStationList = new ArrayList<>();
|
||||
private int mCurrentStation = 0;
|
||||
|
||||
public BusPresenter(BusFragment view) {
|
||||
@@ -168,9 +164,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
|
||||
int state = autopilotStatusInfo.getState();
|
||||
// CallerLogger.INSTANCE.d(M_BUS + TAG, "onStateChange: " + state + "currentAutopilotStatus = " + currentAutopilotStatus);
|
||||
public void onAutopilotStatusResponse(int state) {
|
||||
switch (state) {
|
||||
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE:
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
|
||||
@@ -206,26 +200,21 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING:
|
||||
if (FunctionBuildConfig.isDemoMode
|
||||
&& (
|
||||
(mCurrentStation >= 0 && mCurrentStation <= mStationList.size() - 1)
|
||||
&& OrderModel.getInstance().isGoingToNextStation()
|
||||
|
||||
)
|
||||
) {
|
||||
CallerLogger.INSTANCE.d(M_BUS + "BusOrderModel=", "有美化功能");
|
||||
@@ -234,9 +223,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING) {
|
||||
currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING;
|
||||
}
|
||||
runOnUIThread(() -> {
|
||||
mView.onAutopilotStatusChanged(currentAutopilotStatus);
|
||||
});
|
||||
runOnUIThread(() -> mView.onAutopilotStatusChanged(currentAutopilotStatus));
|
||||
break;
|
||||
default:
|
||||
runOnUIThread(() -> mView.onAutopilotEnableChange(false));
|
||||
@@ -275,13 +262,9 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
|
||||
/**
|
||||
* 测试使用
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
public void debugAutoPilotStatus(int status) {
|
||||
AutopilotStatusInfo info = new AutopilotStatusInfo();
|
||||
info.setState(status);
|
||||
onAutopilotStatusResponse(info);
|
||||
onAutopilotStatusResponse(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,4 +323,13 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public void onStartAdasFailure() {
|
||||
runOnUIThread(() -> mView.stopAnimAndUpdateBtnStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotDockerInfo(@NonNull String dockerVersion) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ public class BusAnalyticsManager {
|
||||
|
||||
CallerLogger.INSTANCE.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg );
|
||||
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() !=
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, failMsg);
|
||||
}
|
||||
mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() ==
|
||||
, CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
@@ -54,6 +54,7 @@ public class SlidePanelView extends View {
|
||||
NORMAL_TEXT_MARGIN_RIGHT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_NORMAL_TEXT_MARGIN_RIGHT, NORMAL_TEXT_MARGIN_RIGHT);
|
||||
SHORT_TEXT_MARGIN_LEFT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_SHORT_TEXT_MARGIN_LEFT, SHORT_TEXT_MARGIN_LEFT);
|
||||
SHORT_TEXT_MARGIN_RIGHT = (int) mTypedArray.getDimension(R.styleable.SlidePanelView_SHORT_TEXT_MARGIN_RIGHT, SHORT_TEXT_MARGIN_RIGHT);
|
||||
mTypedArray.recycle();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ public class SlidePanelView extends View {
|
||||
textPaint.setShader(textGradient);
|
||||
textPaint.getFontMetrics(blockTextMetrics);
|
||||
int size = AutoSizeUtils.dp2px(getContext(), 120);
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options(); //todo yakun 优化
|
||||
opts.inDensity = (int) AutoSizeConfig.getInstance().getInitDensity();
|
||||
bmBlock = BitmapFactory.decodeResource(getResources(), R.drawable.bus_base_slide_block,opts);
|
||||
bmBlock = Bitmap.createScaledBitmap(bmBlock, size, size, true);
|
||||
|
||||
@@ -10,11 +10,9 @@ import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.startAutoPilot
|
||||
@@ -28,11 +26,11 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.response.*
|
||||
import com.mogo.och.bus.passenger.callback.*
|
||||
import com.mogo.och.bus.passenger.constant.CharterPassengerConst
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.utils.ToastCharterUtils
|
||||
import com.mogo.och.bus.passenger.utils.VoiceFocusManager
|
||||
@@ -78,7 +76,8 @@ object CharterPassengerModel {
|
||||
private var mContext: Context = AbsMogoApplication.getApp()
|
||||
|
||||
//Model->Presenter:自动驾驶状态相关
|
||||
var mAutoStatusChnageListener = ConcurrentHashMap<String, ICharterPassengerAutoStatusChangeCallback>()
|
||||
var mAutoStatusChnageListener =
|
||||
ConcurrentHashMap<String, ICharterPassengerAutoStatusChangeCallback>()
|
||||
|
||||
// 定位监听
|
||||
private val mControllerStatusCallbackMap =
|
||||
@@ -86,7 +85,6 @@ object CharterPassengerModel {
|
||||
|
||||
// 当前位置坐标
|
||||
private var mLocationGCJ02: MogoLocation? = null
|
||||
private var mLocationWgs: MogoLocation? = null
|
||||
|
||||
// 订单信息 有订单有线路结束订单
|
||||
@Volatile
|
||||
@@ -112,17 +110,18 @@ object CharterPassengerModel {
|
||||
* 到站是否播报 key 线路id+业务 value 是否播报
|
||||
*
|
||||
*/
|
||||
private var broadcastList : MutableMap<String,Boolean> = HashMap()
|
||||
private var broadcastList: MutableMap<String, Boolean> = HashMap()
|
||||
|
||||
// 到站仅一次
|
||||
private val endKey = "arrivedLine"
|
||||
private val endKeyRequestIng = "arrivedLineRequestIng"
|
||||
private val ending100Key = "arrivingLine"
|
||||
private val min5Speak = "min5Speak"
|
||||
|
||||
private var carTypeChageListener: IOrderChangeCallback?=null
|
||||
private var carTypeChageListener: IOrderChangeCallback? = null
|
||||
|
||||
private var subscribeCountDown: Disposable?=null
|
||||
var switchLine5minWait: Disposable?=null
|
||||
private var subscribeCountDown: Disposable? = null
|
||||
var switchLine5minWait: Disposable? = null
|
||||
|
||||
@Volatile
|
||||
var newCheckedSite: SiteInfoResponse.SiteInfo? = null
|
||||
@@ -140,7 +139,6 @@ object CharterPassengerModel {
|
||||
CallerAutoPilotStatusListenerManager.removeListener(mGoAutopilotStatusListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
CallerPlanningRottingListenerManager.removeListener(moGoAutopilotPlanningListener)
|
||||
CallerChassisLocationWGS84ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
@@ -150,8 +148,7 @@ object CharterPassengerModel {
|
||||
// 自动驾驶状态变化监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mGoAutopilotStatusListener)
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
CallerChassisLocationWGS84ListenerManager.addListener(TAG, 2, mMapWGS84LocationListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 4, mMapLocationListener)
|
||||
// 自动驾驶路线规划接口 返回自动驾驶轨迹
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener)
|
||||
// 登录状态监听
|
||||
@@ -167,6 +164,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
mControllerStatusCallbackMap[tag] = callback
|
||||
}
|
||||
|
||||
fun setAutoStatusCallback(tag: String, callback: ICharterPassengerAutoStatusChangeCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (callback == null) {
|
||||
@@ -216,32 +214,18 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
private val mMapWGS84LocationListener: IMoGoChassisLocationWGS84Listener =
|
||||
object : IMoGoChassisLocationWGS84Listener {
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
if (null == gnssInfo) return
|
||||
mLocationWgs = gnssInfo
|
||||
}
|
||||
}
|
||||
|
||||
// 前一个自动驾驶状体
|
||||
@Volatile
|
||||
private var mPreAutoStatus = -1
|
||||
|
||||
// 自动驾驶状态监听
|
||||
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
|
||||
object : IMoGoAutopilotStatusListener {
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
val state = autoPilotStatusInfo.state
|
||||
if(mPreAutoStatus!=state){
|
||||
mPreAutoStatus = state
|
||||
mAutoStatusChnageListener.forEach {
|
||||
it.value.onAutoStatusChange(state)
|
||||
}
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
mAutoStatusChnageListener.forEach {
|
||||
it.value.onAutoStatusChange(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"底盘给到站信息")
|
||||
CallerLogger.d(M_BUS_P + TAG, "底盘给到站信息")
|
||||
arriveDest()
|
||||
}
|
||||
}
|
||||
@@ -252,13 +236,9 @@ object CharterPassengerModel {
|
||||
private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener =
|
||||
object : IMoGoPlanningRottingListener {
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
CallerLogger.d(
|
||||
M_BUS_P + TAG,
|
||||
"onAutopilotRotting = ${GsonUtil.jsonFromObject(globalPathResp)}"
|
||||
)
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
if (it.size > 0) {
|
||||
CallerLogger.d(
|
||||
d(
|
||||
M_BUS_P + TAG,
|
||||
"收到轨迹:${it.size}--第一个点${it[0]}--最后一个点:${it.last()}"
|
||||
)
|
||||
@@ -269,17 +249,21 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location?>?) {
|
||||
fun updateRoutePoints(routePoints: List<MessagePad.Location>) {
|
||||
mRoutePoints = null
|
||||
val latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(mContext, routePoints)
|
||||
mRoutePoints = latLngModels
|
||||
}
|
||||
fun cleanRoutePoints(){
|
||||
|
||||
fun cleanRoutePoints() {
|
||||
mRoutePoints = null
|
||||
}
|
||||
|
||||
fun setStatusChangeListener(tag:String,orderStatusChangeListener: IOrderStatusChangeListener?) {
|
||||
fun setStatusChangeListener(
|
||||
tag: String,
|
||||
orderStatusChangeListener: IOrderStatusChangeListener?
|
||||
) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
orderStatusChangeListeners.remove(tag)
|
||||
@@ -287,7 +271,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
orderStatusChangeListeners[tag] = orderStatusChangeListener
|
||||
}
|
||||
fun setStationDistanceListener(tag:String,orderStatusChangeListener: IDistanceCallback?) {
|
||||
|
||||
fun setStationDistanceListener(tag: String, orderStatusChangeListener: IDistanceCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
stationDistanceListener.remove(tag)
|
||||
@@ -295,7 +280,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
stationDistanceListener[tag] = orderStatusChangeListener
|
||||
}
|
||||
fun setOrderLeftTimeListeners(tag:String,orderStatusChangeListener: ITimeCallback?) {
|
||||
|
||||
fun setOrderLeftTimeListeners(tag: String, orderStatusChangeListener: ITimeCallback?) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
orderLeftTimeListeners.remove(tag)
|
||||
@@ -306,14 +292,15 @@ object CharterPassengerModel {
|
||||
orderStatusChangeListener.setOrderTimeCallBack(leftTime)
|
||||
}
|
||||
|
||||
fun setCarTypeChangeListener(carTypeChageListener: IOrderChangeCallback?){
|
||||
fun setCarTypeChangeListener(carTypeChageListener: IOrderChangeCallback?) {
|
||||
this.carTypeChageListener = carTypeChageListener
|
||||
}
|
||||
|
||||
fun getCurrentOrderStatus(): OrderStatusEnum {
|
||||
return this.orderStatus
|
||||
}
|
||||
fun getCurrentOrderInfo():OrderInfoResponse.OrderInfo?{
|
||||
|
||||
fun getCurrentOrderInfo(): OrderInfoResponse.OrderInfo? {
|
||||
return orderInfo
|
||||
}
|
||||
// endregion
|
||||
@@ -372,13 +359,13 @@ object CharterPassengerModel {
|
||||
BusPassengerServiceManager.queryOrderInfo(
|
||||
mContext, object : OchCommonServiceCallback<OrderInfoResponse> {
|
||||
override fun onSuccess(data: OrderInfoResponse?) {
|
||||
CallerLogger.d(M_BUS_P+TAG,"订单信息:$data")
|
||||
if (data?.data == null){
|
||||
if(orderInfo!=null){
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单信息:$data")
|
||||
if (data?.data == null) {
|
||||
if (orderInfo != null) {
|
||||
// 启动车辆服务状态
|
||||
startCarStatusLoop()
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
// 判断是否有订单
|
||||
ordrLagic(data.data)
|
||||
}
|
||||
@@ -397,21 +384,26 @@ object CharterPassengerModel {
|
||||
// 有订单有线路后结束轮训
|
||||
orderData.let { order ->
|
||||
//设置车模
|
||||
if (this.orderInfo?.productType!=orderData.productType) {
|
||||
if (this.orderInfo?.productType != orderData.productType) {
|
||||
this.carTypeChageListener?.setCarChangeListener(orderData.productType)
|
||||
CallerLogger.d(M_BUS_P+TAG,"设置车模")
|
||||
CallerLogger.d(M_BUS_P + TAG, "设置车模")
|
||||
}
|
||||
if(this.orderInfo?.siteId!=orderData.siteId){
|
||||
if (this.orderInfo?.siteId != orderData.siteId) {
|
||||
val coordinateConverterWgsToGcj =
|
||||
CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(
|
||||
mContext,
|
||||
order.wgs84Lon!!,
|
||||
order.wgs84Lat!!
|
||||
)
|
||||
this.carTypeChageListener?.setEndStationCallBack(order.siteId,order.siteName,coordinateConverterWgsToGcj.longitude,coordinateConverterWgsToGcj.latitude)
|
||||
this.carTypeChageListener?.setEndStationCallBack(
|
||||
order.siteId,
|
||||
order.siteName,
|
||||
coordinateConverterWgsToGcj.longitude,
|
||||
coordinateConverterWgsToGcj.latitude
|
||||
)
|
||||
}
|
||||
this.orderInfo?.orderNo?.let {
|
||||
if(it!=orderData.orderNo){
|
||||
if (it != orderData.orderNo) {
|
||||
// orderNo 变后清理
|
||||
SharedPrefs.getInstance(mContext).remove("${it}$min5Speak")
|
||||
}
|
||||
@@ -428,7 +420,7 @@ object CharterPassengerModel {
|
||||
this.orderInfo = orderData
|
||||
setOrderStatus(OrderStatusEnum.OrdersWithLine)
|
||||
updateAutopilotControlParameters()
|
||||
}else{
|
||||
} else {
|
||||
this.orderInfo = orderData
|
||||
}
|
||||
//计算终点距离
|
||||
@@ -448,7 +440,7 @@ object CharterPassengerModel {
|
||||
)
|
||||
// 小于15m到站
|
||||
if (calculateLineDistance < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE && calculateLineDistance > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于15米到站1")
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于15米到站1")
|
||||
arriveDest()
|
||||
}
|
||||
if (calculateLineDistance < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE && calculateLineDistance > 0) {
|
||||
@@ -465,7 +457,7 @@ object CharterPassengerModel {
|
||||
fun hasSetLineAndSite(): Pair<LineInfoResponse.LineInfo, SiteInfoResponse.SiteInfo>? {
|
||||
orderInfo?.let {
|
||||
if (it.lineId != null && it.lineId > 0 && it.siteId != null && it.siteId!! > 0) {
|
||||
if(it.arriveStatus==OrderInfoResponse.ARRIVED){
|
||||
if (it.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
return null
|
||||
}
|
||||
val lineInfo = LineInfoResponse.LineInfo(it.lineName, it.lineId)
|
||||
@@ -486,7 +478,8 @@ object CharterPassengerModel {
|
||||
}
|
||||
return null
|
||||
}
|
||||
fun hasOrder():Boolean{
|
||||
|
||||
fun hasOrder(): Boolean {
|
||||
return orderInfo != null
|
||||
}
|
||||
// endregion
|
||||
@@ -557,7 +550,7 @@ object CharterPassengerModel {
|
||||
private fun startCalibrationLoop() {
|
||||
BusPassengerModelLoopManager.setLoopFunction(
|
||||
TAGCALIBRATION,
|
||||
LoopInfo(120, ::queryBusinessTime,immediately = true)
|
||||
LoopInfo(120, ::queryBusinessTime, immediately = true)
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + TAG, "启动时间校准轮询")
|
||||
}
|
||||
@@ -587,42 +580,43 @@ object CharterPassengerModel {
|
||||
}
|
||||
val leadTime = endlast / 1000
|
||||
subscribeCountDown =
|
||||
Observable.intervalRange(0L, leadTime, 0, 5, TimeUnit.SECONDS)
|
||||
.map { aLong -> leadTime - aLong }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe{millisUntilFinished->
|
||||
if (millisUntilFinished <= 300L) {
|
||||
orderInfo?.let {
|
||||
val isPlayed = SharedPrefs.getInstance(mContext)
|
||||
.getBoolean("${it.orderNo}$min5Speak", false)
|
||||
if (!isPlayed) {
|
||||
//发送 通知
|
||||
OCHSocketMessageManager.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),
|
||||
AbsMogoApplication.getApp()
|
||||
.getString(R.string.m1_end_order_5min), 2
|
||||
)
|
||||
VoiceManager.surplus5min(VoiceFocusManager.getVoiceCmdCallBack())
|
||||
CallerLogger.d(M_BUS_P+ TAG,"倒计时5分钟${it.orderNo}")
|
||||
SharedPrefs.getInstance(mContext).putBoolean("${it.orderNo}$min5Speak",true)
|
||||
Observable.intervalRange(0L, leadTime, 0, 5, TimeUnit.SECONDS)
|
||||
.map { aLong -> leadTime - aLong }
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe { millisUntilFinished ->
|
||||
if (millisUntilFinished <= 300L) {
|
||||
orderInfo?.let {
|
||||
val isPlayed = SharedPrefs.getInstance(mContext)
|
||||
.getBoolean("${it.orderNo}$min5Speak", false)
|
||||
if (!isPlayed) {
|
||||
//发送 通知
|
||||
OCHSocketMessageManager.pushAppOperationalMsgBox(
|
||||
DateTimeUtil.getCurrentTimeStamp(),
|
||||
AbsMogoApplication.getApp()
|
||||
.getString(R.string.m1_end_order_5min), 2
|
||||
)
|
||||
VoiceManager.surplus5min(VoiceFocusManager.getVoiceCmdCallBack())
|
||||
CallerLogger.d(M_BUS_P + TAG, "倒计时5分钟${it.orderNo}")
|
||||
SharedPrefs.getInstance(mContext)
|
||||
.putBoolean("${it.orderNo}$min5Speak", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(orderInfo==null){
|
||||
subscribeCountDown?.let {
|
||||
if (!it.isDisposed) {
|
||||
it.dispose()
|
||||
if (orderInfo == null) {
|
||||
subscribeCountDown?.let {
|
||||
if (!it.isDisposed) {
|
||||
it.dispose()
|
||||
}
|
||||
}
|
||||
invokeOrderLeftTimeListeners(-1)
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
} else {
|
||||
invokeOrderLeftTimeListeners(millisUntilFinished)
|
||||
}
|
||||
invokeOrderLeftTimeListeners(-1)
|
||||
invokeStationDistanceListener(-1,-1)
|
||||
}else{
|
||||
invokeOrderLeftTimeListeners(millisUntilFinished)
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单倒计时${millisUntilFinished}")
|
||||
}
|
||||
CallerLogger.d(M_BUS_P + TAG, "订单倒计时${millisUntilFinished}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,9 +636,12 @@ object CharterPassengerModel {
|
||||
//设置全局轨迹信息
|
||||
locusInfo = data.data
|
||||
|
||||
CallerLogger.d(M_BUS_P+TAG,"查询自动驾驶轨迹信息")
|
||||
CallerLogger.d(M_BUS_P+TAG,GsonUtil.jsonFromObject(
|
||||
locusInfo))
|
||||
CallerLogger.d(M_BUS_P + TAG, "查询自动驾驶轨迹信息")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + TAG, GsonUtil.jsonFromObject(
|
||||
locusInfo
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
@@ -682,15 +679,15 @@ object CharterPassengerModel {
|
||||
mLocationGCJ02?.let {
|
||||
orderInfo?.let { order ->
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "订单信息:$order")
|
||||
if(order.siteId==null||order.siteId==0L||
|
||||
order.wgs84Lat==null||order.wgs84Lat==0.0||
|
||||
order.wgs84Lon==null||order.wgs84Lon==0.0
|
||||
){
|
||||
if (order.siteId == null || order.siteId == 0L ||
|
||||
order.wgs84Lat == null || order.wgs84Lat == 0.0 ||
|
||||
order.wgs84Lon == null || order.wgs84Lon == 0.0
|
||||
) {
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "站点信息未获得")
|
||||
return
|
||||
}
|
||||
newCheckedSite?.let {
|
||||
if(it.siteId!=order.siteId){
|
||||
if (it.siteId != order.siteId) {
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "站点和已选不吻合")
|
||||
return
|
||||
}
|
||||
@@ -714,46 +711,52 @@ object CharterPassengerModel {
|
||||
mogoLocation.latitude
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "两点距离和站点的直线距离:${lastSumLength}")
|
||||
if(lastSumLength>100) {
|
||||
if (mRoutePoints==null||mRoutePoints?.size == 0){
|
||||
if (lastSumLength > 100) {
|
||||
if (mRoutePoints == null || mRoutePoints?.size == 0) {
|
||||
//ToastCharterUtils.showLong("缺少轨迹数据暂停计算")
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance两点距离",
|
||||
CallerLogger.d(
|
||||
M_BUS_P + "calculateDistance两点距离",
|
||||
"缺少轨迹数据"
|
||||
)
|
||||
return
|
||||
}
|
||||
// 计算距离
|
||||
val templastSumLength =
|
||||
val templastSumLength =
|
||||
CoordinateCalculateRouteUtil.calculateRouteSumLength(
|
||||
mRoutePoints,
|
||||
it,
|
||||
mogoLocation
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + TAG, "使用轨迹轨迹:${mRoutePoints?.size}--第一个点${mRoutePoints!![0]}--最后一个点:${mRoutePoints!!.last()}")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + TAG,
|
||||
"使用轨迹轨迹:${mRoutePoints?.size}--第一个点${mRoutePoints!![0]}--最后一个点:${mRoutePoints!!.last()}"
|
||||
)
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance", "轨迹计算的距离$templastSumLength")
|
||||
if(templastSumLength>100){
|
||||
if (templastSumLength > 100) {
|
||||
lastSumLength = templastSumLength
|
||||
}
|
||||
}
|
||||
|
||||
val lastTime: Double = lastSumLength / CharterPassengerConst.Charter_AVERAGE_SPEED * 3.6 //秒
|
||||
val lastTime: Double =
|
||||
lastSumLength / CharterPassengerConst.Charter_AVERAGE_SPEED * 3.6 //秒
|
||||
|
||||
CallerLogger.d(M_BUS_P + "calculateDistance",
|
||||
CallerLogger.d(
|
||||
M_BUS_P + "calculateDistance",
|
||||
"最终信息:lastSumLength: ${lastSumLength}lastTime : $lastTime thread = ${Thread.currentThread().name}"
|
||||
)
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE&&lastSumLength>0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于100米到站2")
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_SOON_AT_START_STATION_DISTANCE && lastSumLength > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于100米到站2")
|
||||
arriveDestSoon()
|
||||
}
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE&&lastSumLength>0) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"小于15米到站2")
|
||||
if (lastSumLength < CharterPassengerConst.ARRIVE_AT_START_STATION_DISTANCE && lastSumLength > 0) {
|
||||
CallerLogger.d(M_BUS_P + TAG, "小于15米到站2")
|
||||
arriveDest()
|
||||
return
|
||||
}
|
||||
if(order.arriveStatus==OrderInfoResponse.ARRIVING) {
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
invokeStationDistanceListener(lastSumLength.toLong(), lastTime.toLong())
|
||||
}else{
|
||||
invokeStationDistanceListener(-1,-1)
|
||||
} else {
|
||||
invokeStationDistanceListener(-1, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,7 +766,7 @@ object CharterPassengerModel {
|
||||
|
||||
private fun setOrderStatus(orderStatus: OrderStatusEnum) {
|
||||
if (this.orderStatus != orderStatus) {
|
||||
CallerLogger.d(M_BUS_P + TAG,"${this.orderInfo?.orderNo}新的状态:$orderStatus")
|
||||
CallerLogger.d(M_BUS_P + TAG, "${this.orderInfo?.orderNo}新的状态:$orderStatus")
|
||||
this.orderStatus = orderStatus
|
||||
for (callback in orderStatusChangeListeners.values) {
|
||||
callback.onStatusChange(this.orderStatus)
|
||||
@@ -771,10 +774,10 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
fun setEndOrderStatus(){
|
||||
fun setEndOrderStatus() {
|
||||
UiThreadHandler.postDelayed({
|
||||
setOrderStatus(OrderStatusEnum.NoOrderUse)
|
||||
},1000)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -801,16 +804,16 @@ object CharterPassengerModel {
|
||||
val calculateLineDistanceNext = CoordinateUtils.calculateLineDistance(
|
||||
currentInfo.longitude,
|
||||
currentInfo.latitude,
|
||||
data[index+1].GcjLon!!,
|
||||
data[index+1].GcjLat!!
|
||||
data[index + 1].GcjLon!!,
|
||||
data[index + 1].GcjLat!!
|
||||
)
|
||||
if(calculateLineDistanceNext<CharterPassengerConst.MIN_DISTANCE_STATION){
|
||||
if (calculateLineDistanceNext < CharterPassengerConst.MIN_DISTANCE_STATION) {
|
||||
if (index + 2 <= data.size - 1) {
|
||||
return Pair(index + 2, true)// 下下个站点
|
||||
}else{
|
||||
} else {
|
||||
return Pair(-1, true)// 距离最后一个站点小于30m
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
return Pair(index + 1, true)// 下个站点
|
||||
}
|
||||
} else {
|
||||
@@ -822,7 +825,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
for (mutableEntry in distanceMap) {
|
||||
CallerLogger.d(M_BUS_P+ TAG,"距离:${mutableEntry.key}-----第几个站点${mutableEntry.value}")
|
||||
CallerLogger.d(M_BUS_P + TAG, "距离:${mutableEntry.key}-----第几个站点${mutableEntry.value}")
|
||||
}
|
||||
var middle = -1
|
||||
if (distanceMap.size >= 2) {
|
||||
@@ -830,7 +833,7 @@ object CharterPassengerModel {
|
||||
middle = mutableEntry.value
|
||||
break
|
||||
}
|
||||
if(middle==0){
|
||||
if (middle == 0) {
|
||||
return Pair(1, false)
|
||||
}
|
||||
mLocationGCJ02?.let {
|
||||
@@ -839,7 +842,7 @@ object CharterPassengerModel {
|
||||
// middle middle+1
|
||||
// middle-1 middle-2
|
||||
// middle+1 middle+2
|
||||
if(middle-1>=0) {
|
||||
if (middle - 1 >= 0) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle).GcjLon!!, data.get(middle).GcjLat!!,
|
||||
@@ -849,17 +852,17 @@ object CharterPassengerModel {
|
||||
return Pair(middle, false)
|
||||
}
|
||||
}
|
||||
if(middle+1<data.size) {
|
||||
if (middle + 1 < data.size) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle + 1).GcjLon!!, data.get(middle + 1).GcjLat!!,
|
||||
data.get(middle).GcjLon!!, data.get(middle).GcjLat!!,
|
||||
)
|
||||
if (degree > 90) {
|
||||
return Pair(middle+1, false)
|
||||
return Pair(middle + 1, false)
|
||||
}
|
||||
}
|
||||
if(middle-2>=0) {
|
||||
if (middle - 2 >= 0) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle - 1).GcjLon!!, data.get(middle - 1).GcjLat!!,
|
||||
@@ -869,11 +872,11 @@ object CharterPassengerModel {
|
||||
return Pair(middle - 1, false)
|
||||
}
|
||||
}
|
||||
if(middle+2<data.size) {
|
||||
if (middle + 2 < data.size) {
|
||||
val degree = CoordinateCalculateRouteUtil.getDegree(
|
||||
it.longitude, it.latitude,
|
||||
data.get(middle + 2).GcjLon!!, data.get(middle + 2).GcjLat!!,
|
||||
data.get(middle+1).GcjLon!!, data.get(middle+1).GcjLat!!,
|
||||
data.get(middle + 1).GcjLon!!, data.get(middle + 1).GcjLat!!,
|
||||
)
|
||||
if (degree > 90) {
|
||||
return Pair(middle + 2, false)
|
||||
@@ -891,21 +894,29 @@ object CharterPassengerModel {
|
||||
BusPassengerServiceManager.endOrder(mContext, it, callback)
|
||||
}
|
||||
}
|
||||
fun getLineTrajectory(lineId: Long,callback: OchCommonServiceCallback<TrajectoriesResponse>?) {
|
||||
|
||||
fun getLineTrajectory(lineId: Long, callback: OchCommonServiceCallback<TrajectoriesResponse>?) {
|
||||
BusPassengerServiceManager.queryLineLocation(mContext, lineId = lineId.toString(), callback)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun arriveDest() {
|
||||
val (order, lineId, siteId) = getOrderInfo()
|
||||
if(order!=null&&lineId!=null&&siteId!=null){
|
||||
if (order != null && lineId != null && siteId != null) {
|
||||
val requestSuccessSign = "${siteId}$endKey"
|
||||
val requestIngSign = "${siteId}$endKeyRequestIng"//正在请求中
|
||||
CallerLogger.d(M_BUS_P + BaseDPMsg.TAG,
|
||||
"requestSuccessSign${isSuccess(requestSuccessSign)}---requestIngSign${isSuccess(requestIngSign)}")
|
||||
CallerLogger.d(
|
||||
M_BUS_P + BaseDPMsg.TAG,
|
||||
"requestSuccessSign${isSuccess(requestSuccessSign)}---requestIngSign${
|
||||
isSuccess(
|
||||
requestIngSign
|
||||
)
|
||||
}"
|
||||
)
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
if (isSuccess(requestSuccessSign)&&//true 请求还没有成功 false 请求成功
|
||||
isSuccess(requestIngSign)) {// true 还没有正在请求 false 正在请求中
|
||||
if (isSuccess(requestSuccessSign) &&//true 请求还没有成功 false 请求成功
|
||||
isSuccess(requestIngSign)
|
||||
) {// true 还没有正在请求 false 正在请求中
|
||||
val currentTimeStamp = DateTimeUtil.getCurrentTimeStamp()
|
||||
broadcastList[requestIngSign] = true //正在请求中
|
||||
BusPassengerServiceManager.arriveDest(
|
||||
@@ -913,23 +924,23 @@ object CharterPassengerModel {
|
||||
lindId = lineId,
|
||||
writtenVersion = currentTimeStamp,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
arrivedDeskSuccess(currentTimeStamp,true)
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastCharterUtils.showShort("$code:$msg")
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (null != data && 0 == data.code) {
|
||||
arrivedDeskSuccess(currentTimeStamp, true)
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
super.onError()
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
})
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
ToastCharterUtils.showShort("$code:$msg")
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
super.onError()
|
||||
broadcastList[requestIngSign] = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -937,16 +948,16 @@ object CharterPassengerModel {
|
||||
|
||||
fun arrivedDeskSuccess(
|
||||
currentTimeStamp: Long,
|
||||
needSendDriver:Boolean
|
||||
needSendDriver: Boolean
|
||||
) {
|
||||
val (order, lineId, siteId) = getOrderInfo()
|
||||
val requestSuccessSign = "${siteId}$endKey"
|
||||
|
||||
if (!isSuccess(requestSuccessSign)){
|
||||
if (!isSuccess(requestSuccessSign)) {
|
||||
return
|
||||
}
|
||||
|
||||
if(order!=null&&lineId!=null&&siteId!=null){
|
||||
if (order != null && lineId != null && siteId != null) {
|
||||
VoiceManager.arrivedStation(
|
||||
order.siteName!!,
|
||||
order.siteNameKr ?: "",
|
||||
@@ -963,7 +974,7 @@ object CharterPassengerModel {
|
||||
order.startSiteId ?: 0,
|
||||
order.startSiteName ?: "",
|
||||
siteId.toInt(),
|
||||
order.siteName?:"",
|
||||
order.siteName ?: "",
|
||||
true,
|
||||
OrderInfoResponse.ARRIVED,
|
||||
currentTimeStamp
|
||||
@@ -987,15 +998,15 @@ object CharterPassengerModel {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOrderInfo():Triple<OrderInfoResponse.OrderInfo?,Long?,Long?>{
|
||||
this.orderInfo?.let { order->
|
||||
private fun getOrderInfo(): Triple<OrderInfoResponse.OrderInfo?, Long?, Long?> {
|
||||
this.orderInfo?.let { order ->
|
||||
this.orderInfo?.lineId?.let { lineId ->
|
||||
this.orderInfo?.siteId?.let { siteId ->
|
||||
return Triple(order,lineId,siteId)
|
||||
return Triple(order, lineId, siteId)
|
||||
}
|
||||
}
|
||||
}
|
||||
return Triple(null,null,null)
|
||||
return Triple(null, null, null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@@ -1004,7 +1015,8 @@ object CharterPassengerModel {
|
||||
order.siteId?.let { siteId ->
|
||||
if (order.arriveStatus == OrderInfoResponse.ARRIVING) {
|
||||
if (isSuccess("${siteId}$ending100Key")) {
|
||||
val string = mContext.getString(R.string.arrived_station_left_100,order.siteName)
|
||||
val string =
|
||||
mContext.getString(R.string.arrived_station_left_100, order.siteName)
|
||||
VoiceNotice.showNotice(string)
|
||||
broadcastList["${siteId}$ending100Key"] = true
|
||||
}
|
||||
@@ -1040,8 +1052,12 @@ object CharterPassengerModel {
|
||||
}
|
||||
|
||||
fun leaveStation() {
|
||||
orderInfo?.siteName?.let {cn->
|
||||
VoiceManager.leaveStation(cn,orderInfo?.siteNameKr?:"", VoiceFocusManager.getVoiceCmdCallBack())
|
||||
orderInfo?.siteName?.let { cn ->
|
||||
VoiceManager.leaveStation(
|
||||
cn,
|
||||
orderInfo?.siteNameKr ?: "",
|
||||
VoiceFocusManager.getVoiceCmdCallBack()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1065,14 +1081,17 @@ object CharterPassengerModel {
|
||||
return
|
||||
}
|
||||
orderInfo?.let {
|
||||
if(it.arriveStatus==OrderInfoResponse.ARRIVED){
|
||||
if (it.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
ToastCharterUtils.showLong("已到达目的地请重新选择线路")
|
||||
return
|
||||
}
|
||||
val parameters = initAutopilotControlParameters()
|
||||
if (null == parameters) {
|
||||
ToastCharterUtils.showShort("请选择站点")
|
||||
CallerLogger.e(SceneConstant.M_BUS + TAG, "行程日志-AutopilotControlParameters is empty.")
|
||||
CallerLogger.e(
|
||||
SceneConstant.M_BUS + TAG,
|
||||
"行程日志-AutopilotControlParameters is empty."
|
||||
)
|
||||
return
|
||||
}
|
||||
ToastCharterUtils.showShort("启动自动驾驶中")
|
||||
@@ -1099,7 +1118,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
val parameters = AutopilotControlParameters()
|
||||
orderInfo?.let { orderInfo ->
|
||||
mLocationWgs?.let { startPoint ->
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().let { startPoint ->
|
||||
val startWgsLon: Double = startPoint.longitude
|
||||
val startWgsLat: Double = startPoint.latitude
|
||||
val endWgsLon: Double = orderInfo.wgs84Lon!!
|
||||
@@ -1133,12 +1152,14 @@ object CharterPassengerModel {
|
||||
fun sendTripInfo() {
|
||||
//发送前后屏出站消息 3:代表出站
|
||||
orderInfo?.let {
|
||||
CharterSendTripInfoManager.sendCharterTripInfo(LEAVE_STATION,
|
||||
it.lineName!!,it.startSiteName!!,it.siteName!!,false)
|
||||
CharterSendTripInfoManager.sendCharterTripInfo(
|
||||
LEAVE_STATION,
|
||||
it.lineName!!, it.startSiteName!!, it.siteName!!, false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun invokeOrderLeftTimeListeners(timeInSecond: Long){
|
||||
private fun invokeOrderLeftTimeListeners(timeInSecond: Long) {
|
||||
leftTime = timeInSecond
|
||||
UiThreadHandler.post({
|
||||
for (value in orderLeftTimeListeners.values) {
|
||||
@@ -1147,7 +1168,7 @@ object CharterPassengerModel {
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
}
|
||||
|
||||
private fun invokeStationDistanceListener(meters:Long , timeInSecond:Long){
|
||||
private fun invokeStationDistanceListener(meters: Long, timeInSecond: Long) {
|
||||
var tempMeters = meters
|
||||
var tempTimeInSecond = timeInSecond
|
||||
if (orderInfo?.arriveStatus == OrderInfoResponse.ARRIVED) {
|
||||
@@ -1156,7 +1177,7 @@ object CharterPassengerModel {
|
||||
}
|
||||
UiThreadHandler.post({
|
||||
for (value in stationDistanceListener.values) {
|
||||
value.setDistancecAndTime(tempMeters,tempTimeInSecond)
|
||||
value.setDistancecAndTime(tempMeters, tempTimeInSecond)
|
||||
}
|
||||
}, UiThreadHandler.MODE.QUEUE)
|
||||
|
||||
|
||||
@@ -9,11 +9,10 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS_P
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.och.bus.passenger.utils.ToastCharterUtils
|
||||
import com.mogo.och.bus.passenger.bean.LoopInfo
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.bus.passenger.bean.event.EventLineSites
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoListResponse
|
||||
import com.mogo.och.bus.passenger.bean.response.LineInfoResponse
|
||||
@@ -21,7 +20,7 @@ import com.mogo.och.bus.passenger.bean.response.SiteInfoResponse
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import com.mogo.och.bus.passenger.model.IOrderStatusChangeListener
|
||||
import com.mogo.och.bus.passenger.model.OrderStatusEnum
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerModelLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.BusPassengerModelLoopManager
|
||||
import com.mogo.och.bus.passenger.net.BusPassengerServiceManager
|
||||
import com.mogo.och.bus.passenger.ui.dialogfragment.fragment.M1OrderLineFragment
|
||||
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
|
||||
@@ -67,7 +66,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
CharterPassengerModel.setStatusChangeListener(TAG,this)
|
||||
CallerTelematicListenerManager.addListener(TAG, msgReceived)
|
||||
val currentOrderStatus = CharterPassengerModel.getCurrentOrderStatus()
|
||||
onStatusChange(currentOrderStatus)
|
||||
needRunUI(currentOrderStatus)
|
||||
extracted()
|
||||
}
|
||||
|
||||
@@ -185,7 +184,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "onDestroy")
|
||||
CallerLogger.d(M_BUS_P + TAG, "onDestroy")
|
||||
RxUtils.disposeSubscribe(subscribeSelectLine)
|
||||
RxUtils.disposeSubscribe(subscribeSelectSite)
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
@@ -196,7 +195,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
/**
|
||||
* 接收司机屏反馈信息
|
||||
*/
|
||||
val msgReceived = object : IReceivedMsgListener {
|
||||
private val msgReceived = object : IReceivedMsgListener {
|
||||
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {
|
||||
UiThreadHandler.post {
|
||||
if (type == OchCommonConst.BUSINESS_STRING) {
|
||||
@@ -287,23 +286,27 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
ToastCharterUtils.showShort("断开和司机端连接、请联系安全员")
|
||||
BusPassengerModelLoopManager.removeLoopFunction(TAGLINELOOP)
|
||||
mView?.hideDataDriverRefuse()
|
||||
CallerLogger.d(SceneConstant.M_BUS_P + TAG, "endAni666")
|
||||
CallerLogger.d(M_BUS_P + TAG, "endAni666")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStatusChange(currentStatus: OrderStatusEnum) {
|
||||
UiThreadHandler.post {
|
||||
when (currentStatus) {
|
||||
OrderStatusEnum.OrderNoLine -> {
|
||||
mView?.setVisableByTrun(showBiz = true)
|
||||
extracted()
|
||||
}
|
||||
OrderStatusEnum.OrdersWithLine ->{
|
||||
mView?.setVisableByTrun(showBiz = true)
|
||||
}
|
||||
else ->{
|
||||
mView?.setVisableByTrun(showNorOrder = true)
|
||||
}
|
||||
needRunUI(currentStatus)
|
||||
}
|
||||
}
|
||||
|
||||
private fun needRunUI(currentStatus: OrderStatusEnum){
|
||||
when (currentStatus) {
|
||||
OrderStatusEnum.OrderNoLine -> {
|
||||
mView?.setVisableByTrun(showBiz = true)
|
||||
extracted()
|
||||
}
|
||||
OrderStatusEnum.OrdersWithLine ->{
|
||||
mView?.setVisableByTrun(showBiz = true)
|
||||
}
|
||||
else ->{
|
||||
mView?.setVisableByTrun(showNorOrder = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,7 +315,7 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
val gnssSpeed =
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().gnssSpeed
|
||||
if (gnssSpeed < 0.5) {
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
return true
|
||||
}
|
||||
@@ -321,13 +324,13 @@ class BusPassengerFunctionOrderPresenter(view: M1OrderLineFragment?) :
|
||||
}
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
|
||||
// 自动驾驶中
|
||||
when (StopSideStatusManager.stopSiteStatus) {
|
||||
return when (StopSideStatusManager.stopSiteStatus) {
|
||||
StopSideStatusManager.Status.EndingSuccess -> {
|
||||
return true
|
||||
true
|
||||
}
|
||||
else ->{
|
||||
ToastCharterUtils.showShort("自动驾驶中无法切换线路")
|
||||
return false
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ class BusPassengerPresenter(view: MainFragment?) :
|
||||
}
|
||||
OrderStatusEnum.OrdersWithLine -> {}
|
||||
OrderStatusEnum.NoOrderUse -> {
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等,请安全员主动停止车辆")
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class M1ContainFragment :
|
||||
setStyle(STYLE_NO_TITLE, R.style.DialogFullScreen) //dialog全屏
|
||||
}
|
||||
|
||||
private fun setCheckView() {
|
||||
private fun setCheckView() { //todo yakun 优化
|
||||
CallerLogger.d(M_BUS_P+ TAG, "setCheckView")
|
||||
when (tab) {
|
||||
VIDEOTAB -> {
|
||||
@@ -211,7 +211,7 @@ class M1ContainFragment :
|
||||
mShownByMe.isAccessible = true
|
||||
mDismissed.setBoolean(this, false)
|
||||
mShownByMe.setBoolean(this, true)
|
||||
if (isAdded) { //解决方法就是添加这行代码,如果已经添加了,就移除掉然后再show,就不会出现Fragment already added的错误了。
|
||||
if (isAdded) {
|
||||
return
|
||||
}
|
||||
val ft: FragmentTransaction = manager.beginTransaction()
|
||||
@@ -300,10 +300,8 @@ class M1ContainFragment :
|
||||
}
|
||||
if (ClickUtils.isFastClick()) {
|
||||
if (bpFunctionGroup.isAdded) {
|
||||
//解决方法就是添加这行代码,如果已经添加了,就移除掉然后再show,就不会出现Fragment already added的错误了。
|
||||
parentFragmentManager.beginTransaction().remove(bpFunctionGroup)
|
||||
.commitNowAllowingStateLoss()
|
||||
CallerLogger.d(M_BUS_P + DebugViewWatchDogFragment.TAG, "已经添加正在移除")
|
||||
CallerLogger.d(M_BUS_P + DebugViewWatchDogFragment.TAG, "已经添加")
|
||||
return
|
||||
}
|
||||
bpFunctionGroup.show(parentFragmentManager, TAG)
|
||||
CallerLogger.d(M_BUS_P + TAG, "展示$tab---$bpFunctionGroup")
|
||||
|
||||
@@ -934,7 +934,7 @@ public class CarouselLayoutManager extends RecyclerView.LayoutManager implements
|
||||
}
|
||||
|
||||
private CarouselSavedState(@NonNull final Parcel in) {
|
||||
mSuperState = in.readParcelable(Parcelable.class.getClassLoader());
|
||||
mSuperState = in.readParcelable(RecyclerView.LayoutManager.class.getClassLoader());
|
||||
mCenterItemPosition = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class GoViewWithArrive @JvmOverloads constructor(
|
||||
ToastCharterUtils.showShort(string)
|
||||
return
|
||||
}
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等")
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class GoViewWithArrive @JvmOverloads constructor(
|
||||
})
|
||||
RxUtils.disposeSubscribe(startAutoTimeOut)
|
||||
startAutoTimeOut = RxUtils.createSubscribe(20_000) {
|
||||
if (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
val string = AbsMogoApplication.getApp().getString(R.string.m1_start_auto_fail)
|
||||
ToastCharterUtils.showLong(string)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class StopSiteView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun stopSite(){
|
||||
when (CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state) {
|
||||
when (CallerAutoPilotStatusListenerManager.getState()) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {// 不可自动驾驶
|
||||
ToastCharterUtils.showShort("设备未就绪请稍等,请稍后再试")
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import chassis.ChassisStatesOuterClass
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
|
||||
@@ -25,7 +24,6 @@ import com.mogo.eagle.core.utilcode.util.ClickUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.bean.event.DebugView
|
||||
import com.mogo.och.bus.passenger.model.CharterPassengerModel
|
||||
import kotlinx.android.synthetic.main.m1_statusview_datetime.view.*
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -47,8 +45,6 @@ class StatusBarView @JvmOverloads constructor(
|
||||
|
||||
private var mHits = LongArray(COUNTS)
|
||||
|
||||
private var preStatus = -1
|
||||
|
||||
private fun continuousClick(type:String) {
|
||||
//每次点击时,数组向前移动一位
|
||||
System.arraycopy(mHits, 1, mHits, 0, mHits.size - 1)
|
||||
@@ -93,15 +89,11 @@ class StatusBarView @JvmOverloads constructor(
|
||||
progress.progress = 50
|
||||
tv_power_cos.text = "50%"
|
||||
|
||||
val state = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state
|
||||
setAutoPilotSatusInfo(state)
|
||||
val state = CallerAutoPilotStatusListenerManager.getState()
|
||||
setAutoPilotStatusInfo(state)
|
||||
}
|
||||
|
||||
private fun setAutoPilotSatusInfo(state: Int) {
|
||||
if(preStatus==state){
|
||||
return
|
||||
}
|
||||
preStatus = state
|
||||
private fun setAutoPilotStatusInfo(state: Int) {
|
||||
when (state) {
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
|
||||
actv_auto_status.text = "安全接管中"
|
||||
@@ -126,9 +118,9 @@ class StatusBarView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
UiThreadHandler.post {
|
||||
setAutoPilotSatusInfo(autoPilotStatusInfo.state)
|
||||
setAutoPilotStatusInfo(state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 511 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 2.0 MiB |
|
After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 38 KiB |