完成 道路事件预警信息
This commit is contained in:
@@ -115,14 +115,61 @@ class MogoPrivateObuManager private constructor() {
|
||||
mObuRecognizedResultDrawer?.addCvxRvInfoIndInfo(info)
|
||||
}
|
||||
|
||||
// 车与其他,obu与rsu
|
||||
// 道路事件预警信息:CVX_RTI_THREAT_IND 车与其他,obu与rsu
|
||||
override fun onCvxRtiThreatIndInfo(info: CvxRtiThreatIndInfo) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRtiThreatIndInfo ------> $info")
|
||||
//拥堵
|
||||
|
||||
//车内标盘
|
||||
var alertContent = ""
|
||||
var ttsContent = ""
|
||||
val appId = info.threat_info.app_id
|
||||
val status = info.status
|
||||
val level = info.threat_info.threat_level
|
||||
when (appId) {
|
||||
// 道路危险情况预警
|
||||
WarningTypeEnum.TYPE_USECASE_ID_HLW.useCaseId,
|
||||
// 车内标牌
|
||||
WarningTypeEnum.TYPE_USECASE_ID_IVS.useCaseId -> {
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
}
|
||||
// 前方拥堵提醒
|
||||
WarningTypeEnum.TYPE_USECASE_ID_TJW.useCaseId -> {
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
}
|
||||
}
|
||||
|
||||
//道路危险
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
//显示警告红边
|
||||
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
|
||||
getMessageDirection(5),
|
||||
"ACTION_V2X_FRONT_WARNING"
|
||||
)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
if (level == 3) ttsContent else "",
|
||||
appId.toString()
|
||||
)
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
|
||||
}
|
||||
// 更新
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 道路交通事件信息:十字路口、限速、
|
||||
override fun onCvxRoadTrafficInfoIndInfo(info: CvxRoadTrafficInfoIndInfo?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRoadTrafficInfoIndInfo ------> $info")
|
||||
|
||||
}
|
||||
|
||||
@@ -142,7 +189,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
// 弱势交通预警
|
||||
// 弱势交通参与者信息:CVX_PTC_INFO_IND
|
||||
override fun onCvxPtcInfoIndInfo(info: CvxPtcInfoIndInfo?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxPtcInfoIndInfo ------> $info")
|
||||
info?.let {
|
||||
@@ -184,7 +231,10 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
|
||||
|
||||
// V2V预警信息
|
||||
/**
|
||||
* V2V预警信息:CVX_V2V_THREAT_IND
|
||||
* @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID
|
||||
*/
|
||||
override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) {
|
||||
Logger.e(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
|
||||
info?.let {
|
||||
@@ -193,12 +243,12 @@ class MogoPrivateObuManager private constructor() {
|
||||
//预警方位
|
||||
val direction = info.ext_info.target_classification
|
||||
//处理预警类型
|
||||
val useCaseId = info.threat_info.app_id
|
||||
val appId = info.threat_info.app_id
|
||||
val level = info.threat_info.threat_level
|
||||
val status = info.status
|
||||
|
||||
handleSdkObu(
|
||||
useCaseId,
|
||||
appId,
|
||||
direction,
|
||||
status,
|
||||
level,
|
||||
@@ -209,10 +259,40 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回OBU监听
|
||||
*/
|
||||
fun getMogoObuListener(): OnMogoObuListener {
|
||||
return mogoObuListener
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息的方位
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): Int {
|
||||
return when (targetClassification) {
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT,
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> 1 //左前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 2 //左后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT,
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> 3 //右前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 4 //右后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE -> 5 //正前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 6 //正后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> 7 //未知
|
||||
else -> 7
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun release() {
|
||||
MogoObuManager.getInstance().unregisterListener()
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理红绿灯
|
||||
*/
|
||||
private fun handlerTrafficLight(status: Int, lights: List<Light>) =
|
||||
private fun handlerTrafficLight(status: Int, lights: List<Light>) {
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
@@ -244,48 +324,18 @@ class MogoPrivateObuManager private constructor() {
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回OBU监听
|
||||
*/
|
||||
fun getMogoObuListener(): OnMogoObuListener {
|
||||
return mogoObuListener
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取消息的方位
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): Int {
|
||||
return when (targetClassification) {
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT,
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> 1 //左前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 2 //左后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT,
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> 3 //右前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 4 //右后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE -> 5 //正前方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 6 //正后方
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> 7 //未知
|
||||
else -> 7
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun release() {
|
||||
MogoObuManager.getInstance().unregisterListener()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @param useCaseId 使用WarningTypeEnum获取icon、提示内容、tts内容
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容
|
||||
*
|
||||
* @see com.mogo.module.common.enum.WarningTypeEnum
|
||||
*/
|
||||
private fun handleSdkObu(
|
||||
useCaseId: Int,
|
||||
appId: Int,
|
||||
direction: Int,
|
||||
status: Int,
|
||||
level: Int,
|
||||
@@ -294,21 +344,21 @@ class MogoPrivateObuManager private constructor() {
|
||||
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 WarningTypeEnum 提供的
|
||||
var alertContent = ""
|
||||
var ttsContent = ""
|
||||
when (useCaseId) {
|
||||
when (appId) {
|
||||
// 变道预警,注意左后车辆/注意右后车辆
|
||||
WarningTypeEnum.TYPE_USECASE_ID_LCW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
if (direction == 2) {
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
} else if (direction == 4) else {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
}
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
|
||||
//车辆失控预警
|
||||
WarningTypeEnum.TYPE_USECASE_ID_CLW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
|
||||
if (direction == 1) { //左前
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
@@ -317,12 +367,12 @@ class MogoPrivateObuManager private constructor() {
|
||||
} else if (direction == 5) { //正前
|
||||
ttsContent = "前车失控预警"
|
||||
}
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
|
||||
//异常车辆提醒
|
||||
WarningTypeEnum.TYPE_USECASE_ID_AVW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
if (direction == 1) { //左前
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
} else if (direction == 3) { //右前
|
||||
@@ -330,18 +380,18 @@ class MogoPrivateObuManager private constructor() {
|
||||
} else if (direction == 5) { //正前
|
||||
ttsContent = "前车异常"
|
||||
}
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
|
||||
//盲区预警
|
||||
WarningTypeEnum.TYPE_USECASE_ID_BSW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
if (direction == 2) {
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
} else if (direction == 4) else {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
}
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
|
||||
// 弱势交通参与者碰撞预警,行人/摩托车碰撞预警 TODO
|
||||
@@ -351,8 +401,8 @@ class MogoPrivateObuManager private constructor() {
|
||||
|
||||
//限速预警 TODO
|
||||
WarningTypeEnum.TYPE_USECASE_ID_SLW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
if (status == ObuConstants.STATUS.ADD) {
|
||||
mIMoGoWaringProvider!!.showLimitingVelocity(0)
|
||||
} else if (status == ObuConstants.STATUS.DELETE) {
|
||||
@@ -362,15 +412,15 @@ class MogoPrivateObuManager private constructor() {
|
||||
|
||||
// 前方拥堵提醒,前方XXX米道路拥堵,请减速慢行 TODO
|
||||
WarningTypeEnum.TYPE_USECASE_ID_TJW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
// ttsContent = String.format(ttsContent, "")
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
|
||||
//闯红灯预警,应该是红灯。其他灯的时候 TODO
|
||||
WarningTypeEnum.TYPE_USECASE_ID_IVP.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
|
||||
if (status == ObuConstants.STATUS.ADD) {
|
||||
mIMoGoWaringProvider!!.showWarningTrafficLight(0)
|
||||
@@ -381,8 +431,8 @@ class MogoPrivateObuManager private constructor() {
|
||||
|
||||
// 这里处理固定的提示信息
|
||||
else -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
ttsContent = WarningTypeEnum.getWarningTts(appId)
|
||||
alertContent = WarningTypeEnum.getWarningContent(appId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,10 +446,10 @@ class MogoPrivateObuManager private constructor() {
|
||||
)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
useCaseId,
|
||||
appId,
|
||||
alertContent,
|
||||
if (status == 3) ttsContent else "",
|
||||
useCaseId.toString()
|
||||
if (level == 3) ttsContent else "",
|
||||
appId.toString()
|
||||
)
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
mObuRecognizedResultDrawer?.updateCvxRvInfoIndInfo(level, info)
|
||||
@@ -407,7 +457,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(useCaseId.toString())
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
|
||||
// 移除地图元素
|
||||
mObuRecognizedResultDrawer?.removeCvxRvInfoIndInfo(info.vehicle_id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user