[6.7.0][FSM] refactor: 异常后原因修改成多条数组返回;
This commit is contained in:
@@ -173,8 +173,8 @@ object StatusManager {
|
||||
}, 500L)
|
||||
}
|
||||
private fun randomNoFSMChange(ctx: Context) {
|
||||
val fsmStatus = FSMStatus(FSMStateCode.ExistNormal, "正常")
|
||||
val noFsmStatus = FSMStatus(FSMStateCode.NotExist, "")
|
||||
val fsmStatus = FSMStatus(FSMStateCode.ExistNormal, listOf("正常"))
|
||||
val noFsmStatus = FSMStatus(FSMStateCode.NotExist, listOf(""))
|
||||
|
||||
ctx.lifeCycleScope.launch(dispatcher) {
|
||||
model.update(if (hasFSM) fsmStatus else noFsmStatus)
|
||||
@@ -182,8 +182,8 @@ object StatusManager {
|
||||
}
|
||||
|
||||
private fun randomFSMStatus(ctx: Context) {
|
||||
val fsmNormalStatus = FSMStatus(FSMStateCode.ExistNormal, "正常")
|
||||
val fsmErrorStatus = FSMStatus(FSMStateCode.ExistError, "异常")
|
||||
val fsmNormalStatus = FSMStatus(FSMStateCode.ExistNormal, listOf("正常"))
|
||||
val fsmErrorStatus = FSMStatus(FSMStateCode.ExistError, listOf("异常"))
|
||||
|
||||
val fSMList = ArrayList<Status>()?.also {
|
||||
it += fsmNormalStatus
|
||||
|
||||
@@ -141,28 +141,31 @@ enum class FSMStateCode {
|
||||
/**
|
||||
* FSM模块状态
|
||||
*/
|
||||
class FSMStatus(var state: FSMStateCode, var desc: String = ""): Status(), IAutopilotPreLaunchStatus {
|
||||
class FSMStatus(var state: FSMStateCode, var descList: List<String> = emptyList<String>()): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as FSMStatus
|
||||
if (desc != other.desc) {
|
||||
if (state != other.state) {
|
||||
return false
|
||||
}
|
||||
if (state != other.state) {
|
||||
if (descList.size != other.descList.size) {
|
||||
return false
|
||||
}
|
||||
if (descList != other.descList) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = desc.hashCode()
|
||||
var result = descList.hashCode()
|
||||
result = 31 * result + state.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "FSMStatus(state=$state, desc='$desc', raw_data=$rawData)"
|
||||
return "FSMStatus(state=$state, descList='$descList', raw_data=$rawData)"
|
||||
}
|
||||
|
||||
override fun isException(): Boolean = state == FSMStateCode.ExistError
|
||||
|
||||
@@ -34,9 +34,9 @@ internal class FSMImpl(ctx: Context) : IFlow<FSMStatus>(ctx), IMoGoAutopilotStat
|
||||
AtomicReference<Fsm2024.FSMStateMsg>(null)
|
||||
}
|
||||
|
||||
private fun getDesc(): String {
|
||||
private fun getDesc(): List<String> {
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
return "未知"
|
||||
return listOf("未知")
|
||||
} else {
|
||||
val nodeState = CallerAutoPilotControlManager.getNodeStateInfo(AdasConstants.NodeName.FSM2024)?.nodeState ?: AdasConstants.NodeState.NODE_UNKNOWN
|
||||
return getStateDescByNodeStateInfo(nodeState)
|
||||
@@ -61,12 +61,12 @@ internal class FSMImpl(ctx: Context) : IFlow<FSMStatus>(ctx), IMoGoAutopilotStat
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStateDescByNodeStateInfo(nodeState: AdasConstants.NodeState): String {
|
||||
private fun getStateDescByNodeStateInfo(nodeState: AdasConstants.NodeState): List<String> {
|
||||
return when(nodeState) {
|
||||
AdasConstants.NodeState.NODE_UNKNOWN -> "未知"
|
||||
AdasConstants.NodeState.NODE_NOT_EXIST -> "FSM不存在"
|
||||
AdasConstants.NodeState.NODE_EXIST -> if(fsmStateMsg.get()?.pilotStandbyFlag == true) "状态正常" else fsmStateMsg.get()?.pilotNotStandbyReason ?: ""
|
||||
else -> "未知"
|
||||
AdasConstants.NodeState.NODE_UNKNOWN -> listOf("未知")
|
||||
AdasConstants.NodeState.NODE_NOT_EXIST -> listOf("FSM不存在")
|
||||
AdasConstants.NodeState.NODE_EXIST -> if(fsmStateMsg.get()?.pilotStandbyFlag == true) listOf("状态正常") else fsmStateMsg.get()?.repeatedPilotNotStandbyReasonList ?: listOf("")
|
||||
else -> listOf("未知")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ internal class FSMImpl(ctx: Context) : IFlow<FSMStatus>(ctx), IMoGoAutopilotStat
|
||||
} else {
|
||||
CallerLogger.d("$M_DEVA$TAG", "工控机断开了....")
|
||||
fsmStateMsg.set(null)
|
||||
send(FSMStatus(FSMStateCode.UnKnown, "工控机断开了"))
|
||||
send(FSMStatus(FSMStateCode.UnKnown, listOf("工控机断开了")))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ internal class FSMImpl(ctx: Context) : IFlow<FSMStatus>(ctx), IMoGoAutopilotStat
|
||||
)
|
||||
fsmStateMsg.set(fsmState)
|
||||
if (fsmState.pilotStandbyFlag) {
|
||||
send(FSMStatus(FSMStateCode.ExistNormal, "状态正常"))
|
||||
send(FSMStatus(FSMStateCode.ExistNormal, listOf("状态正常")))
|
||||
} else {
|
||||
send(FSMStatus(FSMStateCode.ExistError, fsmState.pilotNotStandbyReason))
|
||||
send(FSMStatus(FSMStateCode.ExistError, fsmState.repeatedPilotNotStandbyReasonList))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ internal class StatusModel : ViewModel() {
|
||||
const val TAG = "StatusModel"
|
||||
val DEFAULTS = Pair(null, ArrayList<Status>().also {
|
||||
it += OverViewStatus()
|
||||
it += FSMStatus(FSMStateCode.UnKnown, "")
|
||||
it += FSMStatus(FSMStateCode.UnKnown, listOf(""))
|
||||
it += RTKStatus("", -1)
|
||||
it += IpcStatus(CallerAutoPilotStatusListenerManager.isConnect())
|
||||
it += CanStatus(false)
|
||||
|
||||
@@ -141,9 +141,7 @@ internal class StatusAdapter(val ctx: Context, var data: List<Status>) : Recycle
|
||||
|
||||
FSMStateCode.ExistError -> {
|
||||
iv.background = ContextCompat.getDrawable(itemView.context, drawable.icon_dev_status_fsm_error)
|
||||
CallerHmiManager.showFSMExceptionStatusWindow(ArrayList<String>().also {
|
||||
it += status.desc
|
||||
})
|
||||
CallerHmiManager.showFSMExceptionStatusWindow(status.descList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user