Merge branch 'dev_robotaxi-d-app-module_2130_221116_2.13.0' into dev_robotaxi-d-app-module_2110_220915_2.11.0_cmdb

This commit is contained in:
lixiaopeng
2022-11-16 21:49:06 +08:00
274 changed files with 12862 additions and 217 deletions

View File

@@ -2,7 +2,9 @@ package com.mogo.eagle.core.function.autopilot
import android.Manifest.permission
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import chassis.SpecialVehicleTaskCmdOuterClass
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
@@ -718,4 +720,9 @@ class MoGoAutopilotProvider :
override fun sendStatusQueryReq() {
AdasManager.getInstance().sendStatusQueryReq()
}
override fun sendSweeperFuTianTaskCmd(fuTianTaskCmd: SpecialVehicleTaskCmdOuterClass.RoboSweeperFuTianTaskCmd) {
Log.d(TAG, "---- sendSweeperFuTianTaskCmd ----")
AdasManager.getInstance().sendRoboSweeperFuTianTaskCmd(fuTianTaskCmd)
}
}

View File

@@ -170,7 +170,10 @@ class MoGoAdasListenerImpl : OnAdasListener {
CallerAutopilotVehicleStateListenerManager.invokeAutopilotThrottle(vehicleState.throttle)
//刹车
CallerAutopilotVehicleStateListenerManager.invokeAutopilotBrake(vehicleState.brake)
//清扫车(福田)清扫控制系统状态
vehicleState.sweeperFutianCleanSystemState?.also {
CallerAutopilotVehicleStateListenerManager.invokeSweeperFutianCleanSystemState(it)
}
} else {
CallerAutopilotVehicleStateListenerManager.invokeAutopilotDataException(header.timestamp.toLong())
}

View File

@@ -24,7 +24,7 @@ import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DRIVER
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.PASSENGER
import mogo.telematics.pad.MessagePad
import java.util.*
import java.util.concurrent.atomic.*
import java.util.concurrent.atomic.AtomicBoolean
/**
* ADAS-SDK与工控机连接状态回调

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
@@ -24,6 +25,7 @@ import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import chassis.VehicleStateOuterClass;
import mogo.telematics.pad.MessagePad;
public class MoGoHandAdasMsgManager implements
@@ -178,4 +180,9 @@ public class MoGoHandAdasMsgManager implements
}
@Override
public void onSweeperFutianCleanSystemState(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
}
}

View File

@@ -4,6 +4,7 @@ import android.content.*
import android.util.Log
import chassis.Chassis.GearPosition
import chassis.Chassis.LightSwitch
import chassis.VehicleStateOuterClass
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.utilcode.kotlin.*
@@ -81,6 +82,11 @@ internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehic
timeOutCheck()
}
override fun onSweeperFutianCleanSystemState(cleanSystemState: VehicleStateOuterClass.SweeperFuTianCleanSystemState) {
send(CanStatus(isCanEnabled()))
timeOutCheck()
}
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo)
send(CanStatus(isCanEnabled()))

View File

@@ -1039,7 +1039,9 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
override fun showWarning(direction: WarningDirectionEnum) {
CallerLogger.d(TAG, "showWarning====")
flV2XWarningView?.showWarning(direction)
flicker(flV2XWarningView)
if (flV2XWarningView != null) {
flicker(flV2XWarningView)
}
}
/**

View File

@@ -19,6 +19,7 @@ import androidx.core.content.ContextCompat
import androidx.core.view.*
import androidx.recyclerview.widget.LinearLayoutManager
import chassis.Chassis
import chassis.VehicleStateOuterClass
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig
@@ -2092,6 +2093,13 @@ class DebugSettingView @JvmOverloads constructor(
}
/**
* 清扫车(福田)清扫控制系统状态
*/
override fun onSweeperFutianCleanSystemState(cleanSystemState: VehicleStateOuterClass.SweeperFuTianCleanSystemState) {
}
/**
* 吐司提示
*/

View File

@@ -27,6 +27,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import chassis.VehicleStateOuterClass;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
import system_master.SystemStatusInfo;
@@ -164,6 +165,10 @@ public class SteeringWheelView extends ConstraintLayout {
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
@Override
public void onSweeperFutianCleanSystemState(@NonNull VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
}
/**
* @param brake 刹车
*/

View File

@@ -26,6 +26,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import chassis.VehicleStateOuterClass;
import mogo.telematics.pad.MessagePad;
/**
@@ -122,6 +123,10 @@ public class TrafficDataView extends ConstraintLayout {
}
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
@Override
public void onSweeperFutianCleanSystemState(@NonNull VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
}
/**
* 车辆转向灯
* @param lightSwitch

View File

@@ -66,6 +66,7 @@ dependencies {
implementation project(':core:mogo-core-function-call')
}
implementation rootProject.ext.dependencies.mogoobuold
implementation rootProject.ext.dependencies.mogoobu
}

View File

@@ -26,6 +26,13 @@
</intent-filter>
</receiver>
<receiver android:name="com.mogo.eagle.core.function.obu.mogo.receiver.ObuTestNewObuReceiver">
<intent-filter>
<action android:name="com.obu.test_newobu" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -10,6 +10,7 @@ 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
/**
* @author xiaoyuzhou
@@ -21,6 +22,11 @@ class MoGoObuProvider : IMoGoObuProvider {
private var mContext: Context? = null
private val busObuIp = "192.168.8.199"
private val taxiObuIp = "192.168.1.199"
// private val taxiObuIp = "192.168.1.186"
override val functionName: String
get() = TAG
@@ -28,30 +34,72 @@ class MoGoObuProvider : IMoGoObuProvider {
}
override fun init(context: Context) {
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU……")
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress())
//bus乘客版本obu功能去掉
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(
FunctionBuildConfig.appIdentityMode
)
) {
//不处理
} else {
mContext = context
val ipAddress =
SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, "192.168.1.199")
MogoPrivateObuManager.INSTANCE.init(context, ipAddress)
mContext?.let {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //bus 司机端
//mogo obu
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
busObuIp,
CommonUtils.getIpAddressString()
)
//old obu
val ipAddress =
SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, busObuIp)
MogoPrivateObuManager.INSTANCE.init(context, ipAddress)
} else if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { //taxi 司机端和乘客端
//mogo obu
MogoPrivateObuNewManager.INSTANCE.connectObu(
it,
taxiObuIp,
CommonUtils.getIpAddressString()
)
//old obu
val ipAddress =
SharedPrefsMgr.getInstance(context).getString(MoGoConfig.OBU_IP, taxiObuIp)
MogoPrivateObuManager.INSTANCE.init(context, ipAddress)
}
}
}
}
/**
* 通过控制面板设置ip进行传递
*/
override fun connect(ipAddress: String) {
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
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()
)
//连接old obu
MogoPrivateObuManager.INSTANCE.connectObu(it, ipAddress)
}
}
}
override fun disConnect() {

View File

@@ -1,6 +1,7 @@
package com.mogo.eagle.core.function.obu.mogo
import android.content.Context
import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.app.AppConfigInfo
@@ -52,6 +53,7 @@ class MogoPrivateObuManager private constructor() {
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
mContext = context
//连接obu设备
connectObu(context, ipAddress)
//控制日志输出
MogoObuManager.getInstance()
@@ -63,17 +65,16 @@ class MogoPrivateObuManager private constructor() {
//自研obu初始化
mObuStatusInfo.connectIP = ipAddress
mObuStatusInfo.obuSdkVersion = MogoObuManager.getInstance().versionName
if (!MogoObuManager.getInstance().isConnected) {
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
} else {
MogoObuManager.getInstance().disConnect()
try {
MogoObuManager.getInstance().disConnect()
Thread.sleep(500)
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
} catch (e: Exception) {
e.printStackTrace()
}
MogoObuManager.getInstance().connect(context, mObuStatusInfo.connectIP)
}
}
@@ -97,6 +98,9 @@ class MogoPrivateObuManager private constructor() {
mObuStatusInfo.obuStatus = true
CallerObuListenerManager.invokeListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) }
//断开mogo obu
com.mogo.support.obu.MogoObuManager.getInstance().disconnect()
}
// OBU连接失败
@@ -208,7 +212,6 @@ class MogoPrivateObuManager private constructor() {
e.printStackTrace()
}
}
}
// (3) 远车信息CVX_RV_INFO_IND

View File

@@ -0,0 +1,788 @@
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
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
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.map.CallerVisualAngleManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose
import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager
import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtilsNew
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.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.EventTypeEnumNew
import com.mogo.module.common.enums.V2iEventTypeEnum
import com.mogo.support.obu.MogoObuManager
import com.mogo.support.obu.OnMogoObuListener
import com.mogo.support.obu.constants.MogoObuComType
import com.mogo.support.obu.constants.MogoObuConstants
import com.mogo.support.obu.constants.MogoObuTopicId
import com.mogo.support.obu.model.*
import com.mogo.support.obu.model.advance.SpatLight
import com.mogo.support.obu.option.MogoObuCom
import com.mogo.support.obu.option.MogoObuOptions
import org.json.JSONObject
/**
*
* @author lixiaopeng
* @since 2021/8/23
* @description 自研OBU 管理
*/
class MogoPrivateObuNewManager private constructor() {
companion object {
val INSTANCE: MogoPrivateObuNewManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
MogoPrivateObuNewManager()
}
}
private var mContext: Context? = null
private val TAG = "ObuNewManager"
private var mObuStatusInfo = CallerObuListenerManager.getObuStatusInfo()
fun connectObu(context: Context, obuIpAddress: String, padIpAddress: String) {
MogoObuManager.getInstance().registerMogoObuListener(mogoObuListener)
val com = MogoObuCom.newBuilder()
.setLocalIp(padIpAddress)
.setComType(MogoObuComType.UDP)
.setLocalPort(8888)
.setServerIp(obuIpAddress)
.setServerPort(32900)
.build()
val options: MogoObuOptions = MogoObuOptions.newBuilder()
.setCom(com)
.registerTopic(MogoObuTopicId.HV_BASIC)
.registerTopic(MogoObuTopicId.RV_WARNING)
.registerTopic(MogoObuTopicId.SPAT_WARNING)
.registerTopic(MogoObuTopicId.RSI_WARNING)
.registerTopic(MogoObuTopicId.RSM_WARNING)
.registerTopic(MogoObuTopicId.MAP_MATCH)
.build()
//每次连接的时候如果连接连接了,先断开
if (MogoObuManager.getInstance().connectStatus == 1) {
try {
MogoObuManager.getInstance().disconnect()
} catch (e: Exception) {
e.printStackTrace()
}
}
MogoObuManager.getInstance().connect(options)
}
fun getMogoObuListener(): OnMogoObuListener {
return mogoObuListener
}
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
/**
* 连接状态的改变
*/
override fun onConnectStatus(connectStatus: Int) {
if (connectStatus == 0) { //断开连接
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnectFail ------> ")
mObuStatusInfo.obuStatus = false
mObuStatusInfo.obuHvStatus = false
mObuStatusInfo.obuRvStatus = false
CallerObuListenerManager.invokeListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_HV", false) }
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU_RV", false) }
} else if (connectStatus == 1) { //连接成功
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "onConnected ------> ")
mObuStatusInfo.obuStatus = true
CallerObuListenerManager.invokeListener(mObuStatusInfo)
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean("OBU", true) }
//断开老obu
try {
com.zhidao.support.obu.MogoObuManager.getInstance().disConnect()
} catch (e: Exception) {
e.printStackTrace()
}
}
}
/**
* HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo
*/
override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) {
Log.d(
TAG,
"onMogoObuHvBasics ------ p0 = ${p0.toString()}" + "-----FunctionBuildConfig.gpsProvider = " + FunctionBuildConfig.gpsProvider
)
if (p0 != null && p0.vehBasicsMsg != null) {
Log.d(
TAG,
"onMogoObuHvBasics lon = ${p0.vehBasicsMsg.longitude} --- lat = ${p0.vehBasicsMsg.latitude} ---speed = ${p0.vehBasicsMsg.speed} ---heading = ${p0.vehBasicsMsg.heading} --acceleration = ${p0.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${p0.vehBasicsMsg.accFourAxes.accYaw}"
)
val data = JSONObject()
try {
data.putOpt("lon", p0.vehBasicsMsg.longitude)
data.putOpt("lat", p0.vehBasicsMsg.latitude)
data.putOpt("speed", p0.vehBasicsMsg.speed)
data.putOpt("heading", p0.vehBasicsMsg.heading)
data.putOpt("acceleration", p0.vehBasicsMsg.accFourAxes.accLat)
data.putOpt("yawRate", p0.vehBasicsMsg.accFourAxes.accYaw)
try {
data.putOpt("systemTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("satelliteTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
p0.vehBasicsMsg.longitude,
p0.vehBasicsMsg.latitude
)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
/**
* v2v预警信息 CvxRvInfoIndInfo CvxV2vThreatIndInfo 他车
*/
override fun onMogoObuRvWarning(data: MogoObuRvWarningData) {
super.onMogoObuRvWarning(data)
// 更新数据远车数据之前要匹配uuid
TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(data)?.let {
TrafficMarkerDrawer.updateITrafficLocationInfo(it)
}
Log.d(TAG, data.toString())
data.let {
//预警信息,预警类型 threat_level 2、3
var status = data.status
data.vehBasicsMsg?.let {
//预警方位
val direction = getMessageDirection(data.vehBasicsMsg.targetPosition)
//处理预警类型
var appId = "0"
var level = -1
data.warningMsg?.let {
if (data.warningMsg.warningData != null && data.warningMsg.warningData.size > 0) {
level = data.warningMsg.warningData[0].warningLevel
appId = data.warningMsg.warningData[0].warningType.toString()
}
}
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onMogoObuRvWarning target_classification = ${
getMessageDirection(data.vehBasicsMsg.targetPosition)
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
)
Log.e(
TAG,
"onMogoObuRvWarning target_classification = ${
getMessageDirection(data.vehBasicsMsg.targetPosition)
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
)
//拼凑数据
if (appId != null) {
handleSdkObu(appId, direction, status, level, data)
}
}
}
}
/**
* 红绿灯预警信息 CvxIvpThreatIndInfo
*/
override fun onMogoObuSpatWarning(data: MogoObuSpatWarningData) {
super.onMogoObuSpatWarning(data)
if (data?.lights != null && data.lights.isNotEmpty()
) {
handlerTrafficLight(
data.warningType,
data.status,
data.lights
)
}
}
/**
* RSI预警信息 CvxRtiThreatIndInfo交通标志预警前方限速、前方学校等等交通事件预警前方拥堵、前方积水等等
*/
override fun onMogoObuRsiWarning(data: MogoObuRsiWarningData) {
super.onMogoObuRsiWarning(data)
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onMogoObuRsiWarning ------> $data"
)
if (data != null && data.warning_Msg != null && data.warning_Msg.size > 0) {
var alertContent = ""
var ttsContent = ""
var appId = data.warning_Msg[0].sceneType.toString()
val status = data.status
val level = data.warning_Msg[0].warningLevel
val direction = getMessageDirection(data.warning_Msg[0].targetPosition)
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onCvxRtiThreatIndInfo appId = $appId --status = $status --level = $level -- eventSerialNum = ${data.warning_Msg[0].eventSerialNum} -- direction = $direction -- targetPosition = ${data.warning_Msg[0].targetPosition}"
)
when (appId) {
// 道路危险情况预警
V2iEventTypeEnum.TYPE_USECASE_ID_HLW.poiType
-> {
when (data.warning_Msg[0].eventSerialNum) {
MogoObuConstants.RTE.RTI_TYPE_RETRIGRADE -> { //车辆逆行
appId =
V2iEventTypeEnum.TYPE_USECASE_ID_ROAD_VEHICLE_RETROGRADE.poiType
}
MogoObuConstants.RTE.RTI_TYPE_SPEEDING -> { //超速行驶
appId = V2iEventTypeEnum.TYPE_USECASE_ID_SLW.poiType
}
MogoObuConstants.RTE.RTI_TYPE_BREAKDOWN -> {//车辆故障
appId = V2iEventTypeEnum.TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType
}
MogoObuConstants.RTE.RTI_TYPE_CONSTRUCTION_RTE -> { //施工占道
appId = V2iEventTypeEnum.FOURS_ROAD_WORK.poiType
}
MogoObuConstants.RTE.RTI_TYPE_PARKING_VIOLATION -> { //异常停车
appId = V2iEventTypeEnum.TYPE_USECASE_ID_ROAD_PARKING.poiType
}
MogoObuConstants.RTE.RTI_TYPE_ROAD_WATER -> { //道路积水
appId = V2iEventTypeEnum.FOURS_PONDING.poiType
}
}
alertContent = V2iEventTypeEnum.getWarningContent(appId)
ttsContent = V2iEventTypeEnum.getWarningTts(appId)
}
V2iEventTypeEnum.TYPE_USECASE_ID_IVS.poiType -> { //车内标牌
when (data.warning_Msg[0].eventSerialNum) {
MogoObuConstants.RTS.RTI_TYPE_SCHOOL -> { //学校
appId =
V2iEventTypeEnum.TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType
}
}
alertContent = V2iEventTypeEnum.getWarningContent(appId)
ttsContent = V2iEventTypeEnum.getWarningTts(appId)
}
// 前方拥堵提醒 TODO
V2iEventTypeEnum.TYPE_USECASE_ID_TJW.poiType -> {
ttsContent = V2iEventTypeEnum.getWarningTts(appId)
alertContent = if (data.warning_Msg[0].distance.toInt() != 0) {
String.format(
V2iEventTypeEnum.getWarningContent(appId),
data.warning_Msg[0].distance.toInt()
)
} else {
"前方拥堵,减速慢行"
}
}
//限速预警 TODO 参考之前的
}
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} "
)
when (status) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE// 更新
-> {
//显示警告红边
// CallerHmiManager.showWarning(direction)
//显示弹框,语音提示
CallerHmiManager.showWarningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
},
true,
3000L
)
// 更新数据
TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)?.let {
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
CallerHmiManager.disableWarningV2X((appId + direction.direction))
// 更新数据
TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)?.let {
// 事件结束,还原车辆颜色
it.threatLevel = 0x01
TrafficMarkerDrawer.updateITrafficInfo(it)
}
}
}
}
}
/**
* RSM预警信息 CvxPtcThreatIndInfo CvxPtcInfoIndInfo主车与弱势交通参与者之间的预警弱势交通参与者碰撞预警
*/
override fun onMogoObuRsmWarning(data: MogoObuRsmWarningData?) {
super.onMogoObuRsmWarning(data)
CallerLogger.d(
"$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(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"onMogoObuRsmWarning ---status---> ${data.status}"
)
var v2xType = ""
if (data.participant.ptcType == 1) { //摩托车
v2xType = EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTORBIKE.poiType
} else if (data.participant.ptcType == 2) { //行人
v2xType = EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.poiType
}
val ttsContent = EventTypeEnumNew.getWarningTts(v2xType)
val alertContent = EventTypeEnumNew.getWarningContent(v2xType)
var level = -1
val direction = getMessageDirection(data.participant.targetPosition)
if (data.m_warning_msg != null && data.m_warning_msg.warningData != null && data.m_warning_msg.warningData.size > 0) {
level = data.m_warning_msg.warningData[0].warningLevel
}
when (data.status) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE// 更新
-> {
// if (level == 2 || level == 3) { //不考虑level
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerHmiManager.showWarningV2X(
v2xType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(v2xType + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
},
true,
3000L
)
// }
// 更新数据
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)?.let {
TrafficMarkerDrawer.updateITrafficInfo(it)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)?.let {
// 事件结束,还原交通参与者颜色
it.threatLevel = 0x01
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
}
//TODO
// CallerHmiManager.disableWarningV2X(ObuConstants.USE_CASE_ID.VRUCW.toString())
}
}
}
}
/**
* 地图匹配 是OBU算法输出地图匹配结果主车匹配道路哪条路或者哪条车道
*/
override fun onMogoObuMapMath(data: MogoObuMapMathData?) {
super.onMogoObuMapMath(data)
}
}
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
CallerLogger.d("$M_OBU${MogoObuConst.TAG_MOGO_OBU}", "预警红边:预警方向->$targetClassification")
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
}
}
/**
* 构造对应展示数据和场景 根据obu的场景add change delete确定是否展示
*
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容
*
* @see com.mogo.module.common.enums.EventTypeEnum
*/
private fun handleSdkObu(
appId: String,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: MogoObuRvWarningData
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的
CallerLogger.d(
"$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
when (appId) {
// 变道预警,注意左后车辆/注意右后车辆
EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType -> {
alertContent = EventTypeEnumNew.getWarningContent(appId)
ttsContent = EventTypeEnumNew.getWarningTts(appId)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
//车辆失控预警
EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType -> {
alertContent = EventTypeEnumNew.getWarningContent(appId)
ttsContent = EventTypeEnumNew.getWarningTts(appId)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//左转辅助
// EventTypeEnum.TYPE_USECASE_ID_LTA.poiType -> {
// alertContent = EventTypeEnum.getWarningContent(appId)
// ttsContent = EventTypeEnum.getWarningTts(appId)
// }
//异常车辆提醒
EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType -> {
alertContent = EventTypeEnumNew.getWarningContent(appId)
ttsContent = EventTypeEnumNew.getWarningTts(appId)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//盲区预警
EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType -> {
ttsContent = EventTypeEnumNew.getWarningTts(appId)
alertContent = EventTypeEnumNew.getWarningContent(appId)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) { //左后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) { //右后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
// 这里处理固定的提示信息,包括了<紧急车辆提醒>
else -> {
ttsContent = EventTypeEnumNew.getWarningTts(appId)
alertContent = EventTypeEnumNew.getWarningContent(appId)
}
}
when (status) {
// 添加,更新 add的时候可能级别是2
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE -> {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
Log.d(
TAG,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
if (level == 2 || level == 3) {
//显示弹框,语音提示
CallerHmiManager.showWarningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(TooClose)
}
}
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(Default())
}
}
},
true,
3000L
)
//显示警告红边
CallerHmiManager.showWarning(direction)
}
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 UUID不需要匹配了
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
CallerHmiManager.disableWarningV2X((appId + direction.direction))
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
it.threatLevel = 0x01
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
}
}
}
}
/**
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>) {
CallerLogger.d(
"$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) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE
-> {
changeTrafficLightStatus(appId, lights)
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
CallerHmiManager.disableWarningTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
}
}
}
private var isRedLight = false
private var isGreenLight = false
/**
* 修改红绿灯
*/
@Synchronized
private fun changeTrafficLightStatus(
appId: Int,
lights: List<SpatLight>
) {
var ttsContent = ""
var alertContent = ""
//这里需要根据真实数据确定 index 取值方式
val currentLight = lights[0]
CallerLogger.d(
"$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
}
0x1 -> {//无违规 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION
CallerHmiManager.disableWarningV2X(appId.toString())
}
0x2 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT
ttsContent = EventTypeEnumNew.getWarningTts(appId.toString())
alertContent = EventTypeEnumNew.getWarningContent(appId.toString())
CallerHmiManager.showWarningV2X(
appId.toString(), alertContent, ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(), null, true, 3000L
)
}
0x3 -> {//闯黄灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_YELLOW_LIGHT
}
}
when (currentLight.light) {
// 灯光不可用
0x0 -> {
CallerHmiManager.showWarningTrafficLight(0, 2)
}
// 红灯
0x1 -> {
if (!isRedLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isRedLight = true
}
isGreenLight = false
CallerHmiManager.showWarningTrafficLight(1, 2)
val red = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownRed(red)
CallerHmiManager.changeCountdownGreen(0)
CallerHmiManager.changeCountdownYellow(0)
}
// 绿灯
0x2 -> {
if (!isGreenLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isGreenLight = true
}
isRedLight = false
CallerHmiManager.showWarningTrafficLight(3, 2)
val green = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownGreen(green)
//防止数据出现问题的容错
CallerHmiManager.changeCountdownRed(0)
CallerHmiManager.changeCountdownYellow(0)
// 拼接建议速度
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_OBU}",
"speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}"
)
val adviceSpeed =
"${currentLight.suggestMinSpeed} - ${currentLight.suggestMaxSpeed}"
val adviceSpeedTts =
"${currentLight.suggestMinSpeed}${currentLight.suggestMaxSpeed}"
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
if (maxSpeed > 0) {
CallerHmiManager.showWarningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
null,
true,
3000L
)
}
}
// 黄灯
0x3 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerHmiManager.showWarningTrafficLight(2, 2)
val yellow = currentLight.countDown.toInt()
CallerHmiManager.changeCountdownYellow(yellow)
CallerHmiManager.changeCountdownGreen(0)
CallerHmiManager.changeCountdownRed(0)
}
}
}
}

View File

@@ -3,16 +3,16 @@ package com.mogo.eagle.core.function.obu.mogo.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.obu.mogo.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.*
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.obu.mogo.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
@@ -31,90 +31,90 @@ class ObuRsuTestTriggerReceiver : BroadcastReceiver() {
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)
}
}
// 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,60 @@
package com.mogo.eagle.core.function.obu.mogo.receiver
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.mogo.eagle.core.function.obu.mogo.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)
Log.d("liyz", "obuType:$obuType obuStatus:$obuStatus obuLevel:$obuLevel")
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

@@ -3,17 +3,17 @@ package com.mogo.eagle.core.function.obu.mogo.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.obu.mogo.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
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.obu.mogo.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
@@ -29,61 +29,61 @@ class ObuTestTriggerReceiver : BroadcastReceiver() {
}
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)
}
}
// 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

@@ -3,14 +3,14 @@ package com.mogo.eagle.core.function.obu.mogo.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.obu.mogo.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
//import com.mogo.eagle.core.function.obu.mogo.MogoObuConst
//import com.mogo.eagle.core.function.obu.mogo.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
@@ -31,30 +31,30 @@ class ObuTestTriggerRecognizedReceiver : BroadcastReceiver() {
* 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)
// 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,143 @@
package com.mogo.eagle.core.function.obu.mogo.utils
import android.util.Log
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 远车 转换交通元素数据,是否需要 TODO
*/
fun cvxRvInfoIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info.vehBasicsMsg == null) {
Log.e("liyz", "cvxRvInfoIndInfo2TrafficData 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.warning_Msg == null || info.warning_Msg.size < 1 || info.warning_Msg[0].position == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxRtiThreatIndInfo2TrafficData info.warning_Msg == null ")
return null
}
val trafficData = TrafficData()
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_DAO_LU_SHI_GONG
trafficData.uuid = info.warning_Msg[0].signSerialNum.toString()
trafficData.lat = info.warning_Msg[0].position.latitude
trafficData.lon = info.warning_Msg[0].position.longitude
trafficData.threatLevel = info.warning_Msg[0].warningLevel
Log.e("liyz", "cvxRtiThreatIndInfo2TrafficData trafficData -- ${trafficData.toString()}")
return trafficData
}
/**
* OBU 预警事件 转换交通元素数据 他车预警
*/
fun cvxV2vThreatIndInfo2TrafficData(info: MogoObuRvWarningData): TrafficData? {
if (info == null || info.vehBasicsMsg == null || info.warningMsg == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxV2vThreatIndInfo2TrafficData info == null ")
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
Log.e("liyz", "cvxV2vThreatIndInfo2TrafficData trafficData = ${trafficData.toString()} ")
return trafficData
}
/**
* OBU 弱势交通参与者信息 转换交通元素数据
*/
fun cvxPtcThreatIndInfo2TrafficData(info: MogoObuRsmWarningData): TrafficData? {
if (info.participant == null) {
CallerLogger.e("$M_OBU$TAG", "数据转换异常,请检查参数是否齐全")
Log.e("liyz", "cvxPtcThreatIndInfo2TrafficData info.participant ")
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
when (info.participant.ptcType) {
// 未知
0 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
}
//机动车 //TODO
1 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
}
// 非机动车
2 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
}
// 行人
3 -> {
trafficData.type = TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
}
}
/**
* 交通参与者类型
* 0未知
* 1机动车
* 2非机动车
* 3行人
* 4OBU自身
*/
val ptcType = 0
// 判断车辆V2X预警级别调整车辆颜色
if (info.m_warning_msg != null && info.m_warning_msg.warningData != null) {
trafficData.threatLevel = info.m_warning_msg.warningData[0].warningLevel
} else {
trafficData.threatLevel = 1
}
Log.e("liyz", "cvxPtcThreatIndInfo2TrafficData trafficData = ${trafficData.toString()} ")
return trafficData
}
}