@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.obu.mogo">
|
||||
|
||||
|
||||
<application>
|
||||
<receiver android:name=".receiver.ObuTestTriggerReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.obu.test_trigger" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receiver.ObuTestTriggerRecognizedReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.obu.test_trigger_recognized" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".receiver.ObuRsuTestTriggerReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.obu.test_light_recognized" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.module.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/2 5:52 下午
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_V2X_OBU_MOGO)
|
||||
class MoGoObuProvider : IMoGoObuProvider {
|
||||
private val TAG = "MoGoObuProvider"
|
||||
override fun init(context: Context) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "初始化蘑菇自研OBU……")
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.init(context)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.module.obu.mogo;
|
||||
|
||||
/**
|
||||
* author : lxiiaopeng
|
||||
* date : 2021-08-4
|
||||
* desc : 常量
|
||||
*/
|
||||
public class MogoObuConst {
|
||||
|
||||
/**
|
||||
* 自研obu的tag
|
||||
*/
|
||||
public static final String TAG_MOGO_OBU = "MogoObu";
|
||||
|
||||
// OBU 场景测试
|
||||
// 场景类型
|
||||
public static String BROADCAST_OBU_TYPE_EXTRA_KEY = "obuType";
|
||||
// 场景操作状态,ObuConstants.STATUS
|
||||
public static String BROADCAST_OBU_STATES_EXTRA_KEY = "obuStates";
|
||||
// 场景预警等级,2-弹窗,3-弹窗+tts+地图绘制
|
||||
public static String BROADCAST_OBU_LEVEL_EXTRA_KEY = "obuLevel";
|
||||
//红绿灯标识 0:不可用,1:红灯,2:绿灯,3:黄灯
|
||||
public static String BROADCAST_LIGHT_LEVEL_EXTRA_KEY = "lightLevel";
|
||||
//弱势交通 0:未知,1:非机动车,2:行人
|
||||
public static String BROADCAST_PTC_INFO_EXTRA_KEY = "ptcInfo";
|
||||
//道路交通信息类型 0x0--0x17
|
||||
public static String BROADCAST_RTI_TYPE_EXTRA_KEY = "rtiType";
|
||||
//道路交通信息触发方向 0x11--0x47
|
||||
public static String BROADCAST_OBU_EVENT_DIRECTION_EXTRA_KEY = "obuEventDirection";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,751 @@
|
||||
package com.mogo.module.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
|
||||
import com.mogo.module.common.drawer.TrafficMarkerDrawer
|
||||
import com.mogo.module.common.enums.EventTypeEnum
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
|
||||
import com.mogo.module.obu.mogo.utils.TrafficDataConvertUtils
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.map.IMogoMapService
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWaringProvider
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.WarningStatusListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.utils.storage.SharedPrefsMgr
|
||||
import com.zhidao.support.obu.MogoObuManager
|
||||
import com.zhidao.support.obu.OnMogoObuListener
|
||||
import com.zhidao.support.obu.constants.ObuConstants
|
||||
import com.zhidao.support.obu.model.*
|
||||
import com.zhidao.support.obu.model.advance.Light
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* @description
|
||||
*
|
||||
* @author lixiaopeng
|
||||
* @since 2021/8/8
|
||||
*/
|
||||
class MogoPrivateObuManager private constructor() {
|
||||
companion object {
|
||||
val INSTANCE: MogoPrivateObuManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoPrivateObuManager()
|
||||
}
|
||||
}
|
||||
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
private var mIMogoMapService: IMogoMapService? = null
|
||||
private var mContext: Context? = null
|
||||
|
||||
fun init(context: Context?) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
mContext = context
|
||||
// 获取预警模块的接口
|
||||
mIMoGoWaringProvider = CallerHmiManager.getWaringProviderApi()
|
||||
mIMogoMapService = mMogoServiceApis!!.mapServiceApi
|
||||
|
||||
//自研obu
|
||||
MogoObuManager.getInstance().connect(context, "192.168.1.199")
|
||||
MogoObuManager.getInstance().registerListener(mogoObuListener)
|
||||
}
|
||||
|
||||
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
|
||||
// OBU连接成功
|
||||
override fun onConnected() {
|
||||
LogUtils.dTag(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 ------> ")
|
||||
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) }
|
||||
}
|
||||
|
||||
// OBU断开连接
|
||||
override fun onDisconnect() {
|
||||
LogUtils.dTag(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) }
|
||||
}
|
||||
|
||||
// 接收到的原始数据
|
||||
override fun onReceiveOriginData(data: String) {
|
||||
super.onReceiveOriginData(data)
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onReceiveOriginData ------> data = $data")
|
||||
|
||||
}
|
||||
|
||||
// 发送的数据
|
||||
override fun onSendData(bytes: ByteArray) {
|
||||
super.onSendData(bytes)
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onSendData ------> ")
|
||||
}
|
||||
|
||||
// CV2X系统信息
|
||||
override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) {
|
||||
super.onCvxAppInitIndInfo(info)
|
||||
LogUtils.dTag(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")
|
||||
if (info != null && info.basic_info != null && info.basic_info.position != null) {
|
||||
val movingObjectInfo = info.basic_info
|
||||
val position = movingObjectInfo.position
|
||||
val data = JSONObject()
|
||||
try {
|
||||
data.putOpt("lon", position.longitude)
|
||||
data.putOpt("lat", position.latitude)
|
||||
data.putOpt("speed", movingObjectInfo.speed)
|
||||
data.putOpt("heading", movingObjectInfo.heading)
|
||||
if (info.acceleration_set != null) {
|
||||
data.putOpt("acceleration", info.acceleration_set.lateral)
|
||||
data.putOpt("yawRate", info.acceleration_set.yaw_rate)
|
||||
}
|
||||
|
||||
data.putOpt("gpsProvider", 2)
|
||||
try {
|
||||
data.putOpt("systemTime", System.currentTimeMillis())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
try {
|
||||
data.putOpt("satelliteTime", System.currentTimeMillis())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
try {
|
||||
data.putOpt("receiverDataTime", System.currentTimeMillis())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
try {
|
||||
data.putOpt("adasSatelliteTime", System.currentTimeMillis())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
mIMogoMapService?.mapUIController?.syncLocation2Map(data)
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(data)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// (3) 远车信息:CVX_RV_INFO_IND
|
||||
override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> $info")
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", true) }
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRvInfoIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficLocationInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
// (3) 道路事件预警信息:CVX_RTI_THREAT_IND
|
||||
override fun onCvxRtiThreatIndInfo(info: CvxRtiThreatIndInfo?) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxRtiThreatIndInfo ------> $info")
|
||||
|
||||
if (info != null && info.threat_info != null && info.ext_info != null) {
|
||||
var alertContent = ""
|
||||
var ttsContent = ""
|
||||
var appId = info.threat_info.app_id.toString()
|
||||
val status = info.status
|
||||
val level = info.threat_info.threat_level
|
||||
val direction =
|
||||
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
|
||||
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}")
|
||||
when (info.ext_info.rti_type) {
|
||||
//急转弯
|
||||
0x2 -> {
|
||||
// 特殊处理左、右方向的
|
||||
when (direction) {
|
||||
WarningDirectionEnum.ALERT_WARNING_LEFT,
|
||||
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT,
|
||||
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
|
||||
appId =
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
//施工
|
||||
0x7 -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_IVS.poiType
|
||||
}
|
||||
//限速
|
||||
0xA -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_SLW.poiType
|
||||
}
|
||||
//事故
|
||||
0xC -> {
|
||||
appId =
|
||||
EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType
|
||||
}
|
||||
//拥堵
|
||||
0xD -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_TJW.poiType
|
||||
}
|
||||
//行人
|
||||
0xF -> {
|
||||
appId =
|
||||
EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_CROSSING.poiType
|
||||
}
|
||||
//禁止停车
|
||||
0x13 -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType
|
||||
}
|
||||
//学校
|
||||
0x14 -> {
|
||||
appId =
|
||||
EventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType
|
||||
}
|
||||
//桥梁
|
||||
0x17 -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType
|
||||
}
|
||||
}
|
||||
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)
|
||||
ttsContent = String.format(
|
||||
EventTypeEnum.getWarningTts(appId),
|
||||
info.threat_info.distance.toInt()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(direction)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId.toInt(),
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X((appId + direction.direction).toString())
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
|
||||
// 事件结束,还原车辆颜色
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// (4) V2I预警信息:CVX_IVP_THREAT_IND
|
||||
override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) {
|
||||
LogUtils.dTag(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,
|
||||
info.status,
|
||||
info.ext_info.lights,
|
||||
info.ext_info.indicator
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// (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")
|
||||
if (info != null) {
|
||||
LogUtils.dTag(
|
||||
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)
|
||||
val level = if (info.threat_info != null) info.threat_info.threat_level else -1
|
||||
|
||||
when (info.status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE// 更新
|
||||
-> {
|
||||
if (level == 2 || level == 3) {
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
v2xType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(v2xType + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 更新数据
|
||||
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
mIMoGoWaringProvider?.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// (5) 限速预警信息:CVX_SLW_THREAT_IND
|
||||
override fun onCvxSlwThreatIndInfo(info: CvxSlwThreatIndInfo?) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxSlwThreatIndInfo ------> $info")
|
||||
if (info != null) {
|
||||
when (info.status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,
|
||||
-> {
|
||||
if (info.ext_info != null) {
|
||||
mIMoGoWaringProvider?.showLimitingVelocity(info.ext_info.speed_limit_max.toInt())
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
mIMoGoWaringProvider?.disableLimitingVelocity()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// (1) V2V预警信息:CVX_V2V_THREAT_IND
|
||||
override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
|
||||
info?.let {
|
||||
//预警信息,预警类型 threat_level 2、3
|
||||
info.threat_info?.let {
|
||||
//预警方位
|
||||
val direction = getMessageDirection(info.ext_info.target_classification)
|
||||
//处理预警类型
|
||||
val appId = info.threat_info.app_id
|
||||
val level = info.threat_info.threat_level
|
||||
val status = info.status
|
||||
LogUtils.dTag(
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回OBU监听
|
||||
*/
|
||||
fun getMogoObuListener(): OnMogoObuListener {
|
||||
return mogoObuListener
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息的方位 车辆相关
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "预警红边:预警方向->$targetClassification")
|
||||
return when (targetClassification) {
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE,
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE,
|
||||
0x04 -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
|
||||
|
||||
0x03 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
|
||||
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE,
|
||||
0x05 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
|
||||
|
||||
0x02 -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
|
||||
|
||||
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 -> 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 -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
|
||||
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT,
|
||||
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 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
|
||||
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
|
||||
else -> WarningDirectionEnum.ALERT_WARNING_ALL
|
||||
}
|
||||
}
|
||||
|
||||
fun release() {
|
||||
MogoObuManager.getInstance().unregisterListener()
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理红绿灯
|
||||
*/
|
||||
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<Light>, indicator: Int) {
|
||||
LogUtils.dTag(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"handlerTrafficLight appId = $appId --- status = $status ---indicator = $indicator ---lights = $lights ---lights.size = ${lights.size}"
|
||||
)
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE,
|
||||
-> {
|
||||
changeTrafficLightStatus(appId, lights, indicator)
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
mIMoGoWaringProvider?.disableWarningTrafficLight()
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var isRedLight = false
|
||||
private var isGreenLight = false
|
||||
|
||||
/**
|
||||
* 修改红绿灯
|
||||
*/
|
||||
private fun changeTrafficLightStatus(
|
||||
appId: Int,
|
||||
lights: List<Light>,
|
||||
indicator: Int
|
||||
) {
|
||||
var ttsContent = ""
|
||||
var alertContent = ""
|
||||
// TODO 这里需要根据真实数据确定 indicator 取值方式,暂时写 0 调试
|
||||
if (lights.size >= indicator) {
|
||||
val currentLight = lights[0]
|
||||
LogUtils.dTag(MogoObuConst.TAG_MOGO_OBU, "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} --- indicator = $indicator ---appId = $appId")
|
||||
when (currentLight.phase) {
|
||||
// 灯光不可用
|
||||
0x0 -> {
|
||||
mIMoGoWaringProvider?.showWarningTrafficLight(0)
|
||||
}
|
||||
// 红灯
|
||||
0x1 -> {
|
||||
if (!isRedLight) {
|
||||
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
|
||||
isRedLight = true
|
||||
}
|
||||
isGreenLight = false
|
||||
mIMoGoWaringProvider?.showWarningTrafficLight(1)
|
||||
mIMoGoWaringProvider?.changeCountdownRed(currentLight.count_down.toInt())
|
||||
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
|
||||
alertContent = EventTypeEnum.getWarningContent(appId.toString())
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
appId.toString(),
|
||||
null
|
||||
)
|
||||
}
|
||||
// 绿灯
|
||||
0x2 -> {
|
||||
if (!isGreenLight) {
|
||||
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
|
||||
isGreenLight = true
|
||||
}
|
||||
isRedLight = false
|
||||
mIMoGoWaringProvider?.showWarningTrafficLight(3)
|
||||
mIMoGoWaringProvider?.changeCountdownGreen(currentLight.count_down.toInt() + 1)
|
||||
//防止数据出现问题的容错
|
||||
mIMoGoWaringProvider?.changeCountdownRed(0)
|
||||
mIMoGoWaringProvider?.changeCountdownYellow(0)
|
||||
// 拼接建议速度
|
||||
LogUtils.dTag(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()}"
|
||||
|
||||
val adviceSpeedTts =
|
||||
"${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
|
||||
)
|
||||
|
||||
alertContent =
|
||||
String.format(
|
||||
EventTypeEnum.getWarningContent(EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType),
|
||||
adviceSpeed
|
||||
)
|
||||
|
||||
var maxSpeed = currentLight.glosa_suggested_speed_max.toInt()
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
appId.toString(),
|
||||
null
|
||||
)
|
||||
}
|
||||
// 黄灯
|
||||
0x3 -> {
|
||||
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
|
||||
mIMoGoWaringProvider?.showWarningTrafficLight(2)
|
||||
mIMoGoWaringProvider?.changeCountdownYellow(currentLight.count_down.toInt() + 1)
|
||||
mIMoGoWaringProvider?.changeCountdownGreen(0)
|
||||
mIMoGoWaringProvider?.changeCountdownRed(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容
|
||||
*
|
||||
* @see com.mogo.module.common.enums.EventTypeEnum
|
||||
*/
|
||||
private fun handleSdkObu(
|
||||
appId: Int,
|
||||
direction: WarningDirectionEnum,
|
||||
status: Int,
|
||||
level: Int,
|
||||
info: CvxV2vThreatIndInfo
|
||||
) {
|
||||
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的
|
||||
LogUtils.dTag(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status"
|
||||
)
|
||||
var alertContent: String
|
||||
var ttsContent: String
|
||||
when (appId.toString()) {
|
||||
// 变道预警,注意左后车辆/注意右后车辆
|
||||
EventTypeEnum.TYPE_USECASE_ID_LCW.poiType -> {
|
||||
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
|
||||
) {
|
||||
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
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
//车辆失控预警
|
||||
EventTypeEnum.TYPE_USECASE_ID_CLW.poiType -> {
|
||||
alertContent = EventTypeEnum.getWarningContent(appId.toString())
|
||||
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
|
||||
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
|
||||
//左转辅助
|
||||
EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> {
|
||||
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
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
} else if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
//异常车辆提醒
|
||||
EventTypeEnum.TYPE_USECASE_ID_AVW.poiType -> {
|
||||
alertContent = EventTypeEnum.getWarningContent(appId.toString())
|
||||
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
|
||||
//盲区预警
|
||||
EventTypeEnum.TYPE_USECASE_ID_BSW.poiType -> {
|
||||
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
|
||||
) { //左后
|
||||
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
|
||||
) { //右后
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
// 这里处理固定的提示信息
|
||||
else -> {
|
||||
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
|
||||
alertContent = EventTypeEnum.getWarningContent(appId.toString())
|
||||
}
|
||||
}
|
||||
|
||||
when (status) {
|
||||
// 添加,更新 add的时候,可能级别是2,
|
||||
ObuConstants.STATUS.ADD,
|
||||
ObuConstants.STATUS.UPDATE -> {
|
||||
LogUtils.dTag(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
if (level == 2 || level == 3) {
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider?.showWarningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的
|
||||
object : WarningStatusListener {
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
}
|
||||
}
|
||||
)
|
||||
//显示警告红边
|
||||
mIMoGoWaringProvider?.showWarning(direction)
|
||||
}
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 关闭警告红边
|
||||
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X((appId + direction.direction).toString())
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtils.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.mogo.module.obu.mogo.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.module.obu.mogo.MogoObuConst
|
||||
import com.mogo.module.obu.mogo.MogoPrivateObuManager
|
||||
import com.zhidao.support.obu.constants.ObuConstants
|
||||
import com.zhidao.support.obu.model.CvxIvpThreatIndInfo
|
||||
import com.zhidao.support.obu.model.CvxPtcThreatIndInfo
|
||||
import com.zhidao.support.obu.model.CvxRtiThreatIndInfo
|
||||
import com.zhidao.support.obu.model.CvxSlwThreatIndInfo
|
||||
import com.zhidao.support.obu.model.advance.*
|
||||
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @date 2021/8/18
|
||||
*
|
||||
* OBU 测试使用
|
||||
* 红绿灯
|
||||
*/
|
||||
class ObuRsuTestTriggerReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ObuRsuTestTriggerReceiver"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
mContext = context
|
||||
|
||||
val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0)
|
||||
val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0)
|
||||
val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3)
|
||||
val indicator = intent.getIntExtra(MogoObuConst.BROADCAST_LIGHT_LEVEL_EXTRA_KEY, 0)
|
||||
val pctType = intent.getIntExtra(MogoObuConst.BROADCAST_PTC_INFO_EXTRA_KEY, 0)
|
||||
val rtiType = intent.getIntExtra(MogoObuConst.BROADCAST_RTI_TYPE_EXTRA_KEY, 0)
|
||||
|
||||
LogUtils.dTag(
|
||||
TAG, "obuStatus:$obuStatus phase:$indicator obuType:$obuType obuLevel:$obuLevel"
|
||||
)
|
||||
|
||||
when (obuType) {
|
||||
ObuConstants.USE_CASE_ID.IVP -> { //构建红绿灯数据
|
||||
val cvxIvpThreatIndInfo = CvxIvpThreatIndInfo(1, 1, 1L)
|
||||
|
||||
val ivpThreat = IvpThreat(1, obuType, null, 1000, obuLevel, 100)
|
||||
|
||||
cvxIvpThreatIndInfo.threat_info = ivpThreat
|
||||
|
||||
val lightList = listOf(
|
||||
Light(1, 0x0, 1000, 3000, 6000, 3000, 100, 1000),
|
||||
Light(1, 0x1, 1000, 3000, 6000, 3000, 100, 1000),
|
||||
Light(1, 0x2, 1000, 3000, 6000, 3000, 100, 1000),
|
||||
Light(1, 0x3, 1000, 3000, 6000, 3000, 100, 1000)
|
||||
)
|
||||
val ivpThreatExt = IvpThreatExt(1, 1000, 1000, 0, indicator, lightList)
|
||||
cvxIvpThreatIndInfo.ext_info = ivpThreatExt
|
||||
cvxIvpThreatIndInfo.status = obuStatus
|
||||
cvxIvpThreatIndInfo.link_id = "1"
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.getMogoObuListener()
|
||||
.onCvxIvpThreatIndInfo(cvxIvpThreatIndInfo)
|
||||
}
|
||||
|
||||
ObuConstants.USE_CASE_ID.SLW -> { //限速预警
|
||||
val cvxSlwThreatIndInfo = CvxSlwThreatIndInfo(1, 1, 1L)
|
||||
val slwThreatExt = SlwThreatExt(1, 2, 6000, 2000)
|
||||
|
||||
cvxSlwThreatIndInfo.ext_info = slwThreatExt
|
||||
cvxSlwThreatIndInfo.status = obuStatus
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.getMogoObuListener()
|
||||
.onCvxSlwThreatIndInfo(cvxSlwThreatIndInfo)
|
||||
}
|
||||
|
||||
//弱势交通参与者碰撞预警,行人/摩托车碰撞预警
|
||||
ObuConstants.USE_CASE_ID.VRUCW -> {
|
||||
val cvxPtcIndInfo = CvxPtcThreatIndInfo(1, 1, 1)
|
||||
val position = Position(1, 399739429, 1164115207, 20)
|
||||
cvxPtcIndInfo.ptc_pos = position
|
||||
cvxPtcIndInfo.ptc_id = "111"
|
||||
cvxPtcIndInfo.ptc_type = pctType
|
||||
cvxPtcIndInfo.status = obuStatus
|
||||
|
||||
val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100)
|
||||
cvxPtcIndInfo.threat_info = v2vThreat
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.getMogoObuListener()
|
||||
.onCvxPtcThreatIndInfo(cvxPtcIndInfo)
|
||||
}
|
||||
|
||||
//道路危险情况, 车内标牌, 前方拥堵提醒
|
||||
ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS, ObuConstants.USE_CASE_ID.TJW -> {
|
||||
val cvxRtiThreatIndInfo = CvxRtiThreatIndInfo(1, 1, 1L)
|
||||
val dateTime = DateTime(1, 1, 1, 1, 1, 1, 1, 1)
|
||||
val rtiThread = RtiThreat(1, obuType, dateTime, 100000, obuLevel, 100)
|
||||
val extInfo = RtiThreatExt(1, rtiType, 0x02, 100000, 100000)
|
||||
val position = Position(1, 399739429, 1164115207, 20)
|
||||
|
||||
// 位置围栏
|
||||
val zonesInfo = listOf(
|
||||
ZoneInfo(1, 2000, 2000, listOf(position))
|
||||
)
|
||||
|
||||
cvxRtiThreatIndInfo.rti_id = "123123"
|
||||
cvxRtiThreatIndInfo.zones_info = zonesInfo
|
||||
cvxRtiThreatIndInfo.threat_info = rtiThread
|
||||
cvxRtiThreatIndInfo.ext_info = extInfo
|
||||
cvxRtiThreatIndInfo.status = obuStatus
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.getMogoObuListener()
|
||||
.onCvxRtiThreatIndInfo(cvxRtiThreatIndInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.mogo.module.obu.mogo.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.module.obu.mogo.MogoObuConst
|
||||
import com.mogo.module.obu.mogo.MogoPrivateObuManager
|
||||
import com.zhidao.support.obu.constants.ObuConstants
|
||||
import com.zhidao.support.obu.model.CvxV2vThreatIndInfo
|
||||
import com.zhidao.support.obu.model.advance.MovingObjectInfo
|
||||
import com.zhidao.support.obu.model.advance.Position
|
||||
import com.zhidao.support.obu.model.advance.V2vThreat
|
||||
import com.zhidao.support.obu.model.advance.V2vThreatExt
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/11 10:50 上午
|
||||
*
|
||||
* OBU 测试使用
|
||||
*/
|
||||
class ObuTestTriggerReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ObuTestTriggerReceiver"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
mContext = context
|
||||
/**
|
||||
* OBU 场景类型
|
||||
* @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID
|
||||
*/
|
||||
val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0)
|
||||
val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0)
|
||||
val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3)
|
||||
val obuDirection =
|
||||
intent.getIntExtra(MogoObuConst.BROADCAST_OBU_EVENT_DIRECTION_EXTRA_KEY, 0x11)
|
||||
LogUtils.dTag(
|
||||
TAG, "obuType:$obuType obuStatus:$obuStatus obuDirection$obuDirection"
|
||||
)
|
||||
|
||||
when (obuType) {
|
||||
ObuConstants.USE_CASE_ID.EBW, ObuConstants.USE_CASE_ID.FCW, ObuConstants.USE_CASE_ID.ICW,
|
||||
ObuConstants.USE_CASE_ID.CLW, ObuConstants.USE_CASE_ID.DNPW, ObuConstants.USE_CASE_ID.AVW,
|
||||
ObuConstants.USE_CASE_ID.BSW, ObuConstants.USE_CASE_ID.LCW, ObuConstants.USE_CASE_ID.EVW, ObuConstants.USE_CASE_ID.VRUCW,
|
||||
ObuConstants.USE_CASE_ID.SLW, ObuConstants.USE_CASE_ID.LTA, ObuConstants.USE_CASE_ID.HLW, ObuConstants.USE_CASE_ID.IVS,
|
||||
ObuConstants.USE_CASE_ID.TJW, ObuConstants.USE_CASE_ID.IVP, ObuConstants.USE_CASE_ID.COC -> {
|
||||
|
||||
// 构建测试数据
|
||||
val cvxV2vThreatIndInfo = CvxV2vThreatIndInfo(1, 1, 1L)
|
||||
|
||||
val v2vThreat = V2vThreat(1, obuType, null, 1000, obuLevel, 100)
|
||||
cvxV2vThreatIndInfo.threat_info = v2vThreat
|
||||
|
||||
val v2vThreatExt =
|
||||
V2vThreatExt(
|
||||
1, 1, obuDirection, 1, 1
|
||||
)
|
||||
cvxV2vThreatIndInfo.ext_info = v2vThreatExt
|
||||
cvxV2vThreatIndInfo.status = obuStatus
|
||||
cvxV2vThreatIndInfo.vehicle_id = "123321"
|
||||
|
||||
|
||||
// 设置位置
|
||||
val randomLocation = Random.nextInt(100, 2000)
|
||||
|
||||
val position = Position(
|
||||
0, (399739429 + randomLocation).toLong(),
|
||||
(1164115207 + randomLocation).toLong(), 20
|
||||
)
|
||||
val movingObjectInfo = MovingObjectInfo(
|
||||
0,
|
||||
position,
|
||||
1800 +randomLocation,
|
||||
6000 +randomLocation
|
||||
)
|
||||
cvxV2vThreatIndInfo.basic_info = movingObjectInfo
|
||||
|
||||
MogoPrivateObuManager.INSTANCE.getMogoObuListener()
|
||||
.onCvxV2vThreatIndInfo(cvxV2vThreatIndInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mogo.module.obu.mogo.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.module.obu.mogo.MogoObuConst
|
||||
import com.mogo.module.obu.mogo.MogoPrivateObuManager
|
||||
import com.zhidao.support.obu.model.CvxHvInfoIndInfo
|
||||
import com.zhidao.support.obu.model.advance.MovingObjectInfo
|
||||
import com.zhidao.support.obu.model.advance.Position
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/11 10:50 上午
|
||||
*
|
||||
* OBU 模拟自车
|
||||
*/
|
||||
class ObuTestTriggerRecognizedReceiver : BroadcastReceiver() {
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ObuTestTriggerRecognizedReceiver"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
mContext = context
|
||||
/**
|
||||
* OBU 场景类型
|
||||
* @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID
|
||||
*/
|
||||
val obuType = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_TYPE_EXTRA_KEY, 0)
|
||||
val obuStatus = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_STATES_EXTRA_KEY, 0)
|
||||
val obuLevel = intent.getIntExtra(MogoObuConst.BROADCAST_OBU_LEVEL_EXTRA_KEY, 3)
|
||||
LogUtils.dTag(TAG, "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel")
|
||||
|
||||
val cvxHvInfoIndInfo = CvxHvInfoIndInfo(0, 1, 2)
|
||||
|
||||
val randomLocation = Random.nextInt(100, 2000)
|
||||
|
||||
val position = Position(
|
||||
0, (399739429 + randomLocation).toLong(),
|
||||
(1164115207 + randomLocation).toLong(), 20
|
||||
)
|
||||
val movingObjectInfo = MovingObjectInfo(
|
||||
0,
|
||||
position,
|
||||
1800 +randomLocation,
|
||||
6000 +randomLocation
|
||||
)
|
||||
cvxHvInfoIndInfo.basic_info = movingObjectInfo
|
||||
|
||||
MogoPrivateObuManager.INSTANCE
|
||||
.getMogoObuListener()
|
||||
.onCvxHvInfoIndInfo(cvxHvInfoIndInfo)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.mogo.module.obu.mogo.utils
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.LogUtils
|
||||
import com.mogo.module.common.drawer.bean.TrafficData
|
||||
import com.mogo.module.common.enums.TrafficTypeEnum
|
||||
import com.zhidao.support.obu.constants.ObuConstants
|
||||
import com.zhidao.support.obu.model.CvxPtcThreatIndInfo
|
||||
import com.zhidao.support.obu.model.CvxRtiThreatIndInfo
|
||||
import com.zhidao.support.obu.model.CvxRvInfoIndInfo
|
||||
import com.zhidao.support.obu.model.CvxV2vThreatIndInfo
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/18 2:30 下午
|
||||
*/
|
||||
object TrafficDataConvertUtils {
|
||||
val TAG = "TrafficDataConvertUtils"
|
||||
|
||||
/**
|
||||
* OBU 远车 转换交通元素数据
|
||||
*/
|
||||
fun cvxRvInfoIndInfo2TrafficData(info: CvxRvInfoIndInfo): TrafficData? {
|
||||
if (info.basic_info == null || info.basic_info.position == null) {
|
||||
LogUtils.eTag(TAG, "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全")
|
||||
return null
|
||||
}
|
||||
val trafficData = TrafficData()
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
|
||||
trafficData.uuid = info.vehicle_id
|
||||
trafficData.lat = info.basic_info.position.latitude
|
||||
trafficData.lon = info.basic_info.position.longitude
|
||||
trafficData.heading = info.basic_info.heading
|
||||
trafficData.speed = info.basic_info.speed
|
||||
|
||||
return trafficData
|
||||
}
|
||||
|
||||
/**
|
||||
* OBU RSU道路事件预警信息 转换交通元素数据
|
||||
*/
|
||||
fun cvxRtiThreatIndInfo2TrafficData(info: CvxRtiThreatIndInfo): TrafficData? {
|
||||
// 这里只处理道路施工
|
||||
if (info.rti_id == null || info.ext_info == null || info.ext_info.rti_type != 0x7
|
||||
|| info.zones_info == null || info.zones_info.first() == null
|
||||
|| info.zones_info.first().path_points.first() == null
|
||||
|| info.threat_info == null
|
||||
) {
|
||||
LogUtils.eTag(TAG, "数据转换异常,请检查参数是否齐全")
|
||||
return null
|
||||
}
|
||||
val trafficData = TrafficData()
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG
|
||||
trafficData.uuid = info.rti_id
|
||||
|
||||
trafficData.lat = info.zones_info.first().path_points.first().latitude
|
||||
trafficData.lon = info.zones_info.first().path_points.first().longitude
|
||||
|
||||
trafficData.threatLevel = info.threat_info.threat_level
|
||||
|
||||
return trafficData
|
||||
}
|
||||
|
||||
/**
|
||||
* OBU 预警事件 转换交通元素数据
|
||||
*/
|
||||
fun cvxV2vThreatIndInfo2TrafficData(info: CvxV2vThreatIndInfo): TrafficData? {
|
||||
if (info.basic_info == null || info.basic_info.position == null || info.threat_info == null) {
|
||||
LogUtils.eTag(TAG, "数据转换异常,请检查参数是否齐全")
|
||||
return null
|
||||
}
|
||||
val trafficData = TrafficData()
|
||||
trafficData.uuid = info.vehicle_id
|
||||
trafficData.lat = info.basic_info.position.latitude
|
||||
trafficData.lon = info.basic_info.position.longitude
|
||||
trafficData.heading = info.basic_info.heading
|
||||
trafficData.speed = info.basic_info.speed
|
||||
// 判断车辆V2X预警级别,调整车辆颜色
|
||||
trafficData.threatLevel = info.threat_info.threat_level
|
||||
|
||||
if (info.threat_info.app_id == ObuConstants.USE_CASE_ID.EVW) {
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE
|
||||
} else {
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
|
||||
}
|
||||
|
||||
return trafficData
|
||||
}
|
||||
|
||||
/**
|
||||
* OBU 弱势交通参与者信息 转换交通元素数据 TODO
|
||||
*/
|
||||
fun cvxPtcThreatIndInfo2TrafficData(info: CvxPtcThreatIndInfo): TrafficData? {
|
||||
if (info.ptc_pos == null || info.threat_info == null) {
|
||||
LogUtils.eTag(TAG, "数据转换异常,请检查参数是否齐全")
|
||||
return null
|
||||
}
|
||||
val trafficData = TrafficData()
|
||||
|
||||
trafficData.uuid = info.ptc_id
|
||||
trafficData.lat = info.ptc_pos.latitude
|
||||
trafficData.lon = info.ptc_pos.longitude
|
||||
// trafficData.heading = info.ptc_pos.heading
|
||||
// trafficData.speed = info.ptc_pos.speed
|
||||
|
||||
when (info.ptc_type) {
|
||||
// 未知
|
||||
0x0 -> {
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
|
||||
}
|
||||
// 非机动车
|
||||
0x1 -> {
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
|
||||
}
|
||||
// 行人
|
||||
0x2 -> {
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
|
||||
}
|
||||
}
|
||||
|
||||
// 判断车辆V2X预警级别,调整车辆颜色
|
||||
if (info.threat_info != null) {
|
||||
trafficData.threatLevel = info.threat_info.threat_level
|
||||
}
|
||||
|
||||
return trafficData
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user