Merge branch 'dev_arch_opt_3.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_arch_opt_3.0

This commit is contained in:
xinfengkun
2023-02-01 18:34:39 +08:00
392 changed files with 11343 additions and 9874 deletions

View File

@@ -1,6 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.eagle.core.function.datacenter">
<application>
<receiver android:name=".obu.receiver.ObuTestTriggerReceiver">
<intent-filter>
<action android:name="com.obu.test_trigger" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name=".obu.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=".obu.receiver.ObuRsuTestTriggerReceiver">
<intent-filter>
<action android:name="com.obu.test_light_recognized" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name=".obu.receiver.ObuTestNewObuReceiver">
<intent-filter>
<action android:name="com.obu.test_newobu" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name=".obu.receiver.ObuTestNewObuRsiReceiver">
<intent-filter>
<action android:name="com.obu.test_newobu_rsi" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -0,0 +1,21 @@
package com.mogo.eagle.core.function
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.datacenter.IDataCenterProvider
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
class DataCenterProvider: IDataCenterProvider {
override val functionName: String
get() = "DataCenterProvider"
override fun init(context: Context?) {
}
override fun onDestroy() {
}
}

View File

@@ -62,9 +62,9 @@ import java.util.concurrent.TimeUnit
/**
* 域控制器
* @author xiaoyuzhou
* @date 2021/9/22 8:43 下午
* 域控制器
*/
@Route(path = MogoServicePaths.PATH_AUTO_PILOT)
class MoGoAutopilotProvider :

View File

@@ -51,7 +51,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListener
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager.invokeAutopilotRotting
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager.invokeAutopilotTrajectory
import com.mogo.eagle.core.function.call.autopilot.CallerStartAutopilotFailedListenerManager.invokeStartAutopilotFailed
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.obucombine.CallerObuDcCombineListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.support.obu.ObuScene
@@ -534,8 +534,9 @@ class MoGoAdasListenerImpl : OnAdasListener {
* @param obuWarningData 数据
*/
override fun onObuWarningData(header: MessagePad.Header?, obuWarningData: ObuWarningEvent.ObuWarningData?) {
CallerObuDcCombineListenerManager.invokeObuDcData(obuWarningData)
}
/**
* OBU 红绿灯预警信息
*

View File

@@ -0,0 +1,103 @@
package com.mogo.eagle.core.function.datacenter.obu
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MoGoConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.obu.IMoGoObuProvider
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.CommonUtils
import com.mogo.support.obu.MogoObuManager
/**
* @author xiaoyuzhou
* @date 2021/8/2 5:52 下午
*/
@Route(path = MogoServicePaths.PATH_V2X_OBU_MOGO)
class MoGoObuProvider : IMoGoObuProvider {
private val TAG = "MoGoObuProvider"
private var mContext: Context? = null
private val busObuIp = "192.168.8.199"
private val taxiObuIp = "192.168.1.199"
override val functionName: String
get() = TAG
override fun onDestroy() {
}
override fun init(context: Context) {
//obu融合数据
MogoObuDcCombineManager.INSTANCE.init(context)
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress())
//bus乘客版本obu功能去掉
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)
) {
//不处理
} else {
mContext = context
mContext?.let {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //bus 司机端
val ipAddress =
SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, busObuIp)
//mogo obu
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
ipAddress,
CommonUtils.getIpAddressString()
)
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { //taxi 司机端和乘客端
val ipAddress =
SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, taxiObuIp)
//mogo obu
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
ipAddress,
CommonUtils.getIpAddressString()
)
}
}
}
}
/**
* 通过控制面板设置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)
//连接 mogo obu
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
ipAddress,
CommonUtils.getIpAddressString()
)
}
}
}
override fun disConnect() {
MogoPrivateObuNewManager.INSTANCE.disconnect()
}
override fun isConnected(): Boolean {
return MogoObuManager.getInstance().connectStatus == 1
}
}

View File

@@ -0,0 +1,33 @@
package com.mogo.eagle.core.function.datacenter.obu;
/**
* author : lxiiaopeng
* date : 2021-08-4
* desc : 常量
*/
public class MogoObuConst {
/**
* 自研obu的tag
*/
public static final String TAG_MOGO_OBU = "MogoObu";
public static final String TAG_MOGO_NEW_OBU = "MogoNewObu";
// 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,668 @@
package com.mogo.eagle.core.function.datacenter.obu
import android.content.Context
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.enums.TrafficLightEnum
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.api.obucombine.IMoGoObuDcCombineListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.obucombine.CallerObuDcCombineListenerManager
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.support.obu.constants.MogoObuConstants
import mogo.v2x.ObuWarningEvent
import mogo.v2x.ObuWarningEvent.*
import kotlin.math.roundToInt
/**
*
* @author lixiaopeng
* @since 2021/11/30
* @description 工控机融合数据
*/
class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener {
companion object {
val INSTANCE: MogoObuDcCombineManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
MogoObuDcCombineManager()
}
}
private var mContext: Context? = null
private val TAG = "MogoObuDcCombineManager"
fun init(context: Context) {
mContext = context
CallerObuDcCombineListenerManager.addListener(TAG, this)
}
fun destoryListener() {
CallerObuDcCombineListenerManager.removeListener(TAG)
}
/**
* 通过工控机中转的obu数据,包括rsirsmspat
*
*/
override fun onMoGoObuDcCombineData(obuWarningData: ObuWarningEvent.ObuWarningData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMoGoObuDcCombineData obuWarningData = ${obuWarningData.toString()} ---obuWarningData.msgDataType = ${obuWarningData?.msgDataType}"
)
obuWarningData?.let {
when (obuWarningData.msgDataType) {
1 -> { //rsiEvent
onMogoObuDcRsiWarning(obuWarningData.rsiEvent)
}
2 -> { //RsmEvent
onMogoObuDcRsmWarning(obuWarningData.rsmEvent)
}
3 -> { //SpatEvent
onMogoObuDcSpatWarning(obuWarningData.spatEvent)
}
4 -> { //map
onMogoObuMapMath(obuWarningData.mapMatchData)
}
}
}
}
/**
* RSI预警信息 CvxRtiThreatIndInfo交通标志预警前方限速、前方学校等等交通事件预警前方拥堵、前方积水等等
*/
fun onMogoObuDcRsiWarning(rsiWarningData: RsiWarningData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsiWarning ------> ${rsiWarningData.toString()}"
)
if (rsiWarningData != null && rsiWarningData.warningMsgList != null && rsiWarningData.warningMsgList.size > 0) {
var alertContent = ""
var ttsContent = "" //列表只有一项
var appId = rsiWarningData.warningMsgList[0].sceneType.toString()
val status = rsiWarningData.status
val level = rsiWarningData.warningMsgList[0].warningLevel
val direction = getMessageDirection(rsiWarningData.warningMsgList[0].targetPosition)
CallerLogger.d("${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuDcRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${rsiWarningData.warningMsgList[0].eventSerialNum} ---signSerialNum = ${rsiWarningData.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${rsiWarningData.warningMsgList[0].targetPosition}"
)
when (appId) {
// 道路危险情况预警
MogoObuConstants.RSI_SCENE_TYPE.HLW.toString() -> {
when (rsiWarningData.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
}
}
alertContent = EventTypeEnumNew.getWarningContent(appId)
ttsContent = EventTypeEnumNew.getWarningTts(appId)
alertContent = String.format( //事件才有影响范围
alertContent,
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
)
ttsContent = String.format(
ttsContent,
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
)
}
//车内标牌
MogoObuConstants.RSI_SCENE_TYPE.IVS.toString() -> {
when (rsiWarningData.warningMsgList[0].signSerialNum) {
// MogoObuConstants.RTS.RTI_TYPE_INTERSECTION -> { //十字路口
// appId = V2iEventTypeEnum.TYPE_ID_NTERSECTION.poiType
// }
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_GO_STRAIGHT_TURN_RIGHT -> { //直行或右转
// appId =
// EventTypeEnumNew.TYPE_USECASE_ID_GO_STRAIGHT_TURN_RIGHT.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(rsiWarningData.warningMsgList[0].distance / 100.0).toString()
)
ttsContent = String.format(
ttsContent,
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).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(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
)
ttsContent = String.format(
ttsContent,
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
)
}
//限速预警, ADD处理一次
MogoObuConstants.RSI_SCENE_TYPE.SLW.toString() -> {
alertContent = EventTypeEnumNew.getWarningContent(appId)
ttsContent = EventTypeEnumNew.getWarningTts(appId)
}
}
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}"
)
when (status) {
// 添加
MogoObuConstants.STATUS.ADD -> {
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
appId,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.TELEMATIC
}
)
CallerHmiManager.warningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
},
true,
5000L
)
// 更新数据,是否需要
// TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(rsiWarningData)?.let {
// CallerMapUIServiceManager.getMarkerService()
// ?.updateITrafficThreatLevelInfo(it)
// }
}
MogoObuConstants.STATUS.UPDATE -> { // 更新
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
CallerHmiManager.disableWarningV2X((appId + direction.direction))
// 更新数据,删除标牌?
// TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(rsiWarningData)
// ?.let {
// // 事件结束,还原车辆颜色
// it.threatLevel = 0x01
// CallerMapUIServiceManager.getMarkerService()
// ?.updateITrafficInfo(it)
// }
}
}
}
}
/**
* RSM预警信息 CvxPtcThreatIndInfo CvxPtcInfoIndInfo主车与弱势交通参与者之间的预警弱势交通参与者碰撞预警
*/
fun onMogoObuDcRsmWarning(rsmWarningData: RsmWarningData?) {
if (HmiBuildConfig.isShowObuWeaknessTrafficView) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsmWarning ------> ${rsmWarningData.toString()}"
)
// 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu
if (rsmWarningData != null && rsmWarningData.participantOfOne != null) {
var v2xType = ""
if (rsmWarningData.participantOfOne.ptcType == 1) { //机动车
v2xType =
EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType
} else if (rsmWarningData.participantOfOne.ptcType == 2) { //非机动车
v2xType =
EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType
} else if (rsmWarningData.participantOfOne.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(rsmWarningData.participantOfOne.targetPosition) //TODO 只有一个
if (rsmWarningData.warningMsg != null && rsmWarningData.warningMsg.warningDataList != null && rsmWarningData.warningMsg.warningDataList.size > 0) {
level = rsmWarningData.warningMsg.warningDataList[0].warningLevel
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsmWarning ---status---> ${rsmWarningData.status} --list status----> ${rsmWarningData.warningMsg.warningDataList.get(0).status} --v2xType--- $v2xType ---alertContent = $alertContent ---ttsContent= $ttsContent"
)
when (rsmWarningData.warningMsg.warningDataList.get(0).status) {
MogoObuConstants.STATUS.ADD -> { // 添加
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
v2xType,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.TELEMATIC
}
)
CallerHmiManager.warningV2X(
v2xType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(v2xType + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(
WarningDirectionEnum.ALERT_WARNING_NON
)
}
},
true,
5000L
)
// 更新数据 TODO
// TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)?.let {
//// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
// CallerMapUIServiceManager.getMarkerService()
// ?.updateITrafficThreatLevelInfo(it)
// }
}
MogoObuConstants.STATUS.UPDATE -> {// 更新
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据 TODO 由于obu通过域控需要转换单位这里临时转换后面3.0不需要转换
// TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)?.let {
// // 事件结束,还原交通参与者颜色
// it.threatLevel = 0x01
//// TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
// CallerMapUIServiceManager.getMarkerService()
// ?.updateITrafficThreatLevelInfo(it)
// }
//删除弱势交通元素
CallerMapUIServiceManager.getMarkerService()
?.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString())
// TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString())
}
}
}
}
}
}
/**
* 红绿灯预警信息
*/
fun onMogoObuDcSpatWarning(spatWarningData: SpatWarningData?) {
CallerLogger.d("${M_OBU}${TAG}", "onMogoObuDcSpatWarning warningType = ${spatWarningData!!.warningType} --status = ${spatWarningData?.status} --lightsList = ${spatWarningData.lightsList}")
handlerTrafficLight(
spatWarningData!!.warningType,
spatWarningData?.status,
spatWarningData?.lightsList
)
}
/**
* 地图匹配 是OBU算法输出地图匹配结果主车匹配道路哪条路或者哪条车道
*/
fun onMogoObuMapMath(data: MapMatchData?) {
CallerLogger.d("${M_OBU}${TAG}", "MogoObuDcCombineManager onMogoObuMapMath HmiBuildConfig.isShowObuLimitSpeedView = " + HmiBuildConfig.isShowObuLimitSpeedView)
if(HmiBuildConfig.isShowObuLimitSpeedView) {
if (data != null) {
CallerLogger.d("${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${Math.round((data.speedMaxLimit*0.02*3.6))} --- data.speedMaxLimit = ${data.speedMaxLimit}")
when (data.status) {
MogoObuConstants.STATUS.ADD -> { // 添加 TODO
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
(data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(),DataSourceType.OBU)
}
MogoObuConstants.STATUS.UPDATE -> { // 更新
}
MogoObuConstants.STATUS.DELETE -> { // 删除
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(-1 ,DataSourceType.OBU)
}
}
}
}
}
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
/**
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<ObuWarningEvent.SpatLight>) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
)
when (status) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE
-> {
if (lights != null && lights.isNotEmpty()) {
changeTrafficLightStatus(appId, lights)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗,当收不到信号的时候触发一次
CallerTrafficLightListenerManager.disableTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
isShowGreenWave = false
isShowRunRedLight = false
}
}
}
private var isRedLight = false
private var isGreenLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
/**
* 修改红绿灯
*/
@Synchronized
private fun changeTrafficLightStatus(
appId: Int,
lights: List<ObuWarningEvent.SpatLight>
) {
var ttsContent = ""
var alertContent = ""
//这里需要根据真实数据确定 index 取值方式
val currentLight = lights[0]
CallerLogger.e(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager currentLight = $currentLight ---currentLight.phaseID = ${currentLight.phaseID} ---appId = $appId ---isShowRunRedLight = $isShowRunRedLight ---isShowGreenWave = $isShowGreenWave"
)
// 闯红灯预警和绿波通行底层是互斥的
when (appId) {
0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效
}
1 -> { //闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
if (!isShowRunRedLight) {
isShowRunRedLight = true
CallerHmiManager.disableWarningV2X(1667.toString())
ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
CallerLogger.d("${M_OBU}${TAG}","MogoObuDcCombineManager changeTrafficLightStatus 闯红灯 --------> ttsContent = $ttsContent ---alertContent = $alertContent ")
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.TELEMATIC
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, null, true, 5000L)
}
}
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次
if (!isShowGreenWave) {
isShowGreenWave = true
CallerHmiManager.disableWarningV2X(1666.toString())
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager 绿波通行引导 --------> speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}")
val adviceSpeed =
"${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}"
val adviceSpeedTts =
"${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}"
ttsContent =
String.format(
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeedTts
)
alertContent =
String.format(
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeed
)
val maxSpeed = currentLight.suggestMaxSpeed*3.6
if (maxSpeed > 0) {
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.TELEMATIC
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
null,
true,
5000L
)
}
}
}
}
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.BLACK, DataSourceType.TELEMATIC)
}
// 红灯
2, 3 -> {
if (!isRedLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isRedLight = true
}
isGreenLight = false
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.RED, DataSourceType.TELEMATIC)
val red = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownRed(red)
}
// 绿灯
4, 5, 6 -> {
if (!isGreenLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isGreenLight = true
}
isRedLight = false
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.GREEN, DataSourceType.TELEMATIC)
val green = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownGreen(green)
}
// 黄灯
7, 8 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.YELLOW, DataSourceType.TELEMATIC)
val yellow = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownYellow(yellow)
}
}
}
}

View File

@@ -0,0 +1,92 @@
package com.mogo.eagle.core.function.datacenter.obu.adapter
import com.mogo.eagle.core.function.call.obu.*
import com.mogo.support.obu.OnMogoObuListener
import com.mogo.support.obu.constants.Define.ConnectStatus
import com.mogo.support.obu.model.*
/**
* 适配 OBU 回调监听分发,这里不做业务,只做数据包装及分发处理
* @author dong hong yu
*/
object MoGoObuListenerImpl : OnMogoObuListener() {
/**
* 连接状态
*
* @param connectStatus 连接状态
* @since 1.0.0
*/
override fun onConnectStatus(@ConnectStatus connectStatus: Int) {
//断开连接
if (connectStatus == 0) {
CallerObuConnectListenerManager.getObuStatusInfo().obuStatus = false
}
//连接成功
else if (connectStatus == 1) {
CallerObuConnectListenerManager.getObuStatusInfo().obuStatus = true
}
CallerObuConnectListenerManager.invokeObuConnectListener()
}
/**
* HV车辆基础信息
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuHvBasics(data: MogoObuHvBasicsData) {
CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(data)
}
/**
* V2V预警信息
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuRvWarning(data: MogoObuRvWarningData) {
CallerObuWarningRvListenerManager.invokeObuRvWarning(data)
}
/**
* 红绿灯预警信息
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuSpatWarning(data: MogoObuSpatWarningData) {
CallerObuWarningSpatListenerManager.invokeObuSpatWarning(data)
}
/**
* RSI预警信息
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuRsiWarning(data: MogoObuRsiWarningData) {
CallerObuWarningRsiListenerManager.invokeObuRsiWarning(data)
}
/**
* RSM预警信息
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuRsmWarning(data: MogoObuRsmWarningData) {
CallerObuWarningRsmListenerManager.invokeObuRsmWarning(data)
}
/**
* 地图匹配结果
*
* @param data 数据
* @since 1.0.0
*/
override fun onMogoObuMapMath(data: MogoObuMapMathData) {
CallerObuMapMathListenerManager.invokeObuMapMath(data)
}
}

View File

@@ -0,0 +1,120 @@
package com.mogo.eagle.core.function.datacenter.obu.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.datacenter.obu.MogoPrivateObuManager
//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
//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)
//
// CallerLogger.d(
// "$M_OBU$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,58 @@
package com.mogo.eagle.core.function.datacenter.obu.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.mogo.eagle.core.function.datacenter.obu.MogoPrivateObuNewManager
import com.mogo.support.obu.model.MogoObuRvWarningData
import com.mogo.support.obu.model.advance.V2xWarning
import com.mogo.support.obu.model.advance.VehBasics
import com.mogo.support.obu.model.advance.WarningData
/**
* @author lixiaopeng
* @date 2022/9/8 10:50 上午
*
* 自研OBU 模拟场景
*/
class ObuTestNewObuReceiver : BroadcastReceiver() {
private var mContext: Context? = null
companion object {
private const val TAG = "ObuTestNewObuReceiver"
}
override fun onReceive(context: Context, intent: Intent) {
mContext = context
/**
* OBU 场景类型
* @see com.zhidao.support.obu.constants.ObuConstants.USE_CASE_ID
*/
val obuType = intent.getIntExtra("type", 0)
val obuStatus = intent.getIntExtra("status", 0)
val obuLevel = intent.getIntExtra("level", 3)
val direction = intent.getIntExtra("direction", 0)
val vehBasicsMsg = VehBasics(1)
vehBasicsMsg.targetPosition = direction
val warningMsg = V2xWarning(1)
val warningData1 = WarningData(1, 2)
warningData1.warningType = obuType
warningData1.warningLevel = obuLevel
// val warningData2 = WarningData(1, 3)
val warningList = listOf(warningData1)
warningMsg.warningData = warningList
val cvxHvInfoIndInfo = MogoObuRvWarningData(0, vehBasicsMsg, warningMsg)
MogoPrivateObuNewManager.INSTANCE
.getMogoObuListener()
.onMogoObuRvWarning(cvxHvInfoIndInfo)
}
}

View File

@@ -0,0 +1,52 @@
package com.mogo.eagle.core.function.datacenter.obu.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.mogo.eagle.core.function.datacenter.obu.MogoPrivateObuNewManager
import com.mogo.support.obu.model.MogoObuRsiWarningData
import com.mogo.support.obu.model.advance.RsiWarning
/**
* @author lixiaopeng
* @date 2023/1/13 10:50 上午
*
* 自研OBU RSI 模拟场景
*/
class ObuTestNewObuRsiReceiver : BroadcastReceiver() {
private var mContext: Context? = null
companion object {
private const val TAG = "ObuTestNewObuReceiver"
}
override fun onReceive(context: Context, intent: Intent) {
mContext = context
/**
* OBU 场景类型
*/
val obuSceneType = intent.getIntExtra("sceneType", 0)
val obuStatus = intent.getIntExtra("status", 0)
// val obuDistance = intent.getDoubleExtra("distance", 0.0)
val obuEventSeriaNum = intent.getIntExtra("seriaNum", 0)
val obuSignSerialNum = intent.getIntExtra("signSerialNum", 0)
val rsiWarning = RsiWarning(1)
rsiWarning.warningLevel = 1
rsiWarning.setDistance(1000)
rsiWarning.sceneType = obuSceneType //预警类型 0无效 1限速信息 2道路危险 3车内标牌 4前方拥堵
rsiWarning.eventSerialNum = obuEventSeriaNum //根据预警类型匹配 101 车辆故障
rsiWarning.signSerialNum = obuSignSerialNum // 2急转弯8桥梁
val rsiWarningList = listOf(rsiWarning) //TODO
val cvxObuRsiInfo = MogoObuRsiWarningData(obuStatus, 1, rsiWarningList)
MogoPrivateObuNewManager.INSTANCE
.getMogoObuListener()
.onMogoObuRsiWarning(cvxObuRsiInfo)
}
}

View File

@@ -0,0 +1,89 @@
package com.mogo.eagle.core.function.datacenter.obu.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.datacenter.obu.MogoPrivateObuManager
//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
//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)
// CallerLogger.d(
// "$M_OBU$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,61 @@
package com.mogo.eagle.core.function.datacenter.obu.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.datacenter.obu.MogoPrivateObuManager
//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
//import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
//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)
// CallerLogger.d("$M_OBU$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,132 @@
package com.mogo.eagle.core.function.datacenter.obu.utils
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.traffic.TrafficData
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
import com.mogo.support.obu.model.MogoObuRsiWarningData
import com.mogo.support.obu.model.MogoObuRsmWarningData
import com.mogo.support.obu.model.MogoObuRvWarningData
/**
* @description 自研obu数据转换
*
* @author lixiaopeng
* @since 2022/8/24
*/
object TrafficDataConvertUtilsNew {
val TAG = "TrafficDataConvertUtilsNew"
/**
* OBU 远车 转换交通元素数据,是否需要
*/
fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info.vehBasicsMsg == null) {
CallerLogger.e("$M_OBU$TAG", "cvxRvInfoIndInfo2TrafficData 数据转换异常,请检查参数是否齐全")
return null
}
val trafficData = TrafficData()
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
trafficData.uuid = info.vehBasicsMsg.id
trafficData.lat = info.vehBasicsMsg.latitude
trafficData.lon = info.vehBasicsMsg.longitude
trafficData.heading = info.vehBasicsMsg.heading
trafficData.speed = info.vehBasicsMsg.speed
return trafficData
}
/**
* OBU RSU道路事件预警信息 转换交通元素数据 标牌 为何要显示level
*/
fun cvxRtiThreatIndInfo2TrafficData(info: MogoObuRsiWarningData): TrafficData? {
if (info.warningMsg == null || info.warningMsg.size < 1 || info.warningMsg[0].position == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
return null
}
val trafficData = TrafficData()
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG
trafficData.uuid = info.warningMsg[0].signSerialNum.toString()
trafficData.lat = info.warningMsg[0].position.latitude
trafficData.lon = info.warningMsg[0].position.longitude
trafficData.threatLevel = info.warningMsg[0].warningLevel
return trafficData
}
/**
* OBU 预警事件 转换交通元素数据 他车预警
*/
fun cvxV2vThreatIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info == null || info.vehBasicsMsg == null || info.warningMsg == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
return null
}
val trafficData = TrafficData()
trafficData.uuid = info.vehBasicsMsg.id
trafficData.lat = info.vehBasicsMsg.latitude
trafficData.lon = info.vehBasicsMsg.longitude
trafficData.heading = info.vehBasicsMsg.heading
trafficData.speed = info.vehBasicsMsg.speed
// 判断车辆V2X预警级别调整车辆颜色
if (info.warningMsg.warningData != null) {
trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel
} else {
trafficData.threatLevel = 1
}
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
return trafficData
}
/**
* OBU 弱势交通参与者信息 转换交通元素数据
*/
fun cvxPtcThreatIndInfo2TrafficData(info: MogoObuRsmWarningData): TrafficData? {
if (info.participant == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
return null
}
val trafficData = TrafficData()
trafficData.uuid = info.participant.ptcId.toString()
trafficData.lat = info.participant.latitude
trafficData.lon = info.participant.longitude
trafficData.heading = info.participant.heading
trafficData.speed = info.participant.speed
/**
* 交通参与者类型
* 0未知
* 1机动车
* 2非机动车
* 3行人
* 4OBU自身
*/
when (info.participant.ptcType) {
// 未知
0 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
}
//机动车
1 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
}
// 非机动车
2 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
}
// 行人
3 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
}
}
// 判断车辆V2X预警级别调整车辆颜色
if (info.warningMsg != null && info.warningMsg.warningData != null) {
trafficData.threatLevel = info.warningMsg.warningData[0].warningLevel
} else {
trafficData.threatLevel = 1
}
return trafficData
}
}

View File

@@ -3,7 +3,6 @@ package com.mogo.eagle.core.function.msgbox
import android.content.Context
import android.os.Looper
import com.mogo.eagle.core.data.msgbox.*
import com.mogo.eagle.core.data.notice.NoticeNormalData
import com.mogo.eagle.core.data.report.ReportEntity
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager
import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb