From 7f72902737c4a0571b1ee27b79ecb34b3a7ca64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Mon, 9 Aug 2021 16:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BA=86=E8=AE=BE=E7=BD=AEV2?= =?UTF-8?q?X=E9=A2=84=E8=AD=A6=E8=BD=A6=E8=BE=86=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/obu/mogo/MogoPrivateObuManager.kt | 68 +++++++------------ .../obu/mogo/map/ObuRecognizedResultDrawer.kt | 42 ++++++++++-- 2 files changed, 61 insertions(+), 49 deletions(-) diff --git a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt index 3e3678db5d..e7e6cace41 100644 --- a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/MogoPrivateObuManager.kt @@ -5,14 +5,12 @@ import com.alibaba.android.arouter.launcher.ARouter import com.mogo.module.obu.mogo.map.ObuRecognizedResultDrawer import com.mogo.service.IMogoServiceApis import com.mogo.service.MogoServicePaths -import com.mogo.service.adas.entity.ADASRecognizedResult import com.mogo.service.warning.IMoGoWaringProvider import com.mogo.utils.logger.Logger 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 java.util.* /** * @description @@ -27,7 +25,6 @@ class MogoPrivateObuManager private constructor() { } } - private var resultList: MutableList? = null private var mMogoServiceApis: IMogoServiceApis? = null private var mIMoGoWaringProvider: IMoGoWaringProvider? = null val icw_data = @@ -118,29 +115,36 @@ class MogoPrivateObuManager private constructor() { //TODO 他车是否一直出现 override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo) { + Logger.e(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info") //预警信息,预警类型 threat_level 3 - if (info != null) { - Logger.e(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info") - if (info.threat_info != null) { - if (info.threat_info.threat_level == 2 || - info.threat_info.threat_level == 3) { - //预警方位 - val direction = info.ext_info.target_classification + if (info.threat_info != null) { + if (info.threat_info.threat_level == 3) { + //预警方位 + val direction = info.ext_info.target_classification - //显示警告弹框 - mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(getMessage(direction), "ACTION_V2X_FRONT_WARNING") + //显示警告弹框 + mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection( + getMessage(direction), + "ACTION_V2X_FRONT_WARNING" + ) - //处理预警类型 - val appId = info.threat_info.app_id - Logger.d(MogoObuConst.TAG_MOGO_OBU, "direction = " + direction + "----" + getMessage(direction) + "--appId = " + appId) - handleSdkObu(getEventType(appId), info.threat_info.threat_level) - } - - //预警数据的组装,车辆实时移动和变色 TODO 这里需要obu提供他车列表 暂时不做 -// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(getResultList(info)); - } else { - Logger.e(MogoObuConst.TAG_MOGO_OBU, "info == null ") + //处理预警类型 + val appId = info.threat_info.app_id + Logger.d( + MogoObuConst.TAG_MOGO_OBU, + "direction = " + direction + "----" + getMessage(direction) + "--appId = " + appId + ) + handleSdkObu(getEventType(appId), info.threat_info.threat_level) } + + //更新周边车辆进行预警颜色变换,车辆实时移动和变色 + mObuRecognizedResultDrawer?.updateCvxRvInfoIndInfo( + info.threat_info.threat_level, + info.vehicle_id, + info.basic_info + ) + } else { + Logger.e(MogoObuConst.TAG_MOGO_OBU, "info == null ") } } } @@ -196,26 +200,6 @@ class MogoPrivateObuManager private constructor() { return 0 } - private fun getResultList(info: CvxV2vThreatIndInfo): List? { - if (resultList == null) { - resultList = ArrayList() - } - val adasRecognizedResult = ADASRecognizedResult() - adasRecognizedResult.uuid = info.vehicle_id - if (info.basic_info != null && info.basic_info.position != null) { - adasRecognizedResult.lat = info.basic_info.position.latitude - adasRecognizedResult.lon = info.basic_info.position.longitude - } - adasRecognizedResult.type = 3 //小轿车 - adasRecognizedResult.heading = info.basic_info.heading - adasRecognizedResult.speed = info.basic_info.speed - - resultList!!.add(adasRecognizedResult) - - return resultList - } - - fun release() { MogoObuManager.getInstance().unregisterListener() } diff --git a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/map/ObuRecognizedResultDrawer.kt b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/map/ObuRecognizedResultDrawer.kt index 8909176798..c7f5664d93 100644 --- a/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/map/ObuRecognizedResultDrawer.kt +++ b/modules/mogo-module-obu-mogo/src/main/java/com/mogo/module/obu/mogo/map/ObuRecognizedResultDrawer.kt @@ -11,7 +11,6 @@ import com.mogo.module.common.MogoApisHandler import com.mogo.module.common.R import com.mogo.module.common.constants.DataTypes import com.mogo.utils.WorkThreadHandler -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 @@ -51,20 +50,23 @@ class ObuRecognizedResultDrawer() { /*// 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 += 10 + latitude += 5 //longitude += 100 - it.value.basic_info.position.setValue( 0, latitude, longitude, 30 ) - addCvxRvInfoIndInfo(it.value) + 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) }*/ @@ -91,7 +93,33 @@ class ObuRecognizedResultDrawer() { * 添加识别的数据 */ fun addCvxRvInfoIndInfo(value: CvxRvInfoIndInfo) { - mCvxRvInfoIndInfoMap[value.vehicle_id] = value; + mCvxRvInfoIndInfoMap[value.vehicle_id] = value + } + + /** + * 更新识别数据,V2V预警的时候需要修改车辆颜色 + */ + fun updateCvxRvInfoIndInfo(threatLevel: Int, key: String, movingObjectInfo: MovingObjectInfo) { + val value = mCvxRvInfoIndInfoMap[key] + value?.let { + value.basic_info = movingObjectInfo + // 修改颜色 + when (threatLevel) { + 1 -> { + mMarkersCaches[key]?.setAnchorColor("#D8D8D8FF") + } + 2 -> { + mMarkersCaches[key]?.setAnchorColor("#FFD53EFF") + } + 3 -> { + mMarkersCaches[key]?.setAnchorColor("#FF3C45FF") + } + else -> { + mMarkersCaches[key]?.setAnchorColor("#D8D8D8FF") + } + } + mCvxRvInfoIndInfoMap[key] = value + } } /**