diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index bc0141771f..0b58988782 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -1236,4 +1236,11 @@ class DebugSettingView @JvmOverloads constructor( } + /** + * 时延显示 + */ + override fun onObuV2iDelayTime(delayTime: Long) { + tvObuDelay.text = "obu时延:" + delayTime.toString() + } + } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml index a304de25f0..512efa5bde 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_debug_setting.xml @@ -843,8 +843,22 @@ android:textSize="@dimen/dp_24" app:layout_constraintTop_toBottomOf="@id/obuDivider" /> - - + + { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType } WarningDirectionEnum.ALERT_WARNING_RIGHT, WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT, WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType } } } @@ -254,7 +255,7 @@ class MogoPrivateObuManager private constructor() { //事故 0xC -> { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType } //拥堵 0xD -> { @@ -263,7 +264,7 @@ class MogoPrivateObuManager private constructor() { //行人 0xF -> { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType } //禁止停车 0x13 -> { @@ -272,7 +273,7 @@ class MogoPrivateObuManager private constructor() { //学校 0x14 -> { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType } //桥梁 0x17 -> { @@ -285,7 +286,7 @@ class MogoPrivateObuManager private constructor() { //人行横道 0x19 -> { appId = - EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType + EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType } //减速慢行 0x1A -> { @@ -316,13 +317,13 @@ class MogoPrivateObuManager private constructor() { ttsContent = EventTypeEnum.getWarningTts(appId) if (info.threat_info != null) { CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "ttsContent = $ttsContent --alertContent = $alertContent ---info.threat_info.distance = ${info.threat_info.distance} " + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "ttsContent = $ttsContent --alertContent = $alertContent ---info.threat_info.distance = ${info.threat_info.distance} " ) if (info.threat_info.distance.toInt() != 0) { alertContent = String.format( - EventTypeEnum.getWarningContent(appId), - info.threat_info.distance.toInt() + EventTypeEnum.getWarningContent(appId), + info.threat_info.distance.toInt() ) } else { alertContent = "前方拥堵,减速慢行" @@ -330,8 +331,8 @@ class MogoPrivateObuManager private constructor() { } CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "ttsContent = $ttsContent --alertContent = $alertContent" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "ttsContent = $ttsContent --alertContent = $alertContent" ) } } @@ -346,17 +347,17 @@ class MogoPrivateObuManager private constructor() { //显示弹框,语音提示 CallerHmiManager.showWarningV2X(appId.toInt(), - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - } - }, - true, - 5000L + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 5000L ) // 更新数据 TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let { @@ -390,10 +391,10 @@ class MogoPrivateObuManager private constructor() { && info.ext_info.lights.isNotEmpty() ) { handlerTrafficLight( - info.threat_info.app_id, - info.status, - info.ext_info.lights, - info.ext_info.index + info.threat_info.app_id, + info.status, + info.ext_info.lights, + info.ext_info.index ) } } @@ -403,9 +404,20 @@ class MogoPrivateObuManager private constructor() { CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onCvxPtcInfoIndInfo ------> $info") // 交通参与者类型 0x0:未知 UNKNOWN | 0x1:非机动车 NON_MOTOR | 0x2:行人 PEDESTRIAN 0x3:RSU if (info != null && (info.ptc_type == 1 || info.ptc_type == 2)) { + //v2i数据传输延迟 + val hvTime = info.threat_info.hv_time.millisecond + val currentTime = TimeUtils.getNowMills() + val delayTime = currentTime - hvTime + CallerObuListenerManager.invokeDelayTime(delayTime) + CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxPtcInfoIndInfo ---status---> ${info.status}" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxPtcInfoIndInfo ---delayTime---> $delayTime" + ) + + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxPtcInfoIndInfo ---status---> ${info.status}" ) var v2xType = "" if (info.ptc_type == 1) { //摩托车 @@ -428,17 +440,17 @@ class MogoPrivateObuManager private constructor() { //显示警告红边 CallerHmiManager.showWarning(direction) CallerHmiManager.showWarningV2X(v2xType.toInt(), - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - } - }, - true, - 5000L + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 5000L ) // } // 更新数据 @@ -505,10 +517,10 @@ class MogoPrivateObuManager private constructor() { val level = info.threat_info.threat_level val status = info.status CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "onCvxV2vThreatIndInfo target_classification = ${ - getMessageDirection(info.ext_info.target_classification) - } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "onCvxV2vThreatIndInfo target_classification = ${ + getMessageDirection(info.ext_info.target_classification) + } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" ) handleSdkObu(appId, direction, status, level, info) } @@ -572,8 +584,8 @@ class MogoPrivateObuManager private constructor() { */ private fun handlerTrafficLight(appId: Int, status: Int, lights: List, index: Int) { CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "handlerTrafficLight appId = $appId --- status = $status ---index = $index ---lights.size = ${lights.size} ---lights = $lights " + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "handlerTrafficLight appId = $appId --- status = $status ---index = $index ---lights.size = ${lights.size} ---lights = $lights " ) when (status) { // 添加 @@ -599,9 +611,9 @@ class MogoPrivateObuManager private constructor() { */ @Synchronized private fun changeTrafficLightStatus( - appId: Int, - lights: List, - index: Int + appId: Int, + lights: List, + index: Int ) { var ttsContent = "" var alertContent = "" @@ -609,8 +621,8 @@ class MogoPrivateObuManager private constructor() { if (index != -1 && lights.size >= index) { val currentLight = lights[index] CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} ---rlvw_violation_type = ${currentLight.rlvw_violation_type} --- index = $index ---appId = $appId ---appId = $appId" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} ---rlvw_violation_type = ${currentLight.rlvw_violation_type} --- index = $index ---appId = $appId ---appId = $appId" ) // 闯红灯预警 when (currentLight.rlvw_violation_type) { @@ -623,8 +635,8 @@ class MogoPrivateObuManager private constructor() { ttsContent = EventTypeEnum.getWarningTts(appId.toString()) alertContent = EventTypeEnum.getWarningContent(appId.toString()) CallerHmiManager.showWarningV2X( - appId, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - appId.toString(), null, true, 5000L + appId, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + appId.toString(), null, true, 5000L ) } 0x3 -> {//闯黄灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_YELLOW_LIGHT @@ -666,37 +678,37 @@ class MogoPrivateObuManager private constructor() { CallerHmiManager.changeCountdownYellow(0) // 拼接建议速度 CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}" ) val adviceSpeed = - "${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}" + "${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}" val adviceSpeedTts = - "${currentLight.glosa_suggested_speed_min.toInt()}到${currentLight.glosa_suggested_speed_max.toInt()}" + "${currentLight.glosa_suggested_speed_min.toInt()}到${currentLight.glosa_suggested_speed_max.toInt()}" ttsContent = - String.format( - EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeedTts - ) + String.format( + EventTypeEnum.getWarningTts(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeedTts + ) alertContent = - String.format( - EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), - adviceSpeed - ) + String.format( + EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType), + adviceSpeed + ) val maxSpeed = currentLight.glosa_suggested_speed_max.toInt() if (maxSpeed > 0) { CallerHmiManager.showWarningV2X( - EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(), - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - appId.toString(), - null, - true, - 5000L + EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(), + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + appId.toString(), + null, + true, + 5000L ) } } @@ -723,16 +735,16 @@ class MogoPrivateObuManager private constructor() { * @see com.mogo.module.common.enums.EventTypeEnum */ private fun handleSdkObu( - appId: Int, - direction: WarningDirectionEnum, - status: Int, - level: Int, - info: CvxV2vThreatIndInfo + appId: Int, + direction: WarningDirectionEnum, + status: Int, + level: Int, + info: CvxV2vThreatIndInfo ) { // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的 CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status" ) var alertContent: String var ttsContent: String @@ -742,16 +754,16 @@ class MogoPrivateObuManager private constructor() { alertContent = EventTypeEnum.getWarningContent(appId.toString()) ttsContent = EventTypeEnum.getWarningTts(appId.toString()) if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT ) { ttsContent = String.format(ttsContent, "左") alertContent = String.format(alertContent, "左") } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT ) { ttsContent = String.format(ttsContent, "右") alertContent = String.format(alertContent, "右") @@ -786,16 +798,16 @@ class MogoPrivateObuManager private constructor() { ttsContent = EventTypeEnum.getWarningTts(appId.toString()) alertContent = EventTypeEnum.getWarningContent(appId.toString()) if ( - direction == WarningDirectionEnum.ALERT_WARNING_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT + direction == WarningDirectionEnum.ALERT_WARNING_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT ) { //左后 ttsContent = String.format(ttsContent, "左") alertContent = String.format(alertContent, "左") } else if ( - direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || - direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT + direction == WarningDirectionEnum.ALERT_WARNING_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT || + direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT ) { //右后 ttsContent = String.format(ttsContent, "右") alertContent = String.format(alertContent, "右") @@ -814,23 +826,23 @@ class MogoPrivateObuManager private constructor() { ObuConstants.STATUS.ADD, ObuConstants.STATUS.UPDATE -> { CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", - "appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" + "$M_OBU${MogoObuConst.TAG_MOGO_OBU}", + "appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" ) if (level == 2 || level == 3) { //显示弹框,语音提示 CallerHmiManager.showWarningV2X(appId, - alertContent, - ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 - object : IMoGoWarningStatusListener { - override fun onDismiss() { - // 关闭警告红边 - CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) - } - }, - true, - 5000L + alertContent, + ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 + (appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + object : IMoGoWarningStatusListener { + override fun onDismiss() { + // 关闭警告红边 + CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON) + } + }, + true, + 5000L ) //显示警告红边 CallerHmiManager.showWarning(direction) diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt index 042bf872e9..a2037a4ebe 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuStatusListener.kt @@ -13,4 +13,10 @@ interface IMoGoObuStatusListener { * @param obuStatusInfo OBU 状态信息 */ fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo) + + /** + * v2i时延 + */ + fun onObuV2iDelayTime(delayTime: Long) + } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuListenerManager.kt index d86e742390..b396fd75ec 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuListenerManager.kt @@ -97,4 +97,13 @@ object CallerObuListenerManager : CallerBase() { } } + fun invokeDelayTime(delayTime: Long) { + mObuStatusListeners.forEach { + val tag = it.key + val listener = it.value + listener.onObuV2iDelayTime(delayTime) + } + } + + } \ No newline at end of file