修改自研OBU业务逻辑目录

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
董宏宇
2021-09-17 19:38:41 +08:00
parent 351d883388
commit ef8f6592e8
25 changed files with 10 additions and 9 deletions

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,226 @@
#### 说明
自研OBU感知预警模块,wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=58209118
接收OBU回调数据,进行UI呈现及相关业务
硬件记录:
经纬度采用WGS84坐标系
自车信息100毫秒回调一次需要处理断连风险采用Android系统自身定位信息「可能需要转换下坐标」
V2I场景会有持续性通知Status。需要有保底的情况进行超时清除事件
RV场景收到即显示收不到或断链的时候清除
多预警场景触发HVRV 会采用两个通道,同时触发的时候会采用集合的形式回调,优先级高的在最上面(待验证)
# OBU Lib
## 下载
* 步骤1添加到项目根目录 build.gradle 中
```groovy
allprojects {
repositories {
maven{
url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven {
url 'http://nexus.zhidaoauto.com/repository/maven-releases/'
}
maven {
url 'http://nexus.zhidaoauto.com/repository/maven-public/'
}
...
}
}
```
* 步骤2添加依赖关系
```groovy
dependencies {
implementation 'com.zhidao.support.obu:mogoobu:1.0.0.8'
...
}
```
## 初始化
```java
MogoObuManager.getInstance().init(Context context);
```
## 连接
```java
//默认192.168.8.199
MogoObuManager.getInstance().connect();
//自定义 IP
MogoObuManager.getInstance().connect(String ip);
```
## 断开连接
```java
MogoObuManager.getInstance().disConnect();
```
## 注册监听
```java
MogoObuManager.getInstance().registerListener(OnMogoObuListener obuListener);
```
## 取消注册监听
```java
MogoObuManager.getInstance().unregisterListener();
```
## OBU监听
```java
private OnMogoObuListener listener = new OnMogoObuListener() {
@Override
public void onConnected() {
//OBU连接成功
}
@Override
public void onConnectFail(boolean isNeedReconnect) {
//OBU连接失败
}
@Override
public void onDisconnect() {
//OBU断开连接
}
@Override
public void onReceiveOriginData(byte[] data) {
super.onReceiveOriginData(data);
//接收到的原始数据
}
@Override
public void onReceiveOriginData(String data) {
super.onReceiveOriginData(data);
//接收到的原始数据
}
@Override
public void onSendData(byte[] bytes) {
super.onSendData(bytes);
//发送的数据
}
@Override
public void onCvxHvCarIndInfo(CvxHvCarIndInfo info) {
super.onCvxHvCarIndInfo(info);
//主车车辆信息
}
@Override
public void onCvxHvInfoIndInfo(CvxHvInfoIndInfo info) {
//主车信息
}
@Override
public void onCvxRvInfoIndInfo(CvxRvInfoIndInfo info) {
//远车信息
}
@Override
public void onCvxRoadTrafficInfoIndInfo(CvxRoadTrafficInfoIndInfo info) {
super.onCvxRoadTrafficInfoIndInfo(info);
}
@Override
public void onCvxPtcInfoIndInfo(CvxPtcInfoIndInfo info) {
super.onCvxPtcInfoIndInfo(info);
}
@Override
public void onCvxMapSpatInfoIndInfo(CvxMapSpatInfoIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxV2vThreatIndInfo(CvxV2vThreatIndInfo info) {
//V2V预警信息
}
@Override
public void onCvxPtcThreatIndInfo(CvxPtcThreatIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxRtiThreatIndInfo(CvxRtiThreatIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxIvpThreatIndInfo(CvxIvpThreatIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxSlwThreatIndInfo(CvxSlwThreatIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxThreatRankIndInfo(CvxThreatRankIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxAppInitIndInfo(CvxAppInitIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
// CVX系统信息
}
@Override
public void onCvxAppErrorIndInfo(CvxAppErrorIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxAppDbgRangeCheckIndInfo(CvxAppDbgRangeCheckIndInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onCvxSetConfigCfm(CvxSetConfigCfmInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
//设置CVX系统的配置确认
}
@Override
public void onCvxAppErrorCfmInfo(CvxAppErrorCfmInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
}
@Override
public void onNuImplInfo(NuImplInfo info) {
super.onCvxMapSpatInfoIndInfo(info);
//异常/错误/未知数据
}
};
```
## 测试数据
```java
//CVX_V2V_THREAT_IND USECASE_ID_ICW 交叉路口碰撞预警
String data = "0200003901000000000000000FFAE449D7DCF8228D0000142A03000907E507020C032C012C00000F1B010B50000B00000662470A5700000653";
//CVX_V2V_THREAT_IND USECASE_ID_FCW 前向碰撞预警
String data = "02000138010000000000001effd7892b11a4440af70100142a02000907e506100e033b0258000006a0010000000b0000146411005a00000c290010000a17f5ea0f45955b1000fd68da01d200090a0006012c01f4009600080032003200320032000b00000000000000000000000000000000190000002300000895000000060000089500000890695a11000000a20010000a17f5eb5a459568ed00fd00001e140010000a17f5eb004595796b00fd000267fa0010000a17f5e9bc45957b9b00fd0002709c0010000a17f5e81945957a9700fd0002786c0010000a17f5e87a4595757300fd000285500010000a17f5e8fd4595649400fd0002a3000010000a17f5e74a459536a400fe0002f6fc0010000a17f5e8ef459525a001000006bb700010000a17f5e92a4595144a01010006d7f400060000448e2710";
//CVX_V2V_THREAT_IND USECASE_ID_BSW 盲区预警
String data = "020000ba010000000000001effd2b073b490d08b0e0100142a07000907e506100c2b070258fffff364010000000b0000365a22465700003a980010000a17f5e977459491bd01032283012e00090a0006012c01f400960008009d009d009d009d000b0000000000000000000000000000000019fffffffcfffff0acfffffd62fffff17000000f4a699222000000240010000a17f5e8fa45948c230103000037dc0010000a17f5e6a345948a4c0121000259f40006000027101f40";
// CVX_V2V_THREAT_IND USECASE_ID_EBW 紧急制动预警
String data = "02000126010000000000001EFF58E70F553F9EA4DE0100142A01000907E506120E360500C8000004930322F7000B000008A4118B99000001F00010000A17F595114595DC2500FB02BD027200090A0006012C01F400960008FE76FE76FE76FE76000B0000000000000000000000000000000019FFFFFFB400000687FFFFFFB4000006870000068C01E511000000900010000A17F588164595D9FF00FB000015180010000A17F579234595D8A900FA000101D00010000A17F577844595D67E00FA00010FD60010000A17F578A64595D49400FA00011B8E0010000A17F57E884595D68B00FA00012D900010000A17F5AA0D4595DE5100FC000184AC0010000A17F5BFB04595E08300FC000204040010000A17F5C0EA4595E06A00F5000798EC00060004FFEC2710";
//CVX_HV_INFO_IND 自车信息
String data = "010100D70000000000000003DF000907E506120E090E01900010000A17F5EF204595EBFF00DB098B028700060000000000000008004E004E004E004E000B000000000000000000000000000000007E0010000A17F5ED014595EA8300DB0000044C0010000A17F5E9914595E5B300DB00000F3C0010000A17F5E82C4595DDE600DB000020D00010000A17F5E88945959A4200E500009A4C0010000A17F5E78945958C6300E50000B8C30010000A17F5E8C8459580A100D40007F51C0010000A17F5E90D459565C900DE000820780006FFFFF07617700000";
//CVX_RV_INFO_IND 远车信息
String data = "010200E700000000000001FEFF58E70F553F9EA4DE00000907E506120F050B00B50010000A17F587544595D9DE00FA145300DE000600000000000000090A0006012C01F400960008FFC7FFC7FFC7FFC7000B0000000000000000000000000000000019FFFFFD9200000834FFFFFD920000083400000891425F000000005A0010000A17F5871A4595D84500FB000006A40010000A17F588AD4595D6DC00FA0000125C0010000A17F5A3264595DD1000FB000682680010000A17F5EC2E4595E99A00FD000718040010000A17F5EE664595E9F900FD00071D180006FFFFD8F0177000000000000000";
```
## 测试方法调用
```java
/**
* @param data 原始OBU数据流
*/
MogoObuManager.getInstance().test(String data);
/**
* @param opCode 参数1: OP_CODE
* 参数2: 目前只有OP_CODE = ObuConstants.OP_CODE.CVX_V2V_THREAT_IND时有效,OP_CODE为其他值时不需要传入
* 当OP_CODE = ObuConstants.OP_CODE.CVX_V2V_THREAT_IND预警时 默认不填紧急制动预警,0:交叉路口碰撞预警,1:前向碰撞预警,2:盲区预警
*/
MogoObuManager.getInstance().test(@Define.OpCode int... opCode) {
```

View File

@@ -0,0 +1,70 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'com.alibaba.arouter'
}
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
//ARouter apt 参数
kapt {
useBuildCache = false
arguments {
arg("AROUTER_MODULE_NAME", project.getName())
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.rxandroid
kapt rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduledata
} else {
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':core:mogo-core-data')
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-function-call')
}
implementation rootProject.ext.dependencies.mogoobu
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-obu-mogo
VERSION_CODE=1

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -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>

View File

@@ -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)
}
}

View File

@@ -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";
}

View File

@@ -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)
}
}
}
}
}

View File

@@ -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)
}
}
}
}

View File

@@ -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)
}
}
}
}

View File

@@ -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)
}
}

View File

@@ -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
}
}

View File

@@ -0,0 +1,14 @@
package com.mogo.eagle.core.function.api.obu;
import com.alibaba.android.arouter.facade.template.IProvider;
/**
* @author xiaoyuzhou
* @date 2021/8/2 5:53 下午
* 蘑菇OBU 功能提接口
*/
public interface IMoGoObuProvider extends IProvider {
}