验证OBU与RSU通讯链路数据通过,细节需要每个预警单独测试

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-27 11:50:01 +08:00
parent bdadad96f2
commit 27b46695c4
8 changed files with 481 additions and 74 deletions

View File

@@ -6,6 +6,7 @@ import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
@@ -39,27 +40,27 @@ class MogoPrivateObuManager private constructor() {
private var mContext: Context? = null
fun init(context: Context?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
mContext = context
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
//自研obu
MogoObuManager.getInstance().connect(context, "192.168.1.199")
MogoObuManager.getInstance().connect(context, "192.168.20.199")
MogoObuManager.getInstance().registerListener(mogoObuListener)
}
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
// OBU连接成功
override fun onConnected() {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onConnected ------> ")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnected ------> ")
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) }
}
// OBU连接失败
override fun onConnectFail(isNeedReconnect: Boolean) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onConnectFail ------> ")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnectFail ------> ")
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) }
@@ -67,7 +68,7 @@ class MogoPrivateObuManager private constructor() {
// OBU断开连接
override fun onDisconnect() {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onDisconnect ------> ")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onDisconnect ------> ")
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) }
@@ -76,26 +77,26 @@ class MogoPrivateObuManager private constructor() {
// 接收到的原始数据
override fun onReceiveOriginData(data: String) {
super.onReceiveOriginData(data)
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onReceiveOriginData ------> data = $data")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onReceiveOriginData ------> data = $data")
}
// 发送的数据
override fun onSendData(bytes: ByteArray) {
super.onSendData(bytes)
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onSendData ------> ")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onSendData ------> ")
}
// CV2X系统信息
override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) {
super.onCvxAppInitIndInfo(info)
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> $info")
}
// (2) 车辆信息CVX_HV_INFO_IND
override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo?) {
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", true) }
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxHvInfoIndInfo ------> $info")
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
val position = movingObjectInfo.position
@@ -142,7 +143,7 @@ class MogoPrivateObuManager private constructor() {
// (3) 远车信息CVX_RV_INFO_IND
override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> $info")
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", true) }
// 更新数据
TrafficDataConvertUtils.cvxRvInfoIndInfo2TrafficData(info)?.let {
@@ -152,7 +153,7 @@ class MogoPrivateObuManager private constructor() {
// (3) 道路事件预警信息CVX_RTI_THREAT_IND
override fun onCvxRtiThreatIndInfo(info: CvxRtiThreatIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxRtiThreatIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRtiThreatIndInfo ------> $info")
if (info != null && info.threat_info != null && info.ext_info != null) {
var alertContent = ""
@@ -162,13 +163,15 @@ class MogoPrivateObuManager private constructor() {
val level = info.threat_info.threat_level
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type}"
)
when (appId) {
// 道路危险情况预警
EventTypeEnum.TYPE_USECASE_ID_HLW.poiType -> {
LogUtils.dTag(
MogoObuConst.TAG_MOGO_OBU,
"onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- handleDirection = $direction --rtiType = ${info.ext_info.rti_type}"
)
EventTypeEnum.TYPE_USECASE_ID_HLW.poiType,
EventTypeEnum.TYPE_USECASE_ID_IVS.poiType
-> {
when (info.ext_info.rti_type) {
//急转弯
0x2 -> {
@@ -190,7 +193,7 @@ class MogoPrivateObuManager private constructor() {
}
//施工
0x7 -> {
appId = EventTypeEnum.TYPE_USECASE_ID_IVS.poiType
appId = EventTypeEnum.FOURS_ROAD_WORK.poiType
}
//限速
0xA -> {
@@ -227,11 +230,6 @@ class MogoPrivateObuManager private constructor() {
alertContent = EventTypeEnum.getWarningContent(appId)
ttsContent = EventTypeEnum.getWarningTts(appId)
}
// 车内标牌
EventTypeEnum.TYPE_USECASE_ID_IVS.poiType -> {
alertContent = EventTypeEnum.getWarningContent(appId)
ttsContent = EventTypeEnum.getWarningTts(appId)
}
// 前方拥堵提醒
EventTypeEnum.TYPE_USECASE_ID_TJW.poiType -> {
alertContent = EventTypeEnum.getWarningContent(appId)
@@ -247,23 +245,21 @@ class MogoPrivateObuManager private constructor() {
ObuConstants.STATUS.ADD,
ObuConstants.STATUS.UPDATE// 更新
-> {
if (level == 2 || level == 3) {
//显示警告红边
CallerHmiManager.showWarning(direction)
//显示弹框,语音提示
CallerHmiManager.showWarningV2X(
appId.toInt(),
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
//显示警告红边
CallerHmiManager.showWarning(direction)
//显示弹框,语音提示
CallerHmiManager.showWarningV2X(
appId.toInt(),
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
)
}
}
)
// 更新数据
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
@@ -289,7 +285,7 @@ class MogoPrivateObuManager private constructor() {
// (4) V2I预警信息CVX_IVP_THREAT_IND
override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "CvxIvpThreatIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "CvxIvpThreatIndInfo ------> $info")
if (info != null && info.ext_info != null && info.threat_info != null && info.ext_info.lights != null && info.ext_info.lights.isNotEmpty()) {
handlerTrafficLight(
info.threat_info.app_id,
@@ -300,24 +296,11 @@ class MogoPrivateObuManager private constructor() {
}
}
// (6) 地图红绿灯信息CVX_MAP_SPAT_INFO_IND
override fun onCvxMapSpatInfoIndInfo(info: CvxMapSpatInfoIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxMapSpatInfoIndInfo ------> $info")
if (info != null && info.ivp_threat_ext != null && info.ivp_threat_ext.lights != null && info.ivp_threat_ext.lights.isNotEmpty()) {
handlerTrafficLight(
info.ivp_threat_info.app_id,
info.status,
info.ivp_threat_ext.lights,
info.ivp_threat_ext.indicator
)
}
}
// (2) 弱势交通参与者预警信息CVX_PTC_THREAT_IND
override fun onCvxPtcThreatIndInfo(info: CvxPtcThreatIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxPtcInfoIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxPtcInfoIndInfo ------> $info")
if (info != null) {
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
)
@@ -379,7 +362,7 @@ class MogoPrivateObuManager private constructor() {
// (5) 限速预警信息CVX_SLW_THREAT_IND
override fun onCvxSlwThreatIndInfo(info: CvxSlwThreatIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxSlwThreatIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxSlwThreatIndInfo ------> $info")
if (info != null) {
when (info.status) {
// 添加
@@ -387,7 +370,8 @@ class MogoPrivateObuManager private constructor() {
ObuConstants.STATUS.UPDATE
-> {
if (info.ext_info != null) {
CallerHmiManager.showLimitingVelocity(info.ext_info.speed_limit_max.toInt())
// 计算为千米每小时 TODO 这里需要做一下向上取整数406080120等
CallerHmiManager.showLimitingVelocity((info.ext_info.speed_limit_max.toInt() * 60 * 60) / 1000)
}
}
// 删除
@@ -401,7 +385,7 @@ class MogoPrivateObuManager private constructor() {
// (1) V2V预警信息CVX_V2V_THREAT_IND
override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
info?.let {
//预警信息,预警类型 threat_level 2、3
info.threat_info?.let {
@@ -411,7 +395,7 @@ class MogoPrivateObuManager private constructor() {
val appId = info.threat_info.app_id
val level = info.threat_info.threat_level
val status = info.status
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"onCvxV2vThreatIndInfo target_classification = ${
getMessageDirection(info.ext_info.target_classification)
@@ -434,7 +418,7 @@ class MogoPrivateObuManager private constructor() {
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "预警红边:预警方向->$targetClassification")
Logger.d(MogoObuConst.TAG_MOGO_OBU, "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE,
@@ -478,7 +462,7 @@ class MogoPrivateObuManager private constructor() {
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<Light>, index: Int) {
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"handlerTrafficLight appId = $appId --- status = $status ---index = $index ---lights.size = ${lights.size} ---lights = $lights "
)
@@ -514,7 +498,7 @@ class MogoPrivateObuManager private constructor() {
//这里需要根据真实数据确定 index 取值方式
if (index != -1 && lights.size >= index) {
val currentLight = lights[index]
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} --- index = $index ---appId = $appId"
)
@@ -531,7 +515,7 @@ class MogoPrivateObuManager private constructor() {
}
isGreenLight = false
CallerHmiManager.showWarningTrafficLight(1)
var red = currentLight.count_down.toInt() + 1
val red = currentLight.count_down.toInt() + 1
CallerHmiManager.changeCountdownRed(if (red >= 0) red else 0)
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
alertContent = EventTypeEnum.getWarningContent(appId.toString())
@@ -554,13 +538,13 @@ class MogoPrivateObuManager private constructor() {
}
isRedLight = false
CallerHmiManager.showWarningTrafficLight(3)
var green = currentLight.count_down.toInt() + 1
val green = currentLight.count_down.toInt() + 1
CallerHmiManager.changeCountdownGreen(if (green >= 0) green else 0)
//防止数据出现问题的容错
CallerHmiManager.changeCountdownRed(0)
CallerHmiManager.changeCountdownYellow(0)
// 拼接建议速度
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}"
)
@@ -582,7 +566,7 @@ class MogoPrivateObuManager private constructor() {
adviceSpeed
)
var maxSpeed = currentLight.glosa_suggested_speed_max.toInt()
val maxSpeed = currentLight.glosa_suggested_speed_max.toInt()
if (maxSpeed > 0) {
CallerHmiManager.showWarningV2X(
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),
@@ -597,7 +581,7 @@ class MogoPrivateObuManager private constructor() {
0x3 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerHmiManager.showWarningTrafficLight(2)
var yellow = currentLight.count_down.toInt() + 1
val yellow = currentLight.count_down.toInt() + 1
CallerHmiManager.changeCountdownYellow(if (yellow >= 0) yellow else 0)
CallerHmiManager.changeCountdownGreen(0)
CallerHmiManager.changeCountdownRed(0)
@@ -623,7 +607,7 @@ class MogoPrivateObuManager private constructor() {
info: CvxV2vThreatIndInfo
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status"
)
@@ -719,7 +703,7 @@ class MogoPrivateObuManager private constructor() {
// 添加,更新 add的时候可能级别是2
ObuConstants.STATUS.ADD,
ObuConstants.STATUS.UPDATE -> {
LogUtils.dTag(
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)