diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/line/LineManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/line/LineManager.kt index 6073d7b725..9456be06d8 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/line/LineManager.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/line/LineManager.kt @@ -38,24 +38,31 @@ object LineManager : CallerBase() { * 线路信息 */ @JvmStatic - var lineInfos: LineInfo? = null + private var _lineInfos: LineInfo? = null + + val lineInfos:LineInfo? + @JvmStatic + get() = _lineInfos /** * 启动自驾信息 */ @JvmStatic - var contraiInfo: ContraiInfo? = null - private set + private var _contraiInfo: ContraiInfo? = null + val contraiInfo:ContraiInfo? + @JvmStatic + get() = _contraiInfo + /** * 起始站点 */ - var startStation: BusStationBean? = null + private var startStation: BusStationBean? = null /** * 结束站点 */ - var endStation: BusStationBean? = null + private var endStation: BusStationBean? = null var isReStartAutopilot = true @@ -77,7 +84,7 @@ object LineManager : CallerBase() { } fun setContraiInfo(contraiInfo: ContraiInfo?){ - this.contraiInfo = contraiInfo + this._contraiInfo = contraiInfo setAutopilotControlParameters() } @@ -87,9 +94,9 @@ object LineManager : CallerBase() { clearGlobalTrajectory(true) CallerOrderListenerManager.invokeOrderLineUpdate("") } - this.lineInfos = lineInfo + this._lineInfos = lineInfo setAutopilotControlParameters() - this.lineInfos?.let { line -> + this._lineInfos?.let { line -> if (ProjectUtils.isSaas()) { val sb = StringBuilder() sb.append(line.lineName) @@ -101,6 +108,10 @@ object LineManager : CallerBase() { } } + fun getStations(): Pair { + return Pair(startStation, endStation) + } + fun getStations(function: (start: BusStationBean, end: BusStationBean) -> Unit) { startStation?.let { start -> endStation?.let { end -> @@ -111,25 +122,10 @@ object LineManager : CallerBase() { OchChainLogManager.writeChainLog("异常情况","startStation:${startStation}__endStation:${endStation}") } - fun getStationsWithContrai(function: (start: BusStationBean, end: BusStationBean, contrai: ContraiInfo) -> Unit) { - startStation?.let { start -> - endStation?.let { end -> - contraiInfo?.let { contrai -> - function.invoke(start, end, contrai) - return - } - } - } - OchChainLogManager.writeChainLog( - "异常情况", - "startStation:${startStation}__endStation:${endStation}__contraiInfo:${contraiInfo}" - ) - } - fun getStationsWithLine(function: (start: BusStationBean, end: BusStationBean, lineInfo: LineInfo) -> Unit) { startStation?.let { start -> endStation?.let { end -> - lineInfos?.let { line -> + _lineInfos?.let { line -> function.invoke(start, end, line) return } @@ -137,15 +133,15 @@ object LineManager : CallerBase() { } OchChainLogManager.writeChainLog( "异常情况", - "startStation:${startStation}__endStation:${endStation}__lineInfos:${lineInfos}" + "startStation:${startStation}__endStation:${endStation}__lineInfos:${_lineInfos}" ) } fun getStationsWithLineAndContrai(function: (start: BusStationBean, end: BusStationBean, lineInfo: LineInfo, contrai: ContraiInfo) -> Unit) { startStation?.let { start -> endStation?.let { end -> - lineInfos?.let { line -> - contraiInfo?.let { contrai -> + _lineInfos?.let { line -> + _contraiInfo?.let { contrai -> function.invoke(start, end, line, contrai) return } @@ -154,17 +150,26 @@ object LineManager : CallerBase() { } OchChainLogManager.writeChainLog( "异常情况", - "startStation:${startStation}__endStation:${endStation}__lineInfos:${lineInfos}__contraiInfo:${contraiInfo}" + "startStation:${startStation}__endStation:${endStation}__lineInfos:${_lineInfos}__contraiInfo:${_contraiInfo}" ) } fun getStartStation(function: (start: BusStationBean) -> Unit) { startStation?.let { start -> function.invoke(start) + return } OchChainLogManager.writeChainLog("异常情况", "startStation:${startStation}") } + fun getLineInfo(function: (lineInfo: LineInfo) -> Unit){ + _lineInfos?.let { line-> + function.invoke(line) + return + } + OchChainLogManager.writeChainLog("异常情况", "lineInfos:${_lineInfos}") + } + override fun doSomeAfterAddListener(tag: String, listener: ILineCallback) { super.doSomeAfterAddListener(tag, listener) @@ -213,7 +218,7 @@ object LineManager : CallerBase() { } fun drawGlobalTrajectory(): Pair { - if (lineInfos == null) { + if (_lineInfos == null) { return Pair(false, "请设置正确线路或订单") } return CallerMapGlobalTrajectoryDrawManager.drawGlobalTrajectory().apply { @@ -278,20 +283,19 @@ object LineManager : CallerBase() { OchAutopilotAnalytics.triggerClickStartAutopilotTime(System.currentTimeMillis()) //1、判断轨迹url是否可用 - if(contraiInfo==null){ + if(_contraiInfo==null){ ToastUtils.showLong("无发布轨迹, 请发布后重试") return }else{ - if (FunctionBuildConfig.isPassStartAutopilotCommand - && TextUtils.isEmpty(contraiInfo!!.csvFileUrl) - && TextUtils.isEmpty(contraiInfo!!.csvFileMd5) + && TextUtils.isEmpty(_contraiInfo!!.csvFileUrl) + && TextUtils.isEmpty(_contraiInfo!!.csvFileMd5) ) { ToastUtils.showLong("无发布轨迹, 请发布后重试") e( TAG, "isPassStartAutopilotCommand = " + FunctionBuildConfig.isPassStartAutopilotCommand - + "busRoutesResult.csvFileUrl = " + LineManager.contraiInfo!!.csvFileUrl + + "busRoutesResult.csvFileUrl = " + LineManager._contraiInfo!!.csvFileUrl ) return } @@ -303,7 +307,7 @@ object LineManager : CallerBase() { } // 3、距离轨迹15m计算 - val resion = OchAutoPilotManager.canStartAutoPilotByDistance(contraiInfo!!.lineId) + val resion = OchAutoPilotManager.canStartAutoPilotByDistance(_contraiInfo!!.lineId) if (!StringUtils.isEmpty(resion)) { ToastUtils.showShort(resion) VoiceNotice.showNotice(resion) @@ -348,13 +352,13 @@ object LineManager : CallerBase() { } fun triggerStartServiceEvent(send: Boolean,source:Int) { - getStations { start, end -> + getStationsWithLine { start, end, lineInfo -> OchAutopilotAnalytics.triggerStartAutopilotEvent( isReStartAutopilot, send, start.name, end.name, - lineInfos!!.lineId.toInt(), + lineInfo.lineId.toInt(), "", System.currentTimeMillis(), source diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java deleted file mode 100644 index 5b64118b83..0000000000 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/callback/IBusADASStatusCallback.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mogo.och.weaknet.callback; - -import com.mogo.och.data.bean.BusStationBean; - -import java.util.List; - -/** - * Created on 2021/9/8 - *

- * Model->Presenter回调:ADAS相关(自动驾驶状态回调,到达终点等等) - */ -public interface IBusADASStatusCallback { - //自驾返回失败 - void onStartAdasFailure(); - - void startOpenAutopilot(); - - void updateBusTaskStatus(String lineName, String lintTime, - List stationList, - int arrivingOrArrivedIndex, - boolean isArrived); - - - /** - * 结束清理一遍、选择任务后清理一遍 - */ - void clearBusStationsMarkers(); -} diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/LineModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/LineModel.kt index 3b6775d2ae..f67787e013 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/LineModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/LineModel.kt @@ -417,14 +417,14 @@ object LineModel { } OchChainLogManager.writeChainLogDb("滑动出发", "task:${currentTask}__taskId:${currentTask?.taskId}") // 设置滑动出发任务 - LineManager.lineInfos?.lineName?.let { lineName-> + LineManager.getLineInfo { lineInfo -> EventRepository.saveEventTaskLeaveSite( task.taskId!!, task.lineId!!, it.siteId.toLong(), it.seq, task.taskStartTime, - lineName + lineInfo.lineName ) } } @@ -439,8 +439,9 @@ object LineModel { ) } } + val (startStation, endStation) = LineManager.getStations() val changeInfo = - "taskId:${currentTask?.taskId}--lineId:${currentTask?.lineId}--currentStationName:${LineManager.startStation?.name}--finalNextStationName:${LineManager.endStation?.name}" + "taskId:${currentTask?.taskId}--lineId:${currentTask?.lineId}--currentStationName:${startStation?.name}--finalNextStationName:${endStation?.name}" OchChainLogManager.writeChainLog("滑动出发", changeInfo) } // 到站 @@ -454,7 +455,7 @@ object LineModel { if (task.taskId!=null&&task.lineId!=null) { TaskSiteRepository.updateDrivingStatusAndLeave(task.taskId!!,start.siteId.toLong(),TaskSiteDataBean.drivingStatusPassed,false) // 设置到站任务 - LineManager.lineInfos?.let {lineInfo -> + LineManager.getLineInfo { lineInfo -> EventRepository.saveEventTaskArriveSite(task.taskId!!,task.lineId!!,start.siteId.toLong(),start.seq,task.taskStartTime,lineInfo.lineName) } } @@ -481,7 +482,8 @@ object LineModel { mBusLinesCallbackMap.forEach {callback-> callback.value.onArriveStationSuccess() } - val startStation = LineManager.endStation + + val startStation = LineManager.getStations().second if(startStationIndex+1< it.size){ val endStation = it[startStationIndex+1] LineManager.setStartAndEndStation(startStation,endStation) @@ -509,8 +511,8 @@ object LineModel { currentTask?.let {task-> if (task.taskId!=null&&task.lineId!=null) { TaskRepository.endTask(task.taskId!!) - LineManager.lineInfos?.lineName?.let {lineName-> - EventRepository.saveEventTaskEnd(task.taskId!!,task.lineId!!,task.taskStartTime,lineName) + LineManager.getLineInfo { lineInfo -> + EventRepository.saveEventTaskEnd(task.taskId!!,task.lineId!!,task.taskStartTime,lineInfo.lineName) } } } @@ -518,7 +520,7 @@ object LineModel { OchChainLogManager.writeChainLog("结束任务", changeInfo) currentTask = null - LineManager.lineInfos = null + LineManager.setLineInfo(null) LineManager.setStartAndEndStation(null,null) stationList = mutableListOf() startStationIndex = 0 @@ -537,17 +539,16 @@ object LineModel { fun setDemoMode() { // 美化是否开始 if (FunctionBuildConfig.isDemoMode) { //行驶过程中设置美化 - if (LineManager.startStation!=null&&LineManager.startStation!!.isLeaving) { + val (startStation, _) = LineManager.getStations() + if (startStation!=null&&startStation.isLeaving) { OrderModel.startBeautificationMode() d(M_BUS + TAG, "美化模式-ignore:置为true(每次滑动出发)") } else if (startStationIndex > 0 && startStationIndex < stationList!!.size - 1) { //美化模式下 中间站点到站 引导线要一直绘制,所以此处不出强制绘制不传false CallerAutoPilotControlManager.setIPCDemoMode(false) d(M_BUS + TAG, "美化模式-ignore:false(到达中间站)") - OrderModel.clearStartAutopilotTag() } else { OrderModel.closeBeautificationMode() - OrderModel.clearStartAutopilotTag() } } } 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 e4b1000006..4abdb8a162 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 @@ -2,8 +2,6 @@ package com.mogo.och.weaknet.model import android.annotation.SuppressLint import android.content.Context -import android.text.TextUtils -import com.elegant.network.utils.GsonUtil import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.map.MogoLocation @@ -15,39 +13,22 @@ 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.Companion.M_BUS import com.mogo.eagle.core.utilcode.util.CoordinateUtils -import com.mogo.eagle.core.utilcode.util.StringUtils import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.common.module.biz.login.LoginStatusManager -import com.mogo.och.common.module.callback.OchAdasStartFailureCallback -import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager -import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation -import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.canStartAutoPilotByDistance -import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.canStartAutoPilotSSM -import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.startAutoPilot -import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics import com.mogo.och.common.module.manager.autopilot.line.LineManager import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager -import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager -import com.mogo.och.common.module.manager.socket.cloud.AbnormalFactorsLoopManager import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager -import com.mogo.och.common.module.manager.socket.cloud.action.OperateAction -import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener -import com.mogo.och.common.module.manager.socket.lan.LanSocketManager import com.mogo.och.common.module.manager.socket.lan.LedScreenManager -import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType -import com.mogo.och.common.module.manager.socket.lan.bean.TaskDetailsMsg import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.common.module.utils.NumberFormatUtil import com.mogo.och.common.module.utils.OCHThreadPoolManager import com.mogo.och.common.module.utils.ResourcesUtils import com.mogo.och.common.module.utils.RxUtils -import com.mogo.och.common.module.voice.VoiceNotice.showNotice import com.mogo.och.shuttle.weaknet.R -import com.mogo.och.weaknet.callback.IBusADASStatusCallback import com.mogo.och.weaknet.constant.BusConst import com.mogo.och.weaknet.util.BusTrajectoryManager import com.mogo.och.weaknet.util.ShuttleVoiceManager @@ -65,7 +46,6 @@ object OrderModel { private var mContext: Context? = null - private var mADASStatusCallback: IBusADASStatusCallback? = null /** * 用来表示是否正在开往下一站 */ @@ -75,40 +55,18 @@ object OrderModel { @Volatile private var isArrivedStation = false - //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0 - @Volatile - private var firstStartAutopilot = 0 - - private const val VEHICLE_TYPE: Int = 10 - @JvmStatic fun init() { mContext = AbsMogoApplication.getApp() + ThirdDeviceData.init() + // 加载核销模块 TicketModel.load() // 定位监听 OchLocationManager.addGCJ02Listener(TAG, 5, mMapLocationListener) - //开启自驾后 异常信息返回 - OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(mAdasStartFailureListener) - - //监听运营消息 - OCHSocketMessageManager.registerSocketMessageListener( - OCHSocketMessageManager.msgMonitorType, - OperateAction(true) - ) - - // 长链接监听 - AbnormalFactorsLoopManager.startLoopAbnormalFactors(AbsMogoApplication.getApp()) - - //监听乘客屏发来的消息 - LanSocketManager.registerSocketMessageListener( - DPMsgType.TYPE_TASK_DETAILS.type, - taskDetailsMsgListener - ) - RxUtils.errCatch() } @@ -116,43 +74,14 @@ object OrderModel { fun release() { // 注销定位监听 + ThirdDeviceData.release() + TicketModel.release() OchLocationManager.removeGCJ02Listener(TAG) - OCHAdasAbilityManager.getInstance().setAdasStartFailureCallback(null) - - OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgMonitorType) - - AbnormalFactorsLoopManager.stopLoopAbnormalFactors() - //监听乘客屏发来的消息 - LanSocketManager.unRegisterSocketMessageListener( - DPMsgType.TYPE_TASK_DETAILS.type, - taskDetailsMsgListener - ) } - // 乘客屏请求线路信息 - private val taskDetailsMsgListener = object : ILanMessageListener { - override fun targetLan(): Class = TaskDetailsMsg::class.java - override fun onLanMsgReceived(taskDetailsMsg: TaskDetailsMsg?) = ThirdDeviceData.sendTaskDetailsToClients() - } - - @JvmStatic - fun setAdasStatusCallback(callback: IBusADASStatusCallback?) { - this.mADASStatusCallback = callback - } - - private val mAdasStartFailureListener: OchAdasStartFailureCallback = - object : OchAdasStartFailureCallback { - - override fun onStartAutopilotFailure(startFailedCode: String, startFailedMessage: String) { - if (!FunctionBuildConfig.isDemoMode) { - e(M_BUS + TAG, "mAdasStartFailureListener = $startFailedMessage") - mADASStatusCallback?.onStartAdasFailure() - } - } - } // 自车定位 private val mMapLocationListener = object : IMoGoChassisLocationGCJ02Listener { @@ -170,20 +99,15 @@ object OrderModel { //根据围栏判断,是否到达站点 private fun judgeArrivedStation(location: MogoLocation) { - if (LineManager.endStation==null) { - e(M_BUS + TAG, "未设置终点坐标") - OchChainLogManager.writeChainLog("shuttle弱网","围栏距离判断 未设置终点坐标") - return - } - LineManager.endStation?.let { - val startLon = it.gcjLon - val startLat = it.gcjLat + LineManager.getStations { start, end -> + val startLon = end.gcjLon + val startLat = end.gcjLat val distance = CoordinateUtils.calculateLineDistance( startLon, startLat, location.longitude, location.latitude ) if (distance <= BusConst.ARRIVE_AT_END_STATION_DISTANCE) { - d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = $distance to ${it.name}") + d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = $distance to ${end.name}") onArriveAt(null, "兜底:根据定位计算到站") } } @@ -202,7 +126,6 @@ object OrderModel { LineManager.setLineInfo(null) updateBusStatus() closeBeautificationMode() - clearStartAutopilotTag() removeTipRunnables() }else{ updateBusStatus() @@ -210,65 +133,11 @@ object OrderModel { } } - /** - * 更新正在运行的任务UI - */ - private fun updateBusTaskStatus() { - var arrivingOrArrivedStationIndex = 0 //已经到站或者即将到站的索引呢 - if(LineModel.stationList.isNullOrEmpty()){ - OchChainLogManager.writeChainLog("更新UI出错","${LineModel.currentTask}") - return - } - LineModel.stationList?.let { - for (i in it.indices) { - val station = it[i] - - if (i == 0) { // 首发站 显示在最上面 - if (station.drivingStatus == BusConst.STATION_STATUS_STOPPED - && !station.isLeaving - ) { //到达第一站 - arrivingOrArrivedStationIndex = 0 - break - } - } else { - val preStation = it[i - 1] - if ((station.drivingStatus == BusConst.STATION_STATUS_STOPPED && !station.isLeaving) - || (station.drivingStatus == BusConst.STATION_STATUS_ARRIVING - && preStation.isLeaving) - ) { - //到站未离开 | 即将到站 显示在最中间 - arrivingOrArrivedStationIndex = i - break - } - } - } - val arrivingOrArrivedStation = it[arrivingOrArrivedStationIndex] - val lineTime = LineModel.getTaskTime() - LineManager.lineInfos?.let {lineInfo-> - if (arrivingOrArrivedStationIndex == 0 || ( - arrivingOrArrivedStation.drivingStatus == BusConst.STATION_STATUS_STOPPED - && !arrivingOrArrivedStation.isLeaving) - ) { - mADASStatusCallback?.updateBusTaskStatus( - lineInfo.lineName, lineTime, - it, arrivingOrArrivedStationIndex, true - ) - } else { - mADASStatusCallback?.updateBusTaskStatus( - lineInfo.lineName, lineTime, - it, arrivingOrArrivedStationIndex, false - ) - } - } - - } - } - /** * 重置路线站点状态--结束路线,当前路线恢复到始发站 */ @JvmStatic - fun abortTask() { + fun completeTask() { OCHThreadPoolManager.getsInstance().execute { d(M_BUS + TAG, "结束当前路线abortTask") @@ -277,7 +146,6 @@ object OrderModel { ThirdDeviceData.endTask() LineModel.endTask() ThirdDeviceData.sendTaskDetailsToClients() - mADASStatusCallback?.clearBusStationsMarkers() removeTipRunnables() ShuttleVoiceManager.endOrderBus() // 取消自驾 @@ -291,8 +159,6 @@ object OrderModel { if (CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING ) { LineManager.startAutopilot() - } else { - firstStartAutopilot = 0 } } @@ -318,17 +184,13 @@ object OrderModel { } /** - * 开启自动驾驶到下一站 + * 滑动出发 */ @JvmStatic - fun autoDriveToNextStation() { + fun driveToNextStation() { if (LineModel.isLastStation()==true) { // 当前站是最后一站,结束当前行程 - abortTask() - return - } - if (LineManager.endStation==null) { - OchChainLogManager.writeChainLog("滑动出发", "未设置终点坐标") + completeTask() return } isArrivedStation = false @@ -370,9 +232,6 @@ object OrderModel { ThirdDeviceData.sendTaskDetailsToClients() - //更新bus路线面板 - updateBusTaskStatus() - //需放在currentStationIndex赋值之后 BusTrajectoryManager.getInstance().syncTrajectoryInfo() } @@ -430,14 +289,6 @@ object OrderModel { UiThreadHandler.removeCallbacks(tip1Runnable) } - fun clearStartAutopilotTag() { - firstStartAutopilot = 0 - } - - @JvmStatic - val isRestartAutopilot: Boolean - get() = firstStartAutopilot > 1 - /** * 到站 * @@ -445,7 +296,7 @@ object OrderModel { */ @JvmStatic fun onArriveAt(data: ArrivedStation?, type: String) { - if (LineManager.endStation==null) { + if (LineManager.getStations().second==null) { e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束") OchChainLogManager.writeChainLog("shuttle弱网","$type 行程日志-到站异常,取消后续操作结束") return @@ -453,29 +304,32 @@ object OrderModel { //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 - if (data != null && data.endLocation != null) { - val latitude = NumberFormatUtil.cutOutNumber(data.endLocation.latitude, 5) //wgs - val longitude = NumberFormatUtil.cutOutNumber(data.endLocation.longitude, 5) + LineManager.getStations { start, end -> + if (data != null && data.endLocation != null) { + val latitude = NumberFormatUtil.cutOutNumber(data.endLocation.latitude, 5) //wgs + val longitude = NumberFormatUtil.cutOutNumber(data.endLocation.longitude, 5) - val arriveLat = NumberFormatUtil.cutOutNumber(LineManager.endStation!!.lat, 5) - val arriveLon = NumberFormatUtil.cutOutNumber(LineManager.endStation!!.lon, 5) + val arriveLat = NumberFormatUtil.cutOutNumber(end.lat, 5) + val arriveLon = NumberFormatUtil.cutOutNumber(end.lon, 5) - if (latitude != arriveLat || longitude != arriveLon) { - e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致") - OchChainLogManager.writeChainLog("shuttle弱网","$type 行程日志-到站拦截,到站坐标不一致") - return + if (latitude != arriveLat || longitude != arriveLon) { + e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致") + OchChainLogManager.writeChainLog("shuttle弱网","$type 行程日志-到站拦截,到站坐标不一致") + return@getStations + } } + + if (isArrivedStation) return@getStations + + OchChainLogManager.writeChainLog("触发进站", type) + isArrivedStation = true + isGoingToNextStation = false + + ThirdDeviceData.arriveStation() + LineModel.arrivedStation() + updateBusStatus() } - if (isArrivedStation) return - - OchChainLogManager.writeChainLog("触发进站", type) - isArrivedStation = true - isGoingToNextStation = false - - ThirdDeviceData.arriveStation() - LineModel.arrivedStation() - updateBusStatus() } // 登出 diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt index 9eb8cb9dee..3be49474bd 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/ThirdDeviceData.kt @@ -1,14 +1,20 @@ package com.mogo.och.weaknet.model +import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS import com.mogo.eagle.core.utilcode.util.GsonUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler 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.socket.cloud.AbnormalFactorsLoopManager +import com.mogo.och.common.module.manager.socket.cloud.OCHSocketMessageManager +import com.mogo.och.common.module.manager.socket.cloud.action.OperateAction +import com.mogo.och.common.module.manager.socket.lan.ILanMessageListener import com.mogo.och.common.module.manager.socket.lan.LanSocketManager import com.mogo.och.common.module.manager.socket.lan.LedScreenManager import com.mogo.och.common.module.manager.socket.lan.bean.BusinessType +import com.mogo.och.common.module.manager.socket.lan.bean.DPMsgType import com.mogo.och.common.module.manager.socket.lan.bean.TaskDetailsMsg import com.mogo.och.data.bean.BusRoutesResult import com.mogo.och.data.bean.BusTransferData @@ -22,41 +28,79 @@ object ThirdDeviceData { @JvmStatic val busRoutesResult: BusRoutesResult = BusRoutesResult() - fun leaveStation(){ - LineManager.getStations { start, end -> + fun init() { + //监听运营消息 + OCHSocketMessageManager.registerSocketMessageListener( + OCHSocketMessageManager.msgMonitorType, + OperateAction(true) + ) + // 长链接监听 + AbnormalFactorsLoopManager.startLoopAbnormalFactors(AbsMogoApplication.getApp()) + + //监听乘客屏发来的消息 + LanSocketManager.registerSocketMessageListener( + DPMsgType.TYPE_TASK_DETAILS.type, + taskDetailsMsgListener + ) + } + + fun release() { + + OCHSocketMessageManager.releaseSocketMessageListener(OCHSocketMessageManager.msgMonitorType) + + AbnormalFactorsLoopManager.stopLoopAbnormalFactors() + + //监听乘客屏发来的消息 + LanSocketManager.unRegisterSocketMessageListener( + DPMsgType.TYPE_TASK_DETAILS.type, + taskDetailsMsgListener + ) + } + + // 乘客屏请求线路信息 + private val taskDetailsMsgListener = object : ILanMessageListener { + override fun targetLan(): Class = TaskDetailsMsg::class.java + override fun onLanMsgReceived(taskDetailsMsg: TaskDetailsMsg?) = sendTaskDetailsToClients() + } + + // 离站 + fun leaveStation() { + LineManager.getStationsWithLine { start, end, lineInfo -> UiThreadHandler.postDelayed({ //延迟10s播报 ShuttleVoiceManager.leaveStationBus(end.name, end.nameKr) }, BusConst.DELAY_10S) //给bus外屏发送 LedScreenManager.sendTripInfo2Led( LedScreenManager.LEAVE_STATION, - LineManager.lineInfos!!.lineName, + lineInfo.lineName, start.name, end.name, - LineModel.isLastStation()==true + LineModel.isLastStation() == true ) } } - fun arriveStation(){ - LineManager.getStations { start, end -> + //到站 + fun arriveStation() { + LineManager.getStationsWithLine { start, end, lineInfo -> ShuttleVoiceManager.arrivedStationBus(end.name, end.nameKr) //给bus外屏发送 LedScreenManager.sendTripInfo2Led( LedScreenManager.ARRIVE_STATION, - LineManager.lineInfos!!.lineName, + lineInfo.lineName, start.name, end.name, - LineModel.isLastStation()==true + LineModel.isLastStation() == true ) } } - fun endTask(){ - LineManager.lineInfos?.let { + //结束任务 + fun endTask() { + LineManager.getLineInfo {lineInfo -> LedScreenManager.sendTripInfo2Led( LedScreenManager.END_TRIP, - it.lineName, + lineInfo.lineName, "", "", false @@ -65,21 +109,23 @@ object ThirdDeviceData { } fun sendTaskDetailsToClients() { - if (LineManager.lineInfos==null|| LineModel.currentTask ==null|| LineModel.stationList.isNullOrEmpty()) { + if (LineManager.lineInfos == null || LineModel.currentTask == null || LineModel.stationList.isNullOrEmpty()) { val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, null) val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) LanSocketManager.sendMsgToClient(msg) - }else{ - busRoutesResult.setSite(LineModel.stationList) - busRoutesResult.lineId = LineManager.lineInfos!!.lineId.toInt() - busRoutesResult.name = LineManager.lineInfos!!.lineName - busRoutesResult.taskId = LineModel.currentTask!!.taskId!!.toInt() - busRoutesResult.taskTime = LineModel.currentTask!!.taskStartTime!! - val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, busRoutesResult) - val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) - d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) - LanSocketManager.sendMsgToClient(msg) + } else { + LineManager.getLineInfo {lineInfo -> + busRoutesResult.setSite(LineModel.stationList) + busRoutesResult.lineId = lineInfo.lineId.toInt() + busRoutesResult.name = lineInfo.lineName + busRoutesResult.taskId = LineModel.currentTask!!.taskId!!.toInt() + busRoutesResult.taskTime = LineModel.currentTask!!.taskStartTime!! + val data = BusTransferData(if (LoginStatusManager.isLogin()) 1 else 0, busRoutesResult) + val msg = TaskDetailsMsg(GsonUtils.toJson(data), BusinessType.shuttle) + d(M_BUS + TAG, "sendTaskDetailsToClients = " + GsonUtils.toJson(msg)) + LanSocketManager.sendMsgToClient(msg) + } } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/TicketModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/TicketModel.kt index 5c1fb34ab3..268a0a1048 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/TicketModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/model/TicketModel.kt @@ -97,7 +97,7 @@ object TicketModel : IOchOnMessageListener{ } private fun selectWriteOffCount(){ - LineManager.endStation?.let { endStation-> + LineManager.getStations().second?.let { endStation-> LineModel.currentTask?.let { currentTask-> OrderServiceManager.queryBusTaskByLineId(AbsMogoApplication.getApp(), "${currentTask.taskId}", diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt index 26b9daed4a..a6e3d88eea 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/bizswitch/SwtichBizeModel.kt @@ -5,6 +5,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.och.weaknet.callback.IBusLinesCallback import com.mogo.och.weaknet.model.LineModel +import com.mogo.och.weaknet.model.OrderModel import com.mogo.och.weaknet.repository.db.bean.LineDataBean /** @@ -28,7 +29,7 @@ class SwtichBizeModel : ViewModel(), IBusLinesCallback { LineModel.setBusLinesCallback(TAG, this) this.viewCallback?.showLoadingView() ThreadUtils.getIoPool().execute { - LineModel.loadStartedTaskAndDefaultInfo() + OrderModel.queryBusRoutes() } } @@ -77,7 +78,7 @@ class SwtichBizeModel : ViewModel(), IBusLinesCallback { override fun onCompleteTask() { super.onCompleteTask() ThreadUtils.getIoPool().execute { - LineModel.loadStartedTaskAndDefaultInfo() + OrderModel.queryBusRoutes() } } } 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 ff8d23d9b1..0067437a28 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 @@ -3,14 +3,9 @@ package com.mogo.och.weaknet.ui.fragment import androidx.lifecycle.LifecycleOwner import com.mogo.commons.AbsMogoApplication import com.mogo.commons.mvp.Presenter -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isCanStartAutopilot -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState 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.UiThreadHandler import com.mogo.och.common.module.biz.login.ILoginCallback import com.mogo.och.common.module.biz.login.LoginStatusEnum import com.mogo.och.common.module.biz.login.LoginStatusManager @@ -19,9 +14,6 @@ import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatusListener import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotStatusListenerManager -import com.mogo.och.data.bean.BusStationBean -import com.mogo.och.weaknet.callback.IBusADASStatusCallback -import com.mogo.och.weaknet.model.LineModel import com.mogo.och.weaknet.model.OrderModel import com.mogo.och.weaknet.util.BusTrajectoryManager import mogo_msg.MogoReportMsg.MogoReportMessage @@ -32,8 +24,7 @@ import mogo_msg.MogoReportMsg.MogoReportMessage * @author tongchenfei */ class BusPresenter(view: ShuttleFragment?) : Presenter(view), - IOchAutopilotStatusListener, ILoginCallback, IBusADASStatusCallback { - private var mCurrentStation = 0 + IOchAutopilotStatusListener, ILoginCallback { init { //2021.11.1 鹰眼架构整合,由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口 @@ -53,13 +44,11 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), } fun initModelListener() { - OrderModel.setAdasStatusCallback(this) OchAutoPilotStatusListenerManager.addListener(TAG, this) LoginStatusManager.addListener(TAG, this) } fun releaseListener() { - OrderModel.setAdasStatusCallback(null) OCHAdasAbilityManager.getInstance().release() OchAutoPilotStatusListenerManager.removeListener(TAG) LoginStatusManager.removeListener(TAG) @@ -70,92 +59,11 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), OrderModel.logout() } - override fun updateBusTaskStatus( - lineName: String, lineTime: String, - stationList: List, - arrivingOrArrivedIndex: Int, - isArrived: Boolean - ) { - mCurrentStation = if (arrivingOrArrivedIndex == 0 || isArrived) { - arrivingOrArrivedIndex - } else { - arrivingOrArrivedIndex - 1 - } - d(SceneConstant.M_BUS + "BusOrderModel =", " mCurrentStation =$mCurrentStation") - } - - - override fun clearBusStationsMarkers() { - // TODO: 清理或展示地图 - UiThreadHandler.post({ - if (mView != null) { - mView!!.clearBusStationsMarkers() - } - }, UiThreadHandler.MODE.QUEUE) - } - override fun onAutopilotArriveAtStation(arrivedStation: ArrivedStation?) { e(SceneConstant.M_BUS + TAG, "行程日志-onAutopilotArriveAtStation arrive") OrderModel.onArriveAt(arrivedStation, "底盘触发进站") } - override fun onAutopilotStatusResponse(state: Int) { - when (state) { - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE, IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING, IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> { - if (FunctionBuildConfig.isDemoMode - && ((mCurrentStation >= 0 && mCurrentStation <= LineModel.stationList!!.size - 1) && OrderModel.isGoingToNextStation) - ) { - d(SceneConstant.M_BUS + "BusOrderModel=", "有美化功能") - return - } - // 改变UI自动驾驶状态 - UiThreadHandler.post({ - if (mView != null) { - mView!!.onAutopilotStatusChanged(state, isCanStartAutopilot(false, 0)) - } - }, UiThreadHandler.MODE.QUEUE) - } - - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> { - // 改变UI自动驾驶状态 - UiThreadHandler.post({ - if (mView != null) { - mView!!.onAutopilotStatusChanged(state, isCanStartAutopilot(false, 0)) - } - }, UiThreadHandler.MODE.QUEUE) - } - - else -> UiThreadHandler.post({ - - }, UiThreadHandler.MODE.QUEUE) - } - } - - override fun startOpenAutopilot() { - //非美化模式下启动动画 - UiThreadHandler.post({ - if (mView != null) { - mView!!.startAutopilotAnimation() - } - }, UiThreadHandler.MODE.QUEUE) - - //中间站点再次开启自驾时, 自动驾驶状态是2未改变, 此次鹰眼底层不再返给业务,需优化按钮动画显示 - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - == getState() && mView != null - ) { - mView!!.onAutopilotStatusChanged( - getState(), - isCanStartAutopilot(false, 0) - ) - } - } - - /** - * 测试使用 - */ - fun debugAutoPilotStatus(status: Int) { - onAutopilotStatusResponse(status) - } override fun onAutopilotGuardian(guardianInfo: MogoReportMessage, lineId: Long) { @@ -168,27 +76,10 @@ class BusPresenter(view: ShuttleFragment?) : Presenter(view), //OrderModel.queryBusRoutes() } else { BusTrajectoryManager.getInstance().stopTrajReqLoop() - clearBusStationsMarkers() OrderModel.closeBeautificationMode() } } - override fun onStartAdasFailure() { - UiThreadHandler.post({ - if (mView != null) { - mView!!.stopAnimAndUpdateBtnStatus() - } - }, UiThreadHandler.MODE.QUEUE) - } - - override fun canStartAutopilot(canStart: Boolean) { - UiThreadHandler.post({ - if (mView != null) { - mView!!.onAutopilotStatusChanged(getState(), canStart) - } - }, UiThreadHandler.MODE.QUEUE) - } - companion object { private const val TAG = "BusPresenter" } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/ShuttleFragment.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/ShuttleFragment.kt index 638bffd274..03520387e9 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/ShuttleFragment.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/fragment/ShuttleFragment.kt @@ -1,55 +1,25 @@ package com.mogo.och.weaknet.ui.fragment -import android.animation.ObjectAnimator import android.graphics.BitmapFactory import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.view.animation.LinearInterpolator -import android.widget.FrameLayout -import android.widget.ImageView -import android.widget.RelativeLayout -import android.widget.TextView import com.mogo.commons.AbsMogoApplication import com.mogo.commons.mvp.MvpFragment import com.mogo.commons.storage.SharedPrefsMgr import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.config.HdMapBuildConfig import com.mogo.eagle.core.data.temp.EventLogout -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.isCanStartAutopilot -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager -import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.attachAutopilotBeforeLaunchView -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getMapUIController -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager.getOverlayManager -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB1 -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isB2 import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener -import com.mogo.eagle.core.utilcode.util.ToastUtils -import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import com.mogo.map.MogoMap -import com.mogo.map.overlay.core.Level -import com.mogo.map.overlay.point.Point -import com.mogo.och.common.module.utils.OCHThreadPoolManager -import com.mogo.och.common.module.utils.ResourcesUtils -import com.mogo.och.common.module.utils.ResourcesUtils.getColor import com.mogo.och.common.module.utils.createQRCodeWithPicture import com.mogo.och.common.module.wigets.BindQRCodeDialog import com.mogo.och.shuttle.weaknet.R -import com.mogo.och.weaknet.constant.BusConst import com.mogo.och.weaknet.ui.bizswitch.SwitchBizView import com.mogo.och.weaknet.ui.taskrunned.RunningTaskManager -import com.mogo.och.weaknet.view.BizMapView import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.boneContainerView -import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.bus_autopilot_btn_iv -import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.bus_autopolot_btn_tv import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.mapBizView -import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.module_mogo_och_autopilot_status -import kotlinx.android.synthetic.main.shuttle_weak_base_fragment.module_mogo_och_station_panel_container import me.jessyan.autosize.utils.AutoSizeUtils import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe @@ -63,18 +33,14 @@ import org.greenrobot.eventbus.ThreadMode * * @author tongchenfei */ -class ShuttleFragment : MvpFragment(), View.OnClickListener { - - private var autopilotLoadingAnimator: ObjectAnimator? = null - - var isAnimateRunning: Boolean = false +class ShuttleFragment : MvpFragment() { override fun getLayoutId(): Int { return R.layout.shuttle_weak_base_fragment } override fun getTagName(): String { - return "BusFragment" + return "ShuttleFragment" } override fun initViews() { @@ -84,15 +50,6 @@ class ShuttleFragment : MvpFragment(), View.OnC } initListener() - setAutopilotBtnStatus( - getState(), - isCanStartAutopilot(false, 0) - ) - module_mogo_och_autopilot_status!!.setOnClickListener(object : OnPreventFastClickListener() { - override fun onClickImpl(v: View) { - - } - }) } @@ -146,152 +103,6 @@ class ShuttleFragment : MvpFragment(), View.OnC private fun initListener() { } - /** - * 改变自动驾驶状态 - * - * @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中 - */ - fun onAutopilotStatusChanged(autopilotStatus: Int, canStartAuto: Boolean) { - UiThreadHandler.post({ - changeAutopilotBtnView( - autopilotStatus, - isAnimateRunning, - canStartAuto - ) - }, UiThreadHandler.MODE.QUEUE) - } - - fun setAutopilotBtnStatus(autopilotStatus: Int, canStartAuto: Boolean) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE == autopilotStatus) { //0不可用 - bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) - bus_autopolot_btn_tv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) - module_mogo_och_autopilot_status!!.isClickable = true - module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) - } else { - bus_autopolot_btn_tv!!.setTextColor( - AbsMogoApplication.getApp().getColor(R.color.bus_autopilot_text_color_normal) - ) - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_ic_autopilot) - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用 - bus_autopolot_btn_tv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_runnig_tv) - if (canStartAuto) { - module_mogo_och_autopilot_status!!.isClickable = true - module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_press) - } else { - bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_disable)) - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_disable_autopilot_icon) - module_mogo_och_autopilot_status!!.isClickable = true - module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_start_fail) - } - } else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) { - bus_autopolot_btn_tv!!.setText(R.string.bus_loading_autopilot_runnig_tv) - module_mogo_och_autopilot_status!!.isClickable = true - module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_in_autopilot) - } else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING - == autopilotStatus - ) { - bus_autopolot_btn_tv!!.setText(R.string.bus_pingxing_driver) - module_mogo_och_autopilot_status!!.isClickable = false - module_mogo_och_autopilot_status!!.setBackgroundResource(R.drawable.common_autopilot_pxjs) - } - } - } - - fun updateAutopilotStatus(autopilotStatus: Int) { - if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - == autopilotStatus - ) { //2 running - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_right_autopilot_icon) - bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - bus_autopolot_btn_tv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_success_tv) - // module_mogo_och_autopilot_status.setSelected(false); - module_mogo_och_autopilot_status!!.isClickable = false - } else { - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_wrong_autopilot_icon) - bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - bus_autopolot_btn_tv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_failure_tv) - module_mogo_och_autopilot_status!!.isClickable = false - // module_mogo_och_autopilot_status.setSelected(false); - } - UiThreadHandler.postDelayed({ - setAutopilotBtnStatus( - autopilotStatus, - isCanStartAutopilot(false, 0) - ) - }, 1000) - } - - private fun changeAutopilotBtnView( - autopilotStatus: Int, - isAnimateRunning: Boolean, - canStartAuto: Boolean - ) { - if (isAnimateRunning && (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - != autopilotStatus) - ) { - // 主动开启自动驾驶中,不为2(为0、1)则继续loading - return - } - if (isAnimateRunning) { - stopAnimAndUpdateBtnStatus() - } else { - setAutopilotBtnStatus(autopilotStatus, canStartAuto) - } - } - - fun stopAnimAndUpdateBtnStatus() { - stopAutopilotAnimation() - updateAutopilotStatus(getState()) - } - - /** - * 开启自动驾驶中间动画 - */ - fun startAutopilotAnimation() { - isAnimateRunning = true - bus_autopolot_btn_tv!!.text = - ResourcesUtils.getString(R.string.bus_loading_autopilot_tv) - bus_autopolot_btn_tv!!.setTextColor(getColor(R.color.bus_autopilot_text_color_normal)) - module_mogo_och_autopilot_status!!.isClickable = true - bus_autopilot_btn_iv!!.setImageResource(R.drawable.bus_loading_autopilot_icon) - if (autopilotLoadingAnimator == null) { - autopilotLoadingAnimator = ObjectAnimator.ofFloat(bus_autopilot_btn_iv!!, "rotation", 0f, 360f) - autopilotLoadingAnimator?.interpolator = LinearInterpolator() - autopilotLoadingAnimator?.repeatCount = -1 //无限循环 - autopilotLoadingAnimator?.setDuration(1000) //设置持续时间 - } - autopilotLoadingAnimator!!.start() //动画开始 - - startingAutoApilotCountDown() - } - - private fun startingAutoApilotCountDown() { - //10s 若自动驾驶没有开启,则结束动画 - UiThreadHandler.postDelayed({ - //未启动成功做处理 - if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态 - stopAutopilotAnimation() - updateAutopilotStatus(getState()) - } - }, BusConst.TIMER_START_AUTOPILOT_INTERVAL) - } - - /** - * 停止自动驾驶中间动画 - */ - protected fun stopAutopilotAnimation() { - if (autopilotLoadingAnimator != null) { - autopilotLoadingAnimator!!.end() - bus_autopilot_btn_iv!!.clearAnimation() - autopilotLoadingAnimator = null - isAnimateRunning = false - } - } override fun onDestroy() { super.onDestroy() @@ -337,80 +148,6 @@ class ShuttleFragment : MvpFragment(), View.OnC } } - fun clearBusStationsMarkers() { -// d(SceneConstant.M_BUS + TAG, "clearBusStationsMarkers()") -// if (null != startStation) { -// setOrRemoveMapMaker( -// false, BusConst.BUS_START_MAP_MAKER, startStation!!.lat, -// startStation!!.lon, R.raw.star_marker -// ) -// } -// if (null != endStation) { -// setOrRemoveMapMaker( -// false, BusConst.BUS_END_MAP_MAKER, endStation!!.lat, -// endStation!!.lon, R.raw.end_marker -// ) -// } - } - - /** - * 绘制地图起点终点 - * - * @param isAdd - * @param uuid - */ - private fun setOrRemoveMapMaker( - isAdd: Boolean, - uuid: String, - lat: Double, - longi: Double, - resourceId: Int - ) { - if (isAdd) { - val setMapMarkerRunnable = Runnable { - d( - SceneConstant.M_BUS + "setMapMaker= " + Thread.currentThread().name, - "$uuid=latitude=$lat,longitude=$longi" - ) - val builder = - Point.Options.Builder(BusConst.TYPE_MARKER_BUS_ORDER, Level.MAP_MARKER) - .setId(uuid) - .anchor(0.5f, 0.5f) - .set3DMode(true) - .isUseGps(true) - .controlAngle(false) - .icon3DRes(resourceId) - .latitude(lat) - .longitude(longi) - val overlayManager = getOverlayManager() - overlayManager?.showOrUpdatePoint(builder.build(), MogoMap.DEFAULT) - } - - OCHThreadPoolManager.getsInstance().execute(setMapMarkerRunnable) - } else { - val removeMapMarkerRunnable = Runnable { - d( - SceneConstant.M_BUS + "RemoveMapMaker=" + Thread.currentThread().name, - "$uuid=latitude=$lat,longitude=$longi" - ) - getOverlayManager()?.removePoint(uuid) - } - OCHThreadPoolManager.getsInstance().execute(removeMapMarkerRunnable) - } - } - - override fun onClick(v: View) { - if (v.id == R.id.switch_line_btn) { //切换路线条件: 自动驾驶过程中,点击则toast提示:自动驾驶中,不可切换路线 - //本次行程未结束,不支持切换路线。点击则toast提示:当前行程未完成,不可切换路线 - if (getState() - == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - ) { - ToastUtils.showLong(ResourcesUtils.getString(R.string.bus_switch_line_btn_warning1)) - return - } - } - } - /** * END */ diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt index 24c8bb8a08..1f22dba37a 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningModel.kt @@ -27,7 +27,7 @@ class TaskRunningModel : ViewModel(), IBusLinesCallback { } fun leaveStation() { - OrderModel.autoDriveToNextStation() + OrderModel.driveToNextStation() } interface SwtichLineViewCallback{ @@ -65,7 +65,7 @@ class TaskRunningModel : ViewModel(), IBusLinesCallback { } fun completeTask() { - OrderModel.abortTask() + OrderModel.completeTask() } } diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt index 01708d17dd..b8dba0274a 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/ui/taskrunning/TaskRunningView.kt @@ -108,7 +108,9 @@ class TaskRunningView: ConstraintLayout, TaskRunningModel.SwtichLineViewCallback } override fun showRunningTaskInfo() { - bus_task_running_line_name.text = LineManager.lineInfos?.lineName?:"" + LineManager.getLineInfo {lineInfo -> + bus_task_running_line_name.text = "班次:${lineInfo.lineName}" + } actv_running_task_time.text = LineModel.getTaskTime() LineModel.stationList?.takeIf { it.size>2 }?.let { actv_running_task_last_station.text = "往${it.last().name ?: ""}" diff --git a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml b/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml index c92322a9ea..9b564bc3b0 100644 --- a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml +++ b/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_base_fragment.xml @@ -125,51 +125,6 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - - - - - - - - - - - - \ No newline at end of file diff --git a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_fragment_och.xml b/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_fragment_och.xml deleted file mode 100644 index d41b790b5d..0000000000 --- a/OCH/shuttle/driver_weaknet/src/main/res/layout/shuttle_weak_fragment_och.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file