优化细节
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
@@ -42,12 +43,13 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val TAG = "liyz"
|
||||
private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo()
|
||||
|
||||
|
||||
fun connectObu(context: Context, obuIpAddress: String, padIpAddress: String) {
|
||||
MogoObuManager.getInstance().registerMogoObuListener(mogoObuListener)
|
||||
|
||||
Log.d(TAG, "obuIpAddress = $obuIpAddress ----- padIpAddress = $padIpAddress")
|
||||
val com = MogoObuCom.newBuilder()
|
||||
.setLocalIp(padIpAddress)
|
||||
.setComType(MogoObuComType.UDP)
|
||||
@@ -75,6 +77,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
*/
|
||||
override fun onConnectStatus(connectStatus: Int) {
|
||||
if (connectStatus == 0) { //断开连接
|
||||
Log.d(TAG, "onConnectFail ------> ")
|
||||
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnectFail ------> ")
|
||||
mObuStatusInfo.obuStatus = false
|
||||
mObuStatusInfo.obuHvStatus = false
|
||||
@@ -84,6 +87,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) }
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) }
|
||||
} else if (connectStatus == 1) { //连接成功
|
||||
Log.d(TAG, "onConnected ------> ")
|
||||
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnected ------> ")
|
||||
mObuStatusInfo.obuStatus = true
|
||||
CallerObuListenerManager.invokeListener(mObuStatusInfo)
|
||||
@@ -95,7 +99,9 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
* HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo
|
||||
*/
|
||||
override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) {
|
||||
Log.d(TAG, "onMogoObuHvBasics p0 = ${p0.toString()}")
|
||||
if (p0 != null && p0.vehBasicsMsg != null) {
|
||||
|
||||
val data = JSONObject()
|
||||
try {
|
||||
data.putOpt("lon", p0.vehBasicsMsg.longitude)
|
||||
@@ -143,11 +149,10 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
// TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let {
|
||||
// TrafficMarkerDrawer.updateITrafficLocationInfo(it)
|
||||
// }
|
||||
|
||||
data?.let {
|
||||
Log.d(TAG, data.toString())
|
||||
data.let {
|
||||
//预警信息,预警类型 threat_level 2、3
|
||||
var status = data.status
|
||||
|
||||
data.vehBasicsMsg?.let {
|
||||
//预警方位
|
||||
val direction = getMessageDirection(data.vehBasicsMsg.targetPosition)
|
||||
@@ -160,9 +165,17 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
level = data.warningMsg.warningData[0].warningLevel
|
||||
}
|
||||
}
|
||||
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"onCvxV2vThreatIndInfo target_classification = ${
|
||||
"onMogoObuRvWarning target_classification = ${
|
||||
getMessageDirection(data.vehBasicsMsg.targetPosition)
|
||||
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
|
||||
)
|
||||
|
||||
Log.d(
|
||||
TAG,
|
||||
"onMogoObuRvWarning target_classification = ${
|
||||
getMessageDirection(data.vehBasicsMsg.targetPosition)
|
||||
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
|
||||
)
|
||||
@@ -198,7 +211,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"onMogoObuRsiWarning ------> $data"
|
||||
)
|
||||
|
||||
Log.d(TAG, "onMogoObuRsiWarning data = ${data.toString()}")
|
||||
if (data != null && data.warning_Msg != null && data.warning_Msg.size > 0) {
|
||||
var alertContent = ""
|
||||
var ttsContent = ""
|
||||
@@ -217,46 +230,37 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
)
|
||||
|
||||
when (appId) {
|
||||
// 道路危险情况预警 TODO
|
||||
// EventTypeEnum.TYPE_USECASE_ID_HLW.poiType,
|
||||
EventTypeEnum.TYPE_USECASE_ID_IVS.poiType
|
||||
// 道路危险情况预警
|
||||
EventTypeEnum.TYPE_USECASE_ID_HLW.poiType,
|
||||
EventTypeEnum.TYPE_USECASE_ID_IVS.poiType //车内标牌
|
||||
-> {
|
||||
when (data.warning_Msg[0].eventSerialNum) { //TODO 没有下面分类
|
||||
//施工
|
||||
0x7 -> {
|
||||
appId = EventTypeEnum.FOURS_ROAD_WORK.poiType
|
||||
// //桥梁 和驼峰桥区别
|
||||
// 1 -> {
|
||||
// appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_HUMP_BRIDGE.poiType
|
||||
// }
|
||||
|
||||
904 -> { //车辆逆行
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType
|
||||
}
|
||||
//限速
|
||||
0xA -> {
|
||||
|
||||
901 -> { //超速行驶
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_SLW.poiType
|
||||
}
|
||||
//事故
|
||||
0xC -> {
|
||||
appId =
|
||||
EventTypeEnum.TYPE_USECASE_ID_ROAD_COLLISION_WARNING.poiType
|
||||
|
||||
103 -> {//车辆故障
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType
|
||||
}
|
||||
//拥堵
|
||||
0xD -> {
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_TJW.poiType
|
||||
|
||||
501 -> { //施工占道 TODO
|
||||
appId = EventTypeEnum.FOURS_ROAD_WORK.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
|
||||
|
||||
412 -> { //异常停车
|
||||
appId = EventTypeEnum.TYPE_USECASE_ID_ROAD_PARKING.poiType
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
alertContent = EventTypeEnum.getWarningContent(appId)
|
||||
ttsContent = EventTypeEnum.getWarningTts(appId)
|
||||
@@ -326,6 +330,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"onMogoObuRsmWarning ------> $data"
|
||||
)
|
||||
Log.d(TAG, "data = ${data.toString()}")
|
||||
// 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu
|
||||
if (data != null && data.participant != null && (data.participant.ptcType == 1 || data.participant.ptcType == 3)) {
|
||||
CallerLogger.d(
|
||||
@@ -406,6 +411,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
|
||||
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "预警红边:预警方向->$targetClassification")
|
||||
Log.d(TAG, "getMessageDirection 预警红边:预警方向->$targetClassification")
|
||||
return when (targetClassification) {
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
|
||||
@@ -454,6 +460,7 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status"
|
||||
)
|
||||
Log.d(TAG, "handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status")
|
||||
var alertContent: String
|
||||
var ttsContent: String
|
||||
var changeVisualAngle = false
|
||||
@@ -596,6 +603,10 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights "
|
||||
)
|
||||
Log.d(
|
||||
TAG,
|
||||
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights "
|
||||
)
|
||||
MogoObuConstants.CONNECT_STATUS.CONNECTED
|
||||
when (status) {
|
||||
// 添加
|
||||
@@ -632,6 +643,9 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
|
||||
"currentLight = $currentLight ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId"
|
||||
)
|
||||
Log.d(TAG,
|
||||
"currentLight = $currentLight ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId"
|
||||
)
|
||||
// 闯红灯预警
|
||||
when (appId) {
|
||||
0x0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE
|
||||
|
||||
@@ -18,7 +18,7 @@ object TrafficDataConvertUtilsNew {
|
||||
val TAG = "TrafficDataConvertUtilsNew"
|
||||
|
||||
/**
|
||||
* OBU 远车 转换交通元素数据
|
||||
* OBU 远车 转换交通元素数据,是否需要 TODO
|
||||
*/
|
||||
fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
|
||||
if (info.vehBasicsMsg == null) {
|
||||
@@ -46,7 +46,7 @@ object TrafficDataConvertUtilsNew {
|
||||
}
|
||||
val trafficData = TrafficData()
|
||||
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG
|
||||
trafficData.uuid = "0" //是否需要 TODO
|
||||
trafficData.uuid = info.warning_Msg[0].signSerialNum.toString() //TODO
|
||||
trafficData.lat = info.warning_Msg[0].position.latitude.toDouble()
|
||||
trafficData.lon = info.warning_Msg[0].position.longitude.toDouble()
|
||||
trafficData.threatLevel = info.warning_Msg[0].warningLevel
|
||||
|
||||
Reference in New Issue
Block a user