[merge2master]
@@ -1,78 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
implementation rootProject.ext.dependencies.mogoaicloudtelematic
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.moduleservice
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_network
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_api
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_call
|
||||
implementation project(':libraries:mogo-adas')
|
||||
} else {
|
||||
implementation project(':modules:mogo-module-common')
|
||||
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-api')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
implementation project(':libraries:mogo-adas')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.eagle.core.function.impl
|
||||
POM_ARTIFACT_ID=autopilot
|
||||
VERSION_CODE=1
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.eagle.core.function.autopilot">
|
||||
|
||||
</manifest>
|
||||
@@ -1,507 +0,0 @@
|
||||
package com.mogo.eagle.core.function.autopilot.adapter
|
||||
|
||||
import bag_manager.BagManagerOuterClass
|
||||
import chassis.VehicleStateOuterClass
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ARRIVE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_GUARDIAN
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_RECORD
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ROUTE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_STATUS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAJECTORY
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_CONFIG
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_ACTIONS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_OBJECTS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_ADAS_STATUS_QUERY_RESP
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_ADAS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_DATA_TRACKED
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_GNSSINFO
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_OBJECTS
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_TRAJECTORY
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeArriveAtStation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotGuardian
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotSNRequest
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.invokeAutopilotStatusRespByQuery
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager.invokeAutopilotAbility
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager.invokeAutopilotCarConfigData
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager.invokeAutopilotCarStateData
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyDataUpdate
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotIdentifyPlanningObj
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager.invokeAutopilotWarnMessage
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningActionsListenerManager.invokePNCActions
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager.invokeAutopilotRotting
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager.invokeAutopilotTrajectory
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPointCloudListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordConfig
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeAutopilotRecordResult
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager.invokeBagManagerResult
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager.invokeAutopilotStatistics
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager
|
||||
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.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.OnAdasListener
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.v2x.ObuWarningEvent
|
||||
import mogo_msg.MogoReportMsg
|
||||
import perception.TrafficLightOuterClass
|
||||
import prediction.Prediction
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import system_master.SystemStatusInfo
|
||||
|
||||
/**
|
||||
* @author emArrow
|
||||
* @since 2022/3/11
|
||||
*
|
||||
*
|
||||
* 适配ADAS 回调监听分发,这里不做业务,只做数据包装及分发处理
|
||||
*/
|
||||
class MoGoAdasListenerImpl : OnAdasListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "OnAdasListenerAdapter"
|
||||
}
|
||||
|
||||
//车前引导线
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_TRAJECTORY,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAJECTORY,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onTrajectory(header: MessagePad.Header, trajectory: MessagePad.Trajectory?) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
if (trajectory != null && trajectory.pointsList.size > 0) {
|
||||
invokeAutopilotTrajectory(trajectory.pointsList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//感知物体
|
||||
// @ChainLog(
|
||||
// linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_DATA_TRACKED,
|
||||
// linkCode = CHAIN_LINK_ADAS,
|
||||
// endpoint = PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA,
|
||||
// paramIndexes = [0, 1],
|
||||
// clientPkFileName = "sn"
|
||||
// )
|
||||
override fun onTrackedObjects(
|
||||
header: MessagePad.Header,
|
||||
trackedObjects: MessagePad.TrackedObjects
|
||||
) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
invokeAutopilotIdentifyDataUpdate(trackedObjects.objsList as List<TrackedObject>?)
|
||||
}
|
||||
}
|
||||
|
||||
//自车定位信息
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_GNSSINFO,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo?) {
|
||||
invokeAutopilotCarStateData(gnssInfo)
|
||||
if (gnssInfo != null) {
|
||||
if (1 == FunctionBuildConfig.gpsProvider) {
|
||||
// 同步给MAP地图
|
||||
CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(gnssInfo)
|
||||
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
|
||||
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
|
||||
gnssInfo.satelliteTime,
|
||||
gnssInfo.longitude,
|
||||
gnssInfo.latitude
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//自车状态(底盘),车灯等。
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_VEHICLE,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_VEHICLE,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onVehicleState(
|
||||
header: MessagePad.Header,
|
||||
vehicleState: VehicleStateOuterClass.VehicleState?
|
||||
) {
|
||||
|
||||
if (vehicleState != null) {
|
||||
//转向灯数据
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotLightSwitchData(vehicleState.light)
|
||||
//刹车灯数据
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotBrakeLightData(vehicleState.brakeLightStatus)
|
||||
//方向盘转向角数据
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotSteeringData(vehicleState.steering)
|
||||
//挂挡档位数据
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotGearData(vehicleState.gear)
|
||||
//加速度
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotAcc(vehicleState.accel)
|
||||
//油门
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotThrottle(vehicleState.throttle)
|
||||
//刹车
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotBrake(vehicleState.brake)
|
||||
//清扫车(福田)清扫控制系统状态
|
||||
vehicleState.sweeperFutianCleanSystemState?.also {
|
||||
CallerAutopilotVehicleStateListenerManager.invokeSweeperFutianCleanSystemState(it)
|
||||
}
|
||||
} else {
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotDataException(header.timestamp.toLong())
|
||||
}
|
||||
}
|
||||
|
||||
//自动驾驶状态
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_STATUS,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onAutopilotState(
|
||||
header: MessagePad.Header,
|
||||
autopilotState: MessagePad.AutopilotState?
|
||||
) {
|
||||
if (autopilotState != null) {
|
||||
//工控机模拟时间
|
||||
CallerAutopilotVehicleStateListenerManager.invokeAutopilotTime(header.timestamp.toLong())
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
// 初始化自动驾驶状态信息
|
||||
val autopilotStatusInfo = getAutoPilotStatusInfo()
|
||||
autopilotStatusInfo.state = autopilotState.state
|
||||
autopilotStatusInfo.pilotmode = autopilotState.autopilotMode
|
||||
autopilotStatusInfo.reason = autopilotState.reason
|
||||
autopilotStatusInfo.camera = autopilotState.camera
|
||||
autopilotStatusInfo.rtk = autopilotState.rtk
|
||||
autopilotStatusInfo.radar = autopilotState.radar
|
||||
autopilotStatusInfo.version = AdasManager.getInstance().adasVersion
|
||||
if (autopilotStatusInfo.connectIP == null) {
|
||||
autopilotStatusInfo.connectIP = AdasManager.getInstance().ipcConnectedIp
|
||||
}
|
||||
if (autopilotStatusInfo.connectPort == null) {
|
||||
autopilotStatusInfo.connectPort = AdasManager.getInstance().ipcConnectedPort
|
||||
}
|
||||
AdasManager.getInstance().carConfig?.let {
|
||||
autopilotStatusInfo.dockVersion = it.dockVersion
|
||||
}
|
||||
CallerLogger.d("Upgrade", "origin = ${autopilotStatusInfo.connectStatus} -----now = ${AppConfigInfo.isConnectAutopilot} ")
|
||||
AppConfigInfo.isConnectAutopilot = autopilotStatusInfo.connectStatus
|
||||
AppConfigInfo.connectStatusDescribe = autopilotStatusInfo.connectStatusDescribe
|
||||
invokeAutoPilotStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监控
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_GUARDIAN,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onReportMessage(
|
||||
header: MessagePad.Header,
|
||||
mogoReportMessage: MogoReportMsg.MogoReportMessage?
|
||||
) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
invokeAutopilotGuardian(mogoReportMessage)
|
||||
}
|
||||
}
|
||||
|
||||
//感知红绿灯
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_TRAFFIC_LIGHT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAFFIC_LIGHT,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onPerceptionTrafficLight(
|
||||
header: MessagePad.Header?,
|
||||
trafficLights: TrafficLightOuterClass.TrafficLights?
|
||||
) {
|
||||
if (trafficLights != null) {
|
||||
CallerAutopilotIdentifyListenerManager.invokeAutopilotPerceptionTrafficLight(
|
||||
trafficLights
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPredictionObstacleTrajectory(
|
||||
header: MessagePad.Header?,
|
||||
predictionObjects: Prediction.mPredictionObjects?
|
||||
) {
|
||||
//他车轨迹预测
|
||||
}
|
||||
|
||||
// override fun onPointCloud(header: MessagePad.Header?, pointCloud: MogoPointCloudOuterClass.MogoPointCloud?) {
|
||||
// //点云数据透传
|
||||
// //Logger.d("pointCloud","pointCloud"+pointCloud);
|
||||
// CallerAutopilotPointCloudListenerManager.invokeAutopilotPointCloudDataUpdate(header, pointCloud)
|
||||
// }
|
||||
|
||||
override fun onPointCloud(pointCloud: ByteArray?) {
|
||||
//点云数据透传
|
||||
CallerAutopilotPointCloudListenerManager.invokeAutopilotPointCloudDataUpdate(pointCloud)
|
||||
}
|
||||
|
||||
//planning障碍物
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_OBJECTS,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_OBJECTS,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onPlanningObjects(
|
||||
header: MessagePad.Header?,
|
||||
planningObjects: MessagePad.PlanningObjects
|
||||
) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
invokeAutopilotIdentifyPlanningObj(planningObjects.objsList as List<MessagePad.PlanningObject>)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBasicInfoReq(
|
||||
header: MessagePad.Header,
|
||||
basicInfoReq: MessagePad.BasicInfoReq?
|
||||
) {
|
||||
invokeAutopilotSNRequest()
|
||||
}
|
||||
|
||||
//工控机基础配置信息
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_CONFIG,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onCarConfigResp(
|
||||
header: MessagePad.Header,
|
||||
carConfigResp: MessagePad.CarConfigResp?
|
||||
) {
|
||||
if (carConfigResp != null) {
|
||||
AppConfigInfo.dockerVersion = carConfigResp.dockVersion
|
||||
AppConfigInfo.plateNumber = carConfigResp.plateNumber//车牌号
|
||||
AppConfigInfo.iPCMacAddress = carConfigResp.macAddress//工控机MAC地址
|
||||
AppConfigInfo.protocolVersionNumber = carConfigResp.protocolVersionValue//工控机协议版本
|
||||
AppConfigInfo.isConnectAutopilot = true
|
||||
invokeAutopilotCarConfigData(carConfigResp)
|
||||
}
|
||||
}
|
||||
|
||||
//全局路径规划
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ROUTE,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onGlobalPathResp(
|
||||
header: MessagePad.Header,
|
||||
globalPathResp: MessagePad.GlobalPathResp?
|
||||
) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
invokeAutopilotRotting(globalPathResp)
|
||||
}
|
||||
}
|
||||
|
||||
//数据采集,badCase
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_RECORD,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onRecordResult(
|
||||
header: MessagePad.Header,
|
||||
recordPanel: RecordPanelOuterClass.RecordPanel?
|
||||
) {
|
||||
if (recordPanel != null) {
|
||||
invokeAutopilotRecordResult(recordPanel)
|
||||
}
|
||||
}
|
||||
|
||||
//预警信息
|
||||
// @ChainLog(
|
||||
// linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
// linkCode = CHAIN_LINK_ADAS,
|
||||
// endpoint = PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_WARN,
|
||||
// paramIndexes = [0, 1],
|
||||
// clientPkFileName = "sn"
|
||||
// )
|
||||
override fun onWarn(header: MessagePad.Header, warn: MessagePad.Warn?) {
|
||||
invokeAutopilotWarnMessage(warn)
|
||||
}
|
||||
|
||||
//到站回调
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ARRIVE,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onArrivalNotification(
|
||||
header: MessagePad.Header,
|
||||
arrivalNotification: MessagePad.ArrivalNotification?
|
||||
) {
|
||||
if (HdMapBuildConfig.isMapLoaded) {
|
||||
invokeArriveAtStation(arrivalNotification)
|
||||
}
|
||||
}
|
||||
|
||||
//状态查询应答
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_STATUS_QUERY_RESP,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onStatusQueryResp(
|
||||
header: MessagePad.Header?,
|
||||
statusInfo: SystemStatusInfo.StatusInfo?
|
||||
) {
|
||||
invokeAutopilotStatusRespByQuery(statusInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据采集配置应答
|
||||
*/
|
||||
override fun onRecordDataConfigResp(
|
||||
header: MessagePad.Header?,
|
||||
config: MessagePad.RecordDataConfig?
|
||||
) {
|
||||
if(config!=null){
|
||||
invokeAutopilotRecordConfig(config)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* planning决策状态, 透传
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_PLANNING_ACTIONS,
|
||||
linkCode = CHAIN_LINK_ADAS,
|
||||
endpoint = PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_PLANNING_ACTIONS,
|
||||
paramIndexes = [0, 1],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onPlanningActionMsg(
|
||||
header: MessagePad.Header?,
|
||||
planningActionMsg: MessagePad.PlanningActionMsg?
|
||||
) {
|
||||
planningActionMsg?.let {
|
||||
invokePNCActions(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* OBU预警事件
|
||||
*
|
||||
* @param header 头
|
||||
* @param obuWarningData 数据
|
||||
*/
|
||||
override fun onObuWarningData(header: MessagePad.Header?, obuWarningData: ObuWarningEvent.ObuWarningData?) {
|
||||
CallerObuDcCombineListenerManager.invokeObuDcData(obuWarningData)
|
||||
}
|
||||
|
||||
/**
|
||||
* Bag管理应答
|
||||
*
|
||||
* @param header 头
|
||||
* @param bagManager 数据
|
||||
*/
|
||||
override fun onBagManagerCmd(header: MessagePad.Header?, bagManager: BagManagerOuterClass.BagManager?) {
|
||||
bagManager?.let {
|
||||
invokeBagManagerResult(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以启动自动驾驶
|
||||
*/
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动自动驾驶失败回调
|
||||
* 根据MAP 系统监控状态返回过滤
|
||||
* message.getMsg() 获取详细错误说明
|
||||
* message.getCode() 可用于判断属于什么类型
|
||||
*
|
||||
* @param message 数据
|
||||
*/
|
||||
override fun onStartAutopilotFailed(message: MogoReportMsg.MogoReportMessage?) {
|
||||
invokeStartAutopilotFailed(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动自动驾驶状态统计
|
||||
* 触发机制:下发启动自动驾驶命令,根据MAP返回状态判断成功或失败
|
||||
* 统计四种状态:成功 失败 取消 超时
|
||||
*
|
||||
* @param statistics 统计数据
|
||||
*/
|
||||
override fun onAutopilotStatistics(statistics: AutopilotStatistics?) {
|
||||
invokeAutopilotStatistics(statistics);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据解析失败、数据异常回调
|
||||
* @param status 错误原因
|
||||
* @param bytes 原始数据
|
||||
*/
|
||||
override fun onError(status: ProtocolStatus, bytes: ByteArray) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
package com.mogo.eagle.core.function.autopilot.adapter;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_DEVA;
|
||||
|
||||
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;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
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
|
||||
IMoGoAutopilotVehicleStateListener,
|
||||
IMoGoAutopilotCarConfigListener,
|
||||
IMoGoAutopilotCarStateListener {
|
||||
|
||||
private final String TAG = "AdasEventManager";
|
||||
|
||||
private static volatile MoGoHandAdasMsgManager moGoHandAdasMsgManager;
|
||||
private Context mContext;
|
||||
|
||||
private MoGoHandAdasMsgManager(Context context) {
|
||||
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotCarConfigListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static MoGoHandAdasMsgManager getInstance(Context context) {
|
||||
if (moGoHandAdasMsgManager == null) {
|
||||
synchronized (MoGoHandAdasMsgManager.class) {
|
||||
if (moGoHandAdasMsgManager == null) {
|
||||
moGoHandAdasMsgManager = new MoGoHandAdasMsgManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return moGoHandAdasMsgManager;
|
||||
}
|
||||
|
||||
private int turnLightTimes = 0;
|
||||
private boolean isOnTurnLight = false;
|
||||
private int turnLight = 0;
|
||||
private volatile boolean isShowTurnLight = false;
|
||||
private int brakeLight = -1;
|
||||
|
||||
|
||||
public void getConfig() {
|
||||
com.elegant.utils.UiThreadHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotManager.INSTANCE.getCarConfig();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private int setTurnLightState(int turn_light) {
|
||||
if (turn_light == 0) {
|
||||
if (isOnTurnLight) {
|
||||
if (turnLightTimes >= 10) {
|
||||
isOnTurnLight = false;
|
||||
turnLight = 0;
|
||||
}
|
||||
turnLightTimes++;
|
||||
}
|
||||
} else if (turn_light == 1) {
|
||||
turnLightTimes = 0;
|
||||
isOnTurnLight = true;
|
||||
turnLight = 1;
|
||||
} else if (turn_light == 2) {
|
||||
turnLightTimes = 0;
|
||||
isOnTurnLight = true;
|
||||
turnLight = 2;
|
||||
}
|
||||
return turnLight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotLightSwitchData(Chassis.LightSwitch lightSwitch) {
|
||||
//can数据转发 转向灯状态 0是正常 1是左转 2是右转
|
||||
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
|
||||
if (lightSwitch != null) {
|
||||
int state = setTurnLightState(lightSwitch.getNumber());
|
||||
CallerLogger.INSTANCE.d(M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.getNumber());
|
||||
if (state == 1 || state == 2) {
|
||||
isShowTurnLight = true;
|
||||
CallerHmiManager.INSTANCE.showBrakeLight(0);
|
||||
} else {
|
||||
isShowTurnLight = false;
|
||||
}
|
||||
CallerHmiManager.INSTANCE.showTurnLight(state);
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotBrakeLightData(boolean brakeLight) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotCarConfig(@NotNull MessagePad.CarConfigResp carConfigResp) {
|
||||
if (carConfigResp != null && !TextUtils.isEmpty(carConfigResp.getMacAddress())) {
|
||||
Log.d("Upgrade", "MoGoHandAdasMsgManager address = " + carConfigResp.getMacAddress());
|
||||
CallerBindingcarManager.getBindingcarProvider().getBindingcarInfo(carConfigResp.getMacAddress(), MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotCarStateData(@Nullable MessagePad.GnssInfo gnssInfo) {
|
||||
//根据加速度判断 是否刹车
|
||||
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
|
||||
if (gnssInfo != null) {
|
||||
//设置刹车信息
|
||||
if (gnssInfo.getAcceleration() < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5F)) {
|
||||
brakeLight = 1;
|
||||
} else {
|
||||
brakeLight = 0;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.getAcceleration() + "-- brakeLight = " + brakeLight);
|
||||
if (!isShowTurnLight) {
|
||||
CallerHmiManager.INSTANCE.showBrakeLight(brakeLight);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆方向盘转向角回调
|
||||
*
|
||||
* @param steering 方向盘转向角
|
||||
*/
|
||||
@Override
|
||||
public void onAutopilotSteeringData(float steering) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆挂挡档位
|
||||
*
|
||||
* @param gear 档位
|
||||
*/
|
||||
@Override
|
||||
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotDataException(long timestamp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAcc(float carAcc) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotThrottle(float throttle) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotBrake(float brake) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSweeperFutianCleanSystemState(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
javaCompileOptions{
|
||||
annotationProcessorOptions{
|
||||
arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.litezxing
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_network
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_call
|
||||
} else {
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.eagle.core.function.bindingcar">
|
||||
|
||||
<application>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingcarProvider;
|
||||
import com.mogo.eagle.core.function.appupgrade.network.UpgradeAppNetWorkManager;
|
||||
import com.mogo.eagle.core.function.bindingcar.network.BindingcarNetWorkManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
|
||||
import com.mogo.eagle.core.function.ipcupgrade.IPCUpgradeManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 绑定sn
|
||||
* @since: 3/26/22
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_BINDING_CAR)
|
||||
public class BindingcarProvider implements IMoGoBindingcarProvider {
|
||||
|
||||
private Context mContext;
|
||||
private volatile String mAddress;
|
||||
private volatile String mWidevineIDWithMd5; //google 数字版权
|
||||
private volatile int mScreenType = -1;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
mContext = context;
|
||||
IPCUpgradeManager.Companion.getINSTANCE().initServer(context);
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typeDriver", 0);
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typePassenger", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取macaddress,每次连接请求一次
|
||||
*
|
||||
* @param macAddress
|
||||
*/
|
||||
@Override
|
||||
public void getBindingcarInfo(String macAddress, String widevineIDWithMd5) {
|
||||
Log.d("Upgrade", "getBindingcarInfo macAddress = " + macAddress + "--widevineIDWithMd5 = " + widevineIDWithMd5);
|
||||
mAddress = macAddress;
|
||||
mWidevineIDWithMd5 = widevineIDWithMd5;
|
||||
if (getScreenType() == 1) { //司机屏
|
||||
driverScreen(macAddress, widevineIDWithMd5);
|
||||
} else if (getScreenType() == 2) { //乘客屏
|
||||
passengerScreen(macAddress, widevineIDWithMd5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认升级工控机docker版本
|
||||
* @param images docker列表
|
||||
* @param padSn SN
|
||||
* @param releaseId 任务ID
|
||||
*/
|
||||
@Override
|
||||
public void upgradeConfirm(List<String> images, String padSn, String releaseId) {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().upgradeConfirm(images, padSn, releaseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
* @param padSn SN
|
||||
* @param dockerVersion 当前工控机版本
|
||||
*/
|
||||
@Override
|
||||
public void queryContainers(String padSn,String dockerVersion) {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().queryContainers(padSn,dockerVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyCarInfo(BindingcarCallBack callBack) {
|
||||
BindingcarNetWorkManager.getInstance().modifyBindingcar(mContext, mAddress, mWidevineIDWithMd5, callBack, getScreenType());
|
||||
}
|
||||
|
||||
private void driverScreen(String macAddress, String widevineIDWithMd5) {
|
||||
long currentHour = System.currentTimeMillis() / (1000 * 60);
|
||||
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typeDriver", 0);
|
||||
//如果2分钟内频繁调,需要拦截,业务导致的会多次请求工控机信息
|
||||
if (HmiBuildConfig.isShowSnBindingView) {
|
||||
if (currentHour - oldHour > 1) {
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typeDriver", System.currentTimeMillis() / (1000 * 60));
|
||||
BindingcarNetWorkManager.getInstance().getBindingcarInfo(mContext, macAddress, widevineIDWithMd5, getScreenType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void passengerScreen(String macAddress, String widevineIDWithMd5) {
|
||||
long currentHour = System.currentTimeMillis() / (1000 * 60);
|
||||
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typePassenger", 0);
|
||||
//如果2分钟内频繁调,需要拦截,业务导致的会多次请求工控机信息
|
||||
if (HmiBuildConfig.isShowSnBindingView) {
|
||||
if (currentHour - oldHour > 1) {
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typePassenger", System.currentTimeMillis() / (1000 * 60));
|
||||
BindingcarNetWorkManager.getInstance().getBindingcarInfo(mContext, macAddress, widevineIDWithMd5, getScreenType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以后可能废弃
|
||||
* @return
|
||||
*/
|
||||
private int getScreenType() {
|
||||
int screenType = -1;
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = 1; //司机屏
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = 2; //乘客屏
|
||||
}
|
||||
return screenType;
|
||||
}
|
||||
|
||||
private int getCarType() {
|
||||
int carType = -1;
|
||||
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
carType = 1; //bus
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
carType = 2; //taxi
|
||||
}
|
||||
|
||||
return carType;
|
||||
|
||||
}
|
||||
|
||||
private String getCarScreenType() {
|
||||
String screenType = "";
|
||||
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = "1"; //taxi乘客端
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = "2"; //taxi司机端
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = "3"; //bus 乘客端
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = "4"; //bus 司机端
|
||||
}
|
||||
|
||||
return screenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询app是否需要升级
|
||||
*/
|
||||
@Override
|
||||
public void queryAppUpgrade() {
|
||||
UpgradeAppNetWorkManager.getInstance().getAppUpgradeInfo(mContext, mAddress, getCarScreenType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BINDING;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.constants.HostConst;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.eagle.core.data.bindingcar.BindingcarInfo;
|
||||
import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
|
||||
import com.mogo.eagle.core.function.bindingcar.R;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 绑定车机网络请求
|
||||
* @since: 3/25/22
|
||||
*/
|
||||
public class BindingcarNetWorkManager {
|
||||
private static volatile BindingcarNetWorkManager requestNoticeManager;
|
||||
private final BindingcarApiService mBindingcarApiService;
|
||||
private static final String TAG = "BindingcarNetManager";
|
||||
|
||||
private BindingcarNetWorkManager() {
|
||||
mBindingcarApiService = MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(BindingcarApiService.class);
|
||||
}
|
||||
|
||||
public static BindingcarNetWorkManager getInstance() {
|
||||
if (requestNoticeManager == null) {
|
||||
synchronized (BindingcarNetWorkManager.class) {
|
||||
if (requestNoticeManager == null) {
|
||||
requestNoticeManager = new BindingcarNetWorkManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return requestNoticeManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取绑定的车辆信息
|
||||
*
|
||||
* @param macAddress mac地址
|
||||
*/
|
||||
public void getBindingcarInfo(Context context, String macAddress, String widevineIDWithMd5, int screenType) {
|
||||
// String macAddress1 = "48:b0:2d:4d:33:40";
|
||||
// String sn = "X2020220417KA94QIN";
|
||||
|
||||
BindingcarRequest request = new BindingcarRequest(macAddress, widevineIDWithMd5, screenType);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mBindingcarApiService.getBindingcarInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BindingcarInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BindingcarInfo info) {
|
||||
if (info != null && info.getData() != null) {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getBindingcarInfo onNext info.getData() =" + info.getData().toString());
|
||||
//根据车辆类型切换不同的车辆模型,只针对红旗做处理
|
||||
updateCarVrIconRes(info.getData().getBrandId());
|
||||
switch (info.getData().getCompare()) {
|
||||
case "0":
|
||||
CallerHmiManager.INSTANCE.showBindingcarDialog();
|
||||
break;
|
||||
case "3":
|
||||
CallerHmiManager.INSTANCE.showModifyBindingcarDialog();
|
||||
break;
|
||||
case "null":
|
||||
TipToast.shortTip("当前工控机没有入库");
|
||||
break;
|
||||
}
|
||||
SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_INFO, GsonUtils.toJson(info.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
CallerLogger.INSTANCE.e(M_BINDING + TAG, "getBindingcarInfo onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定和修改绑定车辆
|
||||
* mac: 48:b0:2d:3a:9c:19
|
||||
*/
|
||||
public void modifyBindingcar(Context context, String macAddress, String widevineIDWithMd5, BindingcarCallBack callBack, int screenType) {
|
||||
BindingcarRequest request = new BindingcarRequest(macAddress, widevineIDWithMd5, screenType);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mBindingcarApiService.modifyBindingcarInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ModifyBindingcarInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull ModifyBindingcarInfo info) {
|
||||
if (info != null) {
|
||||
callBack.callBackResult(info);
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString());
|
||||
updateCarVrIconRes(info.getData().getBrandId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
CallerLogger.INSTANCE.e(M_BINDING + TAG, "modifyBindingcar onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateCarVrIconRes(String brandId) {
|
||||
if (brandId == null || brandId.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if(getDefaultId().equals(brandId)){
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "updateCarVrIconRes : " + brandId);
|
||||
switch (brandId) {
|
||||
case "1":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.chuzuche;
|
||||
break;
|
||||
case "2":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.hq_h9);
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.hq_h9;
|
||||
break;
|
||||
case "3":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.xiaobache);
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.xiaobache;
|
||||
break;
|
||||
default:
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
|
||||
HdMapBuildConfig.currentCarVrIconRes = R.raw.chuzuche;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getDefaultId(){
|
||||
if(HdMapBuildConfig.currentCarVrIconRes == R.raw.chuzuche){
|
||||
return "1";
|
||||
}
|
||||
if(HdMapBuildConfig.currentCarVrIconRes == R.raw.xiaobache){
|
||||
return "3";
|
||||
}
|
||||
return "1";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar.network;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class BindingcarRequest {
|
||||
private String mac;
|
||||
private String sn;
|
||||
private int type;
|
||||
|
||||
public BindingcarRequest(String mac, String sn, int type) {
|
||||
this.mac = mac;
|
||||
this.sn = sn;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BindingcarRequest{" +
|
||||
"mac='" + mac + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,13 @@ plugins {
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
//ARouter apt 参数
|
||||
@@ -25,6 +22,12 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
javaCompileOptions{
|
||||
annotationProcessorOptions{
|
||||
arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -33,43 +36,40 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.coroutinesandroid
|
||||
implementation rootProject.ext.dependencies.coroutinescore
|
||||
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.coroutinescore
|
||||
implementation rootProject.ext.dependencies.coroutinesandroid
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.localbroadcastmanager
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_network
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_call
|
||||
}else{
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(':modules:mogo-module-common')
|
||||
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
}
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
implementation project(':core:mogo-core-res')
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,3 +1,3 @@
|
||||
GROUP=com.mogo.eagle.core.function.impl
|
||||
POM_ARTIFACT_ID=v2x
|
||||
POM_ARTIFACT_ID=biz
|
||||
VERSION_CODE=1
|
||||
@@ -1,13 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.eagle.core.function.v2x">
|
||||
package="com.mogo.eagle.core.function.biz">
|
||||
<application>
|
||||
<receiver android:name=".events.receiver.TestPanelBroadcastReceiver">
|
||||
<receiver android:name="com.mogo.eagle.function.biz.v2x.v2n.test.TestV2XReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.v2x.test_panel_control" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mogo.eagle.function.biz
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.biz.camera.CameraEntity
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoNoticeNetCallBack
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.dispatchAutoPilotManager
|
||||
import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager
|
||||
import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager
|
||||
import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager
|
||||
import com.mogo.eagle.function.biz.v2x.obu.V2xObuEventManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
|
||||
import com.mogo.eagle.function.biz.v2x.road.LineUploadManager
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XEventManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.function.biz.v2x.vip.VipCarManager
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_FUNC_BIZ)
|
||||
class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
|
||||
override val functionName: String
|
||||
get() = "FuncBiz"
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
override fun init(context: Context) {
|
||||
mContext = context
|
||||
noticeSocketManager.init(context)
|
||||
dispatchAutoPilotManager.init(context)
|
||||
cronTaskManager.startCronTask()
|
||||
OverviewDb.getDb(context)
|
||||
MogoTrafficLightManager.INSTANCE.initServer(context)
|
||||
VipCarManager.INSTANCE.initServer(context)
|
||||
if(!(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode))){
|
||||
V2XEventManager.init(context)
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
LineUploadManager.getInstance(context)?.init()
|
||||
}
|
||||
V2xObuEventManager.init(context)
|
||||
// RedLightWarningManager.INSTANCE.listenTrafficLight()
|
||||
}
|
||||
|
||||
override fun feedBackNoticeTraffic(infoId: String, sn: String, accept: Int) {
|
||||
NoticeNetWorkManager.getInstance().sendAccidentAcceptStatus(infoId, sn, accept)
|
||||
}
|
||||
|
||||
override fun requestAccidentInfo(infoId: String, sn: String, callBack: IMoGoNoticeNetCallBack) {
|
||||
NoticeNetWorkManager.getInstance().requestAccidentInfo(infoId, sn, callBack)
|
||||
}
|
||||
|
||||
override fun dispatchAffirm() {
|
||||
dispatchAutoPilotManager.affirm()
|
||||
}
|
||||
|
||||
override fun dispatchCancel(manualTrigger: Boolean) {
|
||||
dispatchAutoPilotManager.cancel(manualTrigger)
|
||||
}
|
||||
|
||||
override fun testDispatch(sceneType: Int) {
|
||||
dispatchAutoPilotManager.testDispatch(sceneType)
|
||||
}
|
||||
|
||||
override val getCameraList: List<CameraEntity>
|
||||
get() = cronTaskManager.getCameraList()
|
||||
|
||||
override fun openCameraStream(cameraIp: String) {
|
||||
cronTaskManager.reqOpenCameraStream(cameraIp)
|
||||
}
|
||||
|
||||
override fun openCameraStream(cameraIp: String, success: (String) -> Unit, error: (Throwable) -> Unit) {
|
||||
cronTaskManager.reqOpenCameraStream(cameraIp, success, error)
|
||||
}
|
||||
|
||||
override fun closeCameraLive() {
|
||||
cronTaskManager.clear()
|
||||
}
|
||||
|
||||
override fun fetchInfStructures() {
|
||||
OverViewDataManager.fetchInfStructures()
|
||||
}
|
||||
|
||||
override fun getAllV2XEvents() {
|
||||
OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn)
|
||||
}
|
||||
|
||||
override fun queryV2XEvents() {
|
||||
v2xPoiLoader.queryWholeRoadEvents()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
noticeSocketManager.release()
|
||||
dispatchAutoPilotManager.release()
|
||||
cronTaskManager.release()
|
||||
|
||||
VipCarManager.INSTANCE.destroy()
|
||||
|
||||
if(!(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|
||||
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode))){
|
||||
V2XEventManager.onDestroy()
|
||||
}
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
mContext?.let {
|
||||
LineUploadManager.getInstance(it)?.onDestroy()
|
||||
}
|
||||
}
|
||||
V2xObuEventManager.release()
|
||||
// RedLightWarningManager.INSTANCE.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package com.mogo.eagle.function.biz.dispatch
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
|
||||
import com.mogo.eagle.core.data.biz.dispatch.DispatchAdasAutoPilotLocReceiverBean
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.function.biz.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_AFFIRM
|
||||
import com.mogo.eagle.function.biz.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_MANUAL_CANCEL
|
||||
import com.mogo.eagle.function.biz.dispatch.network.DispatchServiceModel.Companion.DISPATCH_RESULT_TIMER_CANCEL
|
||||
import com.mogo.eagle.function.biz.dispatch.network.DispatchServiceModel.Companion.dispatchServiceModel
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
|
||||
//负责监听自动驾驶状态并进行状态上报,自动驾驶路线上报,接收调度指令展示指令弹窗
|
||||
class DispatchAutoPilotManager private constructor() :
|
||||
IMogoOnMessageListener<DispatchAdasAutoPilotLocReceiverBean>,
|
||||
IMoGoCheckAutoPilotBtnListener,
|
||||
IMoGoPlanningRottingListener,
|
||||
IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DispatchAutoPilotManager"
|
||||
|
||||
private const val MSG_SOCKET_TYPE = 501000
|
||||
private const val MSG_TYPE_SHOW_DIALOG = 0
|
||||
private const val MSG_TYPE_UPLOAD_AUTOPILOT_STATUS = 1
|
||||
private const val MSG_TYPE_UPLOAD_AUTOPILOT_ROTTING = 2
|
||||
|
||||
val dispatchAutoPilotManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
DispatchAutoPilotManager()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private var receiverBean: DispatchAdasAutoPilotLocReceiverBean? = null
|
||||
private var isDispatch = false
|
||||
private var isArriveEnd = false
|
||||
|
||||
private val handler: Handler = object : Handler() {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
if (msg.what == MSG_TYPE_SHOW_DIALOG) {
|
||||
isDispatch = true
|
||||
isArriveEnd = false
|
||||
val msgData: DispatchAdasAutoPilotLocReceiverBean =
|
||||
msg.obj as DispatchAdasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(msgData)
|
||||
} else if (msg.what == MSG_TYPE_UPLOAD_AUTOPILOT_STATUS) {
|
||||
dispatchServiceModel.uploadAutopilotStatus(
|
||||
getAutoPilotStatusInfo().state,
|
||||
getAutoPilotStatusInfo().reason
|
||||
)
|
||||
sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L)
|
||||
} else if(msg.what == MSG_TYPE_UPLOAD_AUTOPILOT_ROTTING){
|
||||
val data = msg.obj as MessagePad.GlobalPathResp
|
||||
val list: MutableList<AutopilotRouteInfo.RouteModels> = ArrayList()
|
||||
for (location in data.wayPointsList) {
|
||||
val routeModels = AutopilotRouteInfo.RouteModels()
|
||||
routeModels.lat = location.latitude
|
||||
routeModels.lon = location.longitude
|
||||
list.add(routeModels)
|
||||
}
|
||||
dispatchServiceModel.uploadAutopilotRoute(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(MSG_SOCKET_TYPE, this)
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.addListener(TAG, this)
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, this)
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
handler.sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.removeListener(TAG)
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerPlanningRottingListenerManager.removeListener(TAG)
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun target(): Class<DispatchAdasAutoPilotLocReceiverBean> {
|
||||
return DispatchAdasAutoPilotLocReceiverBean::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(adasAutoPilotLocReceiverBean: DispatchAdasAutoPilotLocReceiverBean?) {
|
||||
if (adasAutoPilotLocReceiverBean != null && adasAutoPilotLocReceiverBean.startLat != 0.0 && adasAutoPilotLocReceiverBean.startLon != 0.0) {
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
val message = Message()
|
||||
message.what = MSG_TYPE_SHOW_DIALOG
|
||||
message.obj = adasAutoPilotLocReceiverBean
|
||||
handler.sendMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAutoPilot() {
|
||||
val currentAutopilot = AutopilotControlParameters()
|
||||
currentAutopilot.isSpeakVoice = false
|
||||
val wayLatLon: MutableList<AutopilotControlParameters.AutoPilotLonLat> = ArrayList()
|
||||
receiverBean?.let {
|
||||
if (it.stopsList != null) {
|
||||
for (mogoLatLng in receiverBean!!.stopsList) {
|
||||
wayLatLon.add(
|
||||
AutopilotControlParameters.AutoPilotLonLat(
|
||||
mogoLatLng.lat,
|
||||
mogoLatLng.lon
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
currentAutopilot.wayLatLons = wayLatLon
|
||||
currentAutopilot.startLatLon =
|
||||
AutopilotControlParameters.AutoPilotLonLat(it.startLat, it.startLon)
|
||||
currentAutopilot.endLatLon =
|
||||
AutopilotControlParameters.AutoPilotLonLat(it.endLat, it.endLon)
|
||||
currentAutopilot.vehicleType = 10
|
||||
CallerLogger.d(SceneConstant.Companion.M_DISPATCH + TAG, "开启自动驾驶====$currentAutopilot")
|
||||
CallerAutoPilotControlManager.startAutoPilot(currentAutopilot)
|
||||
}
|
||||
}
|
||||
|
||||
fun affirm() {
|
||||
CallerHmiManager.dismissDispatchDialog()
|
||||
dispatchServiceModel.dispatchResultUpload(DISPATCH_RESULT_AFFIRM)
|
||||
}
|
||||
|
||||
fun cancel(manualTrigger: Boolean) {
|
||||
CallerHmiManager.dismissDispatchDialog()
|
||||
dispatchServiceModel.dispatchResultUpload(
|
||||
if (manualTrigger) DISPATCH_RESULT_MANUAL_CANCEL else DISPATCH_RESULT_TIMER_CANCEL
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCheck(isChecked: Boolean) {
|
||||
if (isChecked) {
|
||||
// 确保到达终点后,再次点击,不会有回馈,并且在下次调开始时,才会重置
|
||||
if (isArriveEnd) {
|
||||
return
|
||||
}
|
||||
//todo 确认是否要根据停靠时自动驾驶状态,再次开启自动驾驶
|
||||
// 确保处于调度中并且返回的自动驾驶状态为1才开启自动驾驶
|
||||
// 上述等待鄂州项目复盘后,产品输出完成方案后再进操作!!!
|
||||
if (isDispatch) {
|
||||
startAutoPilot()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
if (globalPathResp == null || globalPathResp.wayPointsList.isEmpty()) {
|
||||
return
|
||||
}
|
||||
val message = Message()
|
||||
message.what = MSG_TYPE_UPLOAD_AUTOPILOT_ROTTING
|
||||
message.obj = globalPathResp
|
||||
handler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: MessagePad.ArrivalNotification?) {
|
||||
if (!isDispatch) {
|
||||
return
|
||||
}
|
||||
if (arrivalNotification == null) {
|
||||
return
|
||||
}
|
||||
if (receiverBean == null) {
|
||||
return
|
||||
}
|
||||
|
||||
CallerLogger.d(
|
||||
SceneConstant.Companion.M_DISPATCH + TAG,
|
||||
"onArriveAt data : $arrivalNotification"
|
||||
)
|
||||
|
||||
if (arrivalNotification.endLocation == null) {
|
||||
return
|
||||
}
|
||||
val endLat: Double = arrivalNotification.endLocation.latitude
|
||||
val endLon: Double = arrivalNotification.endLocation.longitude
|
||||
// 计算是不是到了终点
|
||||
val distanceFromSelf: Float = CoordinateUtils.calculateLineDistance(
|
||||
receiverBean!!.endLon, receiverBean!!.endLat, endLon, endLat
|
||||
)
|
||||
CallerLogger.d(
|
||||
SceneConstant.Companion.M_DISPATCH + TAG,
|
||||
"onArriveAt cal distance : $distanceFromSelf"
|
||||
)
|
||||
if (distanceFromSelf < 10) {
|
||||
CallerLogger.d(SceneConstant.Companion.M_DISPATCH + TAG, "onArriveAt end location")
|
||||
isDispatch = false
|
||||
isArriveEnd = true
|
||||
}
|
||||
}
|
||||
|
||||
fun testDispatch(sceneType: Int) {
|
||||
when (sceneType) {
|
||||
0 -> testEZhouStart()
|
||||
1 -> testEZhouStop()
|
||||
2 -> testHengYangStart()
|
||||
3 -> testDispatchResultUpload()//验证自动驾驶调度上报接口
|
||||
}
|
||||
}
|
||||
|
||||
private fun testEZhouStart() {
|
||||
val adasAutoPilotLocReceiverBean =
|
||||
DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START,
|
||||
"1",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"起点---5号跑道",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"终点---鄂州机场",
|
||||
"5分钟",
|
||||
"AR453航班",
|
||||
"你车需执行编号ca1098次航班的引导任务,从A区A1到B区B1",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testEZhouStop() {
|
||||
val adasAutoPilotLocReceiverBean =
|
||||
DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_STOP,
|
||||
"1",
|
||||
0.0,
|
||||
0.0,
|
||||
"",
|
||||
0.0,
|
||||
0.0,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testHengYangStart() {
|
||||
val adasAutoPilotLocReceiverBean =
|
||||
DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_HENGYANG,
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START,
|
||||
"2",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"衡阳科学城",
|
||||
26.825571122,
|
||||
112.5762410415,
|
||||
"衡阳首钢集团",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
System.currentTimeMillis(),
|
||||
ArrayList<MogoLatLng>()
|
||||
)
|
||||
receiverBean = adasAutoPilotLocReceiverBean
|
||||
CallerHmiManager.showDispatchDialog(adasAutoPilotLocReceiverBean)
|
||||
}
|
||||
|
||||
private fun testDispatchResultUpload() {
|
||||
dispatchServiceModel.dispatchResultUpload(DISPATCH_RESULT_AFFIRM)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.mogo.eagle.function.biz.dispatch.network
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.commons.context.ContextHolderUtil
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo.RouteModels
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatus
|
||||
import com.mogo.eagle.core.data.biz.dispatch.ReportDispatchResult
|
||||
import com.mogo.eagle.core.data.biz.dispatch.ReportedRoute
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.RequestOptions
|
||||
import com.mogo.eagle.core.network.SubscribeImpl
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.*
|
||||
|
||||
class DispatchServiceModel private constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
const val DISPATCH_RESULT_AFFIRM = 0
|
||||
const val DISPATCH_RESULT_MANUAL_CANCEL = 1
|
||||
const val DISPATCH_RESULT_TIMER_CANCEL = 2
|
||||
|
||||
val dispatchServiceModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
DispatchServiceModel()
|
||||
}
|
||||
}
|
||||
|
||||
private var mAdasApiService: IDispatchAdasApiService =
|
||||
MoGoRetrofitFactory.getInstance(HostConst.getEagleHost()).create(
|
||||
IDispatchAdasApiService::class.java
|
||||
)
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态
|
||||
*/
|
||||
fun uploadAutopilotStatus(state: Int, reason: String?) {
|
||||
val autopilotStatus = AutopilotStatus()
|
||||
autopilotStatus.action = "autopilotstate"
|
||||
val valuesBean = AutopilotStatus.ValuesBean()
|
||||
valuesBean.state = state
|
||||
valuesBean.reason = reason
|
||||
autopilotStatus.values = valuesBean
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportedRoute = ReportedRoute(
|
||||
sn,
|
||||
autopilotStatus.values
|
||||
)
|
||||
val map: MutableMap<String, Any> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportedRoute)
|
||||
mAdasApiService.uploadAutopilotState(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报自动驾驶路线
|
||||
*
|
||||
* @param list 路线集合
|
||||
*/
|
||||
fun uploadAutopilotRoute(list: List<RouteModels?>?) {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportedRoute = ReportedRoute(
|
||||
sn,
|
||||
GsonUtil.jsonFromObject(list)
|
||||
)
|
||||
val map: MutableMap<String, String> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportedRoute)
|
||||
mAdasApiService.uploadAutopilotRoute(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报调度处理结果
|
||||
*
|
||||
* @param dispatchResultType int
|
||||
*/
|
||||
fun dispatchResultUpload(
|
||||
dispatchResultType: Int,
|
||||
onSuccess: ((BaseData) -> Unit)? = null,
|
||||
onError: ((String) -> Unit)? = null
|
||||
) {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val reportDispatchResult =
|
||||
ReportDispatchResult(
|
||||
sn,
|
||||
dispatchResultType
|
||||
)
|
||||
val map: MutableMap<String, Any> = HashMap()
|
||||
map["sn"] = sn
|
||||
map["data"] = GsonUtil.jsonFromObject(reportDispatchResult)
|
||||
mAdasApiService.uploadDispatchResult(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object :
|
||||
SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
|
||||
override fun onNext(o: BaseData) {
|
||||
super.onNext(o)
|
||||
onSuccess?.invoke(o)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
super.onError(e)
|
||||
if (!e.message.isNullOrBlank()) {
|
||||
onError?.invoke(e.message!!)
|
||||
} else {
|
||||
onError?.invoke("上报失败")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSuccess(o: BaseData) {
|
||||
super.onSuccess(o)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.eagle.function.biz.dispatch.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface IDispatchAdasApiService {
|
||||
/**
|
||||
* 上报自动驾驶路径 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("eagle-eye-dns/dataService/autoDriver/receiveCarPreSetPath")
|
||||
fun uploadAutopilotRoute(@FieldMap parameters: Map<String, String>): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 上报自动驾驶调度处理结果 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("eagle-eye-dns/dataService/autoDriver/receiverDestSiteResult")
|
||||
fun uploadDispatchResult(@FieldMap parameters: MutableMap<String, Any>): Observable<BaseData>
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return [BaseData]
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("eagle-eye-dns/dataService/autoDriver/receiveAutopilotState")
|
||||
fun uploadAutopilotState(@FieldMap parameters: MutableMap<String, Any>): Observable<BaseData>
|
||||
}
|
||||
@@ -1,28 +1,32 @@
|
||||
package com.mogo.eagle.core.function.monitoring
|
||||
package com.mogo.eagle.function.biz.monitoring
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
import com.mogo.eagle.core.data.camera.ReqLiveCarBean
|
||||
import com.mogo.commons.utils.RetryWithDelay
|
||||
import com.mogo.eagle.core.data.biz.camera.CameraEntity
|
||||
import com.mogo.eagle.core.data.biz.camera.ReqLiveCarBean
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.monitoring.net.CameraListServices
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MONITOR
|
||||
import com.mogo.map.MogoLocationClient
|
||||
import com.mogo.eagle.function.biz.monitoring.net.ICameraListServices
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class CronTaskManager(private var context: Context?) {
|
||||
class CronTaskManager {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CronTaskManager"
|
||||
private const val CRON_TASK_TYPE = 1011
|
||||
|
||||
val cronTaskManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
CronTaskManager()
|
||||
}
|
||||
}
|
||||
|
||||
// 请求路侧摄像头
|
||||
@@ -57,7 +61,7 @@ class CronTaskManager(private var context: Context?) {
|
||||
private fun requestCameraList() {
|
||||
// 衡阳可直播的摄像头有限,先写死roadId便于调试
|
||||
disposable = MoGoRetrofitFactory.getInstance(HostConst.CAMERA_STREAM_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
.create(ICameraListServices::class.java)
|
||||
.getCameraList("10849")
|
||||
.subscribeOn(Schedulers.io())
|
||||
.map { cameraListInfo ->
|
||||
@@ -86,9 +90,9 @@ class CronTaskManager(private var context: Context?) {
|
||||
* 请求路口一定范围内的设备信息(包含:摄像头、灯)
|
||||
*/
|
||||
private fun requestDeviceList() {
|
||||
MogoLocationClient.getInstance(context).lastKnowLocation?.let { location ->
|
||||
disposable = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()?.let { location ->
|
||||
disposable = MoGoRetrofitFactory.getInstance(HostConst.getEagleHost())
|
||||
.create(ICameraListServices::class.java)
|
||||
.getDeviceList(location.longitude, location.latitude, 500)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.map { cameraListInfo ->
|
||||
@@ -114,15 +118,15 @@ class CronTaskManager(private var context: Context?) {
|
||||
"requestDeviceList:message is:${it.message}, cause is:${it.cause}"
|
||||
)
|
||||
})
|
||||
} ?: run {
|
||||
}?: run {
|
||||
CallerLogger.e("$M_MONITOR$TAG", "CurrentLocation is null!")
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestCarCameraList() {
|
||||
MogoLocationClient.getInstance(context).lastKnowLocation?.let { location ->
|
||||
carDisposable = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()?.let { location ->
|
||||
carDisposable = MoGoRetrofitFactory.getInstance(HostConst.getEagleHost())
|
||||
.create(ICameraListServices::class.java)
|
||||
.getCarCameraList(ReqLiveCarBean(location.longitude, location.latitude))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.map { liveCarCameraInfo ->
|
||||
@@ -161,7 +165,7 @@ class CronTaskManager(private var context: Context?) {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
streamDisposable = MoGoRetrofitFactory.getInstance(HostConst.OPEN_CAMERA_STREAM_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
.create(ICameraListServices::class.java)
|
||||
.openCameraStream(cameraIp)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -189,8 +193,8 @@ class CronTaskManager(private var context: Context?) {
|
||||
streamDisposable?.let {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
streamDisposable = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
streamDisposable = MoGoRetrofitFactory.getInstance(HostConst.getEagleHost())
|
||||
.create(ICameraListServices::class.java)
|
||||
.reqOpenCameraStream(cameraIp)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -218,8 +222,8 @@ class CronTaskManager(private var context: Context?) {
|
||||
streamDisposable2?.let {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
streamDisposable2 = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
streamDisposable2 = MoGoRetrofitFactory.getInstance(HostConst.getEagleHost())
|
||||
.create(ICameraListServices::class.java)
|
||||
.reqOpenCameraStreamWithRetry(cameraIp)
|
||||
.flatMap {
|
||||
if (it.code != 200 && it.code != 0) {
|
||||
@@ -268,8 +272,7 @@ class CronTaskManager(private var context: Context?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
context = null
|
||||
fun release() {
|
||||
disposable?.dispose()
|
||||
carDisposable?.dispose()
|
||||
streamDisposable?.let {
|
||||
@@ -1,29 +1,29 @@
|
||||
package com.mogo.eagle.core.function.monitoring.net
|
||||
package com.mogo.eagle.function.biz.monitoring.net
|
||||
|
||||
import com.mogo.eagle.core.data.camera.*
|
||||
import com.mogo.eagle.core.data.biz.camera.*
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.*
|
||||
|
||||
interface CameraListServices {
|
||||
interface ICameraListServices {
|
||||
@GET("/yycp-smartTransportationAiCloud-service/eagle/device/list")
|
||||
fun getCameraList(@Query("roadId") roadId: String?): Single<CameraListInfo?>
|
||||
|
||||
@POST("/yycp-launcherSnapshot/car/queryLiveCarByLocal")
|
||||
@POST("eagle-eye-dns/yycp-launcherSnapshot/car/queryLiveCarByLocal")
|
||||
fun getCarCameraList(@Body reqBody: ReqLiveCarBean): Single<LiveCarCameraInfo?>
|
||||
|
||||
@GET("/openStream/{cameraIp}")
|
||||
fun openCameraStream(@Path("cameraIp") cameraIp: String): Single<CameraStreamEntity>
|
||||
|
||||
@GET("/camera-stream/stream/camera/openStream")
|
||||
@GET("eagle-eye-dns/camera-stream/stream/camera/openStream")
|
||||
fun reqOpenCameraStream(@Query("ip") cameraIp: String): Single<OpenCameraStreamEntity>
|
||||
|
||||
@GET("/mec-etl-server/crossing/geo/device")
|
||||
@GET("eagle-eye-dns/mec-etl-server/crossing/geo/device")
|
||||
fun getDeviceList(
|
||||
@Query("lon") lon: Double, @Query("lat") lat: Double,
|
||||
@Query("radiusMeter") radiusMeter: Int
|
||||
): Single<CameraListInfo?>
|
||||
|
||||
@GET("/camera-stream/stream/camera/openStream")
|
||||
@GET("eagle-eye-dns/camera-stream/stream/camera/openStream")
|
||||
fun reqOpenCameraStreamWithRetry(@Query("ip") cameraIp: String): Observable<OpenCameraStreamEntity>
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mogo.eagle.function.biz.notice
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeNormalData
|
||||
import java.lang.Class
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeTrafficStylePushData
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告注册、反注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
internal class NoticeSocketManager {
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "NoticeSocketManager"
|
||||
|
||||
val noticeSocketManager:NoticeSocketManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
NoticeSocketManager()
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(301001, mTrafficNoticeListener)
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(100, mNormalNoticeListener)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterOnMessageListener(301001, mTrafficNoticeListener)
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterOnMessageListener(100, mNormalNoticeListener)
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通云公告
|
||||
*/
|
||||
private val mNormalNoticeListener: IMogoOnMessageListener<NoticeNormalData> =
|
||||
object : IMogoOnMessageListener<NoticeNormalData> {
|
||||
override fun target(): Class<NoticeNormalData> {
|
||||
return NoticeNormalData::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: NoticeNormalData?) {
|
||||
if (obj == null) {
|
||||
return
|
||||
}
|
||||
d(SceneConstant.M_NOTICE + TAG, "100-- 普通公告数据:" + GsonUtil.jsonFromObject(obj))
|
||||
val noticeFromCloudMsg = NoticeFrCloudMsg(obj, null, 0)
|
||||
saveMsgBox(MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 交警类型公告弹窗
|
||||
*/
|
||||
private val mTrafficNoticeListener: IMogoOnMessageListener<NoticeTrafficStylePushData> =
|
||||
object : IMogoOnMessageListener<NoticeTrafficStylePushData> {
|
||||
override fun target(): Class<NoticeTrafficStylePushData> {
|
||||
return NoticeTrafficStylePushData::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(obj: NoticeTrafficStylePushData?) {
|
||||
if (obj == null) {
|
||||
return
|
||||
}
|
||||
d(SceneConstant.M_NOTICE + TAG, "301001-- 交警类型公告数据:" + GsonUtil.jsonFromObject(obj))
|
||||
val noticeFromCloudMsg = NoticeFrCloudMsg(null, obj, 1)
|
||||
saveMsgBox(MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.mogo.eagle.core.function.notice.network;
|
||||
package com.mogo.eagle.function.biz.notice.network;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeTrafficStyleInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,7 +19,7 @@ import retrofit2.http.QueryMap;
|
||||
* @description 云公告相关的短链请求接口定义
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public interface NoticeApiService {
|
||||
public interface INoticeApiService {
|
||||
/**
|
||||
* 获取道路事故详情
|
||||
*
|
||||
@@ -27,17 +27,16 @@ public interface NoticeApiService {
|
||||
* @return {@link NoticeTrafficStyleInfo}
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/deva/accidentInfoManage/queryMyAccidentHandleInfo/server/v1")
|
||||
@POST("eagle-eye-dns/deva/accidentInfoManage/queryMyAccidentHandleInfo/server/v1")
|
||||
Observable<NoticeTrafficStyleInfo> getAccidentInfo(@Body RequestBody requestBody);
|
||||
|
||||
|
||||
/**
|
||||
* 反馈对交警事故的操作
|
||||
*
|
||||
* @param accidentParameters 请求数据(infoID事故ID;sn;status接受状态 0否 1是)
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@GET("/deva/accidentInfoManage/policeUpdateTroubleStatus")
|
||||
@GET("eagle-eye-dns/deva/accidentInfoManage/policeUpdateTroubleStatus")
|
||||
Observable<BaseData> sendAcceptStatus(@QueryMap Map<String, String> accidentParameters);
|
||||
|
||||
/**
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.mogo.eagle.core.function.notice.network;
|
||||
package com.mogo.eagle.function.biz.notice.network;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.mogo.cloud.network.NetConstants;
|
||||
import com.mogo.cloud.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.commons.constants.HostConst;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeRequest;
|
||||
import com.mogo.eagle.core.data.biz.notice.NoticeTrafficStyleInfo;
|
||||
|
||||
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoNoticeNetCallBack;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -30,11 +31,11 @@ import okhttp3.RequestBody;
|
||||
*/
|
||||
public class NoticeNetWorkManager {
|
||||
private static volatile NoticeNetWorkManager requestNoticeManager;
|
||||
private final NoticeApiService mNoticeApiService;
|
||||
private final INoticeApiService mNoticeApiService;
|
||||
|
||||
private NoticeNetWorkManager() {
|
||||
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
|
||||
.create(NoticeApiService.class);
|
||||
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(HostConst.getEagleHost())
|
||||
.create(INoticeApiService.class);
|
||||
}
|
||||
|
||||
public static NoticeNetWorkManager getInstance() {
|
||||
@@ -54,8 +55,7 @@ public class NoticeNetWorkManager {
|
||||
* @param infoId 事故id
|
||||
* @param callBack 回调
|
||||
*/
|
||||
public void requestAccidentInfo(String infoId, String sn,NoticeNetCallBack callBack) {
|
||||
|
||||
public void requestAccidentInfo(String infoId, String sn, IMoGoNoticeNetCallBack callBack) {
|
||||
NoticeRequest request = new NoticeRequest(infoId);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"),
|
||||
GsonUtil.jsonFromObject(request));
|
||||
@@ -143,7 +143,6 @@ public class NoticeNetWorkManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull NoticeNormalDetail noticeNormalDetail) {
|
||||
// CallerHmiManager.INSTANCE.showNormalBanner(noticeNormalDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mogo.eagle.function.biz.v2x.obu
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
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.data.obu.MogoObuConst
|
||||
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuSaveMessageListener
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuSaveMessageListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
|
||||
/**
|
||||
* 处理obu分发出来,在消息盒子展示的消息
|
||||
*/
|
||||
object V2xObuEventManager : IMoGoObuSaveMessageListener {
|
||||
private const val TAG = "V2xObuEventManager"
|
||||
|
||||
fun init(context: Context) {
|
||||
registerListener()
|
||||
}
|
||||
|
||||
private fun registerListener() {
|
||||
CallerObuSaveMessageListenerManager.addListener(TAG,this)
|
||||
}
|
||||
|
||||
private fun unRegisterListener() {
|
||||
CallerObuSaveMessageListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private val obuDataMap = mutableMapOf<String, Long>()
|
||||
|
||||
/**
|
||||
* @param type 事件id,类似与uuid
|
||||
* @param content 事件内容
|
||||
* @param tts 事件语音播报 //30秒内同一个事件只出现一次 TODO 临时添加,后面宏宇统一在数据中心处理
|
||||
*/
|
||||
override fun onMoGoObuSaveMessage(type: String, content: String, tts: String, source: DataSourceType) {
|
||||
if (content.isNotEmpty()) {
|
||||
if (obuDataMap.containsKey(type)) {
|
||||
var oldTime = obuDataMap[type]
|
||||
var timeDiff = (System.currentTimeMillis() - oldTime!!) / 1000
|
||||
if (timeDiff < 30) {
|
||||
return
|
||||
}
|
||||
obuDataMap.remove(type)
|
||||
obuDataMap[type] = System.currentTimeMillis()
|
||||
} else {
|
||||
obuDataMap[type] = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${TAG}", "onMoGoObuSaveMessage type = $type ---content = $content ---tts = $tts ")
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
type,
|
||||
content,
|
||||
tts
|
||||
)
|
||||
).apply {
|
||||
sourceType = source
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun release() {
|
||||
unRegisterListener()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,62 +1,37 @@
|
||||
package com.mogo.eagle.core.function.overview.vm
|
||||
package com.mogo.eagle.function.biz.v2x.overview
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.overview.OverviewDao
|
||||
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
|
||||
import com.mogo.eagle.function.biz.v2x.overview.remote.OverViewServiceApi
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class OverViewModel(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModel() {
|
||||
private val _infStructures = MutableLiveData<List<Infrastructure>>()
|
||||
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
|
||||
private var disposable: Disposable? = null
|
||||
object OverViewDataManager {
|
||||
|
||||
companion object {
|
||||
const val TAG = "OverViewModel"
|
||||
private const val TAG = "OverViewDataManager"
|
||||
|
||||
private val overviewDao by lazy {
|
||||
OverviewDb.getDb(AbsMogoApplication.getApp()).overviewDao()
|
||||
}
|
||||
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
|
||||
private val _infStructuresMap = _infStructures
|
||||
.switchMap { infStructures ->
|
||||
liveData {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(map)
|
||||
}
|
||||
}
|
||||
val infStructuresMap
|
||||
get() = _infStructuresMap
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
fun fetchInfStructures() {
|
||||
viewModelScope.launch {
|
||||
ProcessLifecycleOwner.get().lifecycleScope.launch {
|
||||
val data = try {
|
||||
// 只查找摄像头
|
||||
overviewDao.listInfStructures(0)
|
||||
@@ -65,14 +40,33 @@ class OverViewModel(
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
data?.let {
|
||||
_infStructures.value = it
|
||||
data?.let { infStructures ->
|
||||
withContext(Dispatchers.Default) {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
CallerFuncBizListenerManager.invokeInfStructures(map)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateGeoHash(id: Int, geoHash: String) {
|
||||
viewModelScope.launch {
|
||||
ProcessLifecycleOwner.get().lifecycleScope.launch {
|
||||
try {
|
||||
overviewDao.updateGeoHash(id, geoHash)
|
||||
} catch (e: Exception) {
|
||||
@@ -111,20 +105,18 @@ class OverViewModel(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
it?.apply {
|
||||
_V2XEvents.value = this
|
||||
CallerFuncBizListenerManager.invokeV2XEvents(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getV2XEventLiveData() = _V2XEvents
|
||||
|
||||
fun stopQueryV2XEvents() {
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
private fun getLineId(): Long {
|
||||
var lineId: Long = -1
|
||||
val parameter = getAutoPilotStatusInfo()
|
||||
val parameter = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo()
|
||||
.autopilotControlParameters
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
package com.mogo.eagle.function.biz.v2x.overview.db
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
package com.mogo.eagle.function.biz.v2x.overview.db
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.eagle.core.function.overview.remote
|
||||
package com.mogo.eagle.function.biz.v2x.overview.remote
|
||||
|
||||
import com.mogo.eagle.core.data.v2x.V2XEventResult
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
@@ -1,30 +1,31 @@
|
||||
package com.mogo.eagle.core.function.v2x.redlightwarning
|
||||
package com.mogo.eagle.function.biz.v2x.redlightwarning
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.*
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_IVP
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_IVP_GREEN
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.V2I
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.trafficlight.*
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightStatusHelper.getCurrentRoadTrafficLight
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.api.vip.IMoGoVipSetListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
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.data.biz.trafficlight.TrafficLightStatusHelper.getCurrentRoadTrafficLight
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.api.v2x.IMoGoVipSetListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
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.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.LocationUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.zhjt.service_biz.BizConfig
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
@@ -33,7 +34,7 @@ import kotlin.math.min
|
||||
|
||||
|
||||
class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
IMoGoMapLocationListener {
|
||||
IMoGoChassisLocationGCJ02Listener {
|
||||
|
||||
private var vip: Boolean = false
|
||||
|
||||
@@ -82,10 +83,9 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
}
|
||||
|
||||
fun listenTrafficLight() {
|
||||
CallerTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallerMapLocationListenerManager.addListener(TAG, this, false)
|
||||
CallVipSetListenerManager.registerVipSetListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.addListener(TAG, this)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
|
||||
CallVipSetListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun handleRedLightWarning(
|
||||
@@ -100,7 +100,7 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
// 路口100m闯红灯预警
|
||||
mLocation?.let {
|
||||
// 单位m/s
|
||||
val speed = it.speed
|
||||
val speed = it.gnssSpeed
|
||||
// 车停止或者速度非常慢,可能返回负数或者很小的值,需要过滤
|
||||
CallerLogger.d("$M_V2X$TAG", "speed is:$speed")
|
||||
if (speed <= 2.5f) return// 小于等于9km/h不处理
|
||||
@@ -208,19 +208,17 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.content,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts)
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.content,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
null,
|
||||
true,
|
||||
5000L
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -246,19 +244,17 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
content,
|
||||
tts)
|
||||
tts
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
content,
|
||||
tts,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
null,
|
||||
true,
|
||||
5000L
|
||||
tts
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -268,14 +264,13 @@ class RedLightWarningManager : IMoGoTrafficLightListener, IMoGoVipSetListener,
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallVipSetListenerManager.unRegisterVipSetListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
CallerMapLocationListenerManager.removeListener(TAG,false)
|
||||
CallVipSetListenerManager.removeListener(TAG)
|
||||
CallerTrafficLightListenerManager.removeListener(TAG)
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
location?.let {
|
||||
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) {
|
||||
gnssInfo?.let {
|
||||
mLocation = it
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.eagle.function.biz.v2x.road
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.POST
|
||||
|
||||
interface ILineUploadApi {
|
||||
|
||||
@Headers("Content-type:application/json;charset=UTF-8" )
|
||||
@POST( "eagle-eye-dns/yycp-data-center-service/carTrack/receiveCarTrack/" )
|
||||
fun uploadLineId(@Body lineId: LineUploadData): Observable<BaseData>
|
||||
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.mogo.eagle.core.function.v2x
|
||||
package com.mogo.eagle.function.biz.v2x.road
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst.DATA_CENTER_HOST
|
||||
import com.mogo.commons.constants.HostConst.getEagleHost
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.events.network.V2XRefreshModel
|
||||
import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@@ -26,7 +25,7 @@ class LineUploadManager private constructor(context: Context) : IMoGoAutopilotSt
|
||||
@Synchronized
|
||||
fun getInstance(context: Context): LineUploadManager? {
|
||||
if (lineUploadManager == null) {
|
||||
synchronized(V2XRefreshModel::class.java) {
|
||||
synchronized(LineUploadManager::class.java) {
|
||||
if (lineUploadManager == null) {
|
||||
lineUploadManager = LineUploadManager(context)
|
||||
}
|
||||
@@ -44,7 +43,6 @@ class LineUploadManager private constructor(context: Context) : IMoGoAutopilotSt
|
||||
}
|
||||
|
||||
fun init() {
|
||||
Log.d("emArrow", "LineUploadManager addListener")
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
@@ -57,15 +55,15 @@ class LineUploadManager private constructor(context: Context) : IMoGoAutopilotSt
|
||||
|
||||
private fun uploadLine(lineId: Long) {
|
||||
val lineUploadData = LineUploadData(lineId, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
disposable = MoGoRetrofitFactory.getInstance(DATA_CENTER_HOST)
|
||||
.create(V2XEventServiceApi::class.java)
|
||||
disposable = MoGoRetrofitFactory.getInstance(getEagleHost())
|
||||
.create(ILineUploadApi::class.java)
|
||||
.uploadLineId(lineUploadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ data ->
|
||||
Log.d("emArrow", " uploadLine : $data")
|
||||
CallerLogger.d(TAG, " uploadLine : $data")
|
||||
}, {
|
||||
Log.d("emArrow", "e : ${it.message}")
|
||||
CallerLogger.d(TAG, "e : ${it.message}")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.trafficlight
|
||||
package com.mogo.eagle.function.biz.v2x.trafficlight
|
||||
|
||||
class TrafficLightConst {
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
package com.mogo.eagle.core.function.v2x.trafficlight.core
|
||||
package com.mogo.eagle.function.biz.v2x.trafficlight.core
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.mogo.eagle.core.data.trafficlight.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.RoadIDResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightControl
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isInRange
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.TrafficLightHMIManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_CROSS_ROAD
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_CROSS_ROAD
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.network.TrafficLightNetWorkModel
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2
|
||||
import com.mogo.module.common.MogoApisHandler
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_CROSS_ROAD
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_LOOP_SEARCH_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_CROSS_ROAD
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.network.TrafficLightNetWorkModel
|
||||
|
||||
class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -31,7 +33,7 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val trafficLightNetWorkModel = TrafficLightNetWorkModel()
|
||||
private var mLocation: Location? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
private var roadIDResult: RoadIDResult? = null
|
||||
private var trafficLightResult: TrafficLightResult? = null
|
||||
|
||||
@@ -42,20 +44,19 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
|
||||
fun initServer(context: Context) {
|
||||
mContext = context
|
||||
MogoApisHandler.getInstance().apis
|
||||
.registerCenterApi.registerCarLocationChangedListener(TAG, this)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
|
||||
mThreadHandler =
|
||||
TrafficLightThreadHandler(Looper.getMainLooper(), {
|
||||
//第一次查询路口时,如果红绿灯显示,则隐藏掉
|
||||
if(firstLoopCrossRoad && TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()){
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
if (firstLoopCrossRoad) {
|
||||
CallerTrafficLightListenerManager.resetTrafficLightStatus()
|
||||
}
|
||||
firstLoopCrossRoad = false
|
||||
mLocation?.let { it ->
|
||||
val tileId = CallerMapUIServiceManager.getMapUIController()?.getTileId(it.longitude, it.latitude) ?: 0
|
||||
val tileId = CallerMapUIServiceManager.getMapUIController()
|
||||
?.getTileId(it.longitude, it.latitude) ?: 0
|
||||
trafficLightNetWorkModel.requestRoadID(
|
||||
tileId, it.latitude, it.longitude, it.bearing.toDouble(),
|
||||
tileId, it.latitude, it.longitude, it.heading,
|
||||
{
|
||||
mThreadHandler?.sendEmptyMessage(MSG_WHAT_STOP_SEARCH_CROSS_ROAD)
|
||||
roadIDResult = it
|
||||
@@ -75,9 +76,8 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
val road =
|
||||
if (roadIDResult?.rsCrossId.isNullOrBlank()) "" else roadIDResult?.rsCrossId
|
||||
trafficLightNetWorkModel.requestTrafficLight(
|
||||
it.latitude, it.longitude, it.bearing.toDouble(), road, { result ->
|
||||
it.latitude, it.longitude, it.heading, road, { result ->
|
||||
trafficLightResult = result
|
||||
// TrafficLightHMIManager.INSTANCE.updateTrafficLight(result)
|
||||
CallerTrafficLightListenerManager.invokeTrafficLightStatus(result)
|
||||
},
|
||||
{ errorMsg ->
|
||||
@@ -98,10 +98,7 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
2_000L
|
||||
)
|
||||
}
|
||||
// if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
// TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
// CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
// }
|
||||
CallerTrafficLightListenerManager.resetTrafficLightStatus()
|
||||
CallerTrafficLightListenerManager.invokeTrafficRequestError()
|
||||
|
||||
})
|
||||
@@ -137,20 +134,12 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
trafficLightResult = null
|
||||
firstLoopCrossRoad = true
|
||||
mThreadHandler?.sendEmptyMessage(MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT)
|
||||
// TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
// CallerTrafficLightListenerManager.resetTrafficLightData()
|
||||
CallerTrafficLightListenerManager.resetTrafficLightStatus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getTrafficLightCurrentState(): TrafficLightDetail? {
|
||||
trafficLightResult?.let {
|
||||
return it.laneList
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getRoadResult(): RoadIDResult? {
|
||||
return roadIDResult
|
||||
}
|
||||
@@ -173,13 +162,6 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCarLocationChanged2(latLng: Location?) {
|
||||
latLng?.let {
|
||||
mLocation = latLng
|
||||
checkOutOfRange()
|
||||
}
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mThreadHandler = null
|
||||
mContext = null
|
||||
@@ -187,4 +169,12 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
trafficLightResult = null
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) {
|
||||
gnssInfo?.let {
|
||||
mLocation = it
|
||||
checkOutOfRange()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.trafficlight.core
|
||||
package com.mogo.eagle.function.biz.v2x.trafficlight.core
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.eagle.core.function.v2x.trafficlight.network
|
||||
package com.mogo.eagle.function.biz.v2x.trafficlight.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.trafficlight.RoadIDResult
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightControl
|
||||
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.RoadIDResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightControl
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.POST
|
||||
@@ -12,17 +12,17 @@ interface TrafficLightApiService {
|
||||
|
||||
//获取前方路口RoadID
|
||||
@FormUrlEncoded
|
||||
@POST("ai-roadInfo-service/cross/near")
|
||||
@POST("eagle-eye-dns/ai-roadInfo-service/cross/near")
|
||||
suspend fun getFrontRoadID(@FieldMap roadID: Map<String, String>): BaseResponse<RoadIDResult>
|
||||
|
||||
//获取前方红绿灯状态
|
||||
@FormUrlEncoded
|
||||
@POST("mec-etl-server/light/bgd/channel/realTime")
|
||||
@POST("eagle-eye-dns/mec-etl-server/light/bgd/channel/realTime")
|
||||
suspend fun getTrafficLight(@FieldMap status: Map<String, String>): BaseResponse<TrafficLightResult>
|
||||
|
||||
//变灯
|
||||
@FormUrlEncoded
|
||||
@POST("mec-etl-server/light/bdg/newTask")
|
||||
@POST("eagle-eye-dns/mec-etl-server/light/bdg/newTask")
|
||||
suspend fun changeLight(@FieldMap turnLight: Map<String, String>): BaseResponse<TrafficLightControl>
|
||||
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.mogo.eagle.core.function.v2x.trafficlight.network
|
||||
package com.mogo.eagle.function.biz.v2x.trafficlight.network
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.trafficlight.*
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.*
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.cancel
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.commons.constants.HostConst.CITY_HOST
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
|
||||
class TrafficLightNetWorkModel {
|
||||
|
||||
private fun getNetWorkApi(baseUrl: String = CITY_HOST): TrafficLightApiService {
|
||||
private fun getNetWorkApi(baseUrl: String = HostConst.getEagleHost()): TrafficLightApiService {
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
|
||||
.create(TrafficLightApiService::class.java)
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.EventTypeHelper
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
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.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.v2x.V2XAdvanceWarning
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.angle.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager
|
||||
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.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.alarm.V2XAlarmServer
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_EXTRA_KEY
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_HANDLER_ACTION
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.receiver.SceneBroadcastReceiver
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.V2XScenarioManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.toRoadMarker
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget
|
||||
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
|
||||
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XCallback
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.toV2XRoadEventEntity
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
IMoGoAutopilotIdentifyListener, IMoGoCloudListener {
|
||||
|
||||
private const val TAG = "V2XEventManager"
|
||||
|
||||
private val scope: CoroutineScope by lazy {
|
||||
CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher(TAG))
|
||||
}
|
||||
|
||||
private val hasInit by lazy { AtomicBoolean(false) }
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.init(context)
|
||||
if (hasInit.compareAndSet(false, true)) {
|
||||
registerListener()
|
||||
v2xPoiLoader.startLoopPoi()
|
||||
// 注册广播接收场景弹窗使用的
|
||||
SceneBroadcastReceiver.register(context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerListener() {
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 1,this)
|
||||
v2xPoiLoader.addCallback(this)
|
||||
CallerCloudListenerManager.addListener(TAG,this)
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun unRegisterListener() {
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
v2xPoiLoader.removeCallback(this)
|
||||
CallerCloudListenerManager.removeListener(TAG)
|
||||
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
BridgeApi.location.set(mogoLocation)
|
||||
mogoLocation?.let {
|
||||
v2xPoiLoader.updateCheck(mogoLocation.longitude,mogoLocation.latitude)
|
||||
refreshCarState(mogoLocation)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshCarState(location: MogoLocation) {
|
||||
// 巡航处理
|
||||
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(
|
||||
BridgeApi.v2xMarker()?.v2XRoadEventEntityList, location
|
||||
)
|
||||
if (v2XRoadEventEntity != null) {
|
||||
val distance = v2XRoadEventEntity.distance
|
||||
val min = if (EventTypeEnumNew.isCloudSocketEvent(v2XRoadEventEntity.poiType)) 0 else 5
|
||||
CallerLogger.d(
|
||||
"$M_V2X$TAG",
|
||||
"--- trigger show before ---:data=>[${location.longitude}, ${location.latitude}, ${location.gnssSpeed}], distance: $distance, minDistance: $min, poiType: ${v2XRoadEventEntity.poiType}"
|
||||
)
|
||||
if (distance >= min) {
|
||||
CallerLogger.d(
|
||||
"$M_V2X$TAG",
|
||||
"--- trigger show ---:poiType:" + v2XRoadEventEntity.poiType
|
||||
)
|
||||
val v2XMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
|
||||
v2XMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING
|
||||
v2XMessageEntity.content = v2XRoadEventEntity
|
||||
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* V2XEvent事件回调
|
||||
*/
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_CLOUD_V2N,
|
||||
linkCode = CHAIN_LINK_CLOUD,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_V2N,
|
||||
paramIndexes = [0],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onAck(event: V2XEvent) {
|
||||
Log.d("$M_V2X$TAG", "OK->: $event")
|
||||
when (event) {
|
||||
is V2XEvent.ForwardsWarning -> {
|
||||
handleAdvanceWarningEvent(event)
|
||||
}
|
||||
is V2XEvent.Marker -> {
|
||||
event.data.result?.let {
|
||||
handleRoadMarkerEvent(it)
|
||||
}
|
||||
}
|
||||
is V2XEvent.Road -> {
|
||||
handleRoadMarkerEvent(event.data)
|
||||
}
|
||||
is V2XEvent.Warning -> {
|
||||
handleWarningTargetEvent(event.data)
|
||||
}
|
||||
is V2XEvent.RoadAI -> {
|
||||
handleRoadMarkerEvent(event.data.toRoadMarker())
|
||||
}
|
||||
is V2XEvent.RoadEventX -> {
|
||||
handleRoadMarkerEvent(event.data.toRoadMarker())
|
||||
}
|
||||
else -> {
|
||||
Logger.e(TAG, "onAck other event: $event")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_LINK_LOG_CLOUD_V2N,
|
||||
linkCode = CHAIN_LINK_CLOUD,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_V2N,
|
||||
paramIndexes = [0],
|
||||
clientPkFileName = "sn"
|
||||
)
|
||||
override fun onAutopilotIdentifyPlanningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
super.onAutopilotIdentifyPlanningObj(planningObjects)
|
||||
planningObjects?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
val first = it.stream()
|
||||
.filter { planningObj: MessagePad.PlanningObject -> planningObj.type >= 1000 }
|
||||
.findFirst()
|
||||
if (first.isPresent) {
|
||||
val poiType = when (first.get().type) {
|
||||
// 1004 -> { //V2N_RSM,静止事件,包括异常停车、异常静止障碍物
|
||||
// }
|
||||
1005 -> { //V2N_RSI,施工事件,包括锥桶或者挡板围城的施工场景,是个多边形包围区域
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType
|
||||
}
|
||||
1007 -> { //三角牌
|
||||
EventTypeEnumNew.FOURS_ACCIDENT_04.poiType
|
||||
}
|
||||
else -> {
|
||||
return
|
||||
}
|
||||
}
|
||||
CallerLogger.d("$M_V2X$TAG", "poiType : $poiType , 触发道路事件")
|
||||
val trackedObj =
|
||||
CallerMapIdentifyManager.getIdentifyObj(first.get().uuid.toString())
|
||||
trackedObj?.let { t ->
|
||||
CallerLogger.d("$M_V2X$TAG", "polygon size : ${(t.polygonList.size)}")
|
||||
val v2XMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
|
||||
v2XMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING
|
||||
v2XMessageEntity.content = t.toRoadMarker(poiType).toV2XRoadEventEntity()
|
||||
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleWarningTargetEvent(data: V2XWarningTarget) {
|
||||
val v2xMessageEntity = V2XMessageEntity<V2XWarningTarget>()
|
||||
v2xMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_WEAKNESS
|
||||
// 设置数据
|
||||
v2xMessageEntity.content = data
|
||||
val intent = Intent(BROADCAST_SCENE_HANDLER_ACTION)
|
||||
intent.putExtra(BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity)
|
||||
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent)
|
||||
}
|
||||
|
||||
private fun handleRoadMarkerEvent(data: V2XMarkerCardResult) {
|
||||
try {
|
||||
scope.launch(Dispatchers.Default) {
|
||||
BridgeApi.v2xMarker()?.analysisV2XRoadEvent(data)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
//todo 可优化,与obu解析类似
|
||||
private fun handleAdvanceWarningEvent(event: V2XEvent.ForwardsWarning) {
|
||||
scope.launch {
|
||||
val message = event.data
|
||||
val trafficData = buildTrafficData(message)
|
||||
var changeVisualAngle = false
|
||||
when (message.status) {
|
||||
1 -> {
|
||||
var tempAppId = 0
|
||||
var tempTts = ""
|
||||
var tempContent = ""
|
||||
when (message.typeId) {
|
||||
1001 -> {
|
||||
// 弱势交通碰撞预警
|
||||
EventTypeHelper.getVRU { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
1002 -> {
|
||||
// 弱势交通逆行预警
|
||||
EventTypeHelper.getVRURI { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
1003 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_ICW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_ICW.content
|
||||
}
|
||||
1004 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType.toInt()
|
||||
tempTts = String.format(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_BSW.tts,
|
||||
getWarningDirection()
|
||||
)
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_BSW.content
|
||||
}
|
||||
1006 -> {
|
||||
// 逆向超车预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.content
|
||||
}
|
||||
1005 -> {
|
||||
// 闯红灯预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.content
|
||||
}
|
||||
2001 -> {
|
||||
// 最优车道100061
|
||||
EventTypeHelper.getOptLine { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
3001 -> {
|
||||
// 前方道路拥堵预警
|
||||
EventTypeHelper.getTJW { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
}
|
||||
// 不显示弹框,其它保留
|
||||
if (tempContent.isEmpty() || tempTts.isEmpty()) {
|
||||
Log.d("MsgBox-V2XEventManager", "alertContent或ttsContent为空!")
|
||||
}
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts,
|
||||
object : IMoGoWarningStatusListener {
|
||||
val change = changeVisualAngle
|
||||
override fun onShow() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(TooClose)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(Default())
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
2 -> {
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
3 -> {
|
||||
trafficData.uuid?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()?.removeCvxRvInfoIndInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWarningDirection(): String {
|
||||
return "右" //TODO renwj 原来的逻辑,预警方向先写死, 后续做兼容
|
||||
}
|
||||
|
||||
private fun buildTrafficData(message: V2XAdvanceWarning): TrafficData {
|
||||
return TrafficData().apply {
|
||||
type = when (message.objectType) {
|
||||
1 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
|
||||
2 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
|
||||
3 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
|
||||
4 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
|
||||
6 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS
|
||||
8 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK
|
||||
9 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_CAMERA
|
||||
else -> TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
|
||||
}
|
||||
uuid = message.objectId
|
||||
lat = message.position?.lat ?: 0.0
|
||||
lon = message.position?.lon ?: 0.0
|
||||
heading = message.heading ?: 0.0
|
||||
threatLevel = message.threatLevel ?: -1
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(msg: String) {
|
||||
CallerLogger.e("$M_V2X$TAG", "Error: $msg")
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
if (hasInit.compareAndSet(true, false)) {
|
||||
try {
|
||||
scope.cancel()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
unRegisterListener()
|
||||
}
|
||||
v2xPoiLoader.stopLoopPoi()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
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.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerResponse
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.V2XRefreshModel
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XCallback
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XRefreshCallback
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.DistanceUtils
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class V2XPoiLoader private constructor() {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TAG = "V2XPoiLoader"
|
||||
|
||||
val v2xPoiLoader by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
V2XPoiLoader()
|
||||
}
|
||||
}
|
||||
|
||||
private val lastLongitude by lazy { AtomicReference(0.0) }
|
||||
|
||||
private val lastLatitude by lazy { AtomicReference(0.0) }
|
||||
|
||||
private val realLongitude by lazy { AtomicReference(0.0) }
|
||||
|
||||
private val realLatitude by lazy { AtomicReference(0.0) }
|
||||
|
||||
private val handler by lazy {
|
||||
Handler(Looper.getMainLooper())
|
||||
}
|
||||
|
||||
private val cbs by lazy {
|
||||
CopyOnWriteArrayList<IV2XCallback>()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加相关信息接口回调
|
||||
* @param cb 要添加的回调接口
|
||||
*/
|
||||
fun addCallback(cb: IV2XCallback) {
|
||||
if (cbs.contains(cb)) {
|
||||
return
|
||||
}
|
||||
cbs += cb
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除相关信息接口回调
|
||||
* @param cb 要移除的回调接口
|
||||
*/
|
||||
fun removeCallback(cb: IV2XCallback) {
|
||||
if (!cbs.contains(cb)) {
|
||||
return
|
||||
}
|
||||
cbs.remove(cb)
|
||||
}
|
||||
|
||||
fun updateCheck(longitude: Double, latitude: Double) {
|
||||
realLongitude.set(longitude)
|
||||
realLatitude.set(latitude)
|
||||
val oldLon = lastLongitude.get()
|
||||
val oldLat = lastLatitude.get()
|
||||
var update = false
|
||||
try {
|
||||
if (oldLon == 0.0 || oldLat == 0.0) {
|
||||
handler.removeCallbacks(refreshTask)
|
||||
handler.post(refreshTask)
|
||||
update = true
|
||||
return
|
||||
}
|
||||
if (DistanceUtils.calculateLineDistance(oldLon, oldLat, longitude, latitude) >= 200f) {
|
||||
handler.removeCallbacks(refreshTask)
|
||||
handler.post(refreshTask)
|
||||
update = true
|
||||
}
|
||||
} finally {
|
||||
if (update) {
|
||||
lastLatitude.set(latitude)
|
||||
lastLongitude.set(longitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启loop Poi事件
|
||||
*/
|
||||
fun startLoopPoi() {
|
||||
handler.removeCallbacks(refreshTask)
|
||||
handler.post(refreshTask)
|
||||
}
|
||||
|
||||
private val refreshTask = object : Runnable {
|
||||
override fun run() {
|
||||
V2XRefreshModel.querySnapshot(
|
||||
longitude = realLongitude.get(), latitude = realLatitude.get(),
|
||||
refreshCallback
|
||||
)
|
||||
handler.postDelayed(this, TimeUnit.SECONDS.toMillis(60))
|
||||
}
|
||||
}
|
||||
|
||||
fun stopLoopPoi() {
|
||||
handler.removeCallbacks(refreshTask)
|
||||
lastLatitude.set(0.0)
|
||||
lastLongitude.set(0.0)
|
||||
}
|
||||
|
||||
private val refreshCallback = object : IV2XRefreshCallback<V2XMarkerResponse> {
|
||||
|
||||
override fun onSuccess(result: V2XMarkerResponse) {
|
||||
cbs.forEach {
|
||||
it.onAck(V2XEvent.Marker(result))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(msg: String?) {
|
||||
cbs.forEach {
|
||||
it.onFail(msg ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询全览路径上的事件信息
|
||||
*/
|
||||
fun queryWholeRoadEvents() {
|
||||
V2XRefreshModel.roadEventDispose()
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val lineId = getLineId()
|
||||
if (lineId > 0) {
|
||||
realQueryV2xEvents(lineId.toString(), sn)
|
||||
} else {
|
||||
UiThreadHandler.postDelayed({
|
||||
realQueryV2xEvents(getLineId().toString(), sn)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLineId(): Long {
|
||||
var lineId: Long = -1
|
||||
val parameter = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo()
|
||||
.autopilotControlParameters
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
lineId = parameter.autoPilotLine!!.lineId
|
||||
CallerLogger.d(SceneConstant.M_V2X + TAG, "lineId为:$lineId")
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_V2X + TAG, "parameter.autoPilotLine为null")
|
||||
}
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_V2X + TAG, "parameter为null")
|
||||
}
|
||||
return lineId
|
||||
}
|
||||
|
||||
private fun realQueryV2xEvents(lineId: String, sn: String) {
|
||||
V2XRefreshModel.getRoadEvents(lineId, sn) {
|
||||
val size = it?.size ?: 0
|
||||
if (size > 0) {
|
||||
val msgBoxBean =
|
||||
MsgBoxBean(MsgBoxType.V2X, V2XMsg("", "查询到当前全程共${size}个事件", ""))
|
||||
msgBoxBean.sourceType = DataSourceType.SUMMARY
|
||||
CallerMsgBoxManager.saveMsgBox(msgBoxBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.alarm;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.alarm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.common.logging.LoggingDelegate;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
||||
/**
|
||||
@@ -26,6 +26,8 @@ import io.netty.util.internal.ConcurrentSet;
|
||||
*/
|
||||
public class V2XAlarmServer {
|
||||
|
||||
private static final String TAG = "V2XAlarmServer";
|
||||
|
||||
// 记录道路播报的事件
|
||||
private static final ConcurrentSet<V2XRoadEventEntity> showedEvents = new ConcurrentSet<>();
|
||||
/**
|
||||
@@ -35,6 +37,7 @@ public class V2XAlarmServer {
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
|
||||
MogoLocation currentLocation) {
|
||||
try {
|
||||
//Logger.d(TAG, "getDriveFrontAlarmEvent --- 1 ---" + currentLocation );
|
||||
if (!showedEvents.isEmpty()) {
|
||||
Iterator<V2XRoadEventEntity> iterator = showedEvents.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -46,22 +49,23 @@ public class V2XAlarmServer {
|
||||
if (poiLocation == null) {
|
||||
continue;
|
||||
}
|
||||
if (isOutOfRange(poiLocation.getLon(), poiLocation.getLat(), currentLocation.getLongitude(), currentLocation.getLatitude(), currentLocation.getBearing())) {
|
||||
if (isOutOfRange(poiLocation.getLon(), poiLocation.getLat(), currentLocation.getLongitude(), currentLocation.getLatitude(), currentLocation.getHeading())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Logger.d(TAG, "getDriveFrontAlarmEvent --- 2 ---" + currentLocation);
|
||||
if (currentLocation != null && v2XRoadEventEntityList != null) {
|
||||
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
|
||||
for (V2XRoadEventEntity v2XRoadEventEntity : v2XRoadEventEntityList) {
|
||||
// 0、道路事件必须有朝向,角度>=0;
|
||||
Log.d("RWJ", "entity:" + v2XRoadEventEntity.getLocation());
|
||||
//Logger.d(TAG, "entity:" + v2XRoadEventEntity.getLocation());
|
||||
if (v2XRoadEventEntity.getLocation().getAngle() >= 0) {
|
||||
// 计算车辆距离指定气泡的距离
|
||||
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
|
||||
// 1、判断是否到达了触发距离,20 ~ 500,
|
||||
double distance = v2XRoadEventEntity.getDistance();
|
||||
Log.d("RWJ", "distance:" + distance);
|
||||
//Logger.d(TAG, "distance:" + distance);
|
||||
if (distance <= 500) {
|
||||
if (EventTypeEnumNew.GHOST_PROBE.getPoiType().equals(v2XRoadEventEntity.getPoiType())) {
|
||||
if (distance > 25) {
|
||||
@@ -69,10 +73,10 @@ public class V2XAlarmServer {
|
||||
}
|
||||
}
|
||||
// 2、道路事件方向与当前行驶方向角度偏差《20度以内
|
||||
double carBearing = currentLocation.getBearing();
|
||||
double carBearing = currentLocation.getHeading();
|
||||
double eventBearing = eventLocation.getAngle();
|
||||
double diffAngle = DrivingDirectionUtils.getAngleDiff(carBearing, eventBearing);
|
||||
Log.d("RWJ", "car_bearing:" + carBearing + ",eventBearing:" + eventBearing + ",diffAngle:" + diffAngle);
|
||||
//Logger.d(TAG, "car_bearing:" + carBearing + ",eventBearing:" + eventBearing + ",diffAngle:" + diffAngle);
|
||||
if (diffAngle <= 20) {
|
||||
// 3、计算当前车辆行驶方向与事件位置之间夹角《20度,保证道路事件在车辆前方
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
@@ -80,15 +84,15 @@ public class V2XAlarmServer {
|
||||
currentLocation.getLatitude(),
|
||||
eventLocation.getLon(),
|
||||
eventLocation.getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
(int) currentLocation.getHeading()
|
||||
);
|
||||
|
||||
Log.d("RWJ", "eventAngle:" + eventAngle);
|
||||
//Logger.d(TAG, "eventAngle:" + eventAngle);
|
||||
if (0 <= eventAngle && eventAngle <= 20) {
|
||||
if (showedEvents.contains(v2XRoadEventEntity)) {
|
||||
return null;
|
||||
}
|
||||
Log.d("RWJ", "showed---");
|
||||
//Logger.d(TAG, "showed---");
|
||||
showedEvents.add(v2XRoadEventEntity);
|
||||
return v2XRoadEventEntity;
|
||||
}
|
||||
@@ -99,12 +103,11 @@ public class V2XAlarmServer {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.w("RWJ", "error: " + e.getMessage());
|
||||
Logger.w(TAG, "error: " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isOutOfRange(double poi_lon, double poi_lat, double car_lon, double car_lat, double car_angle) {
|
||||
return !isFrontOfCar(poi_lon, poi_lat, car_lon, car_lat, car_angle);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.bridge
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
internal object BridgeApi {
|
||||
|
||||
private val context by lazy {
|
||||
AtomicReference<WeakReference<Context>>(null)
|
||||
}
|
||||
|
||||
val location by lazy {
|
||||
AtomicReference<MogoLocation>()
|
||||
}
|
||||
|
||||
private val v2xMarker by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context()) as? IMoGoV2XMarkerManager
|
||||
}
|
||||
|
||||
private val v2xWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xPersonWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoPersonWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xStopPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoStopPolylineManager
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.context.set(WeakReference(context))
|
||||
}
|
||||
|
||||
fun context(): Context = context.get()?.get() ?: Utils.getApp()
|
||||
|
||||
fun v2xMarker() = v2xMarker
|
||||
|
||||
fun v2xWarnPolyline() = v2xWarnPolyline
|
||||
|
||||
fun v2xPersonWarnPolyline() = v2xPersonWarnPolyline
|
||||
|
||||
fun v2xStopPolyline() = v2xStopPolyline
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.consts;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.consts;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
@@ -13,11 +13,6 @@ import androidx.annotation.Keep;
|
||||
*/
|
||||
@Keep
|
||||
public class MoGoV2XServicePaths {
|
||||
/**
|
||||
* V2X 状态管理
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_STATUS_MANAGER = "/v2xStatusManager/api";
|
||||
|
||||
/**
|
||||
* V2X 道路事件POI点
|
||||
@@ -25,11 +20,6 @@ public class MoGoV2XServicePaths {
|
||||
@Keep
|
||||
public static final String PATH_V2X_MARKER_MANAGER = "/v2xMarkerManager/api";
|
||||
|
||||
/**
|
||||
* V2X 道路事件与车辆的连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_POLYLINE_MANAGER = "/v2xPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 道路事件与车辆的连接线
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.consts;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-2114:10
|
||||
* desc : V2X使用到的常量
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XConst {
|
||||
|
||||
|
||||
/**
|
||||
* V2X 场景广播 Action
|
||||
*/
|
||||
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
|
||||
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
|
||||
|
||||
|
||||
/**
|
||||
* V2X预警日志tag
|
||||
*/
|
||||
public static final String LOG_NAME_WARN = "PersonWarn";
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@@ -19,11 +19,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
*/
|
||||
public interface IMoGoV2XMarkerManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 重新绘制最后一次的POI点
|
||||
*/
|
||||
void drawableLastAllPOI();
|
||||
|
||||
/**
|
||||
* 获取所有的道路事件点,探路事件,返回结果是按照距离当前车辆从近到远排列好的
|
||||
*
|
||||
@@ -43,20 +38,4 @@ public interface IMoGoV2XMarkerManager extends IProvider {
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener);
|
||||
|
||||
/**
|
||||
* 清除 道路事件 POI
|
||||
*/
|
||||
void clearAlarmPOI();
|
||||
|
||||
/**
|
||||
* 清除 所有的 POI
|
||||
*/
|
||||
void clearALLPOI();
|
||||
|
||||
|
||||
/**
|
||||
* 强制清除道路事件POI
|
||||
*/
|
||||
void forceClearAlarmPOI();
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
@@ -6,13 +6,12 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
@@ -55,7 +54,7 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = MogoOverlayManager.getInstance();
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
@@ -6,13 +6,12 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
@@ -54,7 +53,7 @@ public class MoGoStopPolylineManager implements IMoGoStopPolylineManager {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = MogoOverlayManager.getInstance();
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_NOVELTY;
|
||||
import static com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_EVENT_ALARM_POI;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
@@ -17,26 +13,18 @@ import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XStatusManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.V2XStatusManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.marker.V2XMarkerAdapter;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.EntityUtilsKt;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.MapUtils;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.marker.V2XMarkerAdapter;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.MapUtils;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.eagle.core.function.v2x.internal.V2XManager;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerExploreWay;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -55,25 +43,16 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
private static final String TAG = "MoGoV2XMarkerManager";
|
||||
|
||||
// 记录所有的:新鲜事儿的道路事件点、探路事件
|
||||
private static final CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
|
||||
|
||||
private final CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Override
|
||||
public void drawableLastAllPOI() {
|
||||
// 清除连接线
|
||||
IMoGoV2XPolylineManager polylineManager = BridgeApi.INSTANCE.v2xPolyline();
|
||||
if (polylineManager != null) {
|
||||
polylineManager.clearLine();
|
||||
}
|
||||
clearAlarmPOI();
|
||||
V2XManager.INSTANCE.forceRefresh();
|
||||
}
|
||||
public void init(Context context) {}
|
||||
|
||||
@Override
|
||||
public CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList() {
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
|
||||
// 当前车辆数据
|
||||
MogoLocation currentLocation = V2XStatusManager.getInstance().getLocation();
|
||||
MogoLocation currentLocation = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02();
|
||||
if (currentLocation != null) {
|
||||
// 重新计算距离
|
||||
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {
|
||||
@@ -108,18 +87,18 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
// 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
|
||||
mV2XRoadEventEntityArrayList.clear();
|
||||
// 获取探路以及新鲜事儿
|
||||
List<V2XMarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
if (exploreWayList != null) {
|
||||
for (V2XMarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
for (MarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
if (EventTypeEnumNew.isRoadEvent(markerExploreWay.getPoiType())) {
|
||||
V2XMarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
// 记录道路事件
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(EntityUtilsKt.toMarkerLocation(markerLocation));
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
String poi = markerExploreWay.getPoiType();
|
||||
v2XRoadEventEntity.setPoiType(poi);
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay, markerCardResult.getExtras()));
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
}
|
||||
@@ -134,12 +113,7 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
@Override
|
||||
public IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener) {
|
||||
try {
|
||||
IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
|
||||
if (v2xStatus != null) {
|
||||
v2xStatus.setRoadEventPOIShow(TAG, true);
|
||||
}
|
||||
// 清除原来的大而全的新鲜事儿
|
||||
clearAlarmPOI();
|
||||
if (roadEventEntity.getLocation() != null) {
|
||||
// 道路事件,或者水波纹扩散效果
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
@@ -156,25 +130,11 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
markerShowEntity.setMarkerType(CARD_TYPE_NOVELTY);
|
||||
optionsRipple.icons(V2XMarkerAdapter.getV2XRoadEventViewGif(context, roadEventEntity));
|
||||
optionsRipple.period(1);
|
||||
IMogoMarker ret = null;
|
||||
if (MogoStatusManager.getInstance().isVrMode()) {
|
||||
ret = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawMarker(markerShowEntity);
|
||||
} else {
|
||||
optionsRipple.icon(V2XMarkerAdapter.getV2XRoadEventViewPng(context, roadEventEntity));
|
||||
IMogoMarkerManager marker = MogoMarkerManager.getInstance(context);
|
||||
if (marker != null) {
|
||||
ret = marker.addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
|
||||
}
|
||||
}
|
||||
IMogoMarker ret = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawMarker(markerShowEntity);
|
||||
// 当前Marker设置为最上面
|
||||
if (ret != null) {
|
||||
ret.setToTop();
|
||||
}
|
||||
// 绘制连接线
|
||||
IMoGoV2XPolylineManager polylineManager = BridgeApi.INSTANCE.v2xPolyline();
|
||||
if (polylineManager != null) {
|
||||
polylineManager.drawablePolyline(context, roadEventEntity);
|
||||
}
|
||||
// 缩放地图
|
||||
MapUtils.zoomMap(
|
||||
new MogoLatLng(roadEventEntity.getLocation().getLat(),
|
||||
@@ -190,43 +150,4 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAlarmPOI() {
|
||||
// boolean isRoadEventPOIShow = false;
|
||||
// IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
|
||||
// if (v2xStatus != null) {
|
||||
// isRoadEventPOIShow = v2xStatus.isRoadEventPOIShow();
|
||||
// }
|
||||
// if (isRoadEventPOIShow) {
|
||||
// v2xStatus.setRoadEventPOIShow(TAG, false);
|
||||
// if (mAlarmInfoMarker != null) {
|
||||
// mAlarmInfoMarker.remove();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearALLPOI() {
|
||||
try {
|
||||
IMogoMarkerManager markerManager = MogoMarkerManager.getInstance(AbsMogoApplication.getApp());
|
||||
if (markerManager != null) {
|
||||
markerManager.removeMarkers();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceClearAlarmPOI() {
|
||||
// if (mAlarmInfoMarker != null) {
|
||||
// mAlarmInfoMarker.remove();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.manager.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
@@ -6,12 +6,11 @@ import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
@@ -62,7 +61,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
}
|
||||
// 绘制线的对象
|
||||
|
||||
IMogoOverlayManager overlay = MogoOverlayManager.getInstance();
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.marker;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.v2x.R;
|
||||
import com.mogo.eagle.core.function.biz.R;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.view.V2XMarkerRoadEventView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -24,28 +24,6 @@ public class V2XMarkerAdapter {
|
||||
return new V2XMarkerRoadEventView(context, alarmInfo).setBackground(imageRes).getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回道路事件静态的图,因为车机性能不行,会卡顿
|
||||
*/
|
||||
public static Bitmap getV2XRoadEventViewPng(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
Bitmap bitmap;
|
||||
if (EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_SUGGEST.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_WARNING.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.FOURS_BLOCK_UP.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_CAR_TROUBLE_WARNING.getPoiType().equals(alarmInfo.getPoiType())) {
|
||||
bitmap = getV2XRoadEventMarkerView(
|
||||
context,
|
||||
alarmInfo,
|
||||
R.drawable.v_to_x_warning_circle_orange_00040);
|
||||
} else {
|
||||
bitmap = getV2XRoadEventMarkerView(
|
||||
context,
|
||||
alarmInfo,
|
||||
R.drawable.v_to_x_warning_circle_red_00040);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回道路事件gif序列图集合
|
||||
*/
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.network
|
||||
|
||||
import com.elegant.network.utils.GsonUtil
|
||||
import com.elegant.network.utils.SignUtil
|
||||
import com.elegant.utils.CommonUtils
|
||||
import com.mogo.cloud.network.RetrofitFactory
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.commons.network.ParamsUtil
|
||||
import com.mogo.eagle.core.data.v2x.V2XEventData
|
||||
import com.mogo.eagle.core.data.v2x.V2XLocation
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerResponse
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.api.V2XApiService
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.body.V2XRefreshEntity
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XRefreshCallback
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
internal class V2XRefreshModel {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val TAG = "V2XRefreshModel"
|
||||
|
||||
fun querySnapshot(
|
||||
longitude: Double,
|
||||
latitude: Double,
|
||||
callback: IV2XRefreshCallback<V2XMarkerResponse>?
|
||||
): Disposable? {
|
||||
val retrofit = RetrofitFactory.getInstance(HostConst.getEagleHost()) ?: return null
|
||||
return retrofit
|
||||
.create(V2XApiService::class.java)
|
||||
.querySnapshotSync(buildParams(longitude, latitude))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ data ->
|
||||
if (data == null) {
|
||||
callback?.onFail("returned data is null.")
|
||||
return@subscribe
|
||||
}
|
||||
if (data.code != 0 && data.code != 200) {
|
||||
callback?.onFail("code:${data.code}, msg: ${data.msg}")
|
||||
} else {
|
||||
callback?.onSuccess(data)
|
||||
}
|
||||
}, {
|
||||
callback?.onFail(it.message)
|
||||
})
|
||||
}
|
||||
|
||||
private fun buildParams(
|
||||
longitude: Double,
|
||||
latitude: Double,
|
||||
): Map<String, Any> = mutableMapOf<String, Any>().apply {
|
||||
putAll(ParamsUtil.getStaticParams().let {
|
||||
val handled = mutableMapOf<String, Any>()
|
||||
it.asIterable().forEach { itx ->
|
||||
val value = itx.value
|
||||
if (value != null) {
|
||||
handled[itx.key] = value
|
||||
}
|
||||
}
|
||||
handled
|
||||
})
|
||||
this["netType"] = CommonUtils.getNetworkType(AbsMogoApplication.getApp())
|
||||
this["cellId"] = DeviceUtils.getCellId() ?: ""
|
||||
this["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
this["ticket"] = MoGoAiCloudClientConfig.getInstance().token
|
||||
this["sig"] = SignUtil.createSign(this, "JGjZx6")
|
||||
this["data"] = GsonUtil.jsonFromObject(V2XRefreshEntity().apply {
|
||||
limit = 999
|
||||
location = V2XLocation().also {
|
||||
it.lat = latitude
|
||||
it.lon = longitude
|
||||
}
|
||||
radius = 1000
|
||||
dataType.add("CARD_TYPE_ROAD_CONDITION")
|
||||
viewPush = true
|
||||
})
|
||||
}
|
||||
|
||||
private var v2xEventDisposable: Disposable? = null
|
||||
|
||||
fun roadEventDispose(){
|
||||
if (v2xEventDisposable != null && !v2xEventDisposable!!.isDisposed) {
|
||||
v2xEventDisposable!!.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
fun getRoadEvents(lineId: String, sn: String, onSuccess:((List<V2XEventData>?) -> Unit)){
|
||||
v2xEventDisposable = MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(V2XApiService::class.java)
|
||||
.queryAllV2XEventsByLineId(lineId, sn)
|
||||
.map {
|
||||
if (it.code == 200 || it.code == 0) {
|
||||
CallerLogger.d(SceneConstant.M_V2X + TAG, "请求成功,size为:${it.result?.v2XEventList?.size}")
|
||||
return@map it.result?.v2XEventList
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_V2X + TAG, "请求失败,code为:${it.code}")
|
||||
return@map ArrayList()
|
||||
}
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
onSuccess.invoke(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.network.api
|
||||
|
||||
import com.mogo.eagle.core.data.v2x.V2XEventResult
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerResponse
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.*
|
||||
|
||||
internal interface V2XApiService {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("eagle-eye-dns/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync")
|
||||
fun querySnapshotSync(@FieldMap parameters: Map<String, @JvmSuppressWildcards Any>): Maybe<V2XMarkerResponse?>
|
||||
|
||||
@GET("/eagleEye-mis/config/queryV2NInformation")
|
||||
fun queryAllV2XEventsByLineId(@Query("lineId") lineId: String, @Query("sn") sn: String): Observable<V2XEventResult>
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.http.body
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.network.body
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XLocation
|
||||
import com.mogo.eagle.core.data.v2x.V2XLocation
|
||||
|
||||
/**
|
||||
* 刷新地图信息接口
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.callback
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.network.callback
|
||||
|
||||
import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
|
||||
interface IV2XCallback {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.http.callback
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.network.callback
|
||||
|
||||
/**
|
||||
* 刷新回调
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.V2XScenarioManager
|
||||
|
||||
class SceneBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
companion object {
|
||||
fun register(context: Context) {
|
||||
val localReceiver = SceneBroadcastReceiver()
|
||||
val localBroadcastManager = LocalBroadcastManager.getInstance(context)
|
||||
val intentFilter = IntentFilter()
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION)
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
try {
|
||||
val v2XMessageEntity =
|
||||
intent?.getSerializableExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY) as? V2XMessageEntity<*>
|
||||
v2XMessageEntity?.let {
|
||||
V2XScenarioManager.getInstance().handlerMessage(it)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.marker
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.remove
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import kotlinx.coroutines.Runnable
|
||||
import java.util.LinkedList
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -52,7 +53,7 @@ data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val c
|
||||
}
|
||||
}
|
||||
|
||||
object MarkerManager {
|
||||
object MarkerRemoveManager {
|
||||
|
||||
private const val TAG = "MarkerManager"
|
||||
|
||||
@@ -64,9 +65,9 @@ object MarkerManager {
|
||||
|
||||
private val elapsedDistances by lazy { ConcurrentHashMap<MarkerWrapper, Double>() }
|
||||
|
||||
private val lastCarLocation by lazy { AtomicReference<MogoLocation>() }
|
||||
private val lastCarLocation by lazy { AtomicReference<Pair<Double, Double>>() }
|
||||
|
||||
private val lastGpsLocation by lazy { AtomicReference<MogoLocation>() }
|
||||
private val lastGpsLocation by lazy { AtomicReference<Pair<Double, Double>>() }
|
||||
|
||||
private val checkTask = object : Runnable {
|
||||
|
||||
@@ -89,15 +90,16 @@ object MarkerManager {
|
||||
if (carLoc.get() == null) {
|
||||
carLoc.set(if (marker.coordinateType == 0) {
|
||||
//高德坐标
|
||||
CallerMapLocationListenerManager.getCurrentLocation()
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||
} else {
|
||||
CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
//高精坐标
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
})
|
||||
}
|
||||
val currentLocation = carLoc.get()
|
||||
val lastLocation = if (marker.coordinateType == 0) lastCarLocation.get() else lastGpsLocation.get()
|
||||
if (currentLocation != null && lastLocation != null) {
|
||||
val delta = CoordinateUtils.calculateLineDistance(currentLocation.longitude, currentLocation.latitude, lastLocation.longitude, lastLocation.latitude)
|
||||
val delta = CoordinateUtils.calculateLineDistance(currentLocation.longitude, currentLocation.latitude, lastLocation.first, lastLocation.second)
|
||||
Log.d(TAG, "--- checkTask --- 4 ---:delta:$delta, id:${marker.id}")
|
||||
var elapsed = elapsedDistances[marker]
|
||||
if (elapsed == null) {
|
||||
@@ -148,14 +150,15 @@ object MarkerManager {
|
||||
if (carLoc.get() == null) {
|
||||
carLoc.set(if (marker.coordinateType == 0) {
|
||||
//高德坐标
|
||||
CallerMapLocationListenerManager.getCurrentLocation()
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||
} else {
|
||||
CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
//高精坐标
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
})
|
||||
}
|
||||
val location = carLoc.get()
|
||||
if (location != null) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, marker.lon, marker.lat, location.bearing.toDouble())
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, marker.lon, marker.lat, location.heading)
|
||||
if (angle >= 90) {
|
||||
iterator.remove()
|
||||
synchronized(toRemoveMakers) {
|
||||
@@ -167,8 +170,10 @@ object MarkerManager {
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
} finally {
|
||||
lastCarLocation.set(CallerMapLocationListenerManager.getCurrentLocation())
|
||||
lastGpsLocation.set(CallerMapLocationListenerManager.getCurrentGpsLocation())
|
||||
val gcInfo = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||
lastCarLocation.set((gcInfo?.longitude ?: 0.0) to (gcInfo?.latitude ?: 0.0))
|
||||
val wgsInfo = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
lastGpsLocation.set((wgsInfo?.longitude ?: 0.0) to (wgsInfo?.latitude ?: 0.0))
|
||||
handler.postDelayed(this, 1000)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario;
|
||||
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario;
|
||||
|
||||
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.impl;
|
||||
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.IV2XScenario;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.IV2XScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.impl;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.IV2XScenarioManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.V2XRoadEventScenario;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.route.V2XOptimalRouteVREventScenario;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.warning.V2XFrontWarningScenario;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.IV2XScenarioManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XRoadEventScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning.V2XFrontWarningScenario;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.Utils;
|
||||
import com.mogo.map.MogoMapUIController;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -59,19 +53,11 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 提取之前存储的场景
|
||||
if (v2XMessageEntity != null) {
|
||||
// 广播给应用内部其它模块
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent);
|
||||
// 如果没有拿到之前的,根据类型分发
|
||||
switch (v2XMessageEntity.getType()) {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
|
||||
mV2XScenario = new V2XRoadEventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
|
||||
sceneChange();
|
||||
mV2XScenario = new V2XOptimalRouteVREventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_WEAKNESS:
|
||||
if (HmiBuildConfig.isShowCloudWeaknessTrafficView) { //默认关闭云端弱势交通
|
||||
sceneChange();
|
||||
@@ -107,7 +93,7 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
* 道路事件触发后,切换到中景
|
||||
*/
|
||||
private void sceneChange() {
|
||||
IMogoMapUIController mapUiController = MogoMapUIController.getInstance();
|
||||
IMogoMapUIController mapUiController = CallerMapUIServiceManager.INSTANCE.getMapUIController();
|
||||
if (mapUiController != null && mapUiController.getCurrentMapVisualAngle() != VisualAngleMode.MODE_MEDIUM_SIGHT) {
|
||||
mapUiController.changeMapVisualAngle(VisualAngleMode.MODE_MEDIUM_SIGHT, null);
|
||||
}
|
||||
@@ -1,26 +1,27 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad
|
||||
|
||||
import android.animation.*
|
||||
import android.graphics.*
|
||||
import android.os.*
|
||||
import android.view.animation.*
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.graphics.Color
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.v2x.events.marker.MarkerManager
|
||||
import com.mogo.eagle.core.function.v2x.events.marker.MarkerWrapper
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.*
|
||||
import java.lang.Runnable
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.*
|
||||
import kotlin.collections.ArrayList
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
|
||||
/**
|
||||
* Ai云道路施工事件,道路颜色标记类
|
||||
@@ -36,10 +37,12 @@ class AiRoadMarker {
|
||||
|
||||
private val marker by lazy { AtomicReference<Marker>() }
|
||||
|
||||
private val overlayManager by lazy { MogoOverlayManager.getInstance() }
|
||||
private val overlayManager by lazy {
|
||||
CallerMapUIServiceManager.getOverlayManager()
|
||||
}
|
||||
|
||||
private val START_COLOR = Color.parseColor("#002ABAD9")
|
||||
private val END_COLOR = Color.parseColor("#66FF7A30")
|
||||
private val END_COLOR = Color.parseColor("#66FF7A30")
|
||||
|
||||
private val roadMarker by lazy { V2XAiRoadEventMarker() }
|
||||
|
||||
@@ -51,7 +54,7 @@ class AiRoadMarker {
|
||||
|
||||
private val checkExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, poi.poi_lon, poi.poi_lat)
|
||||
if (distance < 500) {
|
||||
@@ -70,7 +73,7 @@ class AiRoadMarker {
|
||||
}
|
||||
|
||||
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false) {
|
||||
val location = CallerMapLocationListenerManager.getCurrentGpsLocation() ?: return
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() ?: return
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
@@ -78,10 +81,10 @@ class AiRoadMarker {
|
||||
}
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.bearing, 300f)
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), 300f)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.bearing, -300f)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), -300f)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Logger.d(TAG, "--- marker --- 3 --- return ----")
|
||||
return
|
||||
@@ -100,7 +103,7 @@ class AiRoadMarker {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.bearing.toDouble())
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.heading)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
@@ -112,7 +115,7 @@ class AiRoadMarker {
|
||||
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
|
||||
if (l1 != null && l1.points.isNotEmpty()) {
|
||||
for (l in l1.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, (location.bearing + 180).toDouble()) < 90L) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, (location.heading + 180)) < 90L) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
@@ -132,7 +135,7 @@ class AiRoadMarker {
|
||||
options.colorValues(colors)
|
||||
Logger.d(TAG, "--- marker --- 7 --- points: ${points.size}")
|
||||
if (line == null || line.isDestroyed) {
|
||||
val l = overlayManager.addPolyline(options)
|
||||
val l = overlayManager?.addPolyline(options)
|
||||
this.line.set(l)
|
||||
line = l
|
||||
} else {
|
||||
@@ -145,7 +148,7 @@ class AiRoadMarker {
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
MarkerManager.addMarker(wrapper)
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
|
||||
private fun removeLine() {
|
||||
@@ -170,7 +173,7 @@ class AiRoadMarker {
|
||||
fun receive() {
|
||||
Logger.d(TAG, "receive --- 1 ---")
|
||||
val poi = this.marker.get()
|
||||
val car = CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, poi.poi_lon, poi.poi_lat)
|
||||
Logger.d(TAG, "receive --- 2 ---:car:[${car.longitude}, ${car.latitude}] -> poi:[${poi.poi_lon}, ${poi.poi_lat}] --> distance:$distance")
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road
|
||||
|
||||
import android.graphics.Color
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class V2XAiRoadEventMarker {
|
||||
|
||||
private val current = AtomicReference<Pair<IMogoPolyline?, List<IMogoMarker>?>>()
|
||||
|
||||
private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager() }
|
||||
|
||||
fun drawMarkers(entity: V2XRoadEventEntity, wrapper: MarkerWrapper) {
|
||||
val polygon = entity.noveltyInfo.polygon
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)?.also {
|
||||
wrapper.addMarker(it)
|
||||
}
|
||||
if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) {
|
||||
val options = MogoPolylineOptions()
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
options.colorValues(colors)
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
|
||||
for (p in polygon) {
|
||||
points.add(MogoLatLng(p.first, p.second))
|
||||
}
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
options.points(points)
|
||||
options.useGradient(true)
|
||||
options.useFacade(true)
|
||||
options.setGps(true)
|
||||
options.width(5f)
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager?.addPolyline(options)
|
||||
line?.let {
|
||||
current.set(Pair(line, wrapper.markers))
|
||||
line.isVisible = true
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun removeMarkers() {
|
||||
val prev = current.get()
|
||||
if (prev != null) {
|
||||
realRemove(prev)
|
||||
}
|
||||
}
|
||||
|
||||
private fun realRemove(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>) {
|
||||
val line = pair.first
|
||||
if (line != null && line.isVisible) {
|
||||
line.remove()
|
||||
}
|
||||
val markers = pair.second
|
||||
if (markers != null && markers.isNotEmpty()) {
|
||||
for (m in markers) {
|
||||
m.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road;
|
||||
|
||||
import android.util.Log;
|
||||
import androidx.core.util.Pair;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 道路V2X事件的Marker
|
||||
*/
|
||||
public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
try {
|
||||
// 清除道路事件
|
||||
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (marker != null) {
|
||||
if (entity != null) {
|
||||
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType());
|
||||
if (isAiRoadEvent(entity.getPoiType())) {
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo);
|
||||
if (noveltyInfo != null) {
|
||||
Pair<Double, Double> gpsLocation = noveltyInfo.getGpsLocation();
|
||||
List<Pair<Double, Double>> polygons = noveltyInfo.getPolygon();
|
||||
if (gpsLocation != null && polygons != null) {
|
||||
MarkerLocation location = noveltyInfo.getLocation();
|
||||
AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity);
|
||||
AiRoadMarker aiMarker = new AiRoadMarker();
|
||||
aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType()));
|
||||
AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
if (iMarker != null) {
|
||||
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- add Marker");
|
||||
ArrayList<IMogoMarker> markers = new ArrayList<>();
|
||||
markers.add(iMarker);
|
||||
String id = entity.getLocation().getLon() + "_" + entity.getLocation().getLat();
|
||||
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null));
|
||||
} else {
|
||||
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAiRoadEvent(String poiType) {
|
||||
return Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType())
|
||||
&& Objects.equals(poiType, EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType())
|
||||
&& Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType())
|
||||
&& Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType());
|
||||
}
|
||||
|
||||
private boolean isDrawRoadLine(String poiType) {
|
||||
return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.analytics.AnalyticsUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
@@ -16,20 +11,22 @@ 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.map.angle.Default;
|
||||
import com.mogo.eagle.core.function.api.map.angle.RoadEvent;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.V2XStatusManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -47,21 +44,18 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
@Override
|
||||
public void init(V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity) {
|
||||
try {
|
||||
Log.d(TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
Logger.d(TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
V2XRoadEventEntity v2XRoadEventEntity = v2XMessageEntity.getContent();
|
||||
if (v2XRoadEventEntity != null) {
|
||||
if (v2XMessageEntity.isShowState()) {
|
||||
if (!isSameScenario(v2XMessageEntity)) {
|
||||
// 更新要提醒的数据
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
show();
|
||||
} else {
|
||||
// 更新要提醒的数据
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
}
|
||||
if (!isSameScenario(v2XMessageEntity)) {
|
||||
// 更新要提醒的数据
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
show();
|
||||
} else {
|
||||
close();
|
||||
// 更新要提醒的数据
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -74,30 +68,14 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
|
||||
//只展示不播报 不广播
|
||||
V2XMessageEntity<V2XRoadEventEntity> entity = getV2XMessageEntity();
|
||||
boolean onlyShow = entity.isOnlyShow();
|
||||
if (!onlyShow) {
|
||||
// 设置TTS
|
||||
V2XRoadEventEntity content = entity.getContent();
|
||||
if (content != null && !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType())) {
|
||||
content.getTts(false);
|
||||
}
|
||||
V2XRoadEventEntity content = entity.getContent();
|
||||
if (content != null && !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType())
|
||||
&& !Objects.equals(content.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType())) {
|
||||
content.getTts(false);
|
||||
}
|
||||
showWindow();
|
||||
String poiType = entity.getContent().getPoiType();
|
||||
String lat = String.valueOf(entity.getContent().getLocation().getLat());
|
||||
String lon = String.valueOf(entity.getContent().getLocation().getLon());
|
||||
String infoId = entity.getContent().getNoveltyInfo().getInfoId();
|
||||
String style = "1";
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("dbid", infoId);
|
||||
properties.put("type", poiType);
|
||||
properties.put("lng", lon);
|
||||
properties.put("lat", lat);
|
||||
properties.put("style", style);
|
||||
AnalyticsUtils.track(V2XConst.V2X_ROAD_SHOW, properties);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -113,16 +91,15 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
String ttsText = content.getTts();
|
||||
if (alarmText == null || alarmText.isEmpty()
|
||||
|| ttsText == null || ttsText.isEmpty()) {
|
||||
Log.d("MsgBox-V2XRoadScenario", "alertContent或ttsContent为空!");
|
||||
Logger.d("MsgBox-V2XRoadScenario", "alertContent或ttsContent为空!");
|
||||
}
|
||||
String poiType = content.getPoiType();
|
||||
if (EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew. TYPE_SOCKET_ROAD_JINGZHI.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType().equals(poiType)) {
|
||||
MogoLocation carLocation = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType().equals(poiType)) {
|
||||
MarkerExploreWay noveltyInfo = content.getNoveltyInfo();
|
||||
if (carLocation != null && noveltyInfo != null) {
|
||||
if (noveltyInfo != null) {
|
||||
MarkerLocation eventLocation = noveltyInfo.getLocation();
|
||||
if (eventLocation != null) {
|
||||
double distance = content.getDistance();
|
||||
@@ -132,6 +109,16 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
}
|
||||
}
|
||||
|
||||
//占道施工预警
|
||||
if (poiType.equals("10006") || poiType.equals("100061")) {
|
||||
long currentTime = System.currentTimeMillis() / 1000;
|
||||
long oldTime = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).getLong("roadwork", 0);
|
||||
if (currentTime - oldTime > 60) { //超过一分钟,才会继续播报重复提醒
|
||||
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()).putLong("roadwork", System.currentTimeMillis() / 1000);
|
||||
CallerAutoPilotControlManager.sendTripInfo(5, "", "", "", false);
|
||||
}
|
||||
}
|
||||
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(
|
||||
new MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
@@ -141,7 +128,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
)
|
||||
);
|
||||
CallerHmiManager.INSTANCE.warningV2X(poiType, alarmText,
|
||||
ttsText, TAG, this, !entity.isOnlyShow(),
|
||||
ttsText, this,WarningDirectionEnum.ALERT_WARNING_TOP,
|
||||
TimeUnit.SECONDS.toMillis(5));
|
||||
}
|
||||
}
|
||||
@@ -151,7 +138,6 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
IV2XMarker marker = getV2XMarker();
|
||||
if (marker != null) {
|
||||
// 重置告警信息
|
||||
V2XStatusManager.getInstance().setAlarmInfo(getV2XMessageEntity().getContent());
|
||||
marker.drawPOI(getV2XMessageEntity().getContent());
|
||||
}
|
||||
}
|
||||
@@ -167,21 +153,15 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
@Override
|
||||
public void onShow() {
|
||||
if (isNeedChangeAngle()) {
|
||||
CallerVisualAngleManager.INSTANCE.changeVisualAngle(CallerVisualAngleManager.Scene.RoadEvent.INSTANCE);
|
||||
CallerVisualAngleManager.INSTANCE.changeAngle(RoadEvent.INSTANCE);
|
||||
}
|
||||
CallerHmiManager.INSTANCE.showWarning(WarningDirectionEnum.ALERT_WARNING_TOP, TimeUnit.HOURS.toMillis(1));
|
||||
V2XMessageEntity<V2XRoadEventEntity> entity = getV2XMessageEntity();
|
||||
if (entity != null) {
|
||||
|
||||
V2XRoadEventEntity content = entity.getContent();
|
||||
if (content != null) {
|
||||
if (entity.isNeedAddLine() && !EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(content.getPoiType()) ) {
|
||||
if (entity.isNeedAddLine() && !EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(content.getPoiType())) {
|
||||
drawPOI();
|
||||
}
|
||||
MarkerExploreWay noveltyInfo = content.getNoveltyInfo();
|
||||
if (noveltyInfo != null && EventTypeEnumNew.FOURS_FOG.getPoiType().equals(content.getNoveltyInfo().getPoiType())) {
|
||||
CallerHmiManager.INSTANCE.displayEffects();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +179,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
public void onDismiss() {
|
||||
CallerHmiManager.INSTANCE.dismissWarning(WarningDirectionEnum.ALERT_WARNING_TOP);
|
||||
if (isNeedChangeAngle()) {
|
||||
CallerVisualAngleManager.INSTANCE.changeVisualAngle(new CallerVisualAngleManager.Scene.Default(3, TimeUnit.SECONDS));
|
||||
CallerVisualAngleManager.INSTANCE.changeAngle(new Default(3, TimeUnit.SECONDS));
|
||||
}
|
||||
release();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.warning;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
@@ -17,13 +17,13 @@ import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
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.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener;
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
|
||||
* @since: 2021/3/24
|
||||
*/
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapLocationListener, IMoGoWarningStatusListener {
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChassisLocationGCJ02Listener, IMoGoWarningStatusListener {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
private V2XWarningTarget mMarkerEntity;
|
||||
@@ -83,8 +83,8 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
|
||||
);
|
||||
CallerHmiManager.INSTANCE.warningV2X(v2xType + "",
|
||||
getAlertContentForFrontWarning(mMarkerEntity), mMarkerEntity.getTts(),
|
||||
TAG, this, !entity.isOnlyShow(),
|
||||
TimeUnit.SECONDS.toMillis(3));
|
||||
this,getDirection(),
|
||||
TimeUnit.SECONDS.toMillis(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,13 +131,11 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
|
||||
sV2XWarningMarker.onCarLocationChanged2(location);
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
sV2XWarningMarker.onCarLocationChanged2(gnssInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
//预警蒙层
|
||||
private WarningDirectionEnum getDirection(){
|
||||
WarningDirectionEnum warningDirectionEnum = WarningDirectionEnum.ALERT_WARNING_ALL;
|
||||
switch (mMarkerEntity.getDirection()) {
|
||||
case 0:
|
||||
@@ -156,8 +154,13 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
|
||||
warningDirectionEnum = WarningDirectionEnum.ALERT_WARNING_RIGHT;
|
||||
break;
|
||||
}
|
||||
CallerHmiManager.INSTANCE.showWarning(warningDirectionEnum, TimeUnit.HOURS.toMillis(1));
|
||||
mDirection = warningDirectionEnum;
|
||||
return warningDirectionEnum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
//预警蒙层
|
||||
drawPOI();
|
||||
}
|
||||
|
||||
@@ -1,32 +1,30 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.warning;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
import static com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_FRONT_WARNING_MARKER;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.commons.utils.Trigonometric;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.model.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XLocation;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.commons.utils.Trigonometric;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XLocation;
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -46,8 +44,8 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
private final List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat(),
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon()
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude(),
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude()
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -55,7 +53,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
private static long showTime = 6000;
|
||||
private float bearing;
|
||||
private double bearing;
|
||||
private boolean hasStopLines = false;
|
||||
|
||||
@Override
|
||||
@@ -78,7 +76,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
bearing = location.getBearing();
|
||||
bearing = location.getHeading();
|
||||
|
||||
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
|
||||
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
@@ -97,7 +95,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
} else {
|
||||
}
|
||||
//二轮车和行人的渲染和移动
|
||||
IMogoMarkerManager marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp());
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
}
|
||||
@@ -218,7 +216,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
stopPolyLineManager.clearLine();
|
||||
}
|
||||
|
||||
IMogoMarkerManager marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp());
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
//清除小箭头
|
||||
marker.removeMarkers(WARNING_ARROWS);
|
||||
@@ -267,7 +265,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
private void handleStopLine() {
|
||||
try {
|
||||
if (mCloundWarningInfo != null) {
|
||||
IMogoMarkerManager marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp());
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}
|
||||
@@ -445,19 +443,4 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "车辆行驶轨迹" + latLng.getLongitude() + "," + latLng.getLatitude());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
IMogoMarkerManager marker = MogoMarkerManager.getInstance(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(V2X_FRONT_WARNING_MARKER);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
IMoGoWarnPolylineManager warnPolylineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
if (warnPolylineManager != null) {
|
||||
warnPolylineManager.clearLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.view;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.view;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -10,7 +10,4 @@ package com.mogo.eagle.core.function.v2x.events.scenario.view;
|
||||
public interface IV2XMarker<T> {
|
||||
|
||||
void drawPOI(T entity);
|
||||
|
||||
void clearPOI();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.test
|
||||
|
||||
class TestConsts {
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* V2X 测试控制面板广播Action
|
||||
*/
|
||||
@JvmField
|
||||
val BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType"
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils;
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.test;
|
||||
|
||||
import static com.mogo.eagle.core.data.map.entity.V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerResponse;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XWarningEntity;
|
||||
import com.mogo.eagle.core.function.v2x.R;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.net.V2XOptimalRouteDataRes;
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.eagle.core.data.v2x.V2XOptimalRouteDataRes;
|
||||
import com.mogo.eagle.core.function.biz.R;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.util.Utils;
|
||||
|
||||
@@ -28,73 +25,6 @@ import java.util.List;
|
||||
*/
|
||||
public class TestOnLineCarUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 获取测试的违章停车数据
|
||||
*/
|
||||
public static V2XMessageEntity<List<MarkerExploreWay>> getV2XIllegalParkData() {
|
||||
try {
|
||||
InputStream inputStream = Utils.getApp().getResources().openRawResource(R.raw.illegal_park_data);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
MarkerResponse markerResponse = GsonUtil.objectFromJson(baos.toString(), MarkerResponse.class);
|
||||
|
||||
V2XMessageEntity<List<MarkerExploreWay>> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(markerResponse.getResult().getExploreWay());
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模拟道路事件测试数据
|
||||
*/
|
||||
public static V2XMessageEntity<V2XRoadEventEntity> getV2XScenarioRoadEventData() {
|
||||
try {
|
||||
InputStream inputStream = Utils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_road_event_data);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
V2XRoadEventEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XRoadEventEntity.class);
|
||||
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(ALERT_ROAD_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟道路事件测试数据
|
||||
*/
|
||||
@@ -105,12 +35,11 @@ public class TestOnLineCarUtils {
|
||||
entity.setPoiType("100061");
|
||||
entity.setExpireTime(20000);
|
||||
V2XMessageEntity<V2XRoadEventEntity> body = new V2XMessageEntity<>();
|
||||
body.setOnlyShow(false);
|
||||
body.setShowState(true);
|
||||
body.setContent(entity);
|
||||
body.setType(ALERT_ROAD_WARNING);
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟道路事件UGC测试数据
|
||||
*/
|
||||
@@ -135,8 +64,6 @@ public class TestOnLineCarUtils {
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -183,76 +110,6 @@ public class TestOnLineCarUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模拟 道路求助
|
||||
*/
|
||||
public static V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> getV2XScenarioSeekHelpData() {
|
||||
try {
|
||||
InputStream inputStream = Utils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_seek_help);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
V2XSpecialCarRes v2xRoadEventEntity =
|
||||
GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class);
|
||||
|
||||
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates());
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟 后方VIP
|
||||
*/
|
||||
public static V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> getV2XScenarionVRBehindVIPData() {
|
||||
try {
|
||||
InputStream inputStream = Utils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_push_vr_hehind_vip_data);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
V2XSpecialCarRes v2xRoadEventEntity =
|
||||
GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class);
|
||||
|
||||
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates());
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模拟最优路线推送
|
||||
*/
|
||||
@@ -277,8 +134,6 @@ public class TestOnLineCarUtils {
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -297,8 +152,6 @@ public class TestOnLineCarUtils {
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_CAR_FOR_HELP);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(true);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.test;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.data.v2x.V2XOptimalRouteDataRes;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* V2X 测试面板广播接收,目的是可以通过广播调用起来面板
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
public class TestV2XReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "TestV2XReceiver";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(TestConsts.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
if (sceneType == 1) {// 触发AI道路施工事件
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioAIRoadEventData();
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 10) {//触发事件UGC
|
||||
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioRoadEventUGCData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 12) {//车路云场景预警-右侧
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("right");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 13) {//车路云场景预警-左侧
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("left");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 14) {//行人预警,行人路线预测 车路云预警-前方行人
|
||||
V2XMessageEntity messageEntity = TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData("pedestrians");
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, messageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 17) {//最优路线推荐
|
||||
V2XMessageEntity<V2XOptimalRouteDataRes> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XOptimalRoute();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
|
||||
} else if (sceneType == 20) {// 小地图绘制线
|
||||
List<MogoLatLng> coordinates = TestOnLineCarUtils.getTestCoordinates();
|
||||
// CallerSmpManager.drawablePolyline(coordinates);
|
||||
} else if (sceneType == 21) {// 小地图清除绘制线
|
||||
// CallerSmpManager.clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.utils
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import kotlin.math.asin
|
||||
import kotlin.math.cos
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.data.v2x.V2XRoadXData
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import roadwork.Road
|
||||
|
||||
|
||||
fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
|
||||
V2XMarkerCardResult().also { l1 ->
|
||||
val centerX = this.roadwork?.center?.point?.lon ?: 0.0
|
||||
val centerY = this.roadwork?.center?.point?.lat ?: 0.0
|
||||
val id = "${centerX}_${centerY}"
|
||||
l1.exploreWay = ArrayList<MarkerExploreWay>().also { l2 ->
|
||||
l2.add(MarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.roadwork?.poiType?.toString()
|
||||
l3.setGenerateTime(this.roadwork?.detectTime ?: 0L)
|
||||
l3.location = MarkerLocation().also { l4 ->
|
||||
val p = CoordinateTransform.WGS84ToGCJ02(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0)
|
||||
l4.lon = p[0]
|
||||
l4.lat = p[1]
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
}
|
||||
l3.infoId = id
|
||||
l3.gpsLocation = Pair(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0)
|
||||
l3.polygon = this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) }
|
||||
})
|
||||
}
|
||||
AiRoadMarker.aiMakers[id]?.receive()
|
||||
}
|
||||
|
||||
fun V2XRoadXData.toRoadMarker(): V2XMarkerCardResult =
|
||||
V2XMarkerCardResult().also { l1 ->
|
||||
l1.exploreWay = ArrayList<MarkerExploreWay>().also { l2 ->
|
||||
l2.add(MarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.poiType
|
||||
l3.setGenerateTime(this.detectTime ?: 0L)
|
||||
l3.location = MarkerLocation().also { l4 ->
|
||||
val p = CoordinateTransform.WGS84ToGCJ02(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0)
|
||||
l4.lon = p[0]
|
||||
l4.lat = p[1]
|
||||
l4.angle = this.centerRoad?.bearing ?: 0.0
|
||||
}
|
||||
l3.infoId = this.index
|
||||
l3.gpsLocation = Pair(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0)
|
||||
l3.polygon = this.polygon?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) }
|
||||
})
|
||||
}
|
||||
AiRoadMarker.aiMakers[this.index]?.receive()
|
||||
}
|
||||
|
||||
fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult =
|
||||
V2XMarkerCardResult().also { l1 ->
|
||||
val id = "${this.longitude}_${this.latitude}"
|
||||
l1.exploreWay = ArrayList<MarkerExploreWay>().also { l2 ->
|
||||
l2.add(MarkerExploreWay().also { l3 ->
|
||||
l3.poiType = poiType
|
||||
l3.setGenerateTime(0L)
|
||||
l3.location = MarkerLocation().also { l4 ->
|
||||
val p = CoordinateTransform.WGS84ToGCJ02(this.longitude, this.latitude)
|
||||
l4.lon = p[0]
|
||||
l4.lat = p[1]
|
||||
l4.angle = this.heading
|
||||
}
|
||||
l3.infoId = id
|
||||
|
||||
l3.gpsLocation = Pair(this.longitude, this.latitude)
|
||||
l3.polygon = this.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.longitude, it.latitude) }
|
||||
})
|
||||
}
|
||||
AiRoadMarker.aiMakers[id]?.receive()
|
||||
}
|
||||
|
||||
fun V2XMarkerCardResult.toV2XRoadEventEntity(): V2XRoadEventEntity =
|
||||
V2XRoadEventEntity().also { l1 ->
|
||||
val exploreWayList: List<MarkerExploreWay>? = this.exploreWay
|
||||
if (!exploreWayList.isNullOrEmpty() && exploreWayList.isNotEmpty()) {
|
||||
for (markerExploreWay in exploreWayList) {
|
||||
if (isRoadEvent(markerExploreWay.poiType)) {
|
||||
val markerLocation = markerExploreWay.location
|
||||
l1.location = markerLocation
|
||||
l1.poiType = markerExploreWay.poiType
|
||||
l1.noveltyInfo = markerExploreWay
|
||||
l1.expireTime = 20000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils
|
||||
|
||||
@@ -24,8 +24,8 @@ class MapUtils {
|
||||
mBoundRect.right = WindowUtils.dip2px(context, 100f)
|
||||
// 当前车辆位置
|
||||
val carLocation = MogoLatLng(
|
||||
CallerAutoPilotStatusListenerManager.getCurWgs84Lat(),
|
||||
CallerAutoPilotStatusListenerManager.getCurWgs84Lon()
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude,
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude
|
||||
)
|
||||
// 调整自适应的地图镜头
|
||||
CallerMapUIServiceManager.getMapUIController()
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.marker
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.view
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.v2x.R
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.biz.R
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils
|
||||
import kotlinx.android.synthetic.main.view_marker_event_car.view.*
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,10 @@ import kotlinx.android.synthetic.main.view_marker_event_car.view.*
|
||||
*/
|
||||
class V2XMarkerRoadEventView(context: Context, alarmInfo: V2XRoadEventEntity) :
|
||||
ConstraintLayout(context) {
|
||||
val TAG = "V2XMarkerRoadEventView"
|
||||
|
||||
companion object{
|
||||
const val TAG = "V2XMarkerRoadEventView"
|
||||
}
|
||||
|
||||
init {
|
||||
initView(context, alarmInfo)
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.vip
|
||||
package com.mogo.eagle.function.biz.v2x.vip
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
@@ -14,21 +14,23 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
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.data.trafficlight.*
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isGreen
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isRed
|
||||
import com.mogo.eagle.core.data.v2x.VipMessage
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
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.trafficlight.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.vip.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.vip.network.VipNetWorkModel
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.function.biz.v2x.vip.network.VipNetWorkModel
|
||||
import com.zhjt.service_biz.BizConfig
|
||||
|
||||
class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListener,
|
||||
@@ -153,10 +155,8 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
MSG_WHAT_VIP_CANCEL,
|
||||
cancelDelayTime - System.currentTimeMillis()
|
||||
)
|
||||
CallerHmiManager.vipIdentification(true)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(true)
|
||||
CallerTrafficLightListenerManager.registerTrafficLightListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.registerEnterCrossRoadListener(TAG, this)
|
||||
CallerTrafficLightListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun cancelVip() {
|
||||
@@ -165,10 +165,8 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
handler.removeMessages(MSG_WHAT_VIP_CANCEL)
|
||||
}
|
||||
resetConditions()
|
||||
CallerHmiManager.vipIdentification(false)
|
||||
CallVipSetListenerManager.invokeVipSetStatus(false)
|
||||
CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG)
|
||||
CallerTrafficLightListenerManager.unRegisterEnterCrossRoadListener(TAG)
|
||||
CallerTrafficLightListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
private fun requestVip() {
|
||||
@@ -196,10 +194,9 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
|
||||
fun turnLight(controlTime: Int) {
|
||||
if (result == null || mContext == null) return
|
||||
val locationClient = CallerMapUIServiceManager.getSingletonLocationClient(mContext!!)
|
||||
if (locationClient != null) {
|
||||
val bearing =
|
||||
locationClient.lastKnowLocation.bearing.toDouble()
|
||||
val mogoLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (mogoLocation != null) {
|
||||
val bearing = mogoLocation.heading
|
||||
CallerLogger.d("$M_V2X$TAG", "-- turnLight -- ")
|
||||
MogoTrafficLightManager.INSTANCE.turnLightToGreen(
|
||||
result!!.lightId, result!!.crossId, bearing, controlTime,
|
||||
@@ -213,15 +210,13 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts
|
||||
)
|
||||
} else {
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts
|
||||
)
|
||||
}
|
||||
return@turnLightToGreen
|
||||
@@ -232,8 +227,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.content + ", 稍后重试",
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts,
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts
|
||||
)
|
||||
return@turnLightToGreen
|
||||
}
|
||||
@@ -253,8 +247,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.content + time,
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts,
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.poiType
|
||||
EventTypeEnumNew.TYPE_VIP_ERROR_IDENTIFICATION.tts
|
||||
)
|
||||
} else {
|
||||
CallerLogger.d(
|
||||
@@ -274,23 +267,14 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
v2xType: String,
|
||||
alertContent: CharSequence,
|
||||
ttsContent: String,
|
||||
tag: String
|
||||
) {
|
||||
if (alertContent.toString().isNullOrEmpty() || ttsContent.isNullOrEmpty()) {
|
||||
if (alertContent.toString().isEmpty() || ttsContent.isEmpty()) {
|
||||
Log.d("MsgBox-VipCarManager", "alertContent或ttsContent为空!")
|
||||
}
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(MsgBoxType.V2X, V2XMsg(v2xType, alertContent.toString(), ttsContent))
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
v2xType, alertContent, ttsContent, tag,
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {}
|
||||
override fun onDismiss() {}
|
||||
},
|
||||
true,
|
||||
5000L
|
||||
)
|
||||
CallerHmiManager.warningV2X(v2xType, alertContent, ttsContent)
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.v2x.vip.network
|
||||
package com.mogo.eagle.function.biz.v2x.vip.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.v2x.VipRequest
|
||||
@@ -7,7 +7,7 @@ import retrofit2.http.*
|
||||
interface VipApiService {
|
||||
|
||||
//查询是否为VIP车辆
|
||||
@GET("/dataService/carUser/getVipStatusBySn")
|
||||
@GET("eagle-eye-dns/dataService/carUser/getVipStatusBySn")
|
||||
suspend fun requestVip(@Query("sn") sn: String): BaseResponse<VipRequest>
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.mogo.eagle.core.function.v2x.vip.network
|
||||
package com.mogo.eagle.function.biz.v2x.vip.network
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.v2x.VipRequest
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.commons.constants.HostConst.DATA_SERVICE_HOST
|
||||
|
||||
|
||||
class VipNetWorkModel {
|
||||
|
||||
private fun getNetWorkApi(baseUrl: String = DATA_SERVICE_HOST): VipApiService {
|
||||
private fun getNetWorkApi(baseUrl: String = HostConst.getEagleHost()): VipApiService {
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
|
||||
.create(VipApiService::class.java)
|
||||
}
|
||||
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |