增加OBU状态管理

增加Debug调试页面

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-30 20:49:04 +08:00
parent 0170a7a11c
commit f3ee6c8795
18 changed files with 207 additions and 48 deletions

View File

@@ -4,7 +4,7 @@ import android.content.Context
import android.view.View
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatAnimator
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.utils.WindowUtils
import com.mogo.utils.logger.Logger
@@ -138,12 +138,12 @@ class WarningFloat {
/**
* 设置视图状态监听showdismiss
* @param listener 设置视图状态监听
* @param listenerIMoGo 设置视图状态监听
*/
fun addWarningStatusListener(listener: WarningStatusListener?) =
fun addWarningStatusListener(listenerIMoGo: IMoGoWarningStatusListener?) =
apply {
if (listener != null) {
config.statusListenerMap.add(listener)
if (listenerIMoGo != null) {
config.statusListenerMapIMoGo.add(listenerIMoGo)
}
}

View File

@@ -134,7 +134,7 @@ internal class WarningFloatWindowHelper(
* 入场动画
*/
private fun enterAnim(floatingView: View) {
config.statusListenerMap.forEach { listener ->
config.statusListenerMapIMoGo.forEach { listener ->
listener.onShow()
}
if (frameLayout == null || config.isAnim) return
@@ -175,7 +175,7 @@ internal class WarningFloatWindowHelper(
* 退出动画
*/
fun exitAnim() {
config.statusListenerMap.forEach { listener ->
config.statusListenerMapIMoGo.forEach { listener ->
listener.onDismiss()
}
if (frameLayout == null || (config.isAnim && enterAnimator == null)) return

View File

@@ -6,7 +6,7 @@ import com.mogo.eagle.core.function.hmi.notification.enums.ShowPattern
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatAnimator
import com.mogo.eagle.core.function.hmi.notification.interfaces.OnFloatCallbacks
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
/**
* @author xiaoyuzhou
@@ -54,7 +54,7 @@ data class WarningNotificationConfig(
var floatAnimator: OnFloatAnimator? = DefaultAnimator(),
// 设置视图状态监听showdismiss
var statusListenerMap: ArrayList< WarningStatusListener> = ArrayList(),
var statusListenerMapIMoGo: ArrayList< IMoGoWarningStatusListener> = ArrayList(),
// Callbacks
var callbacks: OnFloatCallbacks? = null,

View File

@@ -14,7 +14,7 @@ import com.mogo.eagle.core.function.hmi.notification.WarningFloat
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
import com.mogo.eagle.core.function.hmi.notification.enums.SidePattern
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.hmi.R
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.fragment_hmi.*
@@ -55,7 +55,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
alertContent: String?,
ttsContent: String?,
tag: String?,
listener: WarningStatusListener?
listenerIMoGo: IMoGoWarningStatusListener?
) {
activity?.let {
@@ -80,8 +80,8 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
.setCountDownTime(10000)
.setGravity(Gravity.CENTER_HORIZONTAL, offsetY = 110)
.setImmersionStatusBar(true)
.addWarningStatusListener(listener)
.addWarningStatusListener(object : WarningStatusListener {
.addWarningStatusListener(listenerIMoGo)
.addWarningStatusListener(object : IMoGoWarningStatusListener {
override fun onShow() {
// 创建弹窗成功才进行TTS播报
Logger.d(

View File

@@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.hmi.ui
import com.mogo.commons.mvp.IView
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
/**
@@ -26,7 +26,7 @@ interface MoGoWarningContract {
alertContent: String?,
ttsContent: String?,
tag: String?,
listener: WarningStatusListener?
listenerIMoGo: IMoGoWarningStatusListener?
)
/**

View File

@@ -0,0 +1,11 @@
package com.mogo.eagle.core.function.hmi.ui.setting;
/**
* @author xiaoyuzhou
* @date 2021/9/30 8:46 下午
* 调试使用的设置页面,这里制作为调试使用
* 展示 本机、网络、工控机、OBU等状态信息支持设置IP等参数进行调试
*/
public class DebugSettingView {
}

View File

@@ -8,7 +8,7 @@ import android.util.Log
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.function.hmi.WaringConst
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.service.MogoServicePaths
import com.mogo.utils.logger.Logger
@@ -72,9 +72,9 @@ class MoGoWarningProvider : IMoGoWaringProvider {
override fun showWarningV2X(
v2xType: Int, alertContent: String?,
ttsContent: String?, tag: String?,
listener: WarningStatusListener?
listenerIMoGo: IMoGoWarningStatusListener?
) {
mMoGoHmiFragment?.showWarningV2X(v2xType, alertContent, ttsContent, tag, listener)
mMoGoHmiFragment?.showWarningV2X(v2xType, alertContent, ttsContent, tag, listenerIMoGo)
}
override fun disableWarningV2X(tag: String?) {

View File

@@ -2,9 +2,9 @@ package com.mogo.eagle.core.function.obu.mogo
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.service.MogoServicePaths
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
/**
* @author xiaoyuzhou
@@ -13,8 +13,9 @@ import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
@Route(path = MogoServicePaths.PATH_V2X_OBU_MOGO)
class MoGoObuProvider : IMoGoObuProvider {
private val TAG = "MoGoObuProvider"
override fun init(context: Context) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "初始化蘑菇自研OBU……")
LogUtils.dTag(TAG, "初始化蘑菇自研OBU……")
MogoPrivateObuManager.INSTANCE.init(context)
}

View File

@@ -3,8 +3,10 @@ package com.mogo.eagle.core.function.obu.mogo
import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.data.obu.ObuStatusInfo
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
@@ -22,10 +24,10 @@ import com.zhidao.support.obu.model.advance.Light
import org.json.JSONObject
/**
* @description
*
* @author lixiaopeng
* @since 2021/8/8
* @description OBU 管理
*/
class MogoPrivateObuManager private constructor() {
companion object {
@@ -37,6 +39,7 @@ class MogoPrivateObuManager private constructor() {
private var mMogoServiceApis: IMogoServiceApis? = null
private var mIMogoMapService: IMogoMapService? = null
private var mContext: Context? = null
private var mObuStatusInfo = ObuStatusInfo()
fun init(context: Context?) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
@@ -46,7 +49,7 @@ class MogoPrivateObuManager private constructor() {
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
//自研obu
MogoObuManager.getInstance().connect(context, "192.168.1.199")
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
MogoObuManager.getInstance().registerListener(mogoObuListener)
}
@@ -54,12 +57,18 @@ class MogoPrivateObuManager private constructor() {
// OBU连接成功
override fun onConnected() {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnected ------> ")
mObuStatusInfo.obuStatus = true
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) }
}
// OBU连接失败
override fun onConnectFail(isNeedReconnect: Boolean) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnectFail ------> ")
mObuStatusInfo.obuStatus = false
mObuStatusInfo.obuHvStatus = false
mObuStatusInfo.obuRvStatus = false
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) }
@@ -68,6 +77,10 @@ class MogoPrivateObuManager private constructor() {
// OBU断开连接
override fun onDisconnect() {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onDisconnect ------> ")
mObuStatusInfo.obuStatus = false
mObuStatusInfo.obuHvStatus = false
mObuStatusInfo.obuRvStatus = false
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) }
@@ -90,11 +103,18 @@ class MogoPrivateObuManager private constructor() {
override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) {
super.onCvxAppInitIndInfo(info)
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> $info")
mObuStatusInfo.stackInfo = info.stack_info
mObuStatusInfo.appInfo = info.app_info
mObuStatusInfo.hliInfo = info.hli_info
mObuStatusInfo.otherInfo = info.other_info
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
}
// (2) 车辆信息CVX_HV_INFO_IND
override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo?) {
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", true) }
mObuStatusInfo.obuHvStatus = true
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxHvInfoIndInfo ------> $info")
if (info != null && info.basic_info != null && info.basic_info.position != null) {
val movingObjectInfo = info.basic_info
@@ -143,6 +163,8 @@ class MogoPrivateObuManager private constructor() {
// (3) 远车信息CVX_RV_INFO_IND
override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> $info")
mObuStatusInfo.obuRvStatus = true
CallerObuListenerManager.invokeCheckAutoPilotBtnListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", true) }
// 更新数据
TrafficDataConvertUtils.cvxRvInfoIndInfo2TrafficData(info)?.let {
@@ -231,7 +253,8 @@ class MogoPrivateObuManager private constructor() {
}
//人行横道
0x19 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType
appId =
EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType
}
//减速慢行
0x1A -> {
@@ -263,8 +286,8 @@ class MogoPrivateObuManager private constructor() {
if (info.threat_info != null) {
if (info.threat_info.distance.toInt() != 0) {
ttsContent = String.format(
EventTypeEnum.getWarningTts(appId),
info.threat_info.distance.toInt()
EventTypeEnum.getWarningTts(appId),
info.threat_info.distance.toInt()
)
} else {
ttsContent = "前方道路拥堵,请减速慢行"
@@ -286,7 +309,7 @@ class MogoPrivateObuManager private constructor() {
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
@@ -367,7 +390,7 @@ class MogoPrivateObuManager private constructor() {
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
@@ -754,7 +777,7 @@ class MogoPrivateObuManager private constructor() {
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)

View File

@@ -0,0 +1,47 @@
package com.mogo.eagle.core.data.obu
/**
* @author xiaoyuzhou
* @date 2021/9/30 5:38 下午
* OBU 相关的状态信息数据
*/
class ObuStatusInfo {
// 当前链接的IP地址, 默认地址 192.168.1.199
var connectIP: String = "192.168.1.199"
/**
* false--没有链接true--链接成功
*/
var obuStatus = false
/**
* false--没有链接true--链接成功
*/
var obuHvStatus = false
/**
* false--没有链接true--链接成功
*/
var obuRvStatus = false
/**
* Stack information
*/
var stackInfo: String = "v0.0"
/**
* Usecase APP information
*/
var appInfo: String = "v0.0"
/**
* HLI information
*/
var hliInfo: String = "v0.0"
/**
* Other information
*/
var otherInfo: String = "v0.0"
}

View File

@@ -21,7 +21,7 @@ interface IMoGoWaringProvider : IMoGoFunctionProvider {
alertContent: String?,
ttsContent: String?,
tag: String?,
listener: WarningStatusListener?
listenerIMoGo: IMoGoWarningStatusListener?
)
/**

View File

@@ -4,7 +4,7 @@ package com.mogo.eagle.core.function.api.hmi.warning
* @author xiaoyuzhou
* @date 2021/9/13 4:41 下午
*/
interface WarningStatusListener {
interface IMoGoWarningStatusListener {
fun onShow() {}
fun onDismiss() {}
}

View File

@@ -1,14 +1,13 @@
package com.mogo.eagle.core.function.api.obu;
package com.mogo.eagle.core.function.api.obu
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
/**
* @author xiaoyuzhou
* @date 2021/8/2 5:53 下午
* 蘑菇OBU 功能提接口
*/
public interface IMoGoObuProvider extends IProvider {
interface IMoGoObuProvider : IMoGoFunctionServerProvider {
}
}

View File

@@ -0,0 +1,16 @@
package com.mogo.eagle.core.function.api.obu
import com.mogo.eagle.core.data.obu.ObuStatusInfo
/**
* @author xiaoyuzhou
* @date 2021/9/30 5:53 下午
* OBU 状态监听回调
*/
interface IMoGoObuStatusListener {
/**
* 检查OBU连链接信息
* @param obuStatusInfo OBU 状态信息
*/
fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo)
}

View File

@@ -14,8 +14,11 @@ object CallerHmiListenerManager : CallerBase() {
private val TAG = "CallerHmiListenerManager"
private val checkAutoPilotBtnListeners: HashMap<String, IMoGoCheckAutoPilotBtnListener> =
HashMap()
// 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态
private var mIsChecked: Boolean = false
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mAutoPilotBtnListeners: HashMap<String, IMoGoCheckAutoPilotBtnListener> = HashMap()
/**
@@ -27,7 +30,8 @@ object CallerHmiListenerManager : CallerBase() {
@Nullable tag: String,
@Nullable listener: IMoGoCheckAutoPilotBtnListener
) {
checkAutoPilotBtnListeners[tag] = listener
mAutoPilotBtnListeners[tag] = listener
listener.onCheck(mIsChecked)
}
/**
@@ -35,7 +39,7 @@ object CallerHmiListenerManager : CallerBase() {
* @param tag 标记,用来注销监听使用
*/
fun removeCheckAutoPilotBtnListener(@Nullable tag: String) {
checkAutoPilotBtnListeners.remove(tag)
mAutoPilotBtnListeners.remove(tag)
}
/**
@@ -44,11 +48,12 @@ object CallerHmiListenerManager : CallerBase() {
*/
fun invokeCheckAutoPilotBtnListener(isChecked: Boolean) {
LogUtils.dTag(TAG, "isChecked:$isChecked")
checkAutoPilotBtnListeners.forEach {
mIsChecked = isChecked
mAutoPilotBtnListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onCheck(isChecked)
listener.onCheck(mIsChecked)
}
}

View File

@@ -2,9 +2,8 @@ package com.mogo.eagle.core.function.call.hmi
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.base.CallerBase
/**
@@ -31,9 +30,9 @@ object CallerHmiManager : CallerBase() {
alertContent: String?,
ttsContent: String?,
tag: String?,
listener: WarningStatusListener?
listenerIMoGo: IMoGoWarningStatusListener?
) {
waringProviderApi.showWarningV2X(v2xType, alertContent, ttsContent, tag, listener)
waringProviderApi.showWarningV2X(v2xType, alertContent, ttsContent, tag, listenerIMoGo)
}
/**

View File

@@ -0,0 +1,58 @@
package com.mogo.eagle.core.function.call.obu
import androidx.annotation.Nullable
import com.mogo.eagle.core.data.obu.ObuStatusInfo
import com.mogo.eagle.core.function.api.obu.IMoGoObuStatusListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.LogUtils
/**
* @author xiaoyuzhou
* @date 2021/9/30 5:48 下午
* OBU 监听管理
*/
object CallerObuListenerManager : CallerBase() {
private val TAG = "CallerObuListenerManager"
// 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态
private var mObuStatusInfo: ObuStatusInfo = ObuStatusInfo()
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mObuStatusListeners: HashMap<String, IMoGoObuStatusListener> = HashMap()
/**
* 添加自动驾驶按钮选中监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addCheckAutoPilotBtnListener(
@Nullable tag: String,
@Nullable listener: IMoGoObuStatusListener
) {
mObuStatusListeners[tag] = listener
listener.onObuStatusResponse(mObuStatusInfo)
}
/**
* 删除自动驾驶按钮选中监听
* @param tag 标记,用来注销监听使用
*/
fun removeCheckAutoPilotBtnListener(@Nullable tag: String) {
mObuStatusListeners.remove(tag)
}
/**
* 触发自动驾驶按钮选中监听
* @param isChecked 选中状态
*/
fun invokeCheckAutoPilotBtnListener(obuStatusInfo: ObuStatusInfo) {
LogUtils.dTag(TAG, "isChecked:$obuStatusInfo")
mObuStatusInfo = obuStatusInfo
mObuStatusListeners.forEach {
val tag = it.key
val listener = it.value
LogUtils.dTag(TAG, "tag:$tag listener:$listener")
listener.onObuStatusResponse(mObuStatusInfo)
}
}
}

View File

@@ -6,7 +6,7 @@ import com.mogo.service.cloud.socket.IMogoOnMessageListener
import com.mogo.eagle.core.data.v2x.AdvanceWarningBean
import com.mogo.module.v2x.V2XConst
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.module.v2x.utils.V2XUtils
@@ -74,7 +74,7 @@ class V2XMessageListener_404000 : IMogoOnMessageListener<AdvanceWarningBean> {
}
// 显示弹框,语音提示
CallerHmiManager.showWarningV2X(appId, content, tts,
"$appId", object : WarningStatusListener {
"$appId", object : IMoGoWarningStatusListener {
override fun onShow() {}
override fun onDismiss() {
}