[taxi]
[启动自驾超时检测]
This commit is contained in:
yangyakun
2023-12-28 15:52:16 +08:00
parent 621a10c3d9
commit 602cc2a343
2 changed files with 45 additions and 34 deletions

View File

@@ -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()

View File

@@ -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()
}
}