[6.3.0]
[common 添加轨迹统一处理问题件、]
This commit is contained in:
@@ -13,7 +13,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
@@ -26,11 +25,9 @@ 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.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.CallerTelematicManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
@@ -42,7 +39,6 @@ import com.mogo.eagle.core.utilcode.util.StringUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.bus.R;
|
||||
import com.mogo.och.bus.bean.BusRoutePlanningUpdateReqBean;
|
||||
import com.mogo.och.bus.bean.BusRoutesResponse;
|
||||
import com.mogo.och.bus.bean.BusRoutesResult;
|
||||
import com.mogo.och.bus.bean.BusStationBean;
|
||||
@@ -68,9 +64,11 @@ 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.autopilotmanager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.autopilot.ArrivedStation;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.trajectory.ITrajectoryListListener;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.trajectory.TrajectoryManager;
|
||||
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.MultiRequestLimitChecker;
|
||||
import com.mogo.och.common.module.utils.NumberFormatUtil;
|
||||
@@ -86,7 +84,6 @@ import java.util.List;
|
||||
|
||||
import io.reactivex.exceptions.UndeliverableException;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -120,8 +117,6 @@ public class OrderModel {
|
||||
private IPassengerCallback mPassengerCallback; //乘客核销回调
|
||||
private IBusADASStatusCallback mADASStatusCallback;
|
||||
|
||||
List<BusRoutePlanningUpdateReqBean.Result> points = new ArrayList<>();//全路径信息
|
||||
|
||||
private volatile boolean isArrivedStation = false;
|
||||
|
||||
//0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0
|
||||
@@ -159,8 +154,7 @@ public class OrderModel {
|
||||
|
||||
MogoStatusManager.getInstance().registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener);
|
||||
|
||||
//自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
|
||||
TrajectoryManager.INSTANCE.addTrajectoryListListenerr(TAG,iTrajectoryListener);
|
||||
|
||||
//开启自驾后 异常信息返回
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener);
|
||||
@@ -272,36 +266,22 @@ public class OrderModel {
|
||||
private final ITrajectoryListener trajectoryListener = (routeArrivied, routeArriving, location) -> {
|
||||
|
||||
};
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
|
||||
|
||||
|
||||
private final ITrajectoryListListener iTrajectoryListener = new ITrajectoryListListener() {
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(MessagePad.GlobalPathResp routeList) {
|
||||
if (null != routeList && routeList.getWayPointsList().size() > 0) {
|
||||
points.clear();
|
||||
points.addAll(coordinateConverterWgsToGcjList(mContext, routeList.getWayPointsList()));
|
||||
updateOrderRoute();
|
||||
}
|
||||
public void trajectoryCallback(@NonNull List<MogoLocation> trajectoryList) {
|
||||
updateOrderRoute(trajectoryList);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static List<BusRoutePlanningUpdateReqBean.Result> coordinateConverterWgsToGcjList(Context mContext, List<MessagePad.Location> mogoLatLngList) {
|
||||
List<BusRoutePlanningUpdateReqBean.Result> points = new ArrayList<>();
|
||||
for (MessagePad.Location m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m);
|
||||
BusRoutePlanningUpdateReqBean.Result result = new BusRoutePlanningUpdateReqBean.Result();
|
||||
result.latitude = mogoLatLng.latitude;
|
||||
result.longitude = mogoLatLng.longitude;
|
||||
points.add(result);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报订单全路径规划数据
|
||||
*/
|
||||
public void updateOrderRoute() {
|
||||
if (!isGoingToNextStation || backgroundCurrentStationIndex + 1 >= stationList.size() || points.size() == 0) {
|
||||
public void updateOrderRoute(List<MogoLocation> trajectoryList) {
|
||||
if (!isGoingToNextStation || backgroundCurrentStationIndex + 1 >= stationList.size() || trajectoryList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,7 +289,7 @@ public class OrderModel {
|
||||
BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1);
|
||||
|
||||
OrderServiceManager.updateOrderRoute(mContext, currentLineId, currentStation.getSiteId()
|
||||
, nextStation.getSiteId(), points, new OchCommonServiceCallback<BaseData>() {
|
||||
, nextStation.getSiteId(), trajectoryList, new OchCommonServiceCallback<BaseData>() {
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
|
||||
@@ -318,18 +298,12 @@ public class OrderModel {
|
||||
@Override
|
||||
public void onFail(int code, String failMsg) {
|
||||
if (isGoingToNextStation) {//重试
|
||||
updateOrderRoute();
|
||||
updateOrderRoute(trajectoryList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void debugUpdateOrderRoute(List<MessagePad.Location> list) {
|
||||
points.clear();
|
||||
points.addAll(coordinateConverterWgsToGcjList(mContext, list));
|
||||
updateOrderRoute();
|
||||
}
|
||||
|
||||
public void release() {
|
||||
|
||||
startOrStopOrderLoop(false);
|
||||
@@ -339,8 +313,7 @@ public class OrderModel {
|
||||
// 注销定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.removeListener(TAG);
|
||||
|
||||
//自动驾驶路线规划接口
|
||||
CallerPlanningRottingListenerManager.INSTANCE.removeListener(moGoAutopilotPlanningListener);
|
||||
TrajectoryManager.INSTANCE.addTrajectoryListListenerr(TAG,null);
|
||||
loginService = null;
|
||||
|
||||
OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null);
|
||||
@@ -1112,7 +1085,7 @@ public class OrderModel {
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void onArriveAt(MessagePad.ArrivalNotification data) {
|
||||
public void onArriveAt(ArrivedStation data) {
|
||||
if (backgroundCurrentStationIndex + 1 > stationList.size() - 1) {
|
||||
CallerLogger.e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束");
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.och.bus.bean.*
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
|
||||
@@ -330,15 +331,22 @@ object OrderServiceManager {
|
||||
lineId: Int,
|
||||
startSiteId: Int,
|
||||
endSiteId: Int,
|
||||
points: List<BusRoutePlanningUpdateReqBean.Result?>?,
|
||||
points: List<MogoLocation>,
|
||||
callback: OchCommonServiceCallback<BaseData>?
|
||||
) {
|
||||
val pointsResult = mutableListOf<BusRoutePlanningUpdateReqBean.Result>()
|
||||
points.forEach {
|
||||
val result = BusRoutePlanningUpdateReqBean.Result()
|
||||
result.latitude = it.latitude;
|
||||
result.longitude = it.longitude;
|
||||
pointsResult.add(result);
|
||||
}
|
||||
if (DebugConfig.getProjectFlavor().contains("saas")){
|
||||
M_SAAS_SERVICE.updateOrderRoute(
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, points
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, pointsResult
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
@@ -348,7 +356,7 @@ object OrderServiceManager {
|
||||
MoGoAiCloudClientConfig.getInstance().serviceAppId,
|
||||
SharedPrefsMgr.getInstance().token,
|
||||
BusRoutePlanningUpdateReqBean(
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, points
|
||||
SharedPrefsMgr.getInstance().sn, lineId, startSiteId, endSiteId, pointsResult
|
||||
)
|
||||
)
|
||||
.transformTry()
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
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;
|
||||
@@ -32,6 +31,9 @@ import com.mogo.och.common.module.biz.bean.DriverStatusQueryRespBean;
|
||||
import com.mogo.och.common.module.biz.callback.ILoginCallback;
|
||||
import com.mogo.och.common.module.biz.constant.LoginStatusManager;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.autopilot.ArrivedStation;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.autopilot.IOchAutopilotStatusListener;
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.autopilot.OchAutoPilotStatusListenerManager;
|
||||
import com.zhjt.mogo.adas.data.AdasConstants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -47,7 +49,7 @@ import system_master.SystemStatusInfo;
|
||||
*/
|
||||
public class BusPresenter extends Presenter<BusFragment>
|
||||
implements IRefreshBusStationsCallback, ISlidePannelHideCallback
|
||||
, IMoGoAutopilotStatusListener, IBusControllerStatusCallback, ILoginCallback, IPassengerCallback, IBusADASStatusCallback {
|
||||
, IBusControllerStatusCallback, ILoginCallback, IPassengerCallback, IBusADASStatusCallback, IOchAutopilotStatusListener {
|
||||
|
||||
private static final String TAG = "BusPresenter";
|
||||
|
||||
@@ -57,7 +59,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
public BusPresenter(BusFragment view) {
|
||||
super(view);
|
||||
//2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
OchAutoPilotStatusListenerManager.INSTANCE.addListener(TAG,this);
|
||||
OrderModel.getInstance().init();
|
||||
OCHAdasAbilityManager.getInstance().init(AbsMogoApplication.getApp());
|
||||
}
|
||||
@@ -149,9 +151,9 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) {
|
||||
public void onAutopilotArriveAtStation(ArrivedStation arrivedStation) {
|
||||
CallerLogger.e( M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive");
|
||||
OrderModel.getInstance().onArriveAt(arrivalNotification);
|
||||
OrderModel.getInstance().onArriveAt(arrivedStation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,6 @@ public class BDRouteDataTestUtils {
|
||||
builder.setLongitude(s.getDouble("lon"));
|
||||
list.add(builder.build());
|
||||
}
|
||||
OrderModel.getInstance().debugUpdateOrderRoute(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.autopilot;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class ArrivedStation {
|
||||
|
||||
public ArrivedStation(MogoLocation mogoLocation) {
|
||||
this.mogoLocation = mogoLocation;
|
||||
}
|
||||
|
||||
private MogoLocation mogoLocation;
|
||||
|
||||
public MogoLocation getEndLocation(){
|
||||
return mogoLocation;
|
||||
}
|
||||
|
||||
public static ArrivedStation trasform(MessagePad.ArrivalNotification arrivalNotification){
|
||||
MogoLocation mogoLocation = new MogoLocation();
|
||||
MessagePad.Location endLocation = arrivalNotification.getEndLocation();
|
||||
if(endLocation==null){
|
||||
return null;
|
||||
}
|
||||
mogoLocation.setLongitude(endLocation.getLongitude());
|
||||
mogoLocation.setLatitude(endLocation.getLatitude());
|
||||
|
||||
return new ArrivedStation(mogoLocation);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.autopilot
|
||||
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo_msg.MogoReportMsg
|
||||
import system_master.SsmInfo
|
||||
import system_master.SystemStatusInfo
|
||||
|
||||
interface IOchAutopilotStatusListener {
|
||||
/**
|
||||
* 自动驾驶状态信息
|
||||
*
|
||||
* @param state 状态信息
|
||||
*/
|
||||
fun onAutopilotStatusResponse(state: Int) {}
|
||||
|
||||
/**
|
||||
* 自动驾驶docker信息
|
||||
*
|
||||
* @param dockerVersion docker版本
|
||||
*/
|
||||
fun onAutopilotDockerInfo(dockerVersion:String){}
|
||||
|
||||
/**
|
||||
* 自动驾驶到站
|
||||
*
|
||||
* @param arrivalNotification 所到车站的简单信息
|
||||
*/
|
||||
fun onAutopilotArriveAtStation(arrivalNotification: ArrivedStation?) {}
|
||||
|
||||
/**
|
||||
* 工控机获取SN
|
||||
*/
|
||||
fun onAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {}
|
||||
|
||||
/**
|
||||
* 工控机监控节点
|
||||
*/
|
||||
fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {}
|
||||
|
||||
/**
|
||||
* 工控机连接状态回调
|
||||
*/
|
||||
fun onAutopilotIpcConnectStatusChanged(status: AdasConstants.IpcConnectionStatus, reason: String?) {}
|
||||
|
||||
/**
|
||||
* 域控SSM接口接收超时
|
||||
* 状态变动时才会回调,默认SSM状态正常
|
||||
* @param isTimeout true:SSM接口接收超时 false:SSM接口恢复正常
|
||||
*/
|
||||
fun onSsmReceiveTimeout(isTimeout: Boolean) {}
|
||||
|
||||
/**
|
||||
* 工控机主动查询 AdasManager#sendStatusQueryReq(),后会收到如下回调
|
||||
*/
|
||||
fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {}
|
||||
|
||||
/**
|
||||
* 定频SSM
|
||||
* 老版本 SSM(SystemStatusInfo.StatusInfo) HQ、M1 MAP350开始弃用,其他车型MAP360开始弃用
|
||||
*/
|
||||
fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf) {}
|
||||
|
||||
/**
|
||||
* 自动驾驶路线ID回调
|
||||
*/
|
||||
fun onAutopilotRouteLineId(lineId: Long){}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接
|
||||
*/
|
||||
const val STATUS_AUTOPILOT_DISABLE = 0
|
||||
|
||||
/**
|
||||
* 可自动驾驶,工控机连接正常,且处于人工干预状态
|
||||
*/
|
||||
const val STATUS_AUTOPILOT_ENABLE = 1
|
||||
|
||||
/**
|
||||
* 自动驾驶中,可能是停车,可能是行进,但是是机器在处理车的前进后退,不是人
|
||||
*/
|
||||
const val STATUS_AUTOPILOT_RUNNING = 2
|
||||
|
||||
/**
|
||||
* 平行驾驶
|
||||
*/
|
||||
const val STATUS_PARALLEL_DRIVING = 7
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.autopilot
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.och.common.module.utils.CallerBase
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo_msg.MogoReportMsg
|
||||
import system_master.SsmInfo
|
||||
import system_master.SystemStatusInfo
|
||||
|
||||
object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListener>(),IMoGoAutopilotStatusListener {
|
||||
|
||||
const val TAG = "OCHAutoPilotStatusListenerManager"
|
||||
init {
|
||||
//2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
super.onAutopilotStatusResponse(state)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotStatusResponse(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotDockerInfo(dockerVersion: String) {
|
||||
super.onAutopilotDockerInfo(dockerVersion)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotDockerInfo(dockerVersion)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
super.onAutopilotArriveAtStation(arrivalNotification)
|
||||
val trasform = ArrivedStation.trasform(arrivalNotification)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotArriveAtStation(trasform)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {
|
||||
super.onAutopilotSNRequest(basicInfoReq)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotSNRequest(basicInfoReq)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {
|
||||
super.onAutopilotGuardian(guardianInfo)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotGuardian(guardianInfo)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(
|
||||
status: AdasConstants.IpcConnectionStatus,
|
||||
reason: String?
|
||||
) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotIpcConnectStatusChanged(status,reason)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSsmReceiveTimeout(isTimeout: Boolean) {
|
||||
super.onSsmReceiveTimeout(isTimeout)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onSsmReceiveTimeout(isTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {
|
||||
super.onAutopilotStatusRespByQuery(status)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotStatusRespByQuery(status)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf) {
|
||||
super.onSystemStatus(statusInf)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onSystemStatus(statusInf)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRouteLineId(lineId: Long) {
|
||||
super.onAutopilotRouteLineId(lineId)
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotRouteLineId(lineId)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.trajectory
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
|
||||
interface ITrajectoryListListener{
|
||||
/**
|
||||
* @param routeArrivied 已经走过的坐标
|
||||
* @param routeArriving 没有走过的坐标
|
||||
* @param location 车的坐标
|
||||
* @return
|
||||
*/
|
||||
fun trajectoryCallback(
|
||||
trajectoryList: MutableList<MogoLocation>,
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.common.module.manager.distancemamager
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.trajectory
|
||||
|
||||
import com.elegant.network.utils.GsonUtil
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.mogo.och.common.module.manager.autopilotmanager.trajectory
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
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.util.CoordinateUtils
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object TrajectoryManager : IMoGoPlanningRottingListener {
|
||||
const val TAG = "TrajectoryManager"
|
||||
|
||||
private val distanceListeners: ConcurrentHashMap<String, ITrajectoryListListener> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 所有轨迹点
|
||||
*/
|
||||
@Volatile
|
||||
var mRoutePoints = mutableListOf<MogoLocation>()
|
||||
|
||||
/**
|
||||
* 0-1 1-2 2-3 各个轨迹点的距离
|
||||
*/
|
||||
@Volatile
|
||||
private var mRoutePointsDistance: MutableList<Float>? = ArrayList()
|
||||
|
||||
/**
|
||||
* 所有轨迹点距离的和
|
||||
*/
|
||||
@Volatile
|
||||
private var maxDistanceAllPoint: Double = 0.0
|
||||
|
||||
init {
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private var lineId:Long?=0
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "onAutopilotRotting: 收到轨迹")
|
||||
globalPathResp?.wayPointsList?.let {
|
||||
if (it.size > 0) {
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_OCHCOMMON + TAG,
|
||||
"收到轨迹:轨迹个数${it.size}第一个点${it[0]}最后一个点:${it.last()} 轨迹id:${globalPathResp.lineId}"
|
||||
)
|
||||
@Suppress("SENSELESS_COMPARISON")
|
||||
if (globalPathResp.lineId != null) {// 适配低版本不传递lineId
|
||||
if (globalPathResp.lineId == lineId) {
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG, "重复轨迹")
|
||||
return
|
||||
}
|
||||
this.lineId = globalPathResp.lineId
|
||||
}
|
||||
updateRoutePoints(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRoutePoints(routePoints: List<MessagePad.Location>?) {
|
||||
mRoutePointsDistance = null
|
||||
val latLngModels = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterWgsToGcjLocations(AbsMogoApplication.getApp(), routePoints!!)
|
||||
mRoutePoints = latLngModels
|
||||
|
||||
mRoutePointsDistance = ArrayList()
|
||||
maxDistanceAllPoint = 0.0
|
||||
mRoutePoints.forEachIndexed { index, current ->
|
||||
if (mRoutePoints.last() != current) {
|
||||
val next = mRoutePoints[index + 1]
|
||||
val distanceItem = CoordinateUtils.calculateLineDistance(
|
||||
current.longitude,
|
||||
current.latitude,
|
||||
next.longitude,
|
||||
next.latitude
|
||||
)
|
||||
mRoutePointsDistance?.add(distanceItem)
|
||||
maxDistanceAllPoint += distanceItem
|
||||
}
|
||||
}
|
||||
distanceListeners.forEach {
|
||||
it.value.trajectoryCallback(mRoutePoints)
|
||||
}
|
||||
}
|
||||
|
||||
fun addTrajectoryListListenerr(tag: String, listener: ITrajectoryListListener) {
|
||||
if (distanceListeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
distanceListeners[tag] = listener
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.LocationUtils
|
||||
import com.mogo.och.common.module.biz.constant.OchCommonConst
|
||||
import com.mogo.och.common.module.manager.autopilotmanager.trajectory.TrajectoryCache
|
||||
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.och.common.module.manager.orderlogmanager
|
||||
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
|
||||
object OrderChainLogManager {
|
||||
|
||||
private val TAG = OrderChainLogManager::class.java.simpleName
|
||||
|
||||
/**
|
||||
* @param orderInfo 订单详细信息
|
||||
* @param changeInfo 变化信息
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_OCH,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_OCH,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_OCH_COMMON_DISTANCE,
|
||||
paramIndexes = [0,1]
|
||||
)
|
||||
fun writeChainLog(orderInfo: String, changeInfo: String) {
|
||||
d(SceneConstant.M_OCHCOMMON + TAG, orderInfo)
|
||||
d(SceneConstant.M_OCHCOMMON + TAG, changeInfo)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.mogo.och.common.module.utils
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.function.call.CallerBusManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2023/01/04 4:02 下午
|
||||
*/
|
||||
open class CallerBase<T : Any> {
|
||||
|
||||
/**
|
||||
* 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步
|
||||
*/
|
||||
protected val M_LISTENERS: ConcurrentHashMap<String, T> = ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 存储所有注册了监听的对象,并设定监听频率,invokeXXXX进行遍历回调,将信息同步,
|
||||
*/
|
||||
protected val M_LISTENERS_HZ: ConcurrentHashMap<String, Int> = ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* HZ发送,记录最后一次发送时间
|
||||
*/
|
||||
protected val M_LISTENERS_HZ_LAST_SEND_TIME: ConcurrentHashMap<String, Long> =
|
||||
ConcurrentHashMap()
|
||||
|
||||
/**
|
||||
* 设置对应监听,指定Hz频率
|
||||
* @param tag 订阅者标记
|
||||
* @param callBackHz 订阅者想要接受的回调的hz频率
|
||||
*/
|
||||
fun setListenerHz(tag: String, callBackHz: Int) {
|
||||
if (M_LISTENERS_HZ.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ[tag] = callBackHz
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加 监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
* @param listener 监听回调
|
||||
*/
|
||||
fun addListener(
|
||||
tag: String,
|
||||
listener: T
|
||||
) {
|
||||
if (M_LISTENERS.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS[tag] = listener
|
||||
doSomeAfterAddListener(tag, listener)
|
||||
}
|
||||
|
||||
/**
|
||||
* 在添加了监听后执行
|
||||
*/
|
||||
open fun doSomeAfterAddListener(tag: String, listener: T) {}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param tag 标记,用来注销监听使用
|
||||
*/
|
||||
fun removeListener(tag: String) {
|
||||
if (!M_LISTENERS.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS.remove(tag)
|
||||
|
||||
if (!M_LISTENERS_HZ.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ.remove(tag)
|
||||
|
||||
if (!M_LISTENERS_HZ_LAST_SEND_TIME.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ_LAST_SEND_TIME.remove(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除监听
|
||||
* @param listener 要删除的监听对象
|
||||
*/
|
||||
fun removeListener(listener: T) {
|
||||
if (!M_LISTENERS.containsValue(listener)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS.forEach {
|
||||
if (it.value == listener) {
|
||||
M_LISTENERS.remove(it.key)
|
||||
|
||||
if (!M_LISTENERS_HZ.containsKey(it.key)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ.remove(it.key)
|
||||
|
||||
if (!M_LISTENERS_HZ_LAST_SEND_TIME.containsKey(it.key)) {
|
||||
return
|
||||
}
|
||||
M_LISTENERS_HZ_LAST_SEND_TIME.remove(it.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CallerBase"
|
||||
|
||||
@JvmStatic
|
||||
fun <T : IProvider?> getApiInstance(clazz: Class<T>?, path: String): T {
|
||||
var inst = CallerBusManager.get(clazz)
|
||||
if (inst == null) {
|
||||
synchronized(CallerBase::class.java) {
|
||||
inst = CallerBusManager.get(clazz)
|
||||
if (inst != null) {
|
||||
return inst
|
||||
}
|
||||
val newInst = ARouter.getInstance().build(path).navigation() as T
|
||||
try {
|
||||
CallerBusManager.registerApi(clazz, newInst)
|
||||
d(TAG, "keep IProvider instance to SingletonHolder: path :$path")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return newInst
|
||||
}
|
||||
}
|
||||
return inst
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user