[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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.zhjt.mogo_core_function_devatools.status.entity.FSMStateCode
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.FSMStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
|
||||
import kotlinx.android.synthetic.main.view_start_autopilot_status.view.fSMStatusLayout
|
||||
@@ -72,7 +71,7 @@ class StartAutoPilotStatusView @JvmOverloads constructor(
|
||||
|
||||
private fun initView() {
|
||||
// 默认展示 FSM 情况未知的状态
|
||||
handleFSM(FSMStatus(FSMStateCode.UnKnown, "未知"))
|
||||
handleFSM(FSMStatus(FSMStateCode.UnKnown, listOf("未知")))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,9 +131,7 @@ class StartAutoPilotStatusView @JvmOverloads constructor(
|
||||
|
||||
FSMStateCode.ExistError -> {
|
||||
fSMStatusLayout?.onClick {
|
||||
CallerHmiManager.showFSMExceptionStatusWindow(ArrayList<String>().also {
|
||||
it += status.desc
|
||||
})
|
||||
CallerHmiManager.showFSMExceptionStatusWindow(status.descList)
|
||||
}
|
||||
fSMStatusLayout?.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
@@ -233,7 +230,6 @@ class StartAutoPilotStatusView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
StatusManager.addListener(TAG, this)
|
||||
@@ -256,10 +252,6 @@ class StartAutoPilotStatusView @JvmOverloads constructor(
|
||||
handleFSM(status)
|
||||
}
|
||||
|
||||
is SpeedStatus -> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
else -> {
|
||||
handleWithoutFSM(status)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class FSMStatusDetailView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun setFsmErrorStatus(msgArray: ArrayList<String>) {
|
||||
fun setFsmErrorStatus(msgArray: List<String>) {
|
||||
tvTitle?.text = "FSM异常"
|
||||
runCatching {
|
||||
val c = Color.parseColor("#FF4E41")
|
||||
@@ -93,7 +93,7 @@ class FSMStatusDetailView @JvmOverloads constructor(
|
||||
removeFsmMsgItemView()
|
||||
}
|
||||
|
||||
private fun addFsmMsgItemView(msgArray: ArrayList<String>, isError: Boolean) {
|
||||
private fun addFsmMsgItemView(msgArray: List<String>, isError: Boolean) {
|
||||
if (llFsmMsgContainerLayout == null) {
|
||||
Logger.e(TAG, "addFsmMsmItemView llFsmMsgContainerLayout is null")
|
||||
return
|
||||
@@ -145,14 +145,7 @@ class FSMStatusDetailView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
FSMStateCode.ExistError -> {
|
||||
// TODO 修改成多条
|
||||
setFsmErrorStatus(ArrayList<String>().also {
|
||||
it += status.desc
|
||||
it += status.desc
|
||||
it += status.desc
|
||||
it += status.desc
|
||||
it += status.desc
|
||||
})
|
||||
setFsmErrorStatus(status.descList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class FSMStatusDetailWindowManager private constructor() {
|
||||
}
|
||||
|
||||
fun showExceptionStatus(
|
||||
context: Context, errorMsg: ArrayList<String>
|
||||
context: Context, errorMsg: List<String>
|
||||
) {
|
||||
if (mFSMStatusDetailView == null) {
|
||||
mFSMStatusDetailView = FSMStatusDetailView(context)
|
||||
|
||||
@@ -355,7 +355,7 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
/**
|
||||
* 展示 FSM 异常状态弹框
|
||||
*/
|
||||
override fun showFSMExceptionStatusWindow(errorMsg: ArrayList<String>) {
|
||||
override fun showFSMExceptionStatusWindow(errorMsg: List<String>) {
|
||||
context?.let { FSMStatusDetailWindowManager.fsmStatusDetailWindowManager.showExceptionStatus(it, errorMsg)}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ interface IMoGoHmiProvider :IProvider{
|
||||
/**
|
||||
* 展示 FSM 异常状态弹框
|
||||
*/
|
||||
fun showFSMExceptionStatusWindow(errorMsg: ArrayList<String>)
|
||||
fun showFSMExceptionStatusWindow(errorMsg: List<String>)
|
||||
|
||||
/**
|
||||
* 关闭 FSM 异常状态弹框
|
||||
|
||||
@@ -248,7 +248,7 @@ object CallerHmiManager {
|
||||
/**
|
||||
* 展示 FSM 异常状态弹框
|
||||
*/
|
||||
fun showFSMExceptionStatusWindow(errorMsg: ArrayList<String>) {
|
||||
fun showFSMExceptionStatusWindow(errorMsg: List<String>) {
|
||||
hmiProviderApi?.showFSMExceptionStatusWindow(errorMsg)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user