[6.8.0][FSM异常提示优化] 增加消散逻辑

This commit is contained in:
renwj
2024-11-20 19:46:19 +08:00
parent ea6f03a672
commit f2fd0a2285
3 changed files with 31 additions and 1 deletions

View File

@@ -155,10 +155,12 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
AIAssist.getInstance(it).speakTTSVoice("识别故障即将停车,请注意观察,小心接管")
}
CallerHmiManager.toggleSafetyStopCarWarning(true)
}
}
if (state == Fsm2024.State.SAFETY_STOPPED) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
CallerHmiManager.toggleSafetyStopCarWarning(false)
AppStateManager.currentActivity()?.also {
AIAssist.getInstance(it).speakTTSVoice("请接管恢复停车状态")
}

View File

@@ -39,4 +39,6 @@ internal abstract class IFlow< T : Status>(val ctx: Context) : CoroutineScope {
open fun onDestroy() {
chl.safeCancel()
}
fun peek(): T? = chl.tryReceive().getOrNull()
}

View File

@@ -1,21 +1,30 @@
package com.zhjt.mogo_core_function_devatools.status.flow.fsm
import android.content.Context
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoFsm2024Listener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerFsm2024ListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhjt.mogo_core_function_devatools.status.entity.SafetyStopCarStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
import fsm.Fsm2024
import fsm.Fsm2024.FSMStateMsg
internal class SafetyStopCarImpl(ctx: Context): IFlow<SafetyStopCarStatus>(ctx), IMoGoFsm2024Listener {
internal class SafetyStopCarImpl(ctx: Context): IFlow<SafetyStopCarStatus>(ctx), IMoGoFsm2024Listener, IMoGoAutopilotStatusListener {
companion object {
private const val TAG = "SafetyStopCarImpl"
}
@Volatile
private var lastState: Int = -1
override fun onCreate() {
CallerFsm2024ListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
@@ -28,5 +37,22 @@ internal class SafetyStopCarImpl(ctx: Context): IFlow<SafetyStopCarStatus>(ctx),
override fun onDestroy() {
super.onDestroy()
CallerFsm2024ListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(state: Int) {
super.onAutopilotStatusResponse(state)
Logger.d(TAG, "--- onAutopilotStatusResponse --- 1 ---: $state")
if (lastState == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING && lastState != state) {
//从自驾转成非自驾
Logger.d(TAG, "--- onAutopilotStatusResponse --- 2 ---: $state")
if (peek()?.data?.functionState == Fsm2024.State.SAFETY_STOP) {
Logger.d(TAG, "--- onAutopilotStatusResponse --- 3 ---: $state")
CallerHmiManager.toggleSafetyStopCarWarning(false)
}
}
if (lastState != state) {
lastState = state
}
}
}