diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/constant/OchCommonConst.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/constant/OchCommonConst.kt index 4c30321280..a57266e728 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/constant/OchCommonConst.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/constant/OchCommonConst.kt @@ -59,5 +59,7 @@ class OchCommonConst { // 自动驾驶自动规划的最大距离 const val AUTOMATIC_PLANNING_MAX_DISTANCE = 15 + + const val ARRIVE_AT_END_STATION_DISTANCE = 10 } } \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotManager.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotManager.kt index 558ac3c4a8..9da319e419 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotManager.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutoPilotManager.kt @@ -95,7 +95,6 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen @JvmStatic fun startAutoPilot(controlParameters: AutopilotControlParameters?): Long { val sessionId = CallerAutoPilotControlManager.startAutoPilot(controlParameters) - LineManager.isReStartAutopilot = false globalSessionId.set(sessionId) fsmBackSessionId.set(-1L) OchAutopilotAnalytics.triggerStartAutopilotParameters(controlParameters, sessionId) 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 441363f1de..fbc81bca6e 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 @@ -6,11 +6,13 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.util.StringUtils import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.och.common.module.R import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation import com.mogo.och.common.module.manager.autopilot.line.LineManager 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.CallerBase import com.zhjt.mogo.adas.data.AdasConstants import com.zhjt.mogo.adas.data.bean.MogoReport @@ -51,10 +53,12 @@ object OchAutoPilotStatusListenerManager : CallerBase() { */ private var endStation: BusStationBean? = null - var isReStartAutopilot = true + var isFirstStartAutopilot = true + + private var orderId = "" + + // 自车定位 + private val mMapLocationListener = object : IMoGoChassisLocationGCJ02Listener { + override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { + if (null == mogoLocation) return + getStations { start, end -> + val startLon = end.gcjLon + val startLat = end.gcjLat + val distance = CoordinateUtils.calculateLineDistance( + startLon, startLat, + mogoLocation.longitude, mogoLocation.latitude + ) + if (distance <= OchCommonConst.ARRIVE_AT_END_STATION_DISTANCE) { + val token = CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotStation(orderId) + OchChainLogManager.writeChainLogAutopilot("到站逻辑","距离站点:$distance 请求token:$token") + } + } + } + } + + + fun invokeArrivedStation(orderId: String, arrivedStationFlag: Boolean) { + if (this.orderId==orderId&&arrivedStationFlag){ + M_LISTENERS.forEach { + it.value.arrivedStationSuccessBySearch() + } + } + } + + fun invokeSetIsFirstAutopilot(orderId: String?, firstAutopilotFlag: Boolean, count: Int) { + if (this.orderId==orderId){ + if(count>=1){ + isFirstStartAutopilot = false + }else{ + isFirstStartAutopilot = true + } + } + } /** * 设置站点信息 */ fun setStartAndEndStation(startStation: BusStationBean?, endStation: BusStationBean?) { if(this.startStation!=startStation||this.endStation!=endStation){ - isReStartAutopilot = true + isFirstStartAutopilot = true } this.startStation = startStation this.endStation = endStation @@ -197,11 +241,19 @@ object LineManager : CallerBase() { endStationLocation.latitude = end.gcjLat endStationLocation.longitude = end.gcjLon TrajectoryAndDistanceManager.setStationPoint(startStationLocation, endStationLocation, lineInfo.lineId) + OchLocationManager.addGCJ02Listener(TAG,1,mMapLocationListener) + // 恢复启动自驾信息 + searchAutopilotState() } } + fun searchAutopilotState(){ + CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotInfo() + } private fun clearAutopilotControlParameters(){ CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null) TrajectoryAndDistanceManager.setStationPoint(null, null, null) + this.orderId = "" + OchLocationManager.removeGCJ02Listener(TAG) } fun hasDrawnGlobalTrajectory(): Boolean { @@ -245,6 +297,9 @@ object LineManager : CallerBase() { parameters?.startLatLon = AutoPilotLonLat(start.lat, start.lon) parameters?.endLatLon = AutoPilotLonLat(end.lat, end.lon) parameters?.vehicleType = 10 + this.orderId = "${lineInfo.lineId}_${start.siteId}_${end.siteId}" + parameters?.orderId = this.orderId + parameters?.firstAutopilotFlag = isFirstStartAutopilot if (parameters?.autoPilotLine == null) { parameters?.autoPilotLine = AutoPilotLine( @@ -334,7 +389,7 @@ object LineManager : CallerBase() { M_BUS + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) + " startLatLon=" + parameters.startName + ",endLatLon=" + parameters.endName + - "isRestart = " + LineManager.isReStartAutopilot + "isRestart = " + LineManager.isFirstStartAutopilot ) M_LISTENERS.forEach { @@ -354,7 +409,7 @@ object LineManager : CallerBase() { fun triggerStartServiceEvent(send: Boolean,source:Int) { getStationsWithLine { start, end, lineInfo -> OchAutopilotAnalytics.triggerStartAutopilotEvent( - isReStartAutopilot, + isFirstStartAutopilot, send, start.name, end.name, 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 01abfbb83f..de776a3056 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 @@ -18,6 +18,7 @@ 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.manager.autopilot.autopilot.bean.ArrivedStation +import com.mogo.och.common.module.manager.autopilot.line.ILineCallback 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.logchainanalytic.OchChainLogManager @@ -71,8 +72,8 @@ object OrderModel { // 加载核销模块 TicketModel.load() - // 定位监听 - OchLocationManager.addGCJ02Listener(TAG, 5, mMapLocationListener) + + LineManager.addListener(TAG,arriveStationBySearch) OchTransform.addListener(TAG,ochTransform) @@ -87,7 +88,7 @@ object OrderModel { TicketModel.release() - OchLocationManager.removeGCJ02Listener(TAG) + LineManager.removeListener(TAG) OchTransform.removeListener(TAG) } @@ -105,34 +106,17 @@ object OrderModel { // 自车定位 - private val mMapLocationListener = object : IMoGoChassisLocationGCJ02Listener { - override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) { - if (null == mogoLocation) return - + private val arriveStationBySearch = object : ILineCallback { + override fun arrivedStationSuccessBySearch() { //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 if (isGoingToNextStation && !isArrivedStation) { OCHThreadPoolManager.getsInstance().locationExecute { - judgeArrivedStation(mogoLocation) + onArriveAt(null, "兜底:根据定位计算到站") } } } } - //根据围栏判断,是否到达站点 - private fun judgeArrivedStation(location: MogoLocation) { - 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 ${end.name}") - onArriveAt(null, "兜底:根据定位计算到站") - } - } - } /** * 查询小巴路线