[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

@@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.magic.mogo.och.charter.fragment.DriverM1Fragment import com.magic.mogo.och.charter.fragment.DriverM1Fragment
import com.magic.mogo.och.charter.manager.CharterAnalyticsManager import com.magic.mogo.och.charter.manager.CharterAnalyticsManager
import com.magic.mogo.och.charter.manager.CharterTrajectoryManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger 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
import com.mogo.och.common.module.constant.OchCommonConst import com.mogo.och.common.module.constant.OchCommonConst
@@ -29,10 +30,12 @@ class CharterDriverProvider : CommonServiceImpl() {
fragment = DriverM1Fragment() fragment = DriverM1Fragment()
} }
OchAutopilotAnalytics.ochEventKey = CharterAnalyticsManager.getInstance() OchAutopilotAnalytics.ochEventKey = CharterAnalyticsManager.getInstance()
CharterTrajectoryManager.load()
return fragment!! return fragment!!
} }
override fun resetFragment() { override fun resetFragment() {
CharterTrajectoryManager.release()
fragment = null fragment = null
OchAutopilotAnalytics.ochEventKey = null OchAutopilotAnalytics.ochEventKey = null
} }

View File

@@ -15,6 +15,8 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.ActivityUtils import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.och.common.module.biz.login.LoginStatusManager import com.mogo.och.common.module.biz.login.LoginStatusManager
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
import com.mogo.och.common.module.utils.SoundPoolHelper import com.mogo.och.common.module.utils.SoundPoolHelper
import io.reactivex.Observable import io.reactivex.Observable
@@ -29,7 +31,7 @@ import java.util.concurrent.TimeUnit
* Bus轨迹管理给MEC下发用于轨迹下载的信息 * Bus轨迹管理给MEC下发用于轨迹下载的信息
* Created on 2022/6/23 * Created on 2022/6/23
*/ */
object CharterTrajectoryManager { object CharterTrajectoryManager : ITrajectoryListListener {
private const val TAG = "CharterTrajectoryManager" private const val TAG = "CharterTrajectoryManager"
private var mAutoPilotLine: AutoPilotLine? = null private var mAutoPilotLine: AutoPilotLine? = null
@@ -37,6 +39,14 @@ object CharterTrajectoryManager {
private var mLineName = "" private var mLineName = ""
private var mSendReqDisposable: Disposable? = null private var mSendReqDisposable: Disposable? = null
fun load(){
TrajectoryManager.addListener(TAG,this)
}
fun release(){
TrajectoryManager.removeListener(TAG)
}
/** /**
* 同步Bus路线信息 * 同步Bus路线信息
*/ */
@@ -54,57 +64,35 @@ object CharterTrajectoryManager {
} }
} }
fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) { override fun onDownLoadStart(lineId: Long) {
onAutopilotGuardian(guardianInfo) stopTrajReqLoop()
} }
/** override fun onDownLoadSuccess(lineId: Long) {
* 接口MEC反馈的常规信息MAP v2.5.0新增轨迹相关信息) stopTrajReqLoop()
* @param guardianInfo }
*/
fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) { override fun onDownLoadReady(lineId: Long) {
if (guardianInfo == null || !guardianInfo.hasCode()) return super.onDownLoadReady(lineId)
if ("ISYS_INIT_TRAJECTORY_START" == guardianInfo.code) { DriverM1Model.get().getBusOrderResult()?.lineId?.let {
// 1. 轨迹管理_轨迹开始下载本地已有对应轨迹也触发 syncTrajectoryInfo(it, DriverM1Model.get().getBusOrderResult()?.lineName!!)
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() 轨迹开始下载") }
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹开始下载", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) }
stopTrajReqLoop()
} else if ("ISYS_INIT_TRAJECTORY_SUCCESS" == guardianInfo.code) { override fun onDistanceWithTrajectory(lineId: Long) {
// 2. 轨迹管理_轨迹下载成功本地已有对应轨迹也触发 super.onDistanceWithTrajectory(lineId)
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() 轨迹下载成功") DriverM1Model.get().getBusOrderResult()?.lineId?.let {
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载成功", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) syncTrajectoryInfo(it, DriverM1Model.get().getBusOrderResult()?.lineName!!)
stopTrajReqLoop() }
} else if ("ISYS_INIT_TRAJECTORY_FAILURE" == guardianInfo.code) { CallerMsgBoxManager.saveMsgBox(
// 3. 轨迹管理_轨迹下载失败本地无对应轨迹 MsgBoxBean(
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() " + "轨迹下载失败,本地无对应轨迹") MsgBoxType.OPERATION,
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载失败,本地无对应轨迹", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) OperationMsg(
// ToastUtils.showShort("轨迹下载失败,本地无对应轨迹"); System.currentTimeMillis(), "请尽快操作车辆至适当位置掉头!", -1
} else if ("ISYS_INIT_TRAJECTORY_WARNING" == guardianInfo.code) {
// 4. 轨迹管理_轨迹下载失败本地有对应轨迹认为成功
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() " + "轨迹下载失败,本地有对应轨迹,认为成功")
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载失败,本地有对应轨迹,认为成功", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY)
// ToastUtils.showShort("轨迹下载失败,本地有对应轨迹,认为成功");
} else if ("ISYS_INIT_TRAJECTORY_TIMEOUT" == guardianInfo.code) {
// 5. 轨迹管理_轨迹下载超时
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() 轨迹下载超时")
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载超时", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY)
} else if ("EMAP_ATTITUDE_INIT_FAILED" == guardianInfo.getCode()) {
// 收到ssm的自动驾驶变为ready再次下发轨迹下载.解决域控重启或者102域控启动太早107节点初始化未完成导致的轨迹未进行下载。
d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() ssm ready再次发起下载")
OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 当前位置距离轨迹距离大于15m", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY)
DriverM1Model.get().getBusOrderResult()?.lineId?.let {
syncTrajectoryInfo(it, DriverM1Model.get().getBusOrderResult()?.lineName!!)
}
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.OPERATION,
OperationMsg(
System.currentTimeMillis(), "请尽快操作车辆至适当位置掉头!", -1
)
) )
) )
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(ActivityUtils.getTopActivity(), R.raw.startautopilot) )
} SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(ActivityUtils.getTopActivity(), R.raw.startautopilot)
} }
private fun setupAutoPilotLine() { private fun setupAutoPilotLine() {

View File

@@ -125,10 +125,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
,context.getString(R.string.charter_last_15_minutes)) ,context.getString(R.string.charter_last_15_minutes))
} }
override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?, lineId: Long) {
CharterTrajectoryManager.onAutopilotGuardian(guardianInfo,lineId)
}
override fun onAutopilotArriveAtStation(arrivalNotification: ArrivedStation?) { override fun onAutopilotArriveAtStation(arrivalNotification: ArrivedStation?) {
DriverM1Model.get().onAutopilotArriveAtStation() DriverM1Model.get().onAutopilotArriveAtStation()
} }

View File

@@ -13,6 +13,7 @@ public class LoginInfo {
private String phone;//手机号 private String phone;//手机号
private Integer lineId;//线路id private Integer lineId;//线路id
private Integer taskId;//任务id private Integer taskId;//任务id
private Integer siteId;//任务id
private String vin;//车辆唯一识别码 private String vin;//车辆唯一识别码
private String cityCode;//城市编码 private String cityCode;//城市编码
private String brand;//东风 private String brand;//东风
@@ -24,6 +25,8 @@ public class LoginInfo {
private long tenantId;//租户id: private long tenantId;//租户id:
private long driverId; private long driverId;
private long businessStatus;//?????
public int getDriverStatus() { public int getDriverStatus() {
return driverStatus; return driverStatus;
} }
@@ -160,6 +163,22 @@ public class LoginInfo {
this.driverId = driverId; this.driverId = driverId;
} }
public Integer getSiteId() {
return siteId;
}
public void setSiteId(Integer siteId) {
this.siteId = siteId;
}
public long getBusinessStatus() {
return businessStatus;
}
public void setBusinessStatus(long businessStatus) {
this.businessStatus = businessStatus;
}
@Override @Override
public String toString() { public String toString() {
return "LoginInfo{" + return "LoginInfo{" +
@@ -173,6 +192,7 @@ public class LoginInfo {
", phone='" + phone + '\'' + ", phone='" + phone + '\'' +
", lineId=" + lineId + ", lineId=" + lineId +
", taskId=" + taskId + ", taskId=" + taskId +
", siteId=" + siteId +
", vin='" + vin + '\'' + ", vin='" + vin + '\'' +
", cityCode='" + cityCode + '\'' + ", cityCode='" + cityCode + '\'' +
", brand='" + brand + '\'' + ", brand='" + brand + '\'' +
@@ -180,6 +200,7 @@ public class LoginInfo {
", photos='" + photos + '\'' + ", photos='" + photos + '\'' +
", tenantId=" + tenantId + ", tenantId=" + tenantId +
", driverId=" + driverId + ", driverId=" + driverId +
", businessStatus=" + businessStatus +
'}'; '}';
} }
@@ -189,30 +210,7 @@ public class LoginInfo {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
LoginInfo loginInfo = (LoginInfo) o; LoginInfo loginInfo = (LoginInfo) o;
return driverStatus == loginInfo.driverStatus && servingStatus == loginInfo.servingStatus && businessType == loginInfo.businessType && purpose == loginInfo.purpose && tenantId == loginInfo.tenantId && driverId == loginInfo.driverId && businessStatus == loginInfo.businessStatus && Objects.equals(orderNo, loginInfo.orderNo) && Objects.equals(sn, loginInfo.sn) && Objects.equals(plateNumber, loginInfo.plateNumber) && Objects.equals(phone, loginInfo.phone) && Objects.equals(lineId, loginInfo.lineId) && Objects.equals(taskId, loginInfo.taskId) && Objects.equals(siteId, loginInfo.siteId) && Objects.equals(vin, loginInfo.vin) && Objects.equals(cityCode, loginInfo.cityCode) && Objects.equals(brand, loginInfo.brand) && Objects.equals(carModel, loginInfo.carModel) && Objects.equals(photos, loginInfo.photos);
if (driverStatus != loginInfo.driverStatus) return false;
if (servingStatus != loginInfo.servingStatus) return false;
if (businessType != loginInfo.businessType) return false;
if (purpose != loginInfo.purpose) return false;
if (tenantId != loginInfo.tenantId) return false;
if (driverId != loginInfo.driverId) return false;
if (!Objects.equals(orderNo, loginInfo.orderNo))
return false;
if (!Objects.equals(sn, loginInfo.sn)) return false;
if (!Objects.equals(plateNumber, loginInfo.plateNumber))
return false;
if (!Objects.equals(phone, loginInfo.phone)) return false;
if (!Objects.equals(lineId, loginInfo.lineId))
return false;
if (!Objects.equals(taskId, loginInfo.taskId))
return false;
if (!Objects.equals(vin, loginInfo.vin)) return false;
if (!Objects.equals(cityCode, loginInfo.cityCode))
return false;
if (!Objects.equals(brand, loginInfo.brand)) return false;
if (!Objects.equals(carModel, loginInfo.carModel))
return false;
return Objects.equals(photos, loginInfo.photos);
} }
@Override @Override
@@ -220,20 +218,22 @@ public class LoginInfo {
int result = driverStatus; int result = driverStatus;
result = 31 * result + servingStatus; result = 31 * result + servingStatus;
result = 31 * result + businessType; result = 31 * result + businessType;
result = 31 * result + (int)tenantId; result = 31 * result + Objects.hashCode(orderNo);
result = 31 * result + (int)driverId;
result = 31 * result + (orderNo != null ? orderNo.hashCode() : 0);
result = 31 * result + purpose; result = 31 * result + purpose;
result = 31 * result + (sn != null ? sn.hashCode() : 0); result = 31 * result + Objects.hashCode(sn);
result = 31 * result + (plateNumber != null ? plateNumber.hashCode() : 0); result = 31 * result + Objects.hashCode(plateNumber);
result = 31 * result + (phone != null ? phone.hashCode() : 0); result = 31 * result + Objects.hashCode(phone);
result = 31 * result + (lineId != null ? lineId.hashCode() : 0); result = 31 * result + Objects.hashCode(lineId);
result = 31 * result + (taskId != null ? taskId.hashCode() : 0); result = 31 * result + Objects.hashCode(taskId);
result = 31 * result + (vin != null ? vin.hashCode() : 0); result = 31 * result + Objects.hashCode(siteId);
result = 31 * result + (cityCode != null ? cityCode.hashCode() : 0); result = 31 * result + Objects.hashCode(vin);
result = 31 * result + (brand != null ? brand.hashCode() : 0); result = 31 * result + Objects.hashCode(cityCode);
result = 31 * result + (carModel != null ? carModel.hashCode() : 0); result = 31 * result + Objects.hashCode(brand);
result = 31 * result + (photos != null ? photos.hashCode() : 0); result = 31 * result + Objects.hashCode(carModel);
result = 31 * result + Objects.hashCode(photos);
result = 31 * result + Long.hashCode(tenantId);
result = 31 * result + Long.hashCode(driverId);
result = 31 * result + Long.hashCode(businessStatus);
return result; return result;
} }
} }

View File

@@ -132,12 +132,7 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) { override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo) super.onAutopilotGuardian(guardianInfo)
var lineId = -1L var lineId = -1L
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START == guardianInfo?.code || guardianInfo?.let {
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS == guardianInfo?.code ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE == guardianInfo?.code ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING == guardianInfo?.code ||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT == guardianInfo?.code
) {
val msg = guardianInfo.msg val msg = guardianInfo.msg
try { try {
val regex = Regex("lineid:(\\d+)") val regex = Regex("lineid:(\\d+)")
@@ -159,16 +154,9 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
} }
} }
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS == guardianInfo?.code){
TrajectoryManager.addDownLoadSuccessLine(lineId)
}
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE == guardianInfo?.code){
// 更新轨迹没有更新lineId 第二次下载失败 删除App成功缓存(概率很低)
TrajectoryManager.removeDownLoadSuccessLine(lineId)
}
} }
TrajectoryManager.carDownLoadTrajectoryLog(guardianInfo?.code) TrajectoryManager.carDownLoadTrajectoryLog(guardianInfo?.code,lineId)
M_LISTENERS.forEach { M_LISTENERS.forEach {
val listener = it.value val listener = it.value

View File

@@ -4,12 +4,29 @@ import com.mogo.eagle.core.data.map.MogoLocation
interface ITrajectoryListListener{ interface ITrajectoryListListener{
/** /**
* @param routeArrivied 已经走过的坐标 * @param trajectoryList gcj 坐标轨迹集合
* @param routeArriving 没有走过的坐标
* @param location 车的坐标
* @return
*/ */
fun trajectoryCallback( fun trajectoryCallback(trajectoryList: MutableList<MogoLocation>){}
trajectoryList: MutableList<MogoLocation>,
) /**
* @param maxDistanceAllPoint 轨迹全长
*/
fun trajectoryDistanceCallback(maxDistanceAllPoint: Double){}
// 开始下载轨迹
fun onDownLoadStart(lineId: Long){}
// 下载轨迹成功
fun onDownLoadSuccess(lineId: Long){}
// 下载轨迹是吧
fun onDownLoadFail(lineId: Long){}
// 下载轨迹超时
fun onDownLoadTimeout(lineId: Long){}
// 加载轨迹失败
fun onLoadFail(lineId: Long){}
// 轨迹不存在
fun onTrajectoryNotExist(lineId: Long){}
// 底盘已就行
fun onDownLoadReady(lineId: Long) {}
// 当前位置距离轨迹大于15m
fun onDistanceWithTrajectory(lineId: Long) {}
} }

View File

@@ -9,17 +9,14 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.CoordinateUtils import com.mogo.eagle.core.utilcode.util.CoordinateUtils
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog
import com.mogo.och.common.module.utils.CallerBase
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
import com.zhjt.mogo.adas.data.bean.MogoReport import com.zhjt.mogo.adas.data.bean.MogoReport
import mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad
import java.util.concurrent.ConcurrentHashMap
object TrajectoryManager : IMoGoPlanningRottingListener { object TrajectoryManager : CallerBase<ITrajectoryListListener>(),IMoGoPlanningRottingListener {
const val TAG = "TrajectoryManager" const val TAG = "TrajectoryManager"
private val distanceListeners: ConcurrentHashMap<String, ITrajectoryListListener> =
ConcurrentHashMap()
private val downLoadSuccessLineIds = mutableListOf<Long>() private val downLoadSuccessLineIds = mutableListOf<Long>()
/** /**
@@ -88,52 +85,92 @@ object TrajectoryManager : IMoGoPlanningRottingListener {
maxDistanceAllPoint += distanceItem maxDistanceAllPoint += distanceItem
} }
} }
distanceListeners.forEach { M_LISTENERS.forEach {
it.value.trajectoryCallback(mRoutePoints) it.value.trajectoryCallback(mRoutePoints)
} }
M_LISTENERS.forEach {
it.value.trajectoryDistanceCallback(maxDistanceAllPoint)
}
} }
fun addTrajectoryListListenerr(tag: String, listener: ITrajectoryListListener?) { private fun addDownLoadSuccessLine(lineId:Long){
if (distanceListeners.containsKey(tag)) {
return
}
if(listener==null){
distanceListeners.remove(tag)
return
}
distanceListeners[tag] = listener
}
fun addDownLoadSuccessLine(lineId:Long){
if(lineId>0){ if(lineId>0){
OchChainLogManager.writeChainLog("轨迹监控", " 轨迹下载成功${lineId}", true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) OchChainLogManager.writeChainLog("轨迹监控", " 轨迹下载成功${lineId}", true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY)
downLoadSuccessLineIds.add(lineId) downLoadSuccessLineIds.add(lineId)
} }
} }
fun removeDownLoadSuccessLine(lineId:Long){ private fun removeDownLoadSuccessLine(lineId:Long){
if(lineId>0&& downLoadSuccessLineIds.contains(lineId)){ if(lineId>0&& downLoadSuccessLineIds.contains(lineId)){
downLoadSuccessLineIds.remove(lineId) downLoadSuccessLineIds.remove(lineId)
} }
} }
fun carDownLoadTrajectoryLog(code:String?){ fun carDownLoadTrajectoryLog(code: String?, lineId: Long){
when (code) { when (code) {
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START -> writeTrajectoryLog("轨迹开始下载") MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START -> {
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS -> writeTrajectoryLog("轨迹下载成功") writeTrajectoryLog("轨迹开始下载")
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE -> writeTrajectoryLog("轨迹下载失败,本地无对应轨迹") M_LISTENERS.forEach {
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING -> writeTrajectoryLog("轨迹下载失败,本地有对应轨迹,认为成功") it.value.onDownLoadStart(lineId)
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT -> writeTrajectoryLog("轨迹下载超时") }
MogoReport.Code.Info.ISSM.FUNC_AUTO_PILOT_READY -> writeTrajectoryLog("再次发起下载、 ssm ready再次发起下载") }
MogoReport.Code.Error.EMAP.TRA_LOAD_FAILED -> writeTrajectoryLog("onAutopilotGuardian() 加载轨迹文件失败") MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS -> {
MogoReport.Code.Error.EMAP.TRA_NOT_EXIST -> writeTrajectoryLog("onAutopilotGuardian() 无法找到轨迹文件") writeTrajectoryLog("轨迹下载成功")
addDownLoadSuccessLine(lineId)
M_LISTENERS.forEach {
it.value.onDownLoadSuccess(lineId)
}
}
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE -> {
writeTrajectoryLog("轨迹下载失败,本地无对应轨迹")
// 更新轨迹没有更新lineId 第二次下载失败 删除App成功缓存(概率很低)
removeDownLoadSuccessLine(lineId)
M_LISTENERS.forEach {
it.value.onDownLoadFail(lineId)
}
}
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING -> {
writeTrajectoryLog("轨迹下载失败,本地有对应轨迹,认为成功")
M_LISTENERS.forEach {
it.value.onDownLoadSuccess(lineId)
}
}
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT -> {
writeTrajectoryLog("轨迹下载超时")
M_LISTENERS.forEach {
it.value.onDownLoadTimeout(lineId)
}
}
MogoReport.Code.Info.ISSM.FUNC_AUTO_PILOT_READY -> {
writeTrajectoryLog("再次发起下载、 ssm ready再次发起下载")
M_LISTENERS.forEach {
it.value.onDownLoadReady(lineId)
}
}
MogoReport.Code.Error.EMAP.TRA_LOAD_FAILED -> {
writeTrajectoryLog("onAutopilotGuardian() 加载轨迹文件失败")
M_LISTENERS.forEach {
it.value.onLoadFail(lineId)
}
}
MogoReport.Code.Error.EMAP.TRA_NOT_EXIST -> {
writeTrajectoryLog("onAutopilotGuardian() 无法找到轨迹文件")
M_LISTENERS.forEach {
it.value.onTrajectoryNotExist(lineId)
}
}
MogoReport.Code.Error.EMAP.ATTITUDE_INIT_FAILED->{
writeTrajectoryLog("onAutopilotGuardian() 当前位置距离轨迹距离大于15m")
M_LISTENERS.forEach {
it.value.onDistanceWithTrajectory(lineId)
}
}
else -> {} else -> {}
} }
} }
private fun writeTrajectoryLog(message:String){ private fun writeTrajectoryLog(message:String){
writeChainLog("轨迹监控", "再次发起下载", true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) writeChainLog("轨迹监控", message, true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY)
} }
} }

View File

@@ -10,6 +10,7 @@ import com.mogo.och.common.module.constant.OchCommonConst
import com.mogo.och.common.module.biz.provider.CommonServiceImpl import com.mogo.och.common.module.biz.provider.CommonServiceImpl
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import com.mogo.och.offline.util.BusAnalyticsManager import com.mogo.och.offline.util.BusAnalyticsManager
import com.mogo.och.offline.util.OffLineTrajectoryManager
/** /**
* 网约车小巴业务实现入口 * 网约车小巴业务实现入口
@@ -31,11 +32,13 @@ class ShuttleDriverProvider : CommonServiceImpl() {
busFragment = ShuttleFragment() busFragment = ShuttleFragment()
} }
OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager.getInstance() OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager.getInstance()
OffLineTrajectoryManager.load()
return busFragment!! return busFragment!!
} }
override fun resetFragment() { override fun resetFragment() {
OchAutopilotAnalytics.ochEventKey = null OchAutopilotAnalytics.ochEventKey = null
OffLineTrajectoryManager.release()
busFragment = null busFragment = null
} }

View File

@@ -55,7 +55,7 @@ import com.mogo.och.offline.callback.IBusControllerStatusCallback;
import com.mogo.och.offline.callback.IRefreshBusStationsCallback; import com.mogo.och.offline.callback.IRefreshBusStationsCallback;
import com.mogo.och.offline.callback.ISlidePannelHideCallback; import com.mogo.och.offline.callback.ISlidePannelHideCallback;
import com.mogo.och.offline.constant.BusConst; import com.mogo.och.offline.constant.BusConst;
import com.mogo.och.offline.util.BusTrajectoryManager; import com.mogo.och.offline.util.OffLineTrajectoryManager;
import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager; import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager;
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager; import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager;
@@ -826,7 +826,7 @@ public class OrderModel {
updateBusTaskStatus(stationList); updateBusTaskStatus(stationList);
//需放在currentStationIndex赋值之后 //需放在currentStationIndex赋值之后
BusTrajectoryManager.getInstance().syncTrajectoryInfo(); OffLineTrajectoryManager.INSTANCE.syncTrajectoryInfo();
} }
private void beforeTaskTips() { private void beforeTaskTips() {

View File

@@ -28,7 +28,7 @@ import com.mogo.och.offline.callback.ISlidePannelHideCallback;
import com.mogo.och.offline.fragment.ShuttleFragment; import com.mogo.och.offline.fragment.ShuttleFragment;
import com.mogo.och.offline.model.BusLineModel; import com.mogo.och.offline.model.BusLineModel;
import com.mogo.och.offline.model.OrderModel; import com.mogo.och.offline.model.OrderModel;
import com.mogo.och.offline.util.BusTrajectoryManager; import com.mogo.och.offline.util.OffLineTrajectoryManager;
import com.mogo.och.common.module.biz.login.ILoginCallback; import com.mogo.och.common.module.biz.login.ILoginCallback;
import com.mogo.och.common.module.biz.login.LoginStatusManager; import com.mogo.och.common.module.biz.login.LoginStatusManager;
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager; import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager;
@@ -286,11 +286,6 @@ public class BusPresenter extends Presenter<ShuttleFragment>
} }
@Override
public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo, long lineId) {
BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo,lineId);
}
@Override @Override
public void onStatusChange(LoginStatusEnum currentStatus) { public void onStatusChange(LoginStatusEnum currentStatus) {
CallerLogger.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin()); CallerLogger.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin());
@@ -300,8 +295,7 @@ public class BusPresenter extends Presenter<ShuttleFragment>
BusLineModel.startLoopAllLine(); BusLineModel.startLoopAllLine();
}else { }else {
BusLineModel.stopLoopAllLine(); BusLineModel.stopLoopAllLine();
BusTrajectoryManager.getInstance().stopTrajReqLoop(); OffLineTrajectoryManager.INSTANCE.stopTrajReqLoop();
BusTrajectoryManager.getInstance().stopTrajReqLoop();
clearBusStationsMarkers(); clearBusStationsMarkers();
if(mView!=null) { if(mView!=null) {
mView.hideSlidePanel(); mView.hideSlidePanel();

View File

@@ -1,180 +1,183 @@
package com.mogo.och.offline.util; package com.mogo.och.offline.util
import androidx.annotation.Nullable; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendTrajectoryDownloadReq
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
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.GsonUtils; import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager; import com.mogo.och.common.module.biz.login.LoginStatusManager.isLogin
import com.mogo.och.data.bean.BusRoutesResult; import com.mogo.och.common.module.manager.autopilot.trajectory.ITrajectoryListListener
import com.mogo.och.offline.constant.BusConst; import com.mogo.och.common.module.manager.autopilot.trajectory.TrajectoryManager
import com.mogo.och.offline.model.OrderModel; import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.biz.login.LoginStatusManager; import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog
import com.mogo.och.offline.constant.BusConst
import java.util.concurrent.TimeUnit; import com.mogo.och.offline.model.OrderModel
import io.reactivex.Observable
import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable
import io.reactivex.disposables.Disposable; import io.reactivex.functions.Function
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers
import mogo_msg.MogoReportMsg; import mogo_msg.MogoReportMsg.MogoReportMessage
import java.util.concurrent.TimeUnit
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS;
/** /**
* Bus轨迹管理给MEC下发用于轨迹下载的信息 * Bus轨迹管理给MEC下发用于轨迹下载的信息
* Created on 2022/6/23 * Created on 2022/6/23
*/ */
public class BusTrajectoryManager { object OffLineTrajectoryManager : ITrajectoryListListener {
private static final String TAG = BusTrajectoryManager.class.getSimpleName();
private static final class SingletonHolder { private var mAutoPilotLine: AutoPilotLine? = null
private static final BusTrajectoryManager INSTANCE = new BusTrajectoryManager(); private var mSendReqDisposable: Disposable? = null
private val TAG: String = OffLineTrajectoryManager::class.java.simpleName
init {
mAutoPilotLine = AutoPilotLine(
-1, "",
"", "", "", "", 0, "",
"", "", "", "", 0
)
} }
public static BusTrajectoryManager getInstance() { fun load(){
return BusTrajectoryManager.SingletonHolder.INSTANCE; TrajectoryManager.addListener(TAG,this)
} }
private AutopilotControlParameters.AutoPilotLine mAutoPilotLine = null; fun release(){
private Disposable mSendReqDisposable = null; TrajectoryManager.removeListener(TAG)
public BusTrajectoryManager() {
mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(-1, "",
"", "", "", "", 0, "",
"", "", "", "", 0);
} }
/** /**
* 同步Bus路线信息 * 同步Bus路线信息
*/ */
public void syncTrajectoryInfo() { fun syncTrajectoryInfo() {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); val routesResult = OrderModel.getInstance().busRoutesResult
if (LoginStatusManager.isLogin() && routesResult != null if (isLogin() && routesResult != null && OrderModel.getInstance().currentStationIndex == 0 && !OrderModel.getInstance().isGoingToNextStation) {
&& OrderModel.getInstance().getCurrentStationIndex() == 0 d(SceneConstant.M_BUS + TAG, "syncTrajectoryInfo() start.")
&& !OrderModel.getInstance().isGoingToNextStation()) { startTrajReqLoop()
CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() start.");
startTrajReqLoop();
} else { } else {
// 无路线信息or当前未在始发站 // 无路线信息or当前未在始发站
CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() stop."); d(SceneConstant.M_BUS + TAG, "syncTrajectoryInfo() stop.")
stopTrajReqLoop(); stopTrajReqLoop()
} }
} }
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo,long lineId) { override fun onDownLoadStart(lineId: Long) {
onAutopilotGuardian(guardianInfo); stopTrajReqLoop()
} }
/** override fun onDownLoadSuccess(lineId: Long) {
* 接口MEC反馈的常规信息MAP v2.5.0新增轨迹相关信息) stopTrajReqLoop()
* @param guardianInfo
*/
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
if (guardianInfo == null || !guardianInfo.hasCode()) return;
if ("ISYS_INIT_TRAJECTORY_START".equals(guardianInfo.getCode())) {
// 1. 轨迹管理_轨迹开始下载本地已有对应轨迹也触发
stopTrajReqLoop();
} else if ("ISYS_INIT_TRAJECTORY_SUCCESS".equals(guardianInfo.getCode())) {
// 2. 轨迹管理_轨迹下载成功本地已有对应轨迹也触发
stopTrajReqLoop();
} else if ("ISYS_INIT_TRAJECTORY_FAILURE".equals(guardianInfo.getCode())) {
// 3. 轨迹管理_轨迹下载失败本地无对应轨迹
} else if ("ISYS_INIT_TRAJECTORY_WARNING".equals(guardianInfo.getCode())) {
// 4. 轨迹管理_轨迹下载失败本地有对应轨迹认为成功
} else if ("ISYS_INIT_TRAJECTORY_TIMEOUT".equals(guardianInfo.getCode())) {
// 5. 轨迹管理_轨迹下载超时
} else if ("ISSM_FUNC_AUTO_PILOT_READY".equals(guardianInfo.getCode())) {
// 收到ssm的自动驾驶变为ready再次下发轨迹下载.解决域控重启或者102域控启动太早107节点初始化未完成导致的轨迹未进行下载。
syncTrajectoryInfo();
}
} }
private void setupAutoPilotLine() { override fun onDownLoadReady(lineId: Long) {
BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); super.onDownLoadReady(lineId)
// 收到ssm的自动驾驶变为ready再次下发轨迹下载.解决域控重启或者102域控启动太早107节点初始化未完成导致的轨迹未进行下载。
syncTrajectoryInfo()
}
private fun setupAutoPilotLine() {
val routesResult = OrderModel.getInstance().busRoutesResult
if (routesResult == null) { if (routesResult == null) {
CallerLogger.e(M_BUS + TAG, e(
"setupAutoPilotLine(): routesResult is null."); SceneConstant.M_BUS + TAG,
return; "setupAutoPilotLine(): routesResult is null."
)
return
} else { } else {
if (mAutoPilotLine == null) { if (mAutoPilotLine == null) {
mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine( mAutoPilotLine = AutoPilotLine(
routesResult.getLineId(), routesResult.getName(), routesResult.lineId.toLong(), routesResult.name,
routesResult.csvFileUrl, routesResult.csvFileMd5, routesResult.csvFileUrl, routesResult.csvFileMd5,
routesResult.txtFileUrl, routesResult.txtFileMd5, routesResult.txtFileUrl, routesResult.txtFileMd5,
routesResult.contrailSaveTime, routesResult.carModel, routesResult.contrailSaveTime, routesResult.carModel,
routesResult.csvFileUrlDPQP, routesResult.csvFileMd5DPQP, routesResult.csvFileUrlDPQP, routesResult.csvFileMd5DPQP,
routesResult.txtFileUrlDPQP, routesResult.txtFileMd5DPQP, routesResult.txtFileUrlDPQP, routesResult.txtFileMd5DPQP,
routesResult.contrailSaveTimeDPQP); routesResult.contrailSaveTimeDPQP
)
} else { } else {
mAutoPilotLine.setLineId(routesResult.getLineId()); mAutoPilotLine!!.lineId = routesResult.lineId.toLong()
mAutoPilotLine.setLineName(routesResult.getName()); mAutoPilotLine!!.lineName = routesResult.name
mAutoPilotLine.setTrajUrl(routesResult.csvFileUrl==null?"":routesResult.csvFileUrl); mAutoPilotLine!!.trajUrl =
mAutoPilotLine.setTrajMd5(routesResult.csvFileMd5==null?"":routesResult.csvFileMd5); if (routesResult.csvFileUrl == null) "" else routesResult.csvFileUrl
mAutoPilotLine.setStopUrl(routesResult.txtFileUrl==null?"":routesResult.txtFileUrl); mAutoPilotLine!!.trajMd5 =
mAutoPilotLine.setStopMd5(routesResult.txtFileMd5==null?"":routesResult.txtFileMd5); if (routesResult.csvFileMd5 == null) "" else routesResult.csvFileMd5
mAutoPilotLine.setTimestamp(routesResult.contrailSaveTime); mAutoPilotLine!!.stopUrl =
mAutoPilotLine.setVehicleModel(routesResult.carModel==null?"":routesResult.carModel); if (routesResult.txtFileUrl == null) "" else routesResult.txtFileUrl
mAutoPilotLine!!.stopMd5 =
if (routesResult.txtFileMd5 == null) "" else routesResult.txtFileMd5
mAutoPilotLine!!.timestamp = routesResult.contrailSaveTime
mAutoPilotLine!!.vehicleModel =
if (routesResult.carModel == null) "" else routesResult.carModel
} }
} }
} }
private void clearAutoPilotLine() { private fun clearAutoPilotLine() {
if (mAutoPilotLine == null) return; if (mAutoPilotLine == null) return
mAutoPilotLine.setLineId(-1); mAutoPilotLine!!.lineId = -1
mAutoPilotLine.setLineName(""); mAutoPilotLine!!.lineName = ""
mAutoPilotLine.setTrajUrl(""); mAutoPilotLine!!.trajUrl = ""
mAutoPilotLine.setTrajMd5(""); mAutoPilotLine!!.trajMd5 = ""
mAutoPilotLine.setStopUrl(""); mAutoPilotLine!!.stopUrl = ""
mAutoPilotLine.setStopMd5(""); mAutoPilotLine!!.stopMd5 = ""
mAutoPilotLine.setTimestamp(0); mAutoPilotLine!!.timestamp = 0
mAutoPilotLine.setVehicleModel(""); mAutoPilotLine!!.vehicleModel = ""
mAutoPilotLine.setTrajUrl_dpqp(""); mAutoPilotLine!!.trajUrl_dpqp = ""
mAutoPilotLine.setTrajMd5_dpqp(""); mAutoPilotLine!!.trajMd5_dpqp = ""
mAutoPilotLine.setStopUrl_dpqp(""); mAutoPilotLine!!.stopUrl_dpqp = ""
mAutoPilotLine.setStopMd5_dpqp(""); mAutoPilotLine!!.stopMd5_dpqp = ""
mAutoPilotLine.setTimestamp_dpqp(0); mAutoPilotLine!!.timestamp_dpqp = 0
} }
private void startTrajReqLoop() { private fun startTrajReqLoop() {
if (mSendReqDisposable != null && !mSendReqDisposable.isDisposed()) { if (mSendReqDisposable != null && !mSendReqDisposable!!.isDisposed) {
return; return
} }
CallerLogger.d(M_BUS + TAG, "startTrajReqLoop()"); d(SceneConstant.M_BUS + TAG, "startTrajReqLoop()")
setupAutoPilotLine(); setupAutoPilotLine()
mSendReqDisposable = Observable.interval(BusConst.LOOP_DELAY, mSendReqDisposable = Observable.interval(
BusConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS) BusConst.LOOP_DELAY,
.map((aLong -> aLong + 1)) BusConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS
.subscribeOn(Schedulers.io()) )
.observeOn(AndroidSchedulers.mainThread()) .map((Function { aLong: Long -> aLong + 1 }))
.subscribe(aLong -> { .subscribeOn(Schedulers.io())
if (aLong > BusConst.LOOP_SEND_TRAJ_TIMES) { .observeOn(AndroidSchedulers.mainThread())
stopTrajReqLoop(); .subscribe { aLong: Long ->
return; if (aLong > BusConst.LOOP_SEND_TRAJ_TIMES) {
} stopTrajReqLoop()
CallerLogger.d(M_BUS + TAG, "loop sendTrajectoryReq: " + aLong); return@subscribe
sendTrajectoryReq(); }
}); d(SceneConstant.M_BUS + TAG, "loop sendTrajectoryReq: $aLong")
sendTrajectoryReq()
}
} }
public void stopTrajReqLoop() { fun stopTrajReqLoop() {
if (mSendReqDisposable != null) { if (mSendReqDisposable != null) {
CallerLogger.d(M_BUS + TAG, "stopTrajReqLoop()"); d(SceneConstant.M_BUS + TAG, "stopTrajReqLoop()")
mSendReqDisposable.dispose(); mSendReqDisposable!!.dispose()
mSendReqDisposable = null; mSendReqDisposable = null
clearAutoPilotLine(); clearAutoPilotLine()
} }
} }
private void sendTrajectoryReq() { private fun sendTrajectoryReq() {
if (mAutoPilotLine == null) { if (mAutoPilotLine == null) {
CallerLogger.e(M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!"); e(SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!")
return; return
} }
OchChainLogManager.writeChainLog("轨迹监控","sendTrajectoryReq() 下发轨迹 轨迹id"+mAutoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY); writeChainLog(
CallerAutoPilotControlManager.INSTANCE.sendTrajectoryDownloadReq(mAutoPilotLine); "轨迹监控",
CallerLogger.d(M_BUS + TAG, "sendTrajectoryReq(): " "sendTrajectoryReq() 下发轨迹 轨迹id" + mAutoPilotLine!!.lineId,
+ GsonUtils.toJson(mAutoPilotLine)); true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
sendTrajectoryDownloadReq(mAutoPilotLine!!)
d(
SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): "
+ GsonUtils.toJson(mAutoPilotLine)
)
} }
} }

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

View File

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

View File

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

View File

@@ -14,6 +14,7 @@ import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalyt
import com.mogo.och.unmanned.taxi.ui.base.TaxiFragment import com.mogo.och.unmanned.taxi.ui.base.TaxiFragment
import com.mogo.och.unmanned.taxi.ui.bizswitch.SwitchBizView import com.mogo.och.unmanned.taxi.ui.bizswitch.SwitchBizView
import com.mogo.och.unmanned.taxi.utils.TaxiAnalyticsManager import com.mogo.och.unmanned.taxi.utils.TaxiAnalyticsManager
import com.mogo.och.unmanned.taxi.utils.TaxiTrajectoryManager
/** /**
* @author congtaowang * @author congtaowang
@@ -38,11 +39,13 @@ class TaxiUnmannedDriverProvider : CommonServiceImpl() {
ochTaxiFragment = TaxiFragment() ochTaxiFragment = TaxiFragment()
} }
OchAutopilotAnalytics.ochEventKey = TaxiAnalyticsManager.getInstance() OchAutopilotAnalytics.ochEventKey = TaxiAnalyticsManager.getInstance()
TaxiTrajectoryManager.load()
return ochTaxiFragment!! return ochTaxiFragment!!
} }
override fun resetFragment() { override fun resetFragment() {
CallerLogger.d(SceneConstant.M_TAXI + tag, "resetFragment") CallerLogger.d(SceneConstant.M_TAXI + tag, "resetFragment")
TaxiTrajectoryManager.releast()
OchAutopilotAnalytics.ochEventKey = null OchAutopilotAnalytics.ochEventKey = null
ochTaxiFragment = null ochTaxiFragment = null
} }

View File

@@ -279,16 +279,6 @@ object TaxiTaskModel {
private val mMogoAutopilotStatusListener: IOchAutopilotStatusListener = private val mMogoAutopilotStatusListener: IOchAutopilotStatusListener =
object : IOchAutopilotStatusListener { object : IOchAutopilotStatusListener {
override fun onAutopilotIpcConnectStatusChanged(status: AdasConstants.IpcConnectionStatus, reason: String?) {
}
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) {
TaxiTrajectoryManager.onAutopilotGuardian(guardianInfo,lineId)
}
override fun onAutopilotStatusResponseFromCan(state: Int) {
}
override fun onAutopilotStatusResponse(state: Int) { override fun onAutopilotStatusResponse(state: Int) {
i(TAG, "onAutopilotStatusResponse autopilotsState= $state") i(TAG, "onAutopilotStatusResponse autopilotsState= $state")

View File

@@ -8,6 +8,8 @@ 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.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.och.common.module.manager.autopilot.line.LineManager import com.mogo.och.common.module.manager.autopilot.line.LineManager
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
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager.writeChainLog
import com.mogo.och.unmanned.taxi.bean.TrajectoryListRespBean import com.mogo.och.unmanned.taxi.bean.TrajectoryListRespBean
@@ -30,7 +32,7 @@ import java.util.concurrent.TimeUnit
* Taxi轨迹管理给MEC下发用于轨迹下载的信息 * Taxi轨迹管理给MEC下发用于轨迹下载的信息
* Created on 2022/6/22 * Created on 2022/6/22
*/ */
object TaxiTrajectoryManager { object TaxiTrajectoryManager : ITrajectoryListListener {
private val TAG: String = TaxiTrajectoryManager::class.java.simpleName private val TAG: String = TaxiTrajectoryManager::class.java.simpleName
@@ -52,6 +54,14 @@ object TaxiTrajectoryManager {
mPreAutoPilotLine = AutopilotControlParameters() mPreAutoPilotLine = AutopilotControlParameters()
} }
fun load(){
TrajectoryManager.addListener(TAG,this)
}
fun releast(){
TrajectoryManager.removeListener(TAG)
}
/** /**
* 同步订单信息 * 同步订单信息
*/ */
@@ -77,26 +87,16 @@ object TaxiTrajectoryManager {
} }
} }
fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) { override fun onDownLoadStart(lineId: Long) {
onAutopilotGuardian(guardianInfo) stopTrajReqLoop();
} }
/** override fun onDownLoadSuccess(lineId: Long) {
* 接口MEC反馈的常规信息MAP v2.5.0新增轨迹相关信息) stopTrajReqLoop();
* @param guardianInfo }
*/
fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) { override fun onDownLoadReady(lineId: Long) {
if (guardianInfo == null || !guardianInfo.hasCode()) return syncTrajectoryInfo()
if ("ISYS_INIT_TRAJECTORY_START" == guardianInfo.code) {
stopTrajReqLoop()
} else if ("ISYS_INIT_TRAJECTORY_TIMEOUT" == guardianInfo.code) {
writeChainLog(
"轨迹监控",
"onAutopilotGuardian() 轨迹下载超时",
true,
OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY
)
}
} }
private fun setupAutoPilotLine() { private fun setupAutoPilotLine() {