完成OBU 调试
This commit is contained in:
@@ -26,6 +26,9 @@ adb shell am broadcast -a com.hmi.v2x.limitingvelocity --ez limitingVelocityIsSh
|
||||
// 控制OBU场景自测
|
||||
adb shell am broadcast -a com.obu.test_trigger --ei obuStates 1 --ei obuLevel 3 --ei obuType 0x2A01
|
||||
|
||||
// 控制OBU 展示周边周边车辆 惠新西街南口附近,南向北
|
||||
adb shell am broadcast -a com.obu.test_trigger_recognized
|
||||
|
||||
|
||||
|
||||
// (旧版本)使用命令行触发各种测试场景演示
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
<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>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.common.enum.WarningTypeEnum
|
||||
import com.mogo.module.obu.mogo.map.ObuRecognizedResultDrawer
|
||||
@@ -14,7 +13,6 @@ 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.MovingObjectInfo
|
||||
|
||||
/**
|
||||
* @description
|
||||
@@ -247,7 +245,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
|
||||
|
||||
// V2V预警信息 TODO 他车是否一直出现
|
||||
// V2V预警信息
|
||||
override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo?) {
|
||||
Logger.e(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
|
||||
info?.let {
|
||||
@@ -255,26 +253,17 @@ class MogoPrivateObuManager private constructor() {
|
||||
info.threat_info?.let {
|
||||
//预警方位
|
||||
val direction = info.ext_info.target_classification
|
||||
//显示警告红边
|
||||
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
|
||||
getMessageDirection(direction),
|
||||
"ACTION_V2X_FRONT_WARNING"
|
||||
)
|
||||
//处理预警类型
|
||||
val appId = info.threat_info.app_id
|
||||
Logger.d(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"direction = " + direction + "----" + getMessageDirection(
|
||||
direction
|
||||
) + "--appId = " + appId
|
||||
)
|
||||
val useCaseId = info.threat_info.app_id
|
||||
val level = info.threat_info.threat_level
|
||||
val status = info.status
|
||||
|
||||
handleSdkObu(
|
||||
info.vehicle_id,
|
||||
appId,
|
||||
info.threat_info.threat_level,
|
||||
getMessageDirection(direction),
|
||||
info.status,
|
||||
info.basic_info
|
||||
useCaseId,
|
||||
direction,
|
||||
status,
|
||||
level,
|
||||
info
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -321,20 +310,15 @@ class MogoPrivateObuManager private constructor() {
|
||||
* @see com.mogo.module.common.enum.WarningTypeEnum
|
||||
*/
|
||||
private fun handleSdkObu(
|
||||
vehicleId: String,
|
||||
useCaseId: Int,
|
||||
level: Int,
|
||||
direction: Int,
|
||||
status: Int,
|
||||
basicInfo: MovingObjectInfo
|
||||
level: Int,
|
||||
info: CvxV2vThreatIndInfo
|
||||
) {
|
||||
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 WarningTypeEnum 提供的
|
||||
var alertContent = ""
|
||||
var ttsContent = ""
|
||||
Log.d(
|
||||
MogoObuConst.TAG_MOGO_OBU,
|
||||
"useCaseId = $useCaseId ---level = $level --direction = $direction ---status = $status "
|
||||
)
|
||||
// TODO 这里排除需要特殊定制的语音及文案外,其余的都可以使用 WarningTypeEnum 提供的
|
||||
when (useCaseId) {
|
||||
// 变道预警,注意左后车辆/注意右后车辆
|
||||
WarningTypeEnum.TYPE_USECASE_ID_LCW.useCaseId -> {
|
||||
@@ -404,7 +388,7 @@ class MogoPrivateObuManager private constructor() {
|
||||
// 前方拥堵提醒,前方XXX米道路拥堵,请减速慢行 TODO
|
||||
WarningTypeEnum.TYPE_USECASE_ID_TJW.useCaseId -> {
|
||||
ttsContent = WarningTypeEnum.getWarningTts(useCaseId)
|
||||
// ttsContent = String.format(ttsContent, "")
|
||||
// ttsContent = String.format(ttsContent, "")
|
||||
alertContent = WarningTypeEnum.getWarningContent(useCaseId)
|
||||
}
|
||||
|
||||
@@ -427,36 +411,36 @@ class MogoPrivateObuManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
when (status) {
|
||||
when (status) {
|
||||
// 添加
|
||||
ObuConstants.STATUS.ADD -> {
|
||||
ObuConstants.STATUS.ADD-> {
|
||||
//显示警告红边
|
||||
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
|
||||
getMessageDirection(direction),
|
||||
"ACTION_V2X_FRONT_WARNING"
|
||||
)
|
||||
//显示弹框,语音提示
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
useCaseId,
|
||||
alertContent,
|
||||
if (level == 3) ttsContent else "",
|
||||
if (status == 3) ttsContent else "",
|
||||
useCaseId.toString()
|
||||
)
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
mObuRecognizedResultDrawer?.updateCvxRvInfoIndInfo(level, info)
|
||||
}
|
||||
// 删除
|
||||
ObuConstants.STATUS.DELETE -> {
|
||||
// 移除顶部弹窗
|
||||
mIMoGoWaringProvider?.disableWarningV2X(useCaseId.toString())
|
||||
// 移除地图元素
|
||||
mObuRecognizedResultDrawer?.removeCvxRvInfoIndInfo(vehicleId)
|
||||
mObuRecognizedResultDrawer?.removeCvxRvInfoIndInfo(info.vehicle_id)
|
||||
}
|
||||
// 更新
|
||||
else -> {
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
mObuRecognizedResultDrawer?.updateCvxRvInfoIndInfo(
|
||||
level,
|
||||
vehicleId,
|
||||
basicInfo
|
||||
)
|
||||
mObuRecognizedResultDrawer?.updateCvxRvInfoIndInfo(level, info)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,9 @@ import com.mogo.module.common.R
|
||||
import com.mogo.module.common.constants.DataTypes
|
||||
import com.mogo.utils.WorkThreadHandler
|
||||
import com.zhidao.support.obu.model.CvxRvInfoIndInfo
|
||||
import com.zhidao.support.obu.model.CvxV2vThreatIndInfo
|
||||
import com.zhidao.support.obu.model.advance.MovingObjectInfo
|
||||
import com.zhidao.support.obu.model.advance.V2vThreat
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
@@ -43,29 +45,6 @@ class ObuRecognizedResultDrawer() {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
drawerCvxRvInfo()
|
||||
|
||||
/*// TODO 测试数据
|
||||
mCvxRvInfoIndInfoMap.forEach {
|
||||
var latitude = ((it.value.basic_info.position.latitude * 10000000.0).toLong())
|
||||
var longitude = (it.value.basic_info.position.longitude * 10000000.0).toLong()
|
||||
latitude += 5
|
||||
//longitude += 100
|
||||
it.value.basic_info.position.setValue(
|
||||
0,
|
||||
latitude,
|
||||
longitude,
|
||||
30
|
||||
)
|
||||
val result = latitude.toInt() % 2
|
||||
if (result == 0) {
|
||||
updateCvxRvInfoIndInfo(0, it.key, it.value.basic_info)
|
||||
} else {
|
||||
updateCvxRvInfoIndInfo(3, it.key, it.value.basic_info)
|
||||
}
|
||||
//addCvxRvInfoIndInfo(it.value)
|
||||
}*/
|
||||
|
||||
|
||||
// 延时50毫秒重复发送自己,定时轮询进行车辆绘制,可以及时将已经不存在车辆删除
|
||||
sendEmptyMessageDelayed(0, 100L)
|
||||
}
|
||||
@@ -74,22 +53,72 @@ class ObuRecognizedResultDrawer() {
|
||||
init {
|
||||
mContext = AbsMogoApplication.getApp()
|
||||
mDrawerHandler.sendEmptyMessageDelayed(1, 0L)
|
||||
|
||||
/* // TODO 测试数据
|
||||
val cvxRvInfoIndInfo = CvxRvInfoIndInfo(0, 1, 2)
|
||||
cvxRvInfoIndInfo.vehicle_id = "123321"
|
||||
val position = Position(0, 399739429, 1164115207, 20)
|
||||
val movingObjectInfo = MovingObjectInfo(0, position, 1800, 60)
|
||||
cvxRvInfoIndInfo.basic_info = movingObjectInfo
|
||||
addCvxRvInfoIndInfo(cvxRvInfoIndInfo)*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加识别的数据
|
||||
*/
|
||||
fun addCvxRvInfoIndInfo(value: CvxRvInfoIndInfo) {
|
||||
mCvxRvInfoIndInfoMap[value.vehicle_id] = value
|
||||
fun addCvxRvInfoIndInfo(cvxRvInfoIndInfo: CvxRvInfoIndInfo) {
|
||||
mCvxRvInfoIndInfoMap[cvxRvInfoIndInfo.vehicle_id] = cvxRvInfoIndInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新识别数据,V2V预警的时候需要修改车辆颜色
|
||||
*/
|
||||
fun updateCvxRvInfoIndInfo(threatLevel: Int, cvxV2vThreatIndInfo: CvxV2vThreatIndInfo) {
|
||||
val value = mCvxRvInfoIndInfoMap[cvxV2vThreatIndInfo.vehicle_id]
|
||||
// 存在即改变
|
||||
value?.let {
|
||||
// 修改位置信息
|
||||
value.basic_info = cvxV2vThreatIndInfo.basic_info
|
||||
// 修改V2X预警级别
|
||||
if (!value.threat_infos.isNullOrEmpty()) {
|
||||
value.threat_infos[0] = cvxV2vThreatIndInfo.threat_info
|
||||
} else {
|
||||
val threatInfos = ArrayList<V2vThreat>()
|
||||
threatInfos.add(0, cvxV2vThreatIndInfo.threat_info)
|
||||
value.threat_infos = threatInfos
|
||||
}
|
||||
|
||||
// 修改颜色
|
||||
when (threatLevel) {
|
||||
1 -> {
|
||||
mMarkersCaches[cvxV2vThreatIndInfo.vehicle_id]?.setAnchorColor("#D8D8D8FF")
|
||||
}
|
||||
2 -> {
|
||||
mMarkersCaches[cvxV2vThreatIndInfo.vehicle_id]?.setAnchorColor("#FFD53EFF")
|
||||
}
|
||||
3 -> {
|
||||
mMarkersCaches[cvxV2vThreatIndInfo.vehicle_id]?.setAnchorColor("#FF3C45FF")
|
||||
}
|
||||
else -> {
|
||||
mMarkersCaches[cvxV2vThreatIndInfo.vehicle_id]?.setAnchorColor("#D8D8D8FF")
|
||||
}
|
||||
}
|
||||
mCvxRvInfoIndInfoMap[cvxV2vThreatIndInfo.vehicle_id] = value
|
||||
}
|
||||
// 不存在即添加
|
||||
?: let {
|
||||
// 构建周边车辆数据结构
|
||||
val cvxRvInfoIndInfo = CvxRvInfoIndInfo(
|
||||
cvxV2vThreatIndInfo.opCode,
|
||||
cvxV2vThreatIndInfo.ch,
|
||||
cvxV2vThreatIndInfo.bitMask
|
||||
)
|
||||
cvxRvInfoIndInfo.vehicle_id = cvxV2vThreatIndInfo.vehicle_id
|
||||
cvxRvInfoIndInfo.basic_info = cvxV2vThreatIndInfo.basic_info
|
||||
// 修改V2X预警级别
|
||||
if (!cvxRvInfoIndInfo.threat_infos.isNullOrEmpty()) {
|
||||
cvxRvInfoIndInfo.threat_infos[0] = cvxV2vThreatIndInfo.threat_info
|
||||
} else {
|
||||
val threatInfos = ArrayList<V2vThreat>()
|
||||
threatInfos.add(0, cvxV2vThreatIndInfo.threat_info)
|
||||
cvxRvInfoIndInfo.threat_infos = threatInfos
|
||||
}
|
||||
|
||||
|
||||
mCvxRvInfoIndInfoMap[cvxV2vThreatIndInfo.vehicle_id] = cvxRvInfoIndInfo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +151,7 @@ class ObuRecognizedResultDrawer() {
|
||||
* 移除识别的数据
|
||||
*/
|
||||
fun removeCvxRvInfoIndInfo(key: String) {
|
||||
if (mCvxRvInfoIndInfoMap.contains(key)) {
|
||||
if (mCvxRvInfoIndInfoMap.containsKey(key)) {
|
||||
mCvxRvInfoIndInfoMap.remove(key)
|
||||
}
|
||||
}
|
||||
@@ -179,6 +208,26 @@ class ObuRecognizedResultDrawer() {
|
||||
cvxRvInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
)
|
||||
|
||||
// 判断车辆V2X预警级别,调整车辆颜色
|
||||
if (!cvxRvInfoIndInfo.threat_infos.isNullOrEmpty()) {
|
||||
// 修改颜色
|
||||
when (cvxRvInfoIndInfo.threat_infos.first().threat_level) {
|
||||
1 -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
}
|
||||
2 -> {
|
||||
options.anchorColor("#FFD53EFF")
|
||||
}
|
||||
3 -> {
|
||||
options.anchorColor("#FF3C45FF")
|
||||
}
|
||||
else -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val marker = MogoApisHandler.getInstance().apis.mapServiceApi.getMarkerManager(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.module.obu.mogo.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.module.obu.mogo.MogoObuConst
|
||||
import com.mogo.module.obu.mogo.MogoPrivateObuManager
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.support.obu.model.CvxRvInfoIndInfo
|
||||
import com.zhidao.support.obu.model.advance.MovingObjectInfo
|
||||
import com.zhidao.support.obu.model.advance.Position
|
||||
|
||||
/**
|
||||
* @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)
|
||||
Logger.d(TAG, "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel")
|
||||
|
||||
// TODO 测试数据
|
||||
val cvxRvInfoIndInfo = CvxRvInfoIndInfo(0, 1, 2)
|
||||
cvxRvInfoIndInfo.vehicle_id = "123321"
|
||||
val position = Position(0, 399739429, 1164115207, 20)
|
||||
val movingObjectInfo = MovingObjectInfo(0, position, 1800, 60)
|
||||
cvxRvInfoIndInfo.basic_info = movingObjectInfo
|
||||
|
||||
MogoPrivateObuManager.INSTANCE
|
||||
.getMogoObuListener()
|
||||
.onCvxRvInfoIndInfo(cvxRvInfoIndInfo)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user