[fea]
[轨迹下载回调相关]
This commit is contained in:
yangyakun
2024-12-06 14:31:57 +08:00
parent d98a9d3b1a
commit cee6be8bb5
18 changed files with 494 additions and 439 deletions

View File

@@ -23,6 +23,7 @@ import com.mogo.och.weaknet.repository.db.repository.WriteOffDb
import com.mogo.och.weaknet.ui.bizswitch.SwitchBizView
import com.mogo.och.weaknet.ui.qr.QrOpenView
import com.mogo.och.weaknet.util.BusAnalyticsManager
import com.mogo.och.weaknet.util.BusTrajectoryManager
/**
* 网约车小巴业务实现入口
@@ -53,6 +54,7 @@ class ShuttleDriverProvider : CommonServiceImpl() {
OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager
LineModel.init()
ScannerClientManager.load()
BusTrajectoryManager.load()
return busFragment!!
}
@@ -61,6 +63,7 @@ class ShuttleDriverProvider : CommonServiceImpl() {
OchAutopilotAnalytics.ochEventKey = null
LineModel.release()
ScannerClientManager.release()
BusTrajectoryManager.release()
RepositoryManager.release()
}

View File

@@ -109,12 +109,6 @@ object OrderModel {
onArriveAt(arrivedStation, "底盘触发进站")
}
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage, lineId: Long) {
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo, lineId)
}
}
private val ochTransform = object : OchTransformDispatch {
@@ -130,7 +124,7 @@ object OrderModel {
//是否到站的围栏判断 离站状态并且自动驾驶还未触发到站
if (isGoingToNextStation && !isArrivedStation) {
OCHThreadPoolManager.getsInstance().locationExecute {
onArriveAt(null, "兜底:根据定位计算到站")
onArriveAt(null, "兜底:距离站点15m内 每秒钟向底盘查询是否到站 底盘返回")
}
}
}
@@ -367,7 +361,7 @@ object OrderModel {
ThirdDeviceData.sendTaskDetailsToClients()
//需放在currentStationIndex赋值之后
BusTrajectoryManager.getInstance().syncTrajectoryInfo()
BusTrajectoryManager.syncTrajectoryInfo()
}
}
@@ -523,7 +517,7 @@ object OrderModel {
OchChainLogManager.writeChainLog("错误","${e.message}")
}
MapMakerManager.removeAllMapMarkerByOwner(TAG)
BusTrajectoryManager.getInstance().stopTrajReqLoop();
BusTrajectoryManager.stopTrajReqLoop();
LoginStatusManager.loginOut()
}
}

View File

@@ -57,7 +57,7 @@ class BusPresenter(view: ShuttleFragment?) : Presenter<ShuttleFragment?>(view),
if (isLogin()) {
//OrderModel.queryBusRoutes()
} else {
BusTrajectoryManager.getInstance().stopTrajReqLoop()
BusTrajectoryManager.stopTrajReqLoop()
OrderModel.closeBeautificationMode()
}
}

View File

@@ -1,161 +1,197 @@
package com.mogo.och.weaknet.util;
package com.mogo.och.weaknet.util
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.GsonUtils;
import com.mogo.och.common.module.biz.login.LoginStatusManager;
import com.mogo.och.common.module.manager.autopilot.line.LineManager;
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager;
import com.mogo.och.data.bean.ContraiInfo;
import com.mogo.och.data.bean.LineInfo;
import com.mogo.och.weaknet.constant.BusConst;
import com.mogo.och.weaknet.model.OrderModel;
import com.mogo.och.weaknet.model.LineModel;
import com.zhjt.mogo.adas.data.bean.MogoReport;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import mogo_msg.MogoReportMsg;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendTrajectoryDownloadReq
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.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.och.common.module.biz.login.LoginStatusManager.isLogin
import com.mogo.och.common.module.manager.autopilot.line.LineManager.contraiInfo
import com.mogo.och.common.module.manager.autopilot.line.LineManager.initAutopilotControlParameters
import com.mogo.och.common.module.manager.autopilot.line.LineManager.lineInfos
import com.mogo.och.common.module.manager.autopilot.trajectory.ITrajectoryListListener
import com.mogo.och.common.module.manager.autopilot.trajectory.TrajectoryManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog
import com.mogo.och.weaknet.constant.BusConst
import com.mogo.och.weaknet.model.LineModel.currentTask
import com.mogo.och.weaknet.model.LineModel.startStationIndex
import com.mogo.och.weaknet.model.OrderModel.isGoingToNextStation
import com.zhjt.mogo.adas.data.bean.MogoReport
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.functions.Function
import io.reactivex.schedulers.Schedulers
import mogo_msg.MogoReportMsg.MogoReportMessage
import java.util.concurrent.TimeUnit
/**
* Bus轨迹管理给MEC下发用于轨迹下载的信息
* Created on 2022/6/23
*/
public class BusTrajectoryManager {
private static final String TAG = BusTrajectoryManager.class.getSimpleName();
object BusTrajectoryManager : ITrajectoryListListener {
private static final class SingletonHolder {
private static final BusTrajectoryManager INSTANCE = new BusTrajectoryManager();
private val TAG: String = BusTrajectoryManager::class.java.simpleName
private var mAutopilotControlParameters: AutopilotControlParameters? = null
private var mSendReqDisposable: Disposable? = null
init {
mAutopilotControlParameters = AutopilotControlParameters()
}
public static BusTrajectoryManager getInstance() {
return SingletonHolder.INSTANCE;
fun load(){
TrajectoryManager.addListener(TAG,this)
}
private AutopilotControlParameters mAutopilotControlParameters = null;
private Disposable mSendReqDisposable = null;
public BusTrajectoryManager() {
mAutopilotControlParameters = new AutopilotControlParameters();
fun release(){
TrajectoryManager.removeListener(TAG)
}
/**
* 同步Bus路线信息
*/
public void syncTrajectoryInfo() {
if(mAutopilotControlParameters==null||mAutopilotControlParameters.autoPilotLine==null){
OchChainLogManager.writeChainLog("轨迹监控", "开始或者结束下发轨迹 轨迹id" + -1, true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
}else {
OchChainLogManager.writeChainLog("轨迹监控", "开始或者结束下发轨迹 轨迹id" + mAutopilotControlParameters.autoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
fun syncTrajectoryInfo() {
if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) {
writeChainLog(
"轨迹监控",
"开始或者结束下发轨迹 轨迹id" + -1,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
} else {
writeChainLog(
"轨迹监控",
"开始或者结束下发轨迹 轨迹id" + mAutopilotControlParameters!!.autoPilotLine!!.lineId,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
}
if (LoginStatusManager.isLogin() && LineModel.INSTANCE.getCurrentTask() != null
&& LineModel.getStartStationIndex() == 0
&& !OrderModel.isGoingToNextStation()) {
CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() start.");
startTrajReqLoop();
if (isLogin() && currentTask != null && startStationIndex == 0 && !isGoingToNextStation) {
d(SceneConstant.M_BUS + TAG, "syncTrajectoryInfo() start.")
startTrajReqLoop()
} else {
// 无路线信息or当前未在始发站
CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() stop.");
stopTrajReqLoop();
d(SceneConstant.M_BUS + TAG, "syncTrajectoryInfo() stop.")
stopTrajReqLoop()
}
}
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo,long lineId) {
onAutopilotGuardian(guardianInfo);
override fun onDownLoadStart(lineId: Long) {
stopTrajReqLoop()
}
/**
* 接口MEC反馈的常规信息MAP v2.5.0新增轨迹相关信息)
* @param guardianInfo
*/
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
if (guardianInfo == null || !guardianInfo.hasCode()) return;
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START.equals(guardianInfo.getCode())) {
stopTrajReqLoop();
} else if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS.equals(guardianInfo.getCode())) {
stopTrajReqLoop();
} else if (MogoReport.Code.Info.ISSM.FUNC_AUTO_PILOT_READY.equals(guardianInfo.getCode())) {
syncTrajectoryInfo();
}
override fun onDownLoadSuccess(lineId: Long) {
stopTrajReqLoop()
}
private void setupAutoPilotLine() {
ContraiInfo contraiInfo = LineManager.getContraiInfo();
LineInfo lineInfos = LineManager.getLineInfos();
override fun onDownLoadReady(lineId: Long) {
syncTrajectoryInfo()
}
private fun setupAutoPilotLine() {
val contraiInfo = contraiInfo
val lineInfos = lineInfos
if (contraiInfo == null || lineInfos == null) {
CallerLogger.e(M_BUS + TAG,
"setupAutoPilotLine(): routesResult is null.");
return;
e(
SceneConstant.M_BUS + TAG,
"setupAutoPilotLine(): routesResult is null."
)
return
} else {
mAutopilotControlParameters = LineManager.INSTANCE.initAutopilotControlParameters();
mAutopilotControlParameters = initAutopilotControlParameters()
}
}
private void clearAutoPilotLine() {
if (mAutopilotControlParameters == null) return;
mAutopilotControlParameters = null;
private fun clearAutoPilotLine() {
if (mAutopilotControlParameters == null) return
mAutopilotControlParameters = null
}
private void startTrajReqLoop() {
if(mAutopilotControlParameters==null||mAutopilotControlParameters.autoPilotLine==null){
OchChainLogManager.writeChainLog("轨迹监控", "开始下发轨迹 轨迹id" + -1, true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
}else {
OchChainLogManager.writeChainLog("轨迹监控", "开始下发轨迹 轨迹id" + mAutopilotControlParameters.autoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
private fun startTrajReqLoop() {
if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) {
writeChainLog(
"轨迹监控",
"开始下发轨迹 轨迹id" + -1,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
} else {
writeChainLog(
"轨迹监控",
"开始下发轨迹 轨迹id" + mAutopilotControlParameters!!.autoPilotLine!!.lineId,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
}
if (mSendReqDisposable != null && !mSendReqDisposable.isDisposed()) {
return;
if (mSendReqDisposable != null && !mSendReqDisposable!!.isDisposed) {
return
}
CallerLogger.d(M_BUS + TAG, "startTrajReqLoop()");
setupAutoPilotLine();
mSendReqDisposable = Observable.interval(BusConst.LOOP_DELAY,
BusConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS)
.map((aLong -> aLong + 1))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
if (aLong > BusConst.LOOP_SEND_TRAJ_TIMES) {
stopTrajReqLoop();
return;
}
CallerLogger.d(M_BUS + TAG, "loop sendTrajectoryReq: " + aLong);
sendTrajectoryReq();
});
d(SceneConstant.M_BUS + TAG, "startTrajReqLoop()")
setupAutoPilotLine()
mSendReqDisposable = Observable.interval(
BusConst.LOOP_DELAY,
BusConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS
)
.map((Function { aLong: Long -> aLong + 1 }))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { aLong: Long ->
if (aLong > BusConst.LOOP_SEND_TRAJ_TIMES) {
stopTrajReqLoop()
return@subscribe
}
d(SceneConstant.M_BUS + TAG, "loop sendTrajectoryReq: $aLong")
sendTrajectoryReq()
}
}
public void stopTrajReqLoop() {
if(mAutopilotControlParameters==null||mAutopilotControlParameters.autoPilotLine==null){
OchChainLogManager.writeChainLog("轨迹监控", "结束下发轨迹 轨迹id" + -1, true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
}else {
OchChainLogManager.writeChainLog("轨迹监控", "结束下发轨迹 轨迹id" + mAutopilotControlParameters.autoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
fun stopTrajReqLoop() {
if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null) {
writeChainLog(
"轨迹监控",
"结束下发轨迹 轨迹id" + -1,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
} else {
writeChainLog(
"轨迹监控",
"结束下发轨迹 轨迹id" + mAutopilotControlParameters!!.autoPilotLine!!.lineId,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
}
if (mSendReqDisposable != null) {
CallerLogger.d(M_BUS + TAG, "stopTrajReqLoop()");
mSendReqDisposable.dispose();
mSendReqDisposable = null;
clearAutoPilotLine();
d(SceneConstant.M_BUS + TAG, "stopTrajReqLoop()")
mSendReqDisposable!!.dispose()
mSendReqDisposable = null
clearAutoPilotLine()
}
}
private void sendTrajectoryReq() {
if(mAutopilotControlParameters==null||mAutopilotControlParameters.autoPilotLine==null||mAutopilotControlParameters.autoPilotLine.getLineId()==-1){
CallerLogger.e(M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!");
setupAutoPilotLine();
if(mAutopilotControlParameters==null||mAutopilotControlParameters.autoPilotLine==null||mAutopilotControlParameters.autoPilotLine.getLineId()==-1){
return;
private fun sendTrajectoryReq() {
if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null || mAutopilotControlParameters!!.autoPilotLine!!.lineId == -1L) {
e(SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!")
setupAutoPilotLine()
if (mAutopilotControlParameters == null || mAutopilotControlParameters!!.autoPilotLine == null || mAutopilotControlParameters!!.autoPilotLine!!.lineId == -1L) {
return
}
}
OchChainLogManager.writeChainLog("轨迹监控","sendTrajectoryReq() 下发轨迹 轨迹id"+ mAutopilotControlParameters.autoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY);
CallerAutoPilotControlManager.INSTANCE.sendTrajectoryDownloadReq(mAutopilotControlParameters.autoPilotLine,0);
CallerLogger.d(M_BUS + TAG, "sendTrajectoryReq(): "
+ GsonUtils.toJson(mAutopilotControlParameters));
writeChainLog(
"轨迹监控",
"sendTrajectoryReq() 下发轨迹 轨迹id" + mAutopilotControlParameters!!.autoPilotLine!!.lineId,
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
sendTrajectoryDownloadReq(mAutopilotControlParameters!!.autoPilotLine!!, 0)
d(
SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): "
+ GsonUtils.toJson(mAutopilotControlParameters)
)
}
}