完成了预警红边的迁移HMI

调用方式为
//显示警告红边
mIMoGoWaringProvider!!.showWarning(direction)

Signed-off-by: chenfufeng <chenfufeng@zhidaoauto.com>
This commit is contained in:
董宏宇
2021-09-10 22:02:24 +08:00
committed by chenfufeng
parent 17780054d4
commit cd1e2cfcf6
8 changed files with 108 additions and 164 deletions

View File

@@ -54,10 +54,12 @@ dependencies {
api rootProject.ext.dependencies.mogoutils
api rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":foudations:mogo-utils")
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-data')
}
implementation rootProject.ext.dependencies.mogoobu

View File

@@ -7,6 +7,7 @@ import com.mogo.commons.voice.AIAssist
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.EventTypeEnum
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.module.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
@@ -164,8 +165,8 @@ class MogoPrivateObuManager private constructor() {
val status = info.status
val level = info.threat_info.threat_level
val direction =
getOtherObjDirection(if (info.ext_info != null) info.ext_info.pos_classification else 7)
when (info.threat_info.app_id.toString()) {
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
when (appId) {
// 道路危险情况预警
EventTypeEnum.TYPE_USECASE_ID_HLW.poiType -> {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRtiThreatIndInfo appId = ${info.threat_info.app_id} --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type}")
@@ -174,11 +175,15 @@ class MogoPrivateObuManager private constructor() {
0x2 -> {
// 特殊处理左、右方向的
when (direction) {
3 -> {
WarningDirectionEnum.ALERT_WARNING_LEFT,
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT,
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
appId =
EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.poiType
}
4 -> {
WarningDirectionEnum.ALERT_WARNING_RIGHT,
WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT,
WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> {
appId =
EventTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.poiType
}
@@ -242,9 +247,7 @@ class MogoPrivateObuManager private constructor() {
// 添加
ObuConstants.STATUS.ADD -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
//显示弹框,语音提示
mIMoGoWaringProvider!!.showWarningV2X(
appId.toInt(),
@@ -259,10 +262,8 @@ class MogoPrivateObuManager private constructor() {
}
// 删除
ObuConstants.STATUS.DELETE -> {
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
mIMoGoWaringProvider?.disableWarningV2X(appId)
// 更新数据
@@ -275,9 +276,7 @@ class MogoPrivateObuManager private constructor() {
// 更新
else -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
// 更新数据
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficInfo(it)
@@ -322,6 +321,17 @@ class MogoPrivateObuManager private constructor() {
MogoObuConst.TAG_MOGO_OBU,
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
)
var v2xType = ""
if (info.ptc_type == 1) { //摩托车
v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType
} else if (info.ptc_type == 2) { //行人
v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType
}
val ttsContent = EventTypeEnum.getWarningTts(v2xType)
val alertContent = EventTypeEnum.getWarningContent(v2xType)
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1)
when (info.status) {
// 添加
ObuConstants.STATUS.ADD -> {
@@ -329,21 +339,8 @@ class MogoPrivateObuManager private constructor() {
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficInfo(it)
}
var v2xType = ""
if (info.ptc_type == 1) { //摩托车
v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType
} else if (info.ptc_type == 2) { //行人
v2xType = EventTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.poiType
}
val ttsContent = EventTypeEnum.getWarningTts(v2xType)
val alertContent = EventTypeEnum.getWarningContent(v2xType)
val direction = 1
//getOtherObjDirection(if (info.ext_info != null) info.ext_info.target_classification else 7)
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
mIMoGoWaringProvider!!.showWarningV2X(
v2xType.toInt(),
alertContent,
@@ -353,10 +350,8 @@ class MogoPrivateObuManager private constructor() {
}
// 删除
ObuConstants.STATUS.DELETE -> {
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
// 事件结束,还原交通参与者颜色
@@ -367,12 +362,8 @@ class MogoPrivateObuManager private constructor() {
}
// 更新
else -> {
val direction = 1
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction,
"ACTION_V2X_FRONT_WARNING"
)
// 显示警告红边
mIMoGoWaringProvider!!.showWarning(direction)
// 更新数据
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
@@ -437,51 +428,43 @@ class MogoPrivateObuManager private constructor() {
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): Int {
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE -> 1 //正前方
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE,
0x04 -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 2 //正
0x03 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE,
0x05 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
0x02 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正左方
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> 3 //左前方
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> 4 //右前方
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 5 //左后方 弹框目前后方分为左后,右后,正后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 6 //右后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> -1 //未知
else -> 0
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
/**
* 获取道路其他 的方位
*/
private fun getOtherObjDirection(posClassification: Int): Int {
return when (posClassification) {
0x01 -> 0 //事件中
0x02 -> 3 //左侧
0x03 -> 4 //右侧
0x04 -> 1 //前方
0x05 -> 2 //后方
else -> 7
}
}
fun release() {
MogoObuManager.getInstance().unregisterListener()
}
@@ -532,10 +515,7 @@ class MogoPrivateObuManager private constructor() {
// 红灯
0x1 -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
1,
"ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
mIMoGoWaringProvider?.showWarningTrafficLight(1)
mIMoGoWaringProvider?.changeCountdownRed(currentLight.count_down.toInt())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
@@ -599,7 +579,7 @@ class MogoPrivateObuManager private constructor() {
*/
private fun handleSdkObu(
appId: Int,
direction: Int,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: CvxV2vThreatIndInfo
@@ -614,12 +594,20 @@ class MogoPrivateObuManager private constructor() {
when (appId.toString()) {
// 变道预警,注意左后车辆/注意右后车辆
EventTypeEnum.TYPE_USECASE_ID_LCW.poiType -> {
alertContent = EventTypeEnum.getWarningContent(appId.toString())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
if (direction == 5) {
alertContent = EventTypeEnum.getWarningContent(appId)
ttsContent = EventTypeEnum.getWarningTts(appId)
if (
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 == 6) {
} else if (
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, "")
}
@@ -644,11 +632,19 @@ class MogoPrivateObuManager private constructor() {
//左转辅助
EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> {
alertContent = EventTypeEnum.getWarningContent(appId.toString())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
if (direction == 5) {
alertContent = EventTypeEnum.getWarningContent(appId)
ttsContent = EventTypeEnum.getWarningTts(appId)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
} else if (direction == 6) {
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
}
}
@@ -672,12 +668,20 @@ class MogoPrivateObuManager private constructor() {
//盲区预警
EventTypeEnum.TYPE_USECASE_ID_BSW.poiType -> {
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
alertContent = EventTypeEnum.getWarningContent(appId.toString())
if (direction == 5) { //左后
ttsContent = EventTypeEnum.getWarningTts(appId)
alertContent = EventTypeEnum.getWarningContent(appId)
if (
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 == 6) { //右后
} else if (
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, "")
}
@@ -693,17 +697,14 @@ class MogoPrivateObuManager private constructor() {
when (status) {
// 添加, add的时候可能级别是2
ObuConstants.STATUS.ADD -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction,
"ACTION_V2X_FRONT_WARNING"
)
//显示弹框,语音提示
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
mIMoGoWaringProvider!!.showWarningV2X(
//显示警告红边
mIMoGoWaringProvider?.showWarning(direction)
//显示弹框,语音提示
mIMoGoWaringProvider?.showWarningV2X(
appId,
alertContent,
if (level == 3) ttsContent else "",
@@ -720,10 +721,8 @@ class MogoPrivateObuManager private constructor() {
// 删除
ObuConstants.STATUS.DELETE -> {
isStrikeTts = false
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
@@ -735,9 +734,7 @@ class MogoPrivateObuManager private constructor() {
// 更新
else -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider?.showWarning(direction)
if (!isStrikeTts) {
AIAssist.getInstance(mContext).speakTTSVoice(ttsContent)
isStrikeTts = true