diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/CharterDriverProvider.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/CharterDriverProvider.kt index 284fb0dd2c..b50bc443d5 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/CharterDriverProvider.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/CharterDriverProvider.kt @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment import com.alibaba.android.arouter.facade.annotation.Route import com.magic.mogo.och.charter.fragment.DriverM1Fragment 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.scene.SceneConstant import com.mogo.och.common.module.constant.OchCommonConst @@ -29,10 +30,12 @@ class CharterDriverProvider : CommonServiceImpl() { fragment = DriverM1Fragment() } OchAutopilotAnalytics.ochEventKey = CharterAnalyticsManager.getInstance() + CharterTrajectoryManager.load() return fragment!! } override fun resetFragment() { + CharterTrajectoryManager.release() fragment = null OchAutopilotAnalytics.ochEventKey = null } diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterTrajectoryManager.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterTrajectoryManager.kt index b1df9035ef..3cabd439f7 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterTrajectoryManager.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterTrajectoryManager.kt @@ -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.GsonUtils 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.utils.SoundPoolHelper import io.reactivex.Observable @@ -29,7 +31,7 @@ import java.util.concurrent.TimeUnit * Bus轨迹管理:给MEC下发用于轨迹下载的信息 * Created on 2022/6/23 */ -object CharterTrajectoryManager { +object CharterTrajectoryManager : ITrajectoryListListener { private const val TAG = "CharterTrajectoryManager" private var mAutoPilotLine: AutoPilotLine? = null @@ -37,6 +39,14 @@ object CharterTrajectoryManager { private var mLineName = "" private var mSendReqDisposable: Disposable? = null + fun load(){ + TrajectoryManager.addListener(TAG,this) + } + + fun release(){ + TrajectoryManager.removeListener(TAG) + } + /** * 同步Bus路线信息 */ @@ -54,57 +64,35 @@ object CharterTrajectoryManager { } } - fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) { - onAutopilotGuardian(guardianInfo) + override fun onDownLoadStart(lineId: Long) { + stopTrajReqLoop() } - /** - * 接口MEC反馈的常规信息(MAP v2.5.0新增轨迹相关信息) - * @param guardianInfo - */ - fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) { - if (guardianInfo == null || !guardianInfo.hasCode()) return - if ("ISYS_INIT_TRAJECTORY_START" == guardianInfo.code) { - // 1. 轨迹管理_轨迹开始下载(本地已有对应轨迹也触发) - 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) { - // 2. 轨迹管理_轨迹下载成功(本地已有对应轨迹也触发) - d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() 轨迹下载成功") - OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载成功", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) - stopTrajReqLoop() - } else if ("ISYS_INIT_TRAJECTORY_FAILURE" == guardianInfo.code) { - // 3. 轨迹管理_轨迹下载失败,本地无对应轨迹 - d(SceneConstant.M_CHARTER_D + TAG, "onAutopilotGuardian() " + "轨迹下载失败,本地无对应轨迹") - OchChainLogManager.writeChainLog("轨迹监控","onAutopilotGuardian() 轨迹下载失败,本地无对应轨迹", eventID = OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) - // ToastUtils.showShort("轨迹下载失败,本地无对应轨迹"); - } 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 - ) + override fun onDownLoadSuccess(lineId: Long) { + stopTrajReqLoop() + } + + override fun onDownLoadReady(lineId: Long) { + super.onDownLoadReady(lineId) + DriverM1Model.get().getBusOrderResult()?.lineId?.let { + syncTrajectoryInfo(it, DriverM1Model.get().getBusOrderResult()?.lineName!!) + } + } + + override fun onDistanceWithTrajectory(lineId: Long) { + super.onDistanceWithTrajectory(lineId) + 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() { diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt index e00d218480..e69e6df9c6 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt @@ -124,10 +124,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) : DriverM1Model.get().pushOperationalToMsgBox(DateTimeUtil.getCurrentTimeStamp() ,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?) { DriverM1Model.get().onAutopilotArriveAtStation() diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/biz/login/LoginInfo.java b/OCH/common/common/src/main/java/com/mogo/och/common/module/biz/login/LoginInfo.java index beafe04099..91fadee5d0 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/biz/login/LoginInfo.java +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/biz/login/LoginInfo.java @@ -13,6 +13,7 @@ public class LoginInfo { private String phone;//手机号 private Integer lineId;//线路id private Integer taskId;//任务id + private Integer siteId;//任务id private String vin;//车辆唯一识别码 private String cityCode;//城市编码 private String brand;//东风 @@ -24,6 +25,8 @@ public class LoginInfo { private long tenantId;//租户id: private long driverId; + private long businessStatus;//????? + public int getDriverStatus() { return driverStatus; } @@ -160,6 +163,22 @@ public class LoginInfo { 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 public String toString() { return "LoginInfo{" + @@ -173,6 +192,7 @@ public class LoginInfo { ", phone='" + phone + '\'' + ", lineId=" + lineId + ", taskId=" + taskId + + ", siteId=" + siteId + ", vin='" + vin + '\'' + ", cityCode='" + cityCode + '\'' + ", brand='" + brand + '\'' + @@ -180,6 +200,7 @@ public class LoginInfo { ", photos='" + photos + '\'' + ", tenantId=" + tenantId + ", driverId=" + driverId + + ", businessStatus=" + businessStatus + '}'; } @@ -189,30 +210,7 @@ public class LoginInfo { if (o == null || getClass() != o.getClass()) return false; LoginInfo loginInfo = (LoginInfo) o; - - 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); + 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); } @Override @@ -220,20 +218,22 @@ public class LoginInfo { int result = driverStatus; result = 31 * result + servingStatus; result = 31 * result + businessType; - result = 31 * result + (int)tenantId; - result = 31 * result + (int)driverId; - result = 31 * result + (orderNo != null ? orderNo.hashCode() : 0); + result = 31 * result + Objects.hashCode(orderNo); result = 31 * result + purpose; - result = 31 * result + (sn != null ? sn.hashCode() : 0); - result = 31 * result + (plateNumber != null ? plateNumber.hashCode() : 0); - result = 31 * result + (phone != null ? phone.hashCode() : 0); - result = 31 * result + (lineId != null ? lineId.hashCode() : 0); - result = 31 * result + (taskId != null ? taskId.hashCode() : 0); - result = 31 * result + (vin != null ? vin.hashCode() : 0); - result = 31 * result + (cityCode != null ? cityCode.hashCode() : 0); - result = 31 * result + (brand != null ? brand.hashCode() : 0); - result = 31 * result + (carModel != null ? carModel.hashCode() : 0); - result = 31 * result + (photos != null ? photos.hashCode() : 0); + result = 31 * result + Objects.hashCode(sn); + result = 31 * result + Objects.hashCode(plateNumber); + result = 31 * result + Objects.hashCode(phone); + result = 31 * result + Objects.hashCode(lineId); + result = 31 * result + Objects.hashCode(taskId); + result = 31 * result + Objects.hashCode(siteId); + result = 31 * result + Objects.hashCode(vin); + result = 31 * result + Objects.hashCode(cityCode); + result = 31 * result + Objects.hashCode(brand); + 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; } } diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotStatusListenerManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotStatusListenerManager.kt index 0c273facca..babef2cd6e 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotStatusListenerManager.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotStatusListenerManager.kt @@ -132,12 +132,7 @@ object OchAutoPilotStatusListenerManager : CallerBase, - ) + fun trajectoryCallback(trajectoryList: MutableList){} + + /** + * @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) {} } \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/trajectory/TrajectoryManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/trajectory/TrajectoryManager.kt index 8e08e36495..867f77bba2 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/trajectory/TrajectoryManager.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/trajectory/TrajectoryManager.kt @@ -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.och.common.module.manager.logchainanalytic.OchChainLogManager 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.zhjt.mogo.adas.data.bean.MogoReport import mogo.telematics.pad.MessagePad -import java.util.concurrent.ConcurrentHashMap -object TrajectoryManager : IMoGoPlanningRottingListener { +object TrajectoryManager : CallerBase(),IMoGoPlanningRottingListener { const val TAG = "TrajectoryManager" - private val distanceListeners: ConcurrentHashMap = - ConcurrentHashMap() - private val downLoadSuccessLineIds = mutableListOf() /** @@ -88,52 +85,92 @@ object TrajectoryManager : IMoGoPlanningRottingListener { maxDistanceAllPoint += distanceItem } } - distanceListeners.forEach { + M_LISTENERS.forEach { it.value.trajectoryCallback(mRoutePoints) } + M_LISTENERS.forEach { + it.value.trajectoryDistanceCallback(maxDistanceAllPoint) + } } - fun addTrajectoryListListenerr(tag: String, listener: ITrajectoryListListener?) { - if (distanceListeners.containsKey(tag)) { - return - } - if(listener==null){ - distanceListeners.remove(tag) - return - } - distanceListeners[tag] = listener - } - - fun addDownLoadSuccessLine(lineId:Long){ + private fun addDownLoadSuccessLine(lineId:Long){ if(lineId>0){ OchChainLogManager.writeChainLog("轨迹监控", " 轨迹下载成功${lineId}", true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) downLoadSuccessLineIds.add(lineId) } } - fun removeDownLoadSuccessLine(lineId:Long){ + private fun removeDownLoadSuccessLine(lineId:Long){ if(lineId>0&& downLoadSuccessLineIds.contains(lineId)){ downLoadSuccessLineIds.remove(lineId) } } - fun carDownLoadTrajectoryLog(code:String?){ + fun carDownLoadTrajectoryLog(code: String?, lineId: Long){ when (code) { - MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START -> writeTrajectoryLog("轨迹开始下载") - MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS -> writeTrajectoryLog("轨迹下载成功") - MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE -> writeTrajectoryLog("轨迹下载失败,本地无对应轨迹") - MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING -> writeTrajectoryLog("轨迹下载失败,本地有对应轨迹,认为成功") - 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.Error.EMAP.TRA_NOT_EXIST -> writeTrajectoryLog("onAutopilotGuardian() 无法找到轨迹文件") + MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START -> { + writeTrajectoryLog("轨迹开始下载") + M_LISTENERS.forEach { + it.value.onDownLoadStart(lineId) + } + } + MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS -> { + 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 -> {} } - - } private fun writeTrajectoryLog(message:String){ - writeChainLog("轨迹监控", "再次发起下载", true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) + writeChainLog("轨迹监控", message, true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY) } } \ No newline at end of file diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/ShuttleDriverProvider.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/ShuttleDriverProvider.kt index 2620eea1dd..54ef442d7a 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/ShuttleDriverProvider.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/ShuttleDriverProvider.kt @@ -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.manager.autopilot.autopilot.OchAutopilotAnalytics import com.mogo.och.offline.util.BusAnalyticsManager +import com.mogo.och.offline.util.OffLineTrajectoryManager /** * 网约车小巴业务实现入口 @@ -31,11 +32,13 @@ class ShuttleDriverProvider : CommonServiceImpl() { busFragment = ShuttleFragment() } OchAutopilotAnalytics.ochEventKey = BusAnalyticsManager.getInstance() + OffLineTrajectoryManager.load() return busFragment!! } override fun resetFragment() { OchAutopilotAnalytics.ochEventKey = null + OffLineTrajectoryManager.release() busFragment = null } diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/model/OrderModel.java b/OCH/offline/driver/src/main/java/com/mogo/och/offline/model/OrderModel.java index ebe601a4d4..6c4d246dc3 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/model/OrderModel.java +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/model/OrderModel.java @@ -55,7 +55,7 @@ import com.mogo.och.offline.callback.IBusControllerStatusCallback; import com.mogo.och.offline.callback.IRefreshBusStationsCallback; import com.mogo.och.offline.callback.ISlidePannelHideCallback; 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.callback.OchAdasStartFailureCallback; import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager; @@ -826,7 +826,7 @@ public class OrderModel { updateBusTaskStatus(stationList); //需放在currentStationIndex赋值之后 - BusTrajectoryManager.getInstance().syncTrajectoryInfo(); + OffLineTrajectoryManager.INSTANCE.syncTrajectoryInfo(); } private void beforeTaskTips() { diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/presenter/BusPresenter.java b/OCH/offline/driver/src/main/java/com/mogo/och/offline/presenter/BusPresenter.java index a7b1a0118f..8cf0dcae8c 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/presenter/BusPresenter.java +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/presenter/BusPresenter.java @@ -28,7 +28,7 @@ import com.mogo.och.offline.callback.ISlidePannelHideCallback; import com.mogo.och.offline.fragment.ShuttleFragment; import com.mogo.och.offline.model.BusLineModel; 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.LoginStatusManager; import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager; @@ -286,11 +286,6 @@ public class BusPresenter extends Presenter } - @Override - public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo, long lineId) { - BusTrajectoryManager.getInstance().onAutopilotGuardian(guardianInfo,lineId); - } - @Override public void onStatusChange(LoginStatusEnum currentStatus) { CallerLogger.d(M_BUS + TAG, " loginStatus =" + LoginStatusManager.isLogin()); @@ -300,8 +295,7 @@ public class BusPresenter extends Presenter BusLineModel.startLoopAllLine(); }else { BusLineModel.stopLoopAllLine(); - BusTrajectoryManager.getInstance().stopTrajReqLoop(); - BusTrajectoryManager.getInstance().stopTrajReqLoop(); + OffLineTrajectoryManager.INSTANCE.stopTrajReqLoop(); clearBusStationsMarkers(); if(mView!=null) { mView.hideSlidePanel(); diff --git a/OCH/offline/driver/src/main/java/com/mogo/och/offline/util/OffLineTrajectoryManager.kt b/OCH/offline/driver/src/main/java/com/mogo/och/offline/util/OffLineTrajectoryManager.kt index 52bd51fd8c..1beb9ab5ae 100644 --- a/OCH/offline/driver/src/main/java/com/mogo/och/offline/util/OffLineTrajectoryManager.kt +++ b/OCH/offline/driver/src/main/java/com/mogo/och/offline/util/OffLineTrajectoryManager.kt @@ -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; -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.manager.logchainanalytic.OchChainLogManager; -import com.mogo.och.data.bean.BusRoutesResult; -import com.mogo.och.offline.constant.BusConst; -import com.mogo.och.offline.model.OrderModel; -import com.mogo.och.common.module.biz.login.LoginStatusManager; - -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 static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine +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.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.offline.constant.BusConst +import com.mogo.och.offline.model.OrderModel +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 OffLineTrajectoryManager : ITrajectoryListListener { - private static final class SingletonHolder { - private static final BusTrajectoryManager INSTANCE = new BusTrajectoryManager(); + private var mAutoPilotLine: AutoPilotLine? = null + private var mSendReqDisposable: Disposable? = null + + private val TAG: String = OffLineTrajectoryManager::class.java.simpleName + + init { + mAutoPilotLine = AutoPilotLine( + -1, "", + "", "", "", "", 0, "", + "", "", "", "", 0 + ) } - public static BusTrajectoryManager getInstance() { - return BusTrajectoryManager.SingletonHolder.INSTANCE; + fun load(){ + TrajectoryManager.addListener(TAG,this) } - private AutopilotControlParameters.AutoPilotLine mAutoPilotLine = null; - private Disposable mSendReqDisposable = null; - - public BusTrajectoryManager() { - mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(-1, "", - "", "", "", "", 0, "", - "", "", "", "", 0); + fun release(){ + TrajectoryManager.removeListener(TAG) } /** * 同步Bus路线信息 */ - public void syncTrajectoryInfo() { - BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); - if (LoginStatusManager.isLogin() && routesResult != null - && OrderModel.getInstance().getCurrentStationIndex() == 0 - && !OrderModel.getInstance().isGoingToNextStation()) { - CallerLogger.d(M_BUS + TAG, "syncTrajectoryInfo() start."); - startTrajReqLoop(); + fun syncTrajectoryInfo() { + val routesResult = OrderModel.getInstance().busRoutesResult + if (isLogin() && routesResult != null && OrderModel.getInstance().currentStationIndex == 0 && !OrderModel.getInstance().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 ("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(); - } + override fun onDownLoadSuccess(lineId: Long) { + stopTrajReqLoop() } - private void setupAutoPilotLine() { - BusRoutesResult routesResult = OrderModel.getInstance().getBusRoutesResult(); + override fun onDownLoadReady(lineId: Long) { + super.onDownLoadReady(lineId) + // 收到ssm的自动驾驶变为ready,再次下发轨迹下载.解决:域控重启,或者102域控启动太早,107节点初始化未完成导致的轨迹未进行下载。 + syncTrajectoryInfo() + } + + private fun setupAutoPilotLine() { + val routesResult = OrderModel.getInstance().busRoutesResult if (routesResult == null) { - CallerLogger.e(M_BUS + TAG, - "setupAutoPilotLine(): routesResult is null."); - return; + e( + SceneConstant.M_BUS + TAG, + "setupAutoPilotLine(): routesResult is null." + ) + return } else { if (mAutoPilotLine == null) { - mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine( - routesResult.getLineId(), routesResult.getName(), - routesResult.csvFileUrl, routesResult.csvFileMd5, - routesResult.txtFileUrl, routesResult.txtFileMd5, - routesResult.contrailSaveTime, routesResult.carModel, - routesResult.csvFileUrlDPQP, routesResult.csvFileMd5DPQP, - routesResult.txtFileUrlDPQP, routesResult.txtFileMd5DPQP, - routesResult.contrailSaveTimeDPQP); + mAutoPilotLine = AutoPilotLine( + routesResult.lineId.toLong(), routesResult.name, + routesResult.csvFileUrl, routesResult.csvFileMd5, + routesResult.txtFileUrl, routesResult.txtFileMd5, + routesResult.contrailSaveTime, routesResult.carModel, + routesResult.csvFileUrlDPQP, routesResult.csvFileMd5DPQP, + routesResult.txtFileUrlDPQP, routesResult.txtFileMd5DPQP, + routesResult.contrailSaveTimeDPQP + ) } else { - mAutoPilotLine.setLineId(routesResult.getLineId()); - mAutoPilotLine.setLineName(routesResult.getName()); - mAutoPilotLine.setTrajUrl(routesResult.csvFileUrl==null?"":routesResult.csvFileUrl); - mAutoPilotLine.setTrajMd5(routesResult.csvFileMd5==null?"":routesResult.csvFileMd5); - mAutoPilotLine.setStopUrl(routesResult.txtFileUrl==null?"":routesResult.txtFileUrl); - mAutoPilotLine.setStopMd5(routesResult.txtFileMd5==null?"":routesResult.txtFileMd5); - mAutoPilotLine.setTimestamp(routesResult.contrailSaveTime); - mAutoPilotLine.setVehicleModel(routesResult.carModel==null?"":routesResult.carModel); + mAutoPilotLine!!.lineId = routesResult.lineId.toLong() + mAutoPilotLine!!.lineName = routesResult.name + mAutoPilotLine!!.trajUrl = + if (routesResult.csvFileUrl == null) "" else routesResult.csvFileUrl + mAutoPilotLine!!.trajMd5 = + if (routesResult.csvFileMd5 == null) "" else routesResult.csvFileMd5 + mAutoPilotLine!!.stopUrl = + 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() { - if (mAutoPilotLine == null) return; - mAutoPilotLine.setLineId(-1); - mAutoPilotLine.setLineName(""); - mAutoPilotLine.setTrajUrl(""); - mAutoPilotLine.setTrajMd5(""); - mAutoPilotLine.setStopUrl(""); - mAutoPilotLine.setStopMd5(""); - mAutoPilotLine.setTimestamp(0); - mAutoPilotLine.setVehicleModel(""); - mAutoPilotLine.setTrajUrl_dpqp(""); - mAutoPilotLine.setTrajMd5_dpqp(""); - mAutoPilotLine.setStopUrl_dpqp(""); - mAutoPilotLine.setStopMd5_dpqp(""); - mAutoPilotLine.setTimestamp_dpqp(0); + private fun clearAutoPilotLine() { + if (mAutoPilotLine == null) return + mAutoPilotLine!!.lineId = -1 + mAutoPilotLine!!.lineName = "" + mAutoPilotLine!!.trajUrl = "" + mAutoPilotLine!!.trajMd5 = "" + mAutoPilotLine!!.stopUrl = "" + mAutoPilotLine!!.stopMd5 = "" + mAutoPilotLine!!.timestamp = 0 + mAutoPilotLine!!.vehicleModel = "" + mAutoPilotLine!!.trajUrl_dpqp = "" + mAutoPilotLine!!.trajMd5_dpqp = "" + mAutoPilotLine!!.stopUrl_dpqp = "" + mAutoPilotLine!!.stopMd5_dpqp = "" + mAutoPilotLine!!.timestamp_dpqp = 0 } - private void startTrajReqLoop() { - if (mSendReqDisposable != null && !mSendReqDisposable.isDisposed()) { - return; + private fun startTrajReqLoop() { + 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() { + fun stopTrajReqLoop() { 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() { + private fun sendTrajectoryReq() { if (mAutoPilotLine == null) { - CallerLogger.e(M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!"); - return; + e(SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!") + return } - OchChainLogManager.writeChainLog("轨迹监控","sendTrajectoryReq() 下发轨迹 轨迹id"+mAutoPilotLine.getLineId(), true, OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY); - CallerAutoPilotControlManager.INSTANCE.sendTrajectoryDownloadReq(mAutoPilotLine); - CallerLogger.d(M_BUS + TAG, "sendTrajectoryReq(): " - + GsonUtils.toJson(mAutoPilotLine)); + writeChainLog( + "轨迹监控", + "sendTrajectoryReq() 下发轨迹 轨迹id" + mAutoPilotLine!!.lineId, + true, + OchChainLogManager.EVENT_KEY_INFE_WITH_TRAJECTORY + ) + sendTrajectoryDownloadReq(mAutoPilotLine!!) + d( + SceneConstant.M_BUS + TAG, "sendTrajectoryReq(): " + + GsonUtils.toJson(mAutoPilotLine) + ) } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt index 7469c5c8b9..702590f17b 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ShuttleDriverProvider.kt @@ -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() } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt index d21e4be28e..7353e402d8 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/OrderModel.kt @@ -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() } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/BusPresenter.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/BusPresenter.kt index ec938a5400..a0a0f4319f 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/BusPresenter.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/BusPresenter.kt @@ -57,7 +57,7 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), if (isLogin()) { //OrderModel.queryBusRoutes() } else { - BusTrajectoryManager.getInstance().stopTrajReqLoop() + BusTrajectoryManager.stopTrajReqLoop() OrderModel.closeBeautificationMode() } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/util/BusTrajectoryManager.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/util/BusTrajectoryManager.kt index 8e50bfdf4f..d0159b732b 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/util/BusTrajectoryManager.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/util/BusTrajectoryManager.kt @@ -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) + ) } + } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/TaxiUnmannedDriverProvider.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/TaxiUnmannedDriverProvider.kt index bf4001fb40..6d3b58c964 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/TaxiUnmannedDriverProvider.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/TaxiUnmannedDriverProvider.kt @@ -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.bizswitch.SwitchBizView import com.mogo.och.unmanned.taxi.utils.TaxiAnalyticsManager +import com.mogo.och.unmanned.taxi.utils.TaxiTrajectoryManager /** * @author congtaowang @@ -38,11 +39,13 @@ class TaxiUnmannedDriverProvider : CommonServiceImpl() { ochTaxiFragment = TaxiFragment() } OchAutopilotAnalytics.ochEventKey = TaxiAnalyticsManager.getInstance() + TaxiTrajectoryManager.load() return ochTaxiFragment!! } override fun resetFragment() { CallerLogger.d(SceneConstant.M_TAXI + tag, "resetFragment") + TaxiTrajectoryManager.releast() OchAutopilotAnalytics.ochEventKey = null ochTaxiFragment = null } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt index 404483b968..c66c60ada7 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt @@ -279,16 +279,6 @@ object TaxiTaskModel { private val mMogoAutopilotStatusListener: 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) { i(TAG, "onAutopilotStatusResponse autopilotsState= $state") diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiTrajectoryManager.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiTrajectoryManager.kt index 3b889a749f..9cbb4082b6 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiTrajectoryManager.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiTrajectoryManager.kt @@ -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.util.GsonUtils 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.writeChainLog import com.mogo.och.unmanned.taxi.bean.TrajectoryListRespBean @@ -30,7 +32,7 @@ import java.util.concurrent.TimeUnit * Taxi轨迹管理:给MEC下发用于轨迹下载的信息 * Created on 2022/6/22 */ -object TaxiTrajectoryManager { +object TaxiTrajectoryManager : ITrajectoryListListener { private val TAG: String = TaxiTrajectoryManager::class.java.simpleName @@ -52,6 +54,14 @@ object TaxiTrajectoryManager { 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) { - onAutopilotGuardian(guardianInfo) + override fun onDownLoadStart(lineId: Long) { + stopTrajReqLoop(); } - /** - * 接口MEC反馈的常规信息(MAP v2.5.0新增轨迹相关信息) - * @param guardianInfo - */ - fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) { - if (guardianInfo == null || !guardianInfo.hasCode()) return - 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 - ) - } + override fun onDownLoadSuccess(lineId: Long) { + stopTrajReqLoop(); + } + + override fun onDownLoadReady(lineId: Long) { + syncTrajectoryInfo() } private fun setupAutoPilotLine() {