diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt index 29eb90cdbc..0e6f1f200d 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MoGoObuProvider.kt @@ -20,7 +20,6 @@ import com.mogo.support.obu.MogoObuManager @Route(path = MogoServicePaths.PATH_V2X_OBU_MOGO) class MoGoObuProvider : IMoGoObuProvider { private val TAG = "MoGoObuProvider" - private var mContext: Context? = null private val taxiObuIp = "192.168.1.199" //obu的taxi和bus的ip已经全部统一成1网段ip @@ -36,10 +35,11 @@ class MoGoObuProvider : IMoGoObuProvider { MogoObuDcCombineManager.INSTANCE.init(context) CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress()) - //bus乘客版本obu功能去掉,大理项目需要全部车辆接收,不在限制 + //bus乘客版本obu功能去掉,大理项目需要全部车辆接收,不再限制 mContext = context mContext?.let { - val ipAddress = SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, taxiObuIp) + val ipAddress = + SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, taxiObuIp) //mogo obu MogoPrivateObuNewManager.INSTANCE.connectObu( it, @@ -53,32 +53,28 @@ class MoGoObuProvider : IMoGoObuProvider { * 通过控制面板设置ip,进行传递 */ override fun connect(ipAddress: String) { - if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) - && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) - ) { - //不处理 - } else { - mContext?.let { - // 保存本地OBU IP地址 - SharedPrefsMgr.getInstance(it).putString(MoGoConfig.OBU_IP, ipAddress) + mContext?.let { + // 保存本地OBU IP地址 + SharedPrefsMgr.getInstance(it).putString(MoGoConfig.OBU_IP, ipAddress) - //连接 mogo obu - MogoPrivateObuNewManager.INSTANCE.connectObu( - it, - ipAddress, - CommonUtils.getIpAddressString() - ) - - } + //连接 mogo obu + MogoPrivateObuNewManager.INSTANCE.connectObu( + it, + ipAddress, + CommonUtils.getIpAddressString() + ) } } override fun disConnect() { - MogoPrivateObuNewManager.INSTANCE.disconnect() + MogoPrivateObuNewManager.INSTANCE.disConnectObu() } override fun isConnected(): Boolean { - return MogoObuManager.getInstance().connectStatus == 1 + return MogoPrivateObuNewManager.INSTANCE.isConnected() } + override fun setObuLog(isChecked: Boolean) { + MogoPrivateObuNewManager.INSTANCE.setObuLog(isChecked) + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 71a0eab932..cf1a909d8c 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -29,9 +29,11 @@ import com.mogo.support.obu.ObuBase import com.mogo.support.obu.ObuScene import com.mogo.support.obu.constants.MogoObuComType import com.mogo.support.obu.constants.MogoObuConstants +import com.mogo.support.obu.constants.MogoObuLogLevel import com.mogo.support.obu.constants.MogoObuTopicId import com.mogo.support.obu.model.* import com.mogo.support.obu.option.MogoObuCom +import com.mogo.support.obu.option.MogoObuLog import com.mogo.support.obu.option.MogoObuOptions import com.zhidao.support.obu.ObuManager import com.zhidao.support.obu.OnObuListener @@ -74,7 +76,7 @@ class MogoPrivateObuNewManager private constructor() { .build() //每次连接的时候如果连接连接了,先断开,防止ip改变等导致的连接失败 - if (ObuManager.getInstance().connectStatus == 1) { + if (ObuManager.getInstance().connectStatus == MogoObuConstants.CONNECT_STATUS.CONNECTED) { try { ObuManager.getInstance().disconnect() } catch (e: Exception) { @@ -84,12 +86,33 @@ class MogoPrivateObuNewManager private constructor() { ObuManager.getInstance().connect(options) } - fun getMogoObuListener(): OnObuListener { - return mogoObuListener + + /** + * 断开新obu + */ + fun disConnectObu() { + try { + ObuManager.getInstance().disconnect() + } catch (e: Exception) { + e.printStackTrace() + } } - fun disconnect() { - ObuManager.getInstance().disconnect() + /** + * 新obu是否连接 + */ + fun isConnected(): Boolean { + return ObuManager.getInstance().connectStatus == MogoObuConstants.CONNECT_STATUS.CONNECTED + } + + fun setObuLog(isChecked: Boolean) { + ObuManager.getInstance().setEnableLog(isChecked) + val builder: com.mogo.support.obu.option.MogoObuLog.Builder = + MogoObuLog.newBuilder().setEnableStdio(isChecked) + if (isChecked) { + builder.setStdioLevel(MogoObuLogLevel.DBG) + } + ObuManager.getInstance().logConfig(builder.build()) } private val mogoObuListener: OnObuListener = object : OnObuListener { @@ -133,260 +156,270 @@ class MogoPrivateObuNewManager private constructor() { * v2v预警信息 CvxRvInfoIndInfo CvxV2vThreatIndInfo 他车 */ override fun onObuRvWarning(data: ObuScene.RvWarningData) { -// if (HmiBuildConfig.isShowObuV2vView) { //TODO 临时需要关闭v2v开关 - if (data.warningMsg != null && !data.warningMsg.warningDataList.isNullOrEmpty()) { - // 更新数据,远车数据,之前要匹配uuid - TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data.vehBasicsMsg)?.let { - CallerMapUIServiceManager.getMarkerService()?.updateITrafficLocationInfo(it) - } - - CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", data.toString()) - data.let { - //预警信息,预警类型 threat_level 2、3 - data.vehBasicsMsg?.let { - //预警方位 - val direction = getMessageDirection(data.vehBasicsMsg.targetPosition) - //处理预警类型 - var appId = "" - var level = -1 - var status = -1 - data.warningMsg?.let { - if (data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { - level = data.warningMsg.warningDataList[0].warningLevel - appId = data.warningMsg.warningDataList[0].warningType.toString() - status = data.warningMsg.warningDataList[0].status - //拼凑数据 - handleSdkObu(appId, direction, status, level, data) - } + if (HmiBuildConfig.isShowObuV2vView) { + if (data.warningMsg != null && !data.warningMsg.warningDataList.isNullOrEmpty()) { + // 更新数据,远车数据,之前要匹配uuid + TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data.vehBasicsMsg) + ?.let { + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficLocationInfo(it) } - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRvWarning target_classification = ${ - getMessageDirection(data.vehBasicsMsg.targetPosition) - } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" - ) + CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", data.toString()) + data.let { + //预警信息,预警类型 threat_level 2、3 + data.vehBasicsMsg?.let { + //预警方位 + val direction = getMessageDirection(data.vehBasicsMsg.targetPosition) + //处理预警类型 + var appId = "" + var level = -1 + var status = -1 + data.warningMsg?.let { + if (data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { + level = data.warningMsg.warningDataList[0].warningLevel + appId = + data.warningMsg.warningDataList[0].warningType.toString() + status = data.warningMsg.warningDataList[0].status + //拼凑数据 + handleSdkObu(appId, direction, status, level, data) + } + } + + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "onMogoObuRvWarning target_classification = ${ + getMessageDirection(data.vehBasicsMsg.targetPosition) + } --- direction = $direction --- appId = $appId ---level = $level -- status = $status" + ) + } } } } -// } } /** * 红绿灯预警信息 CvxIvpThreatIndInfo */ override fun onObuSpatWarning(data: ObuScene.SpatWarningData) { - handlerTrafficLight( - data.warningType, - data.status, - data.lightsList - ) + if (HmiBuildConfig.isShowObuV2iView) { + handlerTrafficLight( + data.warningType, + data.status, + data.lightsList + ) + } } /** * RSI预警信息 onMogoObuRsiWarning(交通标志预警(前方限速、前方学校等等),交通事件预警(前方拥堵、前方积水等等)) */ override fun onObuRsiWarning(data: ObuScene.RsiWarningData) { -// if (HmiBuildConfig.isShowObuV2iView) { - if (data.warningMsgList != null && data.warningMsgList.size > 0) { - var alertContent = "" - var ttsContent = "" - var appId = data.warningMsgList[0].sceneType.toString() - val status = data.status - val level = data.warningMsgList[0].warningLevel - val direction = getMessageDirection(data.warningMsgList[0].targetPosition) - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${data.warningMsgList[0].targetPosition}" - ) + if (HmiBuildConfig.isShowObuV2iView) { + if (data.warningMsgList != null && data.warningMsgList.size > 0) { + var alertContent = "" + var ttsContent = "" + var appId = data.warningMsgList[0].sceneType.toString() + val status = data.status + val level = data.warningMsgList[0].warningLevel + val direction = getMessageDirection(data.warningMsgList[0].targetPosition) + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "onMogoObuRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${data.warningMsgList[0].targetPosition}" + ) - if (appId != "0") { - when (appId) { - // 道路危险情况预警 - MogoObuConstants.RSI_SCENE_TYPE.HLW.toString() -> { - when (data.warningMsgList[0].eventSerialNum) { - MogoObuConstants.RTE.RTI_TYPE_BREAKDOWN -> {//车辆故障 - appId = - EventTypeEnumNew.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType - } - MogoObuConstants.RTE.RTI_TYPE_ROAD_WATER -> { //道路积水 - appId = EventTypeEnumNew.FOURS_PONDING.poiType - } - MogoObuConstants.RTE.RTI_TYPE_PARKING_VIOLATION -> { //异常停车 - appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PARKING.poiType - } + if (appId != "0") { + when (appId) { + // 道路危险情况预警 + MogoObuConstants.RSI_SCENE_TYPE.HLW.toString() -> { + when (data.warningMsgList[0].eventSerialNum) { + MogoObuConstants.RTE.RTI_TYPE_BREAKDOWN -> {//车辆故障 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType + } + MogoObuConstants.RTE.RTI_TYPE_ROAD_WATER -> { //道路积水 + appId = EventTypeEnumNew.FOURS_PONDING.poiType + } + MogoObuConstants.RTE.RTI_TYPE_PARKING_VIOLATION -> { //异常停车 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PARKING.poiType + } // MogoObuConstants.RTE.RTI_TYPE_CONSTRUCTION_RTE -> { //施工占道,和标牌重复 // appId = EventTypeEnumNew.FOURS_ROAD_WORK.poiType // } - MogoObuConstants.RTE.RTI_TYPE_SPEEDING -> { //超速行驶 - appId = EventTypeEnumNew.TYPE_USECASE_ID_SLW.poiType - } - MogoObuConstants.RTE.RTI_TYPE_RETRIGRADE -> { //车辆逆行 - appId = - EventTypeEnumNew.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType + MogoObuConstants.RTE.RTI_TYPE_SPEEDING -> { //超速行驶 + appId = EventTypeEnumNew.TYPE_USECASE_ID_SLW.poiType + } + MogoObuConstants.RTE.RTI_TYPE_RETRIGRADE -> { //车辆逆行 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType + } } + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //事件才有影响范围 + alertContent, + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() + ) } - alertContent = EventTypeEnumNew.getWarningContent(appId) - ttsContent = EventTypeEnumNew.getWarningTts(appId) - alertContent = String.format( //事件才有影响范围 - alertContent, - Math.round(data.warningMsgList[0].distance).toString(), - Math.round(data.warningMsgList[0].eventRadius).toString() - ) - ttsContent = String.format( - ttsContent, - Math.round(data.warningMsgList[0].distance).toString(), - Math.round(data.warningMsgList[0].eventRadius).toString() - ) - } - //车内标牌 - MogoObuConstants.RSI_SCENE_TYPE.IVS.toString() -> { - when (data.warningMsgList[0].signSerialNum) { - MogoObuConstants.RTS.RTI_TYPE_SHAPR_TURNS -> { //急转弯 - appId = EventTypeEnumNew.TYPE_ID_SHAPR_TURNS.poiType - } - MogoObuConstants.RTS.RTI_TYPE_BRIDGE -> { //桥梁 - appId = EventTypeEnumNew.TYPE_ID_BRIDGE.poiType - } - MogoObuConstants.RTS.RTI_TYPE_PEDESTRIAN -> { //行人 - appId = EventTypeEnumNew.TYPE_ID_PEDESTRIAN.poiType - } - MogoObuConstants.RTS.RTI_TYPE_SLIPPERY_ROAD -> { //路滑 - appId = EventTypeEnumNew.TYPE_ID_SLIPPERY_ROAD.poiType - } - MogoObuConstants.RTS.RTI_TYPE_TUNNEL -> { //隧道 - appId = EventTypeEnumNew.TYPE_ID_TUNNEL.poiType - } - MogoObuConstants.RTS.RTI_TYPE_FERRY -> { //渡轮 - appId = EventTypeEnumNew.TYPE_ID_FERRY.poiType - } - MogoObuConstants.RTS.RTI_TYPE_UNEVEN_ROAD -> { //路面不平 - appId = EventTypeEnumNew.TYPE_ID_UNEVEN_ROAD.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NON_MOTOR_VEHICLE -> { //非机动车 - appId = EventTypeEnumNew.TYPE_ID_NON_MOTOR_VEHICLE.poiType - } - MogoObuConstants.RTS.RTI_TYPE_OBSTACLE -> { //障碍 - appId = EventTypeEnumNew.TYPE_ID_OBSTACLE.poiType - } - MogoObuConstants.RTS.RTI_TYPE_CONSTRUCTION -> { //施工 - appId = EventTypeEnumNew.TYPE_FOURS_ROAD_WORK.poiType - } - MogoObuConstants.RTS.RTI_TYPE_VEHICLE_QUEUE -> { //车队 - appId = EventTypeEnumNew.TYPE_VEHICLE_QUEUE.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NO_PASSING -> { //不通 - appId = EventTypeEnumNew.TYPE_NO_PASSING.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NO_TURNING_AROUND -> { //禁止掉头 - appId = EventTypeEnumNew.TYPE_NO_TURNING_AROUND.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NO_STOPPING -> { //禁止停车 - appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NO_TOOTING -> { //禁止鸣笛 - appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType - } + //车内标牌 + MogoObuConstants.RSI_SCENE_TYPE.IVS.toString() -> { + when (data.warningMsgList[0].signSerialNum) { + MogoObuConstants.RTS.RTI_TYPE_SHAPR_TURNS -> { //急转弯 + appId = EventTypeEnumNew.TYPE_ID_SHAPR_TURNS.poiType + } + MogoObuConstants.RTS.RTI_TYPE_BRIDGE -> { //桥梁 + appId = EventTypeEnumNew.TYPE_ID_BRIDGE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_PEDESTRIAN -> { //行人 + appId = EventTypeEnumNew.TYPE_ID_PEDESTRIAN.poiType + } + MogoObuConstants.RTS.RTI_TYPE_SLIPPERY_ROAD -> { //路滑 + appId = EventTypeEnumNew.TYPE_ID_SLIPPERY_ROAD.poiType + } + MogoObuConstants.RTS.RTI_TYPE_TUNNEL -> { //隧道 + appId = EventTypeEnumNew.TYPE_ID_TUNNEL.poiType + } + MogoObuConstants.RTS.RTI_TYPE_FERRY -> { //渡轮 + appId = EventTypeEnumNew.TYPE_ID_FERRY.poiType + } + MogoObuConstants.RTS.RTI_TYPE_UNEVEN_ROAD -> { //路面不平 + appId = EventTypeEnumNew.TYPE_ID_UNEVEN_ROAD.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NON_MOTOR_VEHICLE -> { //非机动车 + appId = EventTypeEnumNew.TYPE_ID_NON_MOTOR_VEHICLE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_OBSTACLE -> { //障碍 + appId = EventTypeEnumNew.TYPE_ID_OBSTACLE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_CONSTRUCTION -> { //施工 + appId = EventTypeEnumNew.TYPE_FOURS_ROAD_WORK.poiType + } + MogoObuConstants.RTS.RTI_TYPE_VEHICLE_QUEUE -> { //车队 + appId = EventTypeEnumNew.TYPE_VEHICLE_QUEUE.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_PASSING -> { //不通 + appId = EventTypeEnumNew.TYPE_NO_PASSING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_TURNING_AROUND -> { //禁止掉头 + appId = EventTypeEnumNew.TYPE_NO_TURNING_AROUND.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_STOPPING -> { //禁止停车 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_PARKING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NO_TOOTING -> { //禁止鸣笛 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType + } // MogoObuConstants.RTS.RTI_TYPE_SPEED_LIMIT -> { //限速 // appId = // EventTypeEnumNew.TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType // } - MogoObuConstants.RTS.RTI_TYPE_BUS_WARNING -> { //公交提醒 - appId = EventTypeEnumNew.TYPE_USECASE_ID_BUS_WARNING.poiType - } - MogoObuConstants.RTS.RTI_TYPE_NARROW_RIGHT -> { //右侧变窄/车道数减少 - appId = EventTypeEnumNew.TYPE_USECASE_ID_NARROW_RIGHT.poiType - } - MogoObuConstants.RTS.RTI_TYPE_GAS_STATION -> { //加油站 - appId = EventTypeEnumNew.TYPE_USECASE_ID_GAS_STATION.poiType - } - MogoObuConstants.RTS.RTI_TYPE_SCHOOL -> { //学校 - appId = - EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType - } - MogoObuConstants.RTS.RTI_TYPE_ACCIDENT -> { //事故 - appId = EventTypeEnumNew.TYPE_USECASE_ID_ACCIDENT.poiType + MogoObuConstants.RTS.RTI_TYPE_BUS_WARNING -> { //公交提醒 + appId = EventTypeEnumNew.TYPE_USECASE_ID_BUS_WARNING.poiType + } + MogoObuConstants.RTS.RTI_TYPE_NARROW_RIGHT -> { //右侧变窄/车道数减少 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_NARROW_RIGHT.poiType + } + MogoObuConstants.RTS.RTI_TYPE_GAS_STATION -> { //加油站 + appId = EventTypeEnumNew.TYPE_USECASE_ID_GAS_STATION.poiType + } + MogoObuConstants.RTS.RTI_TYPE_SCHOOL -> { //学校 + appId = + EventTypeEnumNew.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType + } + MogoObuConstants.RTS.RTI_TYPE_ACCIDENT -> { //事故 + appId = EventTypeEnumNew.TYPE_USECASE_ID_ACCIDENT.poiType + } } + + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //标牌是没有影响范围的 + alertContent, + Math.round(data.warningMsgList[0].distance).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(data.warningMsgList[0].distance).toString() + ) } - alertContent = EventTypeEnumNew.getWarningContent(appId) - ttsContent = EventTypeEnumNew.getWarningTts(appId) - alertContent = String.format( //标牌是没有影响范围的 - alertContent, - Math.round(data.warningMsgList[0].distance).toString() - ) - ttsContent = String.format( - ttsContent, - Math.round(data.warningMsgList[0].distance).toString() - ) - } - - // 拥堵 - MogoObuConstants.RSI_SCENE_TYPE.TJW.toString() -> { - appId = EventTypeEnumNew.TYPE_USECASE_ID_TJW.poiType - alertContent = EventTypeEnumNew.getWarningContent(appId) - ttsContent = EventTypeEnumNew.getWarningTts(appId) - alertContent = String.format( //事件才有影响范围 - alertContent, - Math.round(data.warningMsgList[0].distance).toString(), - Math.round(data.warningMsgList[0].eventRadius).toString() - ) - ttsContent = String.format( - ttsContent, - Math.round(data.warningMsgList[0].distance).toString(), - Math.round(data.warningMsgList[0].eventRadius).toString() - ) - } - - //限速预警, ADD处理一次 - MogoObuConstants.RSI_SCENE_TYPE.SLW.toString() -> { - appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType - alertContent = EventTypeEnumNew.getWarningContent(appId) - ttsContent = EventTypeEnumNew.getWarningTts(appId) - } - } - - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "new onMogoObuRsiWarning appId = $appId ---status = $status --- ttsContent = $ttsContent --alertContent = $alertContent -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} ---direction = ${direction.direction} --distance = ${ - Math.round(data.warningMsgList[0].distance) - } ---eventRadius = ${Math.round(data.warningMsgList[0].eventRadius)} --speedMaxLimit = ${data.warningMsgList[0].speedMaxLimit.toInt()}" - ) - - when (status) { - MogoObuConstants.STATUS.ADD -> { // 添加 - //不显示弹框,语音提示,数据在消息盒子里面展示,此处不在处理弹框 - if (alertContent.isEmpty() || ttsContent.isEmpty()) { - return + // 拥堵 + MogoObuConstants.RSI_SCENE_TYPE.TJW.toString() -> { + appId = EventTypeEnumNew.TYPE_USECASE_ID_TJW.poiType + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) + alertContent = String.format( //事件才有影响范围 + alertContent, + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() + ) + ttsContent = String.format( + ttsContent, + Math.round(data.warningMsgList[0].distance).toString(), + Math.round(data.warningMsgList[0].eventRadius).toString() + ) } - saveObuData(appId, alertContent, ttsContent) - showWarning(appId, alertContent, ttsContent, direction) - // 更新数据 - TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)?.let { - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) + //限速预警, ADD处理一次 + MogoObuConstants.RSI_SCENE_TYPE.SLW.toString() -> { + appId = EventTypeEnumNew.TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType + alertContent = EventTypeEnumNew.getWarningContent(appId) + ttsContent = EventTypeEnumNew.getWarningTts(appId) } } - MogoObuConstants.STATUS.UPDATE -> { // 更新 - } + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "new onMogoObuRsiWarning appId = $appId ---status = $status --- ttsContent = $ttsContent --alertContent = $alertContent -- eventSerialNum = ${data.warningMsgList[0].eventSerialNum} ---signSerialNum = ${data.warningMsgList[0].signSerialNum} ---direction = ${direction.direction} --distance = ${ + Math.round(data.warningMsgList[0].distance) + } ---eventRadius = ${Math.round(data.warningMsgList[0].eventRadius)} --speedMaxLimit = ${data.warningMsgList[0].speedMaxLimit.toInt()}" + ) - MogoObuConstants.STATUS.DELETE -> { // 删除 - // 更新数据 - TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data) - ?.let { - // 事件结束,还原车辆颜色 - it.threatLevel = 0x01 - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficInfo(it) + when (status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + //不显示弹框,语音提示,数据在消息盒子里面展示,此处不在处理弹框 + if (alertContent.isEmpty() || ttsContent.isEmpty()) { + return } + saveObuData(appId, alertContent, ttsContent) + showWarning(appId, alertContent, ttsContent, direction) + + // 更新数据 + TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data) + ?.let { + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + } + + MogoObuConstants.STATUS.UPDATE -> { // 更新 + } + + MogoObuConstants.STATUS.DELETE -> { // 删除 + // 更新数据 + TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data) + ?.let { + // 事件结束,还原车辆颜色 + it.threatLevel = 0x01 + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficInfo(it) + } + } } } } } -// } } /** @@ -405,133 +438,135 @@ class MogoPrivateObuNewManager private constructor() { "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", "onMogoObuRsmWarning ------> ${data.toString()}" ) -// if (HmiBuildConfig.isShowObuV2iView) { - if (HmiBuildConfig.isShowObuWeaknessTrafficView) { - // 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu - if (data != null && data.participant != null) { - var v2xType = "" - if (data.participant.ptcType == 1) { //机动车 - v2xType = - EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType - } else if (data.participant.ptcType == 2) { //非机动车 - v2xType = - EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType - } else if (data.participant.ptcType == 3) { //行人 - v2xType = - EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.poiType - } else { //未知 - v2xType = EventTypeEnumNew.TYPE_ERROR.poiType - } - - val ttsContent = EventTypeEnumNew.getWarningTts(v2xType) - val alertContent = - EventTypeEnumNew.getWarningContent(v2xType) - var level = -1 - val direction = getMessageDirection(data.participant.targetPosition) - - //物体数据绘制 - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRsmWarning ---- data.status = ${data.status} ---data.participant.ptcId = ${data.participant.ptcId} ---data.participant.ptcType = ${data.participant.ptcType} ---data.warningMsg = ${data.warningMsg} -----data = ${data.toString()}" - ) - when (data.status) { - MogoObuConstants.STATUS.ADD -> { // 添加 - // 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO - TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) - ?.let { - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) - } + if (HmiBuildConfig.isShowObuV2iView) { + if (HmiBuildConfig.isShowObuWeaknessTrafficView) { + // 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu + if (data != null && data.participant != null) { + var v2xType = "" + if (data.participant.ptcType == 1) { //机动车 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType + } else if (data.participant.ptcType == 2) { //非机动车 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType + } else if (data.participant.ptcType == 3) { //行人 + v2xType = + EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.poiType + } else { //未知 + v2xType = EventTypeEnumNew.TYPE_ERROR.poiType } - MogoObuConstants.STATUS.UPDATE -> { // 更新 - } + val ttsContent = EventTypeEnumNew.getWarningTts(v2xType) + val alertContent = + EventTypeEnumNew.getWarningContent(v2xType) + var level = -1 + val direction = getMessageDirection(data.participant.targetPosition) - MogoObuConstants.STATUS.DELETE -> { // 删除 - // 更新数据 TODO 删除原来的,改变颜色,删除marker。不影响别的模型添加 - TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) - ?.let { - // 事件结束,还原交通参与者颜色 - it.threatLevel = 0x01 - CallerMapUIServiceManager.getMarkerService() - ?.updateITrafficThreatLevelInfo(it) - } - - //删除弱势交通元素 - CallerMapUIServiceManager.getMarkerService() - ?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString()) - } - } - - //预警status - if (data.warningMsg != null && data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { - level = data.warningMsg.warningDataList[0].warningLevel //默认是1个 + //物体数据绘制 CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuRsmWarning ---status---> ${data.status} ---data.warningMsg.warningData[0].status = ${data.warningMsg.warningDataList[0].status} ---v2xType = $v2xType ---alertContent = $alertContent ---ttsContent = $ttsContent ---level = $level" + "onMogoObuRsmWarning ---- data.status = ${data.status} ---data.participant.ptcId = ${data.participant.ptcId} ---data.participant.ptcType = ${data.participant.ptcType} ---data.warningMsg = ${data.warningMsg} -----data = ${data.toString()}" ) - when (data.warningMsg.warningDataList[0].status) { + when (data.status) { MogoObuConstants.STATUS.ADD -> { // 添加 - //更新模型的颜色 + // 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) ?.let { CallerMapUIServiceManager.getMarkerService() ?.updateITrafficThreatLevelInfo(it) } - - if (alertContent.isEmpty() || ttsContent.isEmpty()) { - return - } - saveObuData(v2xType, alertContent, ttsContent) - showWarning(v2xType, alertContent, ttsContent, direction) } - MogoObuConstants.STATUS.UPDATE -> {// 更新 + MogoObuConstants.STATUS.UPDATE -> { // 更新 } MogoObuConstants.STATUS.DELETE -> { // 删除 - // 关闭警告红边 - CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) + // 更新数据 TODO 删除原来的,改变颜色,删除marker。不影响别的模型添加 + TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) + ?.let { + // 事件结束,还原交通参与者颜色 + it.threatLevel = 0x01 + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + //删除弱势交通元素 CallerMapUIServiceManager.getMarkerService() ?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString()) } } + + //预警status + if (data.warningMsg != null && data.warningMsg.warningDataList != null && data.warningMsg.warningDataList.size > 0) { + level = data.warningMsg.warningDataList[0].warningLevel //默认是1个 + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "onMogoObuRsmWarning ---status---> ${data.status} ---data.warningMsg.warningData[0].status = ${data.warningMsg.warningDataList[0].status} ---v2xType = $v2xType ---alertContent = $alertContent ---ttsContent = $ttsContent ---level = $level" + ) + when (data.warningMsg.warningDataList[0].status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + //更新模型的颜色 + TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data) + ?.let { + CallerMapUIServiceManager.getMarkerService() + ?.updateITrafficThreatLevelInfo(it) + } + + if (alertContent.isEmpty() || ttsContent.isEmpty()) { + return + } + saveObuData(v2xType, alertContent, ttsContent) + showWarning(v2xType, alertContent, ttsContent, direction) + } + + MogoObuConstants.STATUS.UPDATE -> {// 更新 + } + + MogoObuConstants.STATUS.DELETE -> { // 删除 + // 关闭警告红边 + CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL) + //删除弱势交通元素 + CallerMapUIServiceManager.getMarkerService() + ?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString()) + } + } + } } } } -// } } /** * 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道 */ override fun onObuMapMath(data: ObuScene.MapMatchData?) { - if (data != null) { - CallerLogger.d( - "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "onMogoObuMapMath = ${data.status} --speedMaxLimit = ${(data.speedMaxLimit * 3.6).roundToInt()}" - ) - when (data.status) { - MogoObuConstants.STATUS.ADD -> { // 添加 - UiThreadHandler.post { - if (data.speedMaxLimit > 0) { - CallerLimitingVelocityListenerManager.invokeUnion( - (data.speedMaxLimit * 3.6).roundToInt(), DataSourceType.OBU - ) + if (HmiBuildConfig.isShowObuV2iView) { + if (data != null) { + CallerLogger.d( + "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", + "onMogoObuMapMath = ${data.status} --speedMaxLimit = ${(data.speedMaxLimit * 3.6).roundToInt()}" + ) + when (data.status) { + MogoObuConstants.STATUS.ADD -> { // 添加 + UiThreadHandler.post { + if (data.speedMaxLimit > 0) { + CallerLimitingVelocityListenerManager.invokeUnion( + (data.speedMaxLimit * 3.6).roundToInt(), DataSourceType.OBU + ) + } } } - } - MogoObuConstants.STATUS.UPDATE -> { // 更新 - } + MogoObuConstants.STATUS.UPDATE -> { // 更新 + } - MogoObuConstants.STATUS.DELETE -> { // 删除 - UiThreadHandler.post { - CallerLimitingVelocityListenerManager.invokeUnion( - -1, - DataSourceType.OBU - ) + MogoObuConstants.STATUS.DELETE -> { // 删除 + UiThreadHandler.post { + CallerLimitingVelocityListenerManager.invokeUnion( + -1, + DataSourceType.OBU + ) + } } } } @@ -543,7 +578,6 @@ class MogoPrivateObuNewManager private constructor() { * 获取消息的方位 车辆相关 */ private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum { - // CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification") return when (targetClassification) { MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方 @@ -589,7 +623,9 @@ class MogoPrivateObuNewManager private constructor() { if (FunctionBuildConfig.isObuWarningFusionUnion) { alertContent = "前车距离过近" ttsContent = "前车距离过近" - CallerObuWarningListenerManager.invokeTrackerFusionData(ObuManager.getInstance().obuRvToTrackedObject(info)) + CallerObuWarningListenerManager.invokeTrackerFusionData( + ObuManager.getInstance().obuRvToTrackedObject(info) + ) } else { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) @@ -650,7 +686,7 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) v2xType = EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType - if ( + if ( direction == WarningDirectionEnum.ALERT_WARNING_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT diff --git a/core/function-impl/mogo-core-function-hmi/build.gradle b/core/function-impl/mogo-core-function-hmi/build.gradle index 852be9bd7f..5229ec0dd4 100644 --- a/core/function-impl/mogo-core-function-hmi/build.gradle +++ b/core/function-impl/mogo-core-function-hmi/build.gradle @@ -68,7 +68,6 @@ dependencies { // debugImplementation rootProject.ext.dependencies.debugleakcanary // releaseImplementation rootProject.ext.dependencies.releaseleakcanary - implementation project(':libraries:mogo-obu') implementation rootProject.ext.dependencies.arouter kapt rootProject.ext.dependencies.aroutercompiler diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt index 0e422750f7..0c0f7961b4 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/DebugSettingView.kt @@ -73,9 +73,6 @@ import com.mogo.eagle.core.utilcode.mogo.toast.TipToast import com.mogo.eagle.core.utilcode.util.* import com.mogo.map.uicontroller.VisualAngleMode import com.mogo.map.uicontroller.VisualAngleMode.* -import com.mogo.support.obu.MogoObuManager -import com.mogo.support.obu.constants.MogoObuLogLevel -import com.mogo.support.obu.option.MogoObuLog import kotlinx.android.synthetic.main.view_debug_setting.view.* import kotlinx.coroutines.launch import mogo.telematics.pad.MessagePad @@ -1194,14 +1191,7 @@ internal class DebugSettingView @JvmOverloads constructor( * 设置是否输出OBU日志 true-打印日志,false-不打印日志 */ tbObuLog.setOnCheckedChangeListener { _, isChecked -> - MogoObuManager.getInstance().setEnableLog(isChecked) - - val builder: com.mogo.support.obu.option.MogoObuLog.Builder = - MogoObuLog.newBuilder().setEnableStdio(isChecked) - if (isChecked) { - builder.setStdioLevel(MogoObuLogLevel.DBG) - } - MogoObuManager.getInstance().logConfig(builder.build()) + CallerObuApiManager.setObuLog(isChecked) } /** diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt index 6327b04bed..2b6dadfb77 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt @@ -95,18 +95,19 @@ internal class SOPSettingView @JvmOverloads constructor( } /** - * obu V2V开关 + * obu V2V开关,默认打开 */ + tbObuV2vView.isChecked = HmiBuildConfig.isShowObuV2vView tbObuV2vView.setOnCheckedChangeListener { _, isChecked -> // 默认关闭 HmiBuildConfig.isShowObuV2vView = isChecked } /** - * obu V2i开关 + * obu V2i开关,默认打开 */ + tbObuV2iView.isChecked = HmiBuildConfig.isShowObuV2iView tbObuV2iView.setOnCheckedChangeListener { _, isChecked -> - // 默认关闭 HmiBuildConfig.isShowObuV2iView = isChecked } @@ -174,7 +175,7 @@ internal class SOPSettingView @JvmOverloads constructor( //OBU控制总开关 tbObu.isChecked = CallerObuApiManager.isConnected() tbObu.setOnCheckedChangeListener { _, isChecked -> - if (!isChecked) { + if (isChecked) { CallerObuApiManager.resetObuIpAddress("192.168.1.199") } else { //断开链接 diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml index e9830e19b0..8c7522b317 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml @@ -203,11 +203,13 @@ app:layout_constraintTop_toBottomOf="@id/tbCloudWeaknessTrafficSop" /> +