diff --git a/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt b/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt index 82be59b6e1..b3cd42dc0f 100644 --- a/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt +++ b/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt @@ -2,7 +2,7 @@ package com.mogo.och.taxi.passenger.ui.checkstartautopilot.startautopilot import androidx.lifecycle.ViewModel import com.mogo.commons.voice.AIAssist -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.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant @@ -29,12 +29,12 @@ class StartAutopilotViewModel : ViewModel(), private val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L - var startCountDown: Disposable?=null + var startCountDown: Disposable? = null var doorOpenState = true fun setStartAutopilotCallback(viewCallback: StartAutopilotCallback) { - TaxiDoorStateManager.addListener(TAG,this) + TaxiDoorStateManager.addListener(TAG, this) this.viewCallback = viewCallback setOrderInfo() } @@ -68,9 +68,12 @@ class StartAutopilotViewModel : ViewModel(), * 开启自动驾驶 */ fun startAutopilot() { - val num = ParseVersionUtils.parseVersion(true, CallerAutoPilotStatusListenerManager.getDockerVersion()) + val num = ParseVersionUtils.parseVersion( + true, + CallerAutoPilotStatusListenerManager.getDockerVersion() + ) if (num >= 30600) { - if(doorOpenState){ + if (doorOpenState) { VoiceNotice.showNotice("关紧车门后再出发吧!") ToastUtils.showShort("关紧车门后再出发吧!") viewCallback?.unableStartAutopilotByDoorState() @@ -84,12 +87,16 @@ class StartAutopilotViewModel : ViewModel(), if (AutopilotManager.startAutopilot().isEmpty()) { RxUtils.disposeSubscribe(startCountDown) startCountDown = RxUtils.createSubscribe(TIMER_START_AUTOPILOT_INTERVAL) { - viewCallback?.startAutopilotingTimeout() - //未启动成功20s后做处理 - ToastUtils.showLong(R.string.taxi_p_start_autopilot_fail_10s_tip) - VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) + val autoPilotState = + CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state + if (autoPilotState != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + viewCallback?.startAutopilotingTimeout() + //未启动成功20s后做处理 + ToastUtils.showLong(R.string.taxi_p_start_autopilot_fail_10s_tip) + VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) + } } - }else{ + } else { VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) viewCallback?.startAutopilotingFail() } @@ -106,21 +113,21 @@ class StartAutopilotViewModel : ViewModel(), override fun doorStateChangeCallback(position: DoorPosition, state: DoorState) { CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "门太变化:${position}--${state}") - runMain(position,state) + runMain(position, state) } - private fun runMain(posttion: DoorPosition, state: DoorState){ + private fun runMain(posttion: DoorPosition, state: DoorState) { UiThreadHandler.post({ - viewCallback?.setDoorStatus(posttion,state) - },UiThreadHandler.MODE.QUEUE) + viewCallback?.setDoorStatus(posttion, state) + }, UiThreadHandler.MODE.QUEUE) } interface StartAutopilotCallback { fun setOrderInfo(show: String) - fun setDoorStatus(doorPosition: DoorPosition,state: DoorState) + fun setDoorStatus(doorPosition: DoorPosition, state: DoorState) - fun canStartAutopilot(can:Boolean) + fun canStartAutopilot(can: Boolean) fun startAutopilotingTimeout() fun startAutopilotingFail() diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt index c7c6ced017..7ea050bc7b 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/checkstartautopilot/startautopilot/StartAutopilotViewModel.kt @@ -2,7 +2,7 @@ package com.mogo.och.taxi.passenger.ui.checkstartautopilot.startautopilot import androidx.lifecycle.ViewModel import com.mogo.commons.voice.AIAssist -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.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant @@ -29,12 +29,12 @@ class StartAutopilotViewModel : ViewModel(), private val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L - var startCountDown: Disposable?=null + var startCountDown: Disposable? = null var doorOpenState = true fun setStartAutopilotCallback(viewCallback: StartAutopilotCallback) { - TaxiDoorStateManager.addListener(TAG,this) + TaxiDoorStateManager.addListener(TAG, this) this.viewCallback = viewCallback setOrderInfo() } @@ -68,9 +68,11 @@ class StartAutopilotViewModel : ViewModel(), * 开启自动驾驶 */ fun startAutopilot() { - val num = ParseVersionUtils.parseVersion(true, CallerAutoPilotStatusListenerManager.getDockerVersion()) + val num = ParseVersionUtils.parseVersion( + true, CallerAutoPilotStatusListenerManager.getDockerVersion() + ) if (num >= 30600) { - if(doorOpenState){ + if (doorOpenState) { VoiceNotice.showNotice("关紧车门后再出发吧!") ToastUtils.showShort("关紧车门后再出发吧!") viewCallback?.unableStartAutopilotByDoorState() @@ -84,12 +86,16 @@ class StartAutopilotViewModel : ViewModel(), if (AutopilotManager.startAutopilot().isEmpty()) { RxUtils.disposeSubscribe(startCountDown) startCountDown = RxUtils.createSubscribe(TIMER_START_AUTOPILOT_INTERVAL) { - viewCallback?.startAutopilotingTimeout() - //未启动成功20s后做处理 - ToastUtils.showLong(R.string.taxi_p_start_autopilot_fail_10s_tip) - VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) + val autoPilotState = + CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state + if (autoPilotState != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + viewCallback?.startAutopilotingTimeout() + //未启动成功20s后做处理 + ToastUtils.showLong(R.string.taxi_p_start_autopilot_fail_10s_tip) + VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) + } } - }else{ + } else { VoiceNotice.showNotice("啊哦!系统繁忙中,稍后再试试吧~", AIAssist.LEVEL2) viewCallback?.startAutopilotingFail() } @@ -106,24 +112,22 @@ class StartAutopilotViewModel : ViewModel(), override fun doorStateChangeCallback(position: DoorPosition, state: DoorState) { CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "门太变化:${position}--${state}") - runMain(position,state) + runMain(position, state) } - private fun runMain(posttion: DoorPosition, state: DoorState){ + private fun runMain(posttion: DoorPosition, state: DoorState) { UiThreadHandler.post({ - viewCallback?.setDoorStatus(posttion,state) - },UiThreadHandler.MODE.QUEUE) + viewCallback?.setDoorStatus(posttion, state) + }, UiThreadHandler.MODE.QUEUE) } interface StartAutopilotCallback { fun setOrderInfo(show: String) - fun setDoorStatus(doorPosition: DoorPosition,state: DoorState) - - fun canStartAutopilot(can:Boolean) + fun setDoorStatus(doorPosition: DoorPosition, state: DoorState) + fun canStartAutopilot(can: Boolean) fun startAutopilotingTimeout() fun startAutopilotingFail() - fun unableStartAutopilotByDoorState() } } \ No newline at end of file