diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt index b68f765d6b..46a8a17644 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/msgbox/DataManager.kt @@ -69,12 +69,19 @@ object DataManager { } /** - * FSM消息(缓存数据库时使用) + * FM消息(缓存数据库时使用) */ private val fmInfoList by lazy { mutableListOf() } + /** + * FSM消息(缓存数据库时使用) + */ + private val fsmInfoList by lazy { + mutableListOf() + } + private val scope by lazy { Utils.getApp().lifeCycleScope } @@ -149,6 +156,13 @@ object DataManager { CallerMsgBoxListenerManager.invokeListener(MsgCategory.NOTICE, msg) } + MsgBoxType.FSM -> { + synchronized(this) { + fsmInfoList.add(msg) + } + CallerMsgBoxListenerManager.invokeListener(MsgCategory.NOTICE, msg) + } + MsgBoxType.SSMINFO -> {// 不存数据库 CallerMsgBoxListenerManager.invokeListener(MsgCategory.SYS_INFO, msg) } @@ -346,6 +360,18 @@ object DataManager { } } + MsgBoxType.FSM.ordinal -> { + return@map MsgBoxBean( + MsgBoxType.FSM, + GsonUtils.fromJson(json, FSMMsg::class.java) + ).apply { + this.timestamp = msgInfo.timeStamp + withContext(Dispatchers.Main) { + cacheNotifyList.add(this@apply) + } + } + } + else -> { return@map null } @@ -396,6 +422,13 @@ object DataManager { fmInfoList.clear() } + if (fsmInfoList.isNotEmpty()) { + fsmInfoList.forEach { + msgInfoList.add(MsgBoxInfo(it.bean2Json, it.type.ordinal, it.timestamp)) + } + fsmInfoList.clear() + } + if (msgInfoList.isNotEmpty()) { MsgBoxDb.getDb(context) .monitorDao() diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt index 18436b65e5..fb89246bb1 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxBubbleAdapter.kt @@ -46,7 +46,8 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A private val fm: Int = 6 private val ssm: Int = 7 private val autopilot: Int = 8 - private val none: Int = 9 + private val fsm: Int = 9 + private val none: Int = 10 private var changeViewListener: ChangeViewListener?=null @@ -103,6 +104,10 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_bubble_autopilot,parent,false) return BubbleAutopilotHolder(view) } + fsm -> { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_bubble_fsm,parent,false) + return BubbleFSMHolder(view) + } else -> { val view = LayoutInflater.from(parent.context).inflate(R.layout.item_msg_bubble_v2x,parent,false) return BubbleV2XHolder(view) @@ -308,6 +313,16 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A holder.tvAutopilotTime.text = TimeUtils.millis2String(autopilotMsg.timestamp,getHourMinFormat()) } } + + //FSM消息 + is BubbleFSMHolder ->{ + data?.let { + val fsmMsg = it[position].msgBoxBean.bean as FSMMsg + holder.tvFSMTitle.text = fsmMsg.title + holder.tvFSMContent.text = fsmMsg.content + holder.tvFSMTime.text = TimeUtils.millis2String(fsmMsg.timestamp,getHourMinFormat()) + } + } } val msgBoxBean: MsgBoxCountDownBean = data!![position] @@ -361,6 +376,8 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A ssm }else if(data!![position].msgBoxBean.type == MsgBoxType.AUTOPILOT){ autopilot + }else if(data!![position].msgBoxBean.type == MsgBoxType.FSM){ + fsm } else { v2x } @@ -445,6 +462,14 @@ class DriverMsgBoxBubbleAdapter(private val activity: Activity) : RecyclerView.A var tvAutopilotContent: TextView = itemView.findViewById(R.id.tvAutopilotContent) } + //FSM状态消息(现阶段提示启动自驾失败消息,过渡阶段提示,未来展示fsm消息提醒) + class BubbleFSMHolder(itemView: View): RecyclerView.ViewHolder(itemView){ + var ivFSMImage: ImageView = itemView.findViewById(R.id.ivFSMImage) + var tvFSMTitle: TextView = itemView.findViewById(R.id.tvFSMTitle) + var tvFSMTime: TextView = itemView.findViewById(R.id.tvFSMTime) + var tvFSMContent: TextView = itemView.findViewById(R.id.tvFSMContent) + } + fun setChangeListener(listener: ChangeViewListener){ changeViewListener = listener } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt index 3eca1f6edd..2974aad26c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/msgbox/adapter/DriverMsgBoxListAdapter.kt @@ -48,6 +48,7 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : private val summary: Int = 8 //汇总消息 private val ssm: Int = 9 //SSM连接消息 private val autopilot = 20 //工控机连接消息 + private val fsm = 21 //fsm消息 private val none = -1 @@ -131,6 +132,11 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : .inflate(R.layout.item_msg_box_autopilot,parent,false) return MsgBoxAutopilot(view) } + fsm -> { + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.item_msg_box_fsm,parent,false) + return MsgBoxFSM(view) + } else -> { val view = LayoutInflater.from(parent.context) .inflate(R.layout.item_msg_box_v2x, parent, false) @@ -696,6 +702,15 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : holder.tvAutopilotTime.text = TimeUtils.millis2String(autopilotMsg.timestamp,getHourMinFormat()) } } + //fsm消息 + is MsgBoxFSM ->{ + data?.let { + val fsmMsg = it[position].bean as FSMMsg + holder.tvFSMTitle.text = fsmMsg.title + holder.tvFSMContent.text = fsmMsg.content + holder.tvFSMTime.text = TimeUtils.millis2String(fsmMsg.timestamp,getHourMinFormat()) + } + } } } @@ -736,6 +751,8 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : ssm } else if(data!![position].type == MsgBoxType.AUTOPILOT){ autopilot + } else if(data!![position].type == MsgBoxType.FSM){ + fsm } else if(data!![position].type == MsgBoxType.V2X || data!![position].type == MsgBoxType.OBU){ v2x } else { @@ -852,4 +869,12 @@ class DriverMsgBoxListAdapter(private val activity: Activity) : var tvAutopilotContent: TextView = itemView.findViewById(R.id.tvAutopilotContent) } + //fsm状态 + class MsgBoxFSM(itemView: View) : RecyclerView.ViewHolder(itemView){ + var ivFSMImage: ImageView = itemView.findViewById(R.id.ivFSMImage) + var tvFSMTitle: TextView = itemView.findViewById(R.id.tvFSMTitle) + var tvFSMTime: TextView = itemView.findViewById(R.id.tvFSMTime) + var tvFSMContent: TextView = itemView.findViewById(R.id.tvFSMContent) + } + } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_box_fsm.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_box_fsm.xml new file mode 100644 index 0000000000..9b2403e515 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_box_fsm.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_fsm.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_fsm.xml new file mode 100644 index 0000000000..ed2245fa1f --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/item_msg_bubble_fsm.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/FSMMsg.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/FSMMsg.kt new file mode 100644 index 0000000000..f672d26035 --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/FSMMsg.kt @@ -0,0 +1,11 @@ +package com.mogo.eagle.core.data.msgbox + +/** + * fsm相关的消息 + */ +data class FSMMsg( + val type: Int, + val title: String?, + val content: String?, + val timestamp : Long +) \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxType.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxType.kt index 15596db66c..2c5f37ad55 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxType.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/msgbox/MsgBoxType.kt @@ -2,5 +2,5 @@ package com.mogo.eagle.core.data.msgbox enum class MsgBoxType { // 按功能划分为几大类:运营、通知、V2X模块、OBU模块、工控机Report、录制、交通、FM、语音、SSM、工控机相关等 - OPERATION, NOTICE, V2X, OBU, REPORT, RECORD, TRAFFIC, FMINFO, VOICE, SSMINFO, AUTOPILOT + OPERATION, NOTICE, V2X, OBU, REPORT, RECORD, TRAFFIC, FMINFO, VOICE, SSMINFO, AUTOPILOT, FSM } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt index f4940f5b4f..dd0a51c12a 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutopilotStatisticsListenerManager.kt @@ -1,13 +1,45 @@ package com.mogo.eagle.core.function.call.autopilot +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.msgbox.FSMMsg +import com.mogo.eagle.core.data.msgbox.MsgBoxBean +import com.mogo.eagle.core.data.msgbox.MsgBoxType import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatisticsListener import com.mogo.eagle.core.function.call.base.CallerBase +import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager +import com.mogo.eagle.core.function.call.trace.CallerTrace import com.zhjt.mogo.adas.data.bean.AutopilotStatistics +import kotlin.properties.Delegates object CallerAutopilotStatisticsListenerManager : CallerBase() { + private var autopilotStatistics: AutopilotStatistics? by Delegates.observable(null) { _, _, newV -> + newV?.let { + if (!FunctionBuildConfig.isDemoMode && FunctionBuildConfig.isTakeoverRemind && + it.status == AutopilotStatistics.AUTOPILOT_START_STATUS.FAILED) { + CallerMsgBoxManager.saveMsgBox( + MsgBoxBean( + MsgBoxType.FSM, + FSMMsg( + 0, + "自动驾驶启动失败", + it.failedMessage.msg, + System.currentTimeMillis() + ) + ) + ) + } else { + CallerTrace.write("AutopilotStatistics", mapOf("autopilotStatistics" to it, + "isDemoMode" to FunctionBuildConfig.isDemoMode, + "isTakeoverRemind" to FunctionBuildConfig.isTakeoverRemind)) + } + } + } + + @Synchronized fun invokeAutopilotStatistics(statistics: AutopilotStatistics?) { + autopilotStatistics = statistics M_LISTENERS.forEach { val listener = it.value listener.onAutopilotStatistics(statistics)