add obu delay

This commit is contained in:
lixiaopeng
2022-03-23 15:03:24 +08:00
parent d72cc620ca
commit fc85d3ffff
5 changed files with 160 additions and 112 deletions

View File

@@ -1236,4 +1236,11 @@ class DebugSettingView @JvmOverloads constructor(
}
/**
* 时延显示
*/
override fun onObuV2iDelayTime(delayTime: Long) {
tvObuDelay.text = "obu时延" + delayTime.toString()
}
}

View File

@@ -843,8 +843,22 @@
android:textSize="@dimen/dp_24"
app:layout_constraintTop_toBottomOf="@id/obuDivider"
/>
<View
android:id="@+id/obuDivider2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#F0F0F0"
app:layout_constraintTop_toBottomOf="@id/tvObuInfo"
/>
<TextView
android:id="@+id/tvObuDelay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="obu时延:"
android:textColor="#000"
android:textSize="@dimen/dp_24"
app:layout_constraintTop_toBottomOf="@id/obuDivider2"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<ToggleButton

View File

@@ -4,14 +4,15 @@ import android.content.Context
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
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.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.map.MogoMapUIController
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
@@ -212,12 +213,12 @@ class MogoPrivateObuManager private constructor() {
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onCvxRtiThreatIndInfo direction = $direction -- pos_classification = ${info.ext_info.pos_classification}"
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onCvxRtiThreatIndInfo direction = $direction -- pos_classification = ${info.ext_info.pos_classification}"
)
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type} --direction = $direction -- pos_classification = ${info.ext_info.pos_classification} "
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type} --direction = $direction -- pos_classification = ${info.ext_info.pos_classification} "
)
when (appId) {
// 道路危险情况预警
@@ -233,13 +234,13 @@ class MogoPrivateObuManager private constructor() {
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT,
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
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<Light>, 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<Light>,
index: Int
appId: Int,
lights: List<Light>,
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)

View File

@@ -13,4 +13,10 @@ interface IMoGoObuStatusListener {
* @param obuStatusInfo OBU 状态信息
*/
fun onObuStatusResponse(obuStatusInfo: ObuStatusInfo)
/**
* v2i时延
*/
fun onObuV2iDelayTime(delayTime: Long)
}

View File

@@ -97,4 +97,13 @@ object CallerObuListenerManager : CallerBase() {
}
}
fun invokeDelayTime(delayTime: Long) {
mObuStatusListeners.forEach {
val tag = it.key
val listener = it.value
listener.onObuV2iDelayTime(delayTime)
}
}
}