[6.6.0][FSM] feat: FM 消息和 FSM 消息重复时过滤;

This commit is contained in:
aibingbing
2024-08-21 15:01:50 +08:00
parent d85a334830
commit c53b9359cf

View File

@@ -16,9 +16,12 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxCountDownBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.MsgCategory
import com.mogo.eagle.core.data.msgbox.MsgFmData
import com.mogo.eagle.core.function.api.autopilot.IMoGoNodeStateListener
import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxListener
import com.mogo.eagle.core.function.api.order.IOrderListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerNodeStateListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxEventListenerManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager
@@ -26,9 +29,14 @@ import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.ui.msgbox.adapter.DriverMsgBoxBubbleAdapter
import com.mogo.eagle.core.function.msgbox.MsgBoxConfig
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.SoundPoolUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.zhjt.mogo.adas.data.Adas
import com.zhjt.mogo.adas.data.AdasConstants
import com.zhjt.mogo.adas.data.AdasConstants.NodeState
import kotlinx.android.synthetic.main.layout_driver_msg_box_bubble.view.*
import java.util.concurrent.atomic.AtomicReference
/**
* @author XuXinChao
@@ -39,7 +47,8 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener,IOrderListener {
) : ConstraintLayout(context, attrs, defStyleAttr), IMsgBoxListener,IOrderListener,
IMoGoNodeStateListener {
init {
LayoutInflater.from(context).inflate(R.layout.layout_driver_msg_box_bubble, this, true)
@@ -52,6 +61,9 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
private val dataList :ArrayList<MsgBoxCountDownBean> = ArrayList()
private var isShowData = true
private var isShowSummary = false //是否展示汇总消息
private val fsmNodeState by lazy { // 是否存在 FSM 模块
AtomicReference<NodeState>(CallerAutoPilotControlManager.getNodeStateInfo(AdasConstants.NodeName.FSM2024)?.nodeState ?: NodeState.NODE_UNKNOWN)
}
private fun initView() {
val linearLayoutManager = LinearLayoutManager(context)
@@ -140,14 +152,17 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
//自动驾驶状态 0是不可用 1是ready 2是自动驾驶中 7:平行驾驶中
if(CallerAutoPilotStatusListenerManager.getState() == 2
|| CallerAutoPilotStatusListenerManager.getState() == 7){
//语音提示
try {
SoundPoolUtils.getSoundPool().playSoundWithRedId(context,R.raw.weak_net_tips)
}catch (e: Exception){
e.printStackTrace()
// 6.6.0 ,因为 FSM 模块也会弹修改为只有没有 FSM 模块才弹
if (hasNoneFSMNode()) {
//语音提示
try {
SoundPoolUtils.getSoundPool().playSoundWithRedId(context,R.raw.weak_net_tips)
}catch (e: Exception){
e.printStackTrace()
}
//展示消息
showData(msgBoxBean)
}
//展示消息
showData(msgBoxBean)
}
}
}
@@ -176,12 +191,14 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
super.onAttachedToWindow()
CallerMsgBoxListenerManager.addListener(TAG,this)
CallerOrderListenerManager.addListener(TAG,this)
CallerNodeStateListenerManager.addNodeStateListener(TAG, setOf(AdasConstants.NodeName.FSM2024), this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerMsgBoxListenerManager.removeListener(TAG)
CallerOrderListenerManager.removeListener(TAG)
CallerNodeStateListenerManager.removeNodeStateListener(TAG)
}
override fun onUpdateOrderStatus(inOrder: Boolean) {
@@ -195,4 +212,28 @@ class DriverMsgBoxBubbleView @JvmOverloads constructor(
driverMsgBoxBubbleAdapter?.setData(dataList)
}
/**
* 所连接的域控的节点状态信息
* 目前包含状态 节点是否存在;节点是否超时;
* SSM 只判断超时状态
* FSM 是否存在;是否超时;
*
* @param name 节点名称
* @param stateInfo 节点状态信息 包含:未知;存在;不存在; 以及存在的一些状态
*/
override fun onNodeStateInfo(name: AdasConstants.NodeName, stateInfo: Adas.NodeStateInfo) {
if (AdasConstants.NodeName.FSM2024 == name) {
fsmNodeState.set(stateInfo.nodeState)
}
}
/**
* 没有 FSM 模块
*/
private fun hasNoneFSMNode(): Boolean {
// 只有明确知道没有 FSM 模块才算,未知不算存在
return fsmNodeState.get() == AdasConstants.NodeState.NODE_NOT_EXIST ||
fsmNodeState.get() == AdasConstants.NodeState.NODE_UNKNOWN
}
}