Merge branch 'dev_arch_opt_3.0' into dev_robosweeper-d_app-module_221230_1.1.0

# Conflicts:
#	OCH/mogo-och-sweeper/build.gradle
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/SweeperProvider.java
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/SweeperFragment.java
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperOrderModel.java
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java
#	OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java
#	OCH/mogo-och-sweeper/src/main/res/layout/sweeper_base_fragment.xml
This commit is contained in:
donghongyu
2023-02-08 14:40:42 +08:00
314 changed files with 5403 additions and 6632 deletions

View File

@@ -57,6 +57,7 @@ dependencies {
implementation rootProject.ext.dependencies.mogoaicloudtelematic
implementation rootProject.ext.dependencies.mogoobu
implementation rootProject.ext.dependencies.amapnavi3dmap
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogo_core_data

View File

@@ -4,6 +4,9 @@ import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.datacenter.IDataCenterProvider
import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher
import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher
import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher
@Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE)
class DataCenterProvider: IDataCenterProvider {
@@ -12,10 +15,16 @@ class DataCenterProvider: IDataCenterProvider {
get() = "DataCenterProvider"
override fun init(context: Context?) {
MoGoLocationDispatcher.initListener()
context?.let {
TrafficLightDispatcher.INSTANCE.initServer(it)
SpeedLimitDispatcher.INSTANCE.initLimit(it)
}
}
override fun onDestroy() {
TrafficLightDispatcher.INSTANCE.destroy()
SpeedLimitDispatcher.INSTANCE.destroy()
}
}

View File

@@ -21,7 +21,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LO
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.trafficlight.toTrafficLightDetail
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasListenerImpl
import com.mogo.eagle.core.function.datacenter.autopilot.adapter.MoGoAdasMsgConnectStatusListenerImpl
@@ -52,6 +52,7 @@ import com.zhidao.support.adas.high.OnMultiDeviceListener
import com.zhidao.support.adas.high.common.Constants
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS
import com.zhidao.support.adas.high.common.CupidLogUtils
import com.zhidao.support.adas.high.common.MessageType
import com.zhidao.support.adas.high.common.MogoReport
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants
@@ -67,8 +68,9 @@ import java.util.concurrent.TimeUnit
* @date 2021/9/22 8:43 下午
*/
@Route(path = MogoServicePaths.PATH_AUTO_PILOT)
class MoGoAutopilotProvider :
IMoGoAutopilotProvider, IMoGoMapDataCollectProvider.OnMapCollectCmdListener,
class MoGoAutopilotControlProvider :
IMoGoAutopilotControlProvider,
IMoGoMapDataCollectProvider.OnMapCollectCmdListener,
IMoGoAutopilotCarConfigListener {
private val TAG = "MoGoAutoPilotProvider"
private var mContext: Context? = null
@@ -104,6 +106,7 @@ class MoGoAutopilotProvider :
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
.setClient(false)
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
// .setSubscribeInterfaceOptions(subscribeInterfaceOptions)//
.build()
@@ -194,6 +197,7 @@ class MoGoAutopilotProvider :
val options = AdasOptions
.Builder()
.setClient(true)
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
.build()
AdasManager.getInstance()
.create(options, MoGoAdasMsgConnectStatusListenerImpl())
@@ -221,6 +225,7 @@ class MoGoAutopilotProvider :
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
.setClient(false)// 乘客端直连工控机改为false
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
.build()
AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl())
//////////////////////////////////注意先后顺序AdasManager.getInstance().create后才可以设置监听/////////////////////////////////////////////
@@ -716,7 +721,20 @@ class MoGoAutopilotProvider :
}
override fun sendSweeperFuTianTaskCmd(fuTianTaskCmd: SpecialVehicleTaskCmdOuterClass.RoboSweeperFuTianTaskCmd) {
Log.d(TAG, "---- sendSweeperFuTianTaskCmd ----")
AdasManager.getInstance().sendRoboSweeperFuTianTaskCmd(fuTianTaskCmd)
}
override fun setIsDrawPointCloud(isDrawPointCloud: Boolean) {
if (isDrawPointCloud) {
AdasManager.getInstance().subscribeInterface(
Constants.TERMINAL_ROLE.DRIVER,
Constants.SUBSCRIBE_TYPE.SUBSCRIBE,
MessageType.TYPE_RECEIVE_POINT_CLOUD)
} else {
AdasManager.getInstance().subscribeInterface(
Constants.TERMINAL_ROLE.DRIVER,
Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE,
MessageType.TYPE_RECEIVE_POINT_CLOUD)
}
}
}

View File

@@ -45,8 +45,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListen
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.CallerAutopilotStatisticsListenerManager.invokeAutopilotStatistics
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager.invokePNCActions
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager.invokeAutopilotRotting
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningTrajectoryListenerManager.invokeAutopilotTrajectory
@@ -61,7 +59,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.support.obu.ObuScene
import com.zhidao.support.adas.high.AdasManager
import com.zhidao.support.adas.high.OnAdasListener
import com.zhidao.support.adas.high.bean.AutopilotAbility
import com.zhidao.support.adas.high.bean.AutopilotStatistics
import com.zhidao.support.adas.high.common.ProtocolStatus
import com.zhjt.service.chain.ChainLog
@@ -135,10 +132,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
clientPkFileName = "sn"
)
override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo) {
// WGS84坐标系高精度位置信息
invokeChassisLocationWGS84(gnssInfo)
// GCJ02高德坐标系位置信息
invokeChassisLocationGCJ02(gnssInfo)
CallerChassisGnssListenerManager.invokeChassisGnssListener(gnssInfo)
if (gnssInfo != null) {
if (1 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
@@ -614,8 +609,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
* 是否可以启动自动驾驶
* 使用方法查看app_ipc_monitoring/uiMainActivity/onAutopilotAbility
*/
override fun onAutopilotAbility(ability: AutopilotAbility?) {
invokeAutopilotAbility(ability)
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
}
/**

View File

@@ -5,7 +5,7 @@ import com.mogo.commons.debug.DebugConfig.*
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
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.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
@@ -52,13 +52,13 @@ class MoGoAdasMsgConnectStatusListenerImpl :
// 同步SN给工控机
syncBasicInfoToAutopilot()
//每次工控机连接成功后,需同步当前设置的美化模式状态
CallerAutoPilotManager.setDemoMode(FunctionBuildConfig.isDemoMode)
CallerAutoPilotControlManager.setDemoMode(FunctionBuildConfig.isDemoMode)
//当连接状态是关闭美化模式时,同步给工控机
if (!FunctionBuildConfig.isDemoMode) {
CallerAutoPilotManager.setIPCDemoMode(FunctionBuildConfig.isDemoMode)
CallerAutoPilotControlManager.setIPCDemoMode(FunctionBuildConfig.isDemoMode)
}
//每次工控机连接成功后,需同步当前设置的雨天模式状态
CallerAutoPilotManager.setRainMode(FunctionBuildConfig.isRainMode)
CallerAutoPilotControlManager.setRainMode(FunctionBuildConfig.isRainMode)
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
CallerLogger.d("$M_ADAS_IMPL$TAG", "webSocket 连接失败 reason:$reason")
if (connectStatus) {

View File

@@ -1,9 +1,9 @@
package com.mogo.eagle.core.function.datacenter.autopilot.server
import com.mogo.eagle.core.data.trafficlight.TrafficLightResult
import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.api.v2x.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
/**
* @author xiaoyuzhou
@@ -26,6 +26,6 @@ class AsyncDataToAutopilotServer private constructor() : IMoGoTrafficLightListen
}
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
CallerAutoPilotManager.sendTrafficLightData(trafficLightResult)
CallerAutoPilotControlManager.sendTrafficLightData(trafficLightResult)
}
}

View File

@@ -8,9 +8,9 @@ import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.deva.chain.ChainConstant
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setDemoMode
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager.setIgnoreConditionDraw
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
@@ -174,7 +174,7 @@ class TeleMsgHandler : IMsgHandler {
private fun queryCarConfig() {
invokeNettyConnResult("乘客屏请求司机屏向工控机查询配置信息")
CallerAutoPilotManager.getCarConfig()
CallerAutoPilotControlManager.getCarConfig()
}
override fun handleClientConn2Server(channel: Channel?) {

View File

@@ -1,16 +0,0 @@
package com.mogo.eagle.core.function.datacenter.location
import com.mogo.eagle.core.data.enums.DataSourceType
import mogo.telematics.pad.MessagePad
/**
* 位置回调监听
*/
interface IMoGoLocationListener {
/**
* 位置改变回调用
* @param gnssInfo 位置信息
* @param sourceType 数据来源
*/
fun onLocationChanged(gnssInfo: MessagePad.GnssInfo, sourceType: DataSourceType)
}

View File

@@ -0,0 +1,263 @@
package com.mogo.eagle.core.function.datacenter.location
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.amap.api.location.AMapLocationListener
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
import com.mogo.eagle.core.utilcode.util.FileUtils
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.support.obu.model.MogoObuHvBasicsData
import mogo.telematics.pad.MessagePad
/**
* 融合定位服务,这里同时监听多来源的位置信息,并支持修改频率
*
* @author donghongyu
*/
object MoGoLocationDispatcher :
IMoGoChassisGnssListener,
IMoGoObuLocationWGS84Listener,
AMapLocationListener {
private val TAG = "MoGoLocationManager"
private var mCityCode: String? = null
private var mapLocation: AMapLocation? = null
/**
* 最后一次工控机GNSS返回更新的位置
*/
private var lastGnssLocation: MogoLocation = MogoLocation()
/**
* 最后一次OBU GNSS 返回更新的位置
*/
private var lastOBULocation: MogoLocation = MogoLocation()
/**
* 最后一次高德定位返回的位置信息
*/
private var lastGaoDeLocation: MogoLocation = MogoLocation()
fun initListener() {
// 高德SDK隐私政策
AMapLocationClient.updatePrivacyShow(Utils.getApp(), true, true)
AMapLocationClient.updatePrivacyAgree(Utils.getApp(), true)
try {
val mLocationClient = AMapLocationClient(Utils.getApp())
//初始化定位参数
//声明mLocationOption对象
val mLocationOption = AMapLocationClientOption()
//设置定位监听
mLocationClient.setLocationListener(this)
//设置定位模式为高精度模式Battery_Saving为低功耗模式Device_Sensors是仅设备模式
mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy
//设置定位间隔,单位毫秒,默认为2000ms
mLocationOption.interval = 1000
//设置定位参数
mLocationClient.setLocationOption(mLocationOption)
// 启动定位监听
mLocationClient.startLocation()
} catch (e: Exception) {
e.printStackTrace()
}
// 初始化监听订阅工控机位置信息
CallerChassisGnssListenerManager.addListener(TAG, this)
CallerObuLocationWGS84ListenerManager.addListener(TAG, this)
}
override fun onChassisGnss(gnssInfo: MessagePad.GnssInfo) {
// 更新GNSS 信息
lastGnssLocation.gnssInfo = gnssInfo
lastGnssLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastGnssLocation.cityName = it.city
lastGnssLocation.cityCode = it.cityCode
lastGnssLocation.provider = it.provider
lastGnssLocation.address = it.address
lastGnssLocation.district = it.district
lastGnssLocation.province = it.province
lastGnssLocation.adCode = it.adCode
lastGnssLocation.locationDetail = it.locationDetail
lastGnssLocation.poiName = it.poiName
lastGnssLocation.aoiName = it.aoiName
lastGnssLocation.street = it.street
lastGnssLocation.streetNum = it.streetNum
lastGnssLocation.description = it.description
lastGnssLocation.buildingId = it.buildingId
lastGnssLocation.floor = it.floor
lastGnssLocation.errorCode = it.errorCode
lastGnssLocation.errorInfo = it.errorInfo
}
//FileUtils.writeToFile("/sdcard/Download/", "location_wgs84.txt", "${gnssInfo.longitude},${gnssInfo.latitude}\n")
if (1 == FunctionBuildConfig.gpsProvider) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGnssLocation,
DataSourceType.TELEMATIC
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
lastGnssLocation,
DataSourceType.TELEMATIC
)
}
}
/**
* 高德地图位置改变回调
* @param aMapLocation 位置信息
*/
override fun onLocationChanged(aMapLocation: AMapLocation) {
mapLocation = aMapLocation
// 更新GNSS 信息
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
// 转换 GCJ02-->WGS84 坐标
val wgs84Location =
CoordinateTransform.GCJ02ToWGS84(it.longitude, it.latitude)
lastGaoDeLocation.longitude = wgs84Location[0]
lastGaoDeLocation.latitude = wgs84Location[1]
lastGaoDeLocation.heading = it.bearing.toDouble()
lastGaoDeLocation.gnssSpeed = it.speed
lastGaoDeLocation.altitude = it.altitude
lastGaoDeLocation.satelliteTime = it.time
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
lastGaoDeLocation.cityName = it.city
lastGaoDeLocation.cityCode = it.cityCode
lastGaoDeLocation.provider = it.provider
lastGaoDeLocation.address = it.address
lastGaoDeLocation.district = it.district
lastGaoDeLocation.province = it.province
lastGaoDeLocation.adCode = it.adCode
lastGaoDeLocation.locationDetail = it.locationDetail
lastGaoDeLocation.poiName = it.poiName
lastGaoDeLocation.aoiName = it.aoiName
lastGaoDeLocation.street = it.street
lastGaoDeLocation.streetNum = it.streetNum
lastGaoDeLocation.description = it.description
lastGaoDeLocation.buildingId = it.buildingId
lastGaoDeLocation.floor = it.floor
lastGaoDeLocation.errorCode = it.errorCode
lastGaoDeLocation.errorInfo = it.errorInfo
}
// 计算最后一次工控机同步的定位是否超时,如果超时则切换为高德地图定位,暂定超过30秒需要切换
if (1 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 30000) {
syncGaoDeLocation()
}
} else if (2 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastOBULocation.lastReceiveTime > 30000) {
syncGaoDeLocation()
}
}
// 本地SP缓存城市Code
val cityCode = aMapLocation.cityCode
if (cityCode != null && cityCode.isNotEmpty()) {
mCityCode = aMapLocation.cityCode
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LATITUDE,
aMapLocation.latitude.toString()
)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LONGITUDE,
aMapLocation.longitude.toString()
)
}
}
/**
* 对外同步高德回掉的定位数据
*/
private fun syncGaoDeLocation() {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGaoDeLocation,
DataSourceType.MAP
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
lastGaoDeLocation,
DataSourceType.MAP
)
}
/**
* OBU定位回调监听
*/
override fun onObuLocationWGS84(data: MogoObuHvBasicsData) {
// 更新GNSS 信息
lastOBULocation.longitude = data.vehBasicsMsg.longitude
lastOBULocation.latitude = data.vehBasicsMsg.latitude
lastOBULocation.heading = data.vehBasicsMsg.heading
lastOBULocation.gnssSpeed = data.vehBasicsMsg.speed.toFloat()
lastOBULocation.altitude = data.vehBasicsMsg.elevation
lastOBULocation.satelliteTime = data.vehBasicsMsg.secMark
lastOBULocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastOBULocation.cityName = it.city
lastOBULocation.cityCode = it.cityCode
lastOBULocation.provider = it.provider
lastOBULocation.address = it.address
lastOBULocation.district = it.district
lastOBULocation.province = it.province
lastOBULocation.adCode = it.adCode
lastOBULocation.locationDetail = it.locationDetail
lastOBULocation.poiName = it.poiName
lastOBULocation.aoiName = it.aoiName
lastOBULocation.street = it.street
lastOBULocation.streetNum = it.streetNum
lastOBULocation.description = it.description
lastOBULocation.buildingId = it.buildingId
lastOBULocation.floor = it.floor
lastOBULocation.errorCode = it.errorCode
lastOBULocation.errorInfo = it.errorInfo
}
if (2 == FunctionBuildConfig.gpsProvider) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastOBULocation,
DataSourceType.OBU
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
lastOBULocation,
DataSourceType.OBU
)
}
}
}

View File

@@ -1,71 +0,0 @@
package com.mogo.eagle.core.function.datacenter.location
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.base.CallerBase
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.support.obu.model.MogoObuHvBasicsData
import mogo.telematics.pad.MessagePad
/**
* 融合定位服务,这里同时监听多来源的位置信息,并支持修改频率
*
* @author donghongyu
*/
object MoGoLocationManager :
CallerBase<IMoGoLocationListener>(),
IMoGoChassisLocationWGS84Listener,
IMoGoObuLocationWGS84Listener {
private val TAG = "MoGoLocationManager"
init {
CallerChassisLocationWGS84ListenerManager.addListener(TAG, this)
}
override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo) {
M_LISTENERS.forEach {
val tag = it.key
// 获取数据监听需要的HZ
val hz = M_LISTENERS_HZ[tag]
if (hz != null && hz > 0) {
val hzTime = (1.0 / hz.toDouble()) * 1000
// 获取最后一次回调的时间
val hzLastSendTime = M_LISTENERS_HZ_LAST_SEND_TIME[tag]
if (hzLastSendTime != null && hzLastSendTime > 0) {
// 计算是否进入下一次回调周期
val nowTime = TimeUtils.getNowMills()
if (nowTime - hzLastSendTime > hzTime) {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
} else {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
} else {
syncLocationCallback(tag, it, gnssInfo, DataSourceType.TELEMATIC)
}
}
}
/**
* 向订阅位置信息的发出定位信息
*/
private fun syncLocationCallback(
tag: String,
it: Map.Entry<String, IMoGoLocationListener>,
gnssInfo: MessagePad.GnssInfo,
sourceType: DataSourceType
) {
// 记录最后一次回调时间
M_LISTENERS_HZ_LAST_SEND_TIME[tag] = TimeUtils.getNowMills()
val listener = it.value
listener.onLocationChanged(gnssInfo, sourceType)
}
override fun onObuLocationWGS84(data: MogoObuHvBasicsData) {
}
}

View File

@@ -3,15 +3,20 @@
##### 位置回调融合工控机、OBU、高德地图
```kotlin
// 注册监听位置变换
MoGoLocationManager.addListener(Companion.functionName, object : IMoGoLocationListener {
override fun onLocationChanged(
gnssInfo: MessagePad.GnssInfo,
sourceType: DataSourceType
) {
// 注册监听位置变换,唯一标记要接受数据的HZ回掉监听
CallerChassisLocationWGS84ListenerManager.addListener(Companion.functionName, 20,object :IMoGoChassisLocationWGS84Listener{
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
TODO("Not yet implemented")
}
})
// 设置数据回调频率单位HZ1HZ的周期是1秒50HZ的周期是1/50=0.02秒10HZ的周期是1/10=0.1秒。
MoGoLocationManager.setListenerHz(Companion.functionName, 20)
CallerChassisLocationWGS84ListenerManager.setListenerHz(Companion.functionName, 20)
// 注册监听位置变换,唯一标记要接受数据的HZ回掉监听
CallerChassisLocationGCJ20ListenerManager.addListener(Companion.functionName, 20,object :IMoGoChassisLocationGCJ02Listener{
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation) {
TODO("Not yet implemented")
}
})
```

View File

@@ -36,6 +36,7 @@ class MoGoObuProvider : IMoGoObuProvider {
//obu融合数据
MogoObuDcCombineManager.INSTANCE.init(context)
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress())
//bus乘客版本obu功能去掉
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
&& AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)

View File

@@ -2,26 +2,30 @@ package com.mogo.eagle.core.function.datacenter.obu
import android.content.Context
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.enums.TrafficLightEnum
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
import com.mogo.eagle.core.data.msgbox.MsgBoxType
import com.mogo.eagle.core.data.msgbox.V2XMsg
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.api.obucombine.IMoGoObuDcCombineListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuWarningMapListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuWarningRsiListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuWarningRsmListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuWarningSpatListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.obucombine.CallerObuDcCombineListenerManager
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuMapMathListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningRsiListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningRsmListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuWarningSpatListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
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_OBU
import com.mogo.support.obu.ObuScene
import com.mogo.support.obu.constants.MogoObuConstants
import mogo.v2x.ObuWarningEvent
import mogo.v2x.ObuWarningEvent.*
import kotlin.math.roundToInt
@@ -31,7 +35,8 @@ import kotlin.math.roundToInt
* @since 2021/11/30
* @description 工控机融合数据
*/
class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener {
class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener,
IMoGoObuWarningRsmListener, IMoGoObuWarningMapListener, IMoGoObuWarningSpatListener {
companion object {
val INSTANCE: MogoObuDcCombineManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
MogoObuDcCombineManager()
@@ -44,49 +49,40 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
fun init(context: Context) {
mContext = context
CallerObuDcCombineListenerManager.addListener(TAG, this)
CallerObuWarningRsiListenerManager.addListener(TAG, this)
CallerObuWarningRsmListenerManager.addListener(TAG, this)
CallerObuMapMathListenerManager.addListener(TAG, this)
CallerObuWarningSpatListenerManager.addListener(TAG, this)
}
fun destoryListener() {
CallerObuDcCombineListenerManager.removeListener(TAG)
CallerObuWarningRsiListenerManager.removeListener(TAG)
CallerObuWarningRsmListenerManager.removeListener(TAG)
CallerObuMapMathListenerManager.removeListener(TAG)
CallerObuWarningSpatListenerManager.removeListener(TAG)
}
/**
* 通过工控机中转的obu数据,包括rsirsmspat
*
*/
override fun onMoGoObuDcCombineData(obuWarningData: ObuWarningEvent.ObuWarningData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMoGoObuDcCombineData obuWarningData = ${obuWarningData.toString()} ---obuWarningData.msgDataType = ${obuWarningData?.msgDataType}"
)
obuWarningData?.let {
when (obuWarningData.msgDataType) {
1 -> { //rsiEvent
onMogoObuDcRsiWarning(obuWarningData.rsiEvent)
}
2 -> { //RsmEvent
onMogoObuDcRsmWarning(obuWarningData.rsmEvent)
}
3 -> { //SpatEvent
onMogoObuDcSpatWarning(obuWarningData.spatEvent)
}
4 -> { //map
onMogoObuMapMath(obuWarningData.mapMatchData)
}
}
}
override fun onMoGoObuRsiWarning(rsiWarningData: ObuScene.RsiWarningData) {
onMogoObuDcRsiWarning(rsiWarningData)
}
override fun onMoGoObuRsmWarning(rsmWarningData: ObuScene.RsmWarningData) {
onMogoObuDcRsmWarning(rsmWarningData)
}
override fun onMoGoObuSpatWarning(spatWarningData: ObuScene.SpatWarningData) {
onMogoObuDcSpatWarning(spatWarningData)
}
override fun onMoGoObuMapMath(mapMatchData: ObuScene.MapMatchData) {
onMogoObuMapMath(mapMatchData)
}
/**
* RSI预警信息 CvxRtiThreatIndInfo交通标志预警前方限速、前方学校等等交通事件预警前方拥堵、前方积水等等
*/
fun onMogoObuDcRsiWarning(rsiWarningData: RsiWarningData?) {
private fun onMogoObuDcRsiWarning(rsiWarningData: ObuScene.RsiWarningData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsiWarning ------> ${rsiWarningData.toString()}"
@@ -98,7 +94,8 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
val status = rsiWarningData.status
val level = rsiWarningData.warningMsgList[0].warningLevel
val direction = getMessageDirection(rsiWarningData.warningMsgList[0].targetPosition)
CallerLogger.d("${M_OBU}${TAG}",
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuDcRsiWarning appId = $appId --status = $status --level = $level -- eventSerialNum = ${rsiWarningData.warningMsgList[0].eventSerialNum} ---signSerialNum = ${rsiWarningData.warningMsgList[0].signSerialNum} --- direction = $direction -- targetPosition = ${rsiWarningData.warningMsgList[0].targetPosition}"
)
@@ -259,8 +256,6 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
when (status) {
// 添加
MogoObuConstants.STATUS.ADD -> {
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
@@ -276,16 +271,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
CallerHmiManager.warningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
},
true,
5000L
ttsContent, null, direction
)
// 更新数据,是否需要
@@ -301,9 +287,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
// CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
CallerHmiManager.disableWarningV2X((appId + direction.direction))
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据,删除标牌?
// TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(rsiWarningData)
// ?.let {
@@ -320,22 +304,22 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
/**
* RSM预警信息 CvxPtcThreatIndInfo CvxPtcInfoIndInfo主车与弱势交通参与者之间的预警弱势交通参与者碰撞预警
*/
fun onMogoObuDcRsmWarning(rsmWarningData: RsmWarningData?) {
fun onMogoObuDcRsmWarning(rsmWarningData: ObuScene.RsmWarningData?) {
if (HmiBuildConfig.isShowObuWeaknessTrafficView) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsmWarning ------> ${rsmWarningData.toString()}"
)
// 交通参与者类型 0x0:未知 UNKNOWN | 1机动车 2:非机动车 NON_MOTOR | 3:行人 PEDESTRIAN 4:obu
if (rsmWarningData != null && rsmWarningData.participantOfOne != null) {
if (rsmWarningData != null && rsmWarningData.participant != null) {
var v2xType = ""
if (rsmWarningData.participantOfOne.ptcType == 1) { //机动车
if (rsmWarningData.participant.ptcType == 1) { //机动车
v2xType =
EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType
} else if (rsmWarningData.participantOfOne.ptcType == 2) { //非机动车
} else if (rsmWarningData.participant.ptcType == 2) { //非机动车
v2xType =
EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType
} else if (rsmWarningData.participantOfOne.ptcType == 3) { //行人
} else if (rsmWarningData.participant.ptcType == 3) { //行人
v2xType =
EventTypeEnumNew.TYPE_USECASE_ID_VRUCW_PERSON.poiType
} else { //未知
@@ -346,25 +330,25 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
EventTypeEnumNew.getWarningContent(v2xType)
var level = -1
val direction =
getMessageDirection(rsmWarningData.participantOfOne.targetPosition) //TODO 只有一个
getMessageDirection(rsmWarningData.participant.targetPosition) //TODO 只有一个
if (rsmWarningData.warningMsg != null && rsmWarningData.warningMsg.warningDataList != null && rsmWarningData.warningMsg.warningDataList.size > 0) {
level = rsmWarningData.warningMsg.warningDataList[0].warningLevel
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuRsmWarning ---status---> ${rsmWarningData.status} --list status----> ${rsmWarningData.warningMsg.warningDataList.get(0).status} --v2xType--- $v2xType ---alertContent = $alertContent ---ttsContent= $ttsContent"
"ObuDcCombineManager onObuRsmWarning ---status---> ${rsmWarningData.status} --list status----> ${
rsmWarningData.warningMsg.warningDataList[0].status
} --v2xType--- $v2xType ---alertContent = $alertContent ---ttsContent= $ttsContent"
)
when (rsmWarningData.warningMsg.warningDataList.get(0).status) {
when (rsmWarningData.warningMsg.warningDataList[0].status) {
MogoObuConstants.STATUS.ADD -> { // 添加
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
v2xType,
alertContent,
ttsContent
ttsContent,
)
).apply {
sourceType = DataSourceType.TELEMATIC
@@ -373,18 +357,9 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
CallerHmiManager.warningV2X(
v2xType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(v2xType + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(
WarningDirectionEnum.ALERT_WARNING_NON
)
}
},
true,
5000L
ttsContent,
null,
direction
)
// 更新数据 TODO
@@ -401,7 +376,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
// 更新数据 TODO 由于obu通过域控需要转换单位这里临时转换后面3.0不需要转换
// TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)?.let {
// // 事件结束,还原交通参与者颜色
@@ -412,7 +387,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
// }
//删除弱势交通元素
CallerMapUIServiceManager.getMarkerService()
?.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString())
?.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
// TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participantOfOne.ptcID.toString())
}
}
@@ -425,8 +400,11 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
/**
* 红绿灯预警信息
*/
fun onMogoObuDcSpatWarning(spatWarningData: SpatWarningData?) {
CallerLogger.d("${M_OBU}${TAG}", "onMogoObuDcSpatWarning warningType = ${spatWarningData!!.warningType} --status = ${spatWarningData?.status} --lightsList = ${spatWarningData.lightsList}")
fun onMogoObuDcSpatWarning(spatWarningData: ObuScene.SpatWarningData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"onMogoObuDcSpatWarning warningType = ${spatWarningData!!.warningType} --status = ${spatWarningData?.status} --lightsList = ${spatWarningData.lightsList}"
)
handlerTrafficLight(
spatWarningData!!.warningType,
spatWarningData?.status,
@@ -437,23 +415,37 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
/**
* 地图匹配 是OBU算法输出地图匹配结果主车匹配道路哪条路或者哪条车道
*/
fun onMogoObuMapMath(data: MapMatchData?) {
CallerLogger.d("${M_OBU}${TAG}", "MogoObuDcCombineManager onMogoObuMapMath HmiBuildConfig.isShowObuLimitSpeedView = " + HmiBuildConfig.isShowObuLimitSpeedView)
if(HmiBuildConfig.isShowObuLimitSpeedView) {
fun onMogoObuMapMath(data: ObuScene.MapMatchData?) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuMapMath HmiBuildConfig.isShowObuLimitSpeedView = " + HmiBuildConfig.isShowObuLimitSpeedView
)
if (HmiBuildConfig.isShowObuLimitSpeedView) {
if (data != null) {
CallerLogger.d("${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${Math.round((data.speedMaxLimit*0.02*3.6))} --- data.speedMaxLimit = ${data.speedMaxLimit}")
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${
Math.round(
(data.speedMaxLimit * 0.02 * 3.6)
)
} --- data.speedMaxLimit = ${data.speedMaxLimit}"
)
when (data.status) {
MogoObuConstants.STATUS.ADD -> { // 添加 TODO
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
(data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(),DataSourceType.OBU)
CallerLimitingVelocityListenerManager.invokeUnion(
(data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(),
DataSourceType.OBU
)
}
MogoObuConstants.STATUS.UPDATE -> { // 更新
}
MogoObuConstants.STATUS.DELETE -> { // 删除
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(-1 ,DataSourceType.OBU)
CallerLimitingVelocityListenerManager.invokeUnion(
-1,
DataSourceType.OBU
)
}
}
}
@@ -496,7 +488,11 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
/**
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<ObuWarningEvent.SpatLight>) {
private fun handlerTrafficLight(
appId: Int,
status: Int,
lights: List<com.mogo.support.obu.ObuBase.SpatLight>
) {
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
@@ -514,15 +510,12 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗,当收不到信号的时候触发一次
CallerTrafficLightListenerManager.disableTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
isShowGreenWave = false
isShowRunRedLight = false
}
}
}
private var isRedLight = false
private var isGreenLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
@@ -532,7 +525,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
@Synchronized
private fun changeTrafficLightStatus(
appId: Int,
lights: List<ObuWarningEvent.SpatLight>
lights: List<com.mogo.support.obu.ObuBase.SpatLight>
) {
var ttsContent = ""
var alertContent = ""
@@ -551,10 +544,14 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
1 -> { //闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
if (!isShowRunRedLight) {
isShowRunRedLight = true
CallerHmiManager.disableWarningV2X(1667.toString())
ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
CallerLogger.d("${M_OBU}${TAG}","MogoObuDcCombineManager changeTrafficLightStatus 闯红灯 --------> ttsContent = $ttsContent ---alertContent = $alertContent ")
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager changeTrafficLightStatus 闯红灯 --------> ttsContent = $ttsContent ---alertContent = $alertContent "
)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
@@ -569,22 +566,32 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, alertContent, ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType, null, true, 5000L)
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次
if (!isShowGreenWave) {
isShowGreenWave = true
CallerHmiManager.disableWarningV2X(1666.toString())
CallerLogger.d(
"${M_OBU}${TAG}",
"MogoObuDcCombineManager 绿波通行引导 --------> speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}")
"MogoObuDcCombineManager 绿波通行引导 --------> speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}"
)
val adviceSpeed =
"${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}"
"${Math.round(currentLight.suggestMinSpeed * 3.6 * 0.02)} - ${
Math.round(
currentLight.suggestMaxSpeed * 3.6 * 0.02
)
}"
val adviceSpeedTts =
"${Math.round(currentLight.suggestMinSpeed*3.6*0.02)} - ${Math.round(currentLight.suggestMaxSpeed*3.6*0.02)}"
"${Math.round(currentLight.suggestMinSpeed * 3.6 * 0.02)} - ${
Math.round(
currentLight.suggestMaxSpeed * 3.6 * 0.02
)
}"
ttsContent =
String.format(
@@ -596,7 +603,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeed
)
val maxSpeed = currentLight.suggestMaxSpeed*3.6
val maxSpeed = currentLight.suggestMaxSpeed * 3.6
if (maxSpeed > 0) {
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
@@ -610,15 +617,10 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
sourceType = DataSourceType.TELEMATIC
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
null,
true,
5000L
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
@@ -628,39 +630,38 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.BLACK, DataSourceType.TELEMATIC)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.BLACK,
-1,
DataSourceType.TELEMATIC
)
}
// 红灯
2, 3 -> {
if (!isRedLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isRedLight = true
}
isGreenLight = false
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.RED, DataSourceType.TELEMATIC)
val red = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownRed(red)
val red = (currentLight.countDown / 10).toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.RED,
red,
DataSourceType.TELEMATIC
)
}
// 绿灯
4, 5, 6 -> {
if (!isGreenLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isGreenLight = true
}
isRedLight = false
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.GREEN, DataSourceType.TELEMATIC)
val green = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownGreen(green)
val green = (currentLight.countDown / 10).toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.GREEN,
green,
DataSourceType.TELEMATIC
)
}
// 黄灯
7, 8 -> {
CallerHmiManager.disableWarningV2X(appId.toString())
CallerTrafficLightListenerManager.showTrafficLight(TrafficLightEnum.YELLOW, DataSourceType.TELEMATIC)
val yellow = currentLight.countDown / 10
CallerTrafficLightListenerManager.changeCountdownYellow(yellow)
val yellow = (currentLight.countDown / 10).toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.YELLOW,
yellow,
DataSourceType.TELEMATIC
)
}
}
}

View File

@@ -16,8 +16,9 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Defa
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
@@ -31,7 +32,6 @@ import com.mogo.support.obu.model.*
import com.mogo.support.obu.model.advance.SpatLight
import com.mogo.support.obu.option.MogoObuCom
import com.mogo.support.obu.option.MogoObuOptions
import org.json.JSONObject
import kotlin.math.roundToInt
/**
@@ -107,45 +107,22 @@ class MogoPrivateObuNewManager private constructor() {
/**
* HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo
*/
override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) {
if (p0 != null && p0.vehBasicsMsg != null) {
override fun onMogoObuHvBasics(mogoObuHvBasicsData: MogoObuHvBasicsData?) {
if (mogoObuHvBasicsData != null && mogoObuHvBasicsData.vehBasicsMsg != null) {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"onMogoObuHvBasics lon = ${p0.vehBasicsMsg.longitude} --- lat = ${p0.vehBasicsMsg.latitude} ---speed = ${p0.vehBasicsMsg.speed} ---heading = ${p0.vehBasicsMsg.heading} --acceleration = ${p0.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${p0.vehBasicsMsg.accFourAxes.accYaw}"
"onMogoObuHvBasics lon = ${mogoObuHvBasicsData.vehBasicsMsg.longitude} --- lat = ${mogoObuHvBasicsData.vehBasicsMsg.latitude} ---speed = ${mogoObuHvBasicsData.vehBasicsMsg.speed} ---heading = ${mogoObuHvBasicsData.vehBasicsMsg.heading} --acceleration = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accYaw}"
)
val data = JSONObject()
try {
data.putOpt("lon", p0.vehBasicsMsg.longitude)
data.putOpt("lat", p0.vehBasicsMsg.latitude)
data.putOpt("speed", p0.vehBasicsMsg.speed)
data.putOpt("heading", p0.vehBasicsMsg.heading)
data.putOpt("acceleration", p0.vehBasicsMsg.accFourAxes.accLat)
data.putOpt("yawRate", p0.vehBasicsMsg.accFourAxes.accYaw)
try {
data.putOpt("systemTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("satelliteTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
p0.vehBasicsMsg.longitude,
p0.vehBasicsMsg.latitude
)
}
} catch (e: Exception) {
e.printStackTrace()
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(mogoObuHvBasicsData)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
mogoObuHvBasicsData.vehBasicsMsg.longitude,
mogoObuHvBasicsData.vehBasicsMsg.latitude
)
}
}
}
@@ -410,15 +387,7 @@ class MogoPrivateObuNewManager private constructor() {
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
},
true,
5000L
null, direction
)
// 更新数据
@@ -554,8 +523,6 @@ class MogoPrivateObuNewManager private constructor() {
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
return
}
//显示警告红边
CallerHmiManager.showWarning(direction)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
@@ -573,17 +540,7 @@ class MogoPrivateObuNewManager private constructor() {
v2xType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(v2xType + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(
WarningDirectionEnum.ALERT_WARNING_NON
)
}
},
true,
5000L
null, direction
)
}
@@ -592,7 +549,7 @@ class MogoPrivateObuNewManager private constructor() {
MogoObuConstants.STATUS.DELETE -> { // 删除
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
//删除弱势交通元素
CallerMapUIServiceManager.getMarkerService()
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
@@ -618,7 +575,7 @@ class MogoPrivateObuNewManager private constructor() {
MogoObuConstants.STATUS.ADD -> { // 添加
UiThreadHandler.post {
if (data.speedMaxLimit > 0) {
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
CallerLimitingVelocityListenerManager.invokeUnion(
(data.speedMaxLimit * 3.6).roundToInt(), DataSourceType.OBU
)
}
@@ -630,7 +587,7 @@ class MogoPrivateObuNewManager private constructor() {
MogoObuConstants.STATUS.DELETE -> { // 删除
UiThreadHandler.post {
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
CallerLimitingVelocityListenerManager.invokeUnion(
-1,
DataSourceType.OBU
)
@@ -844,7 +801,6 @@ private fun handleSdkObu(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
@@ -854,18 +810,12 @@ private fun handleSdkObu(
}
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(Default())
}
}
},
true,
5000L
}, direction
)
//显示警告红边
CallerHmiManager.showWarning(direction)
}
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 UUID不需要匹配了
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
@@ -876,9 +826,7 @@ private fun handleSdkObu(
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
// CallerHmiManager.disableWarningV2X((appId + direction.direction))
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
it.threatLevel = 0x01
@@ -910,10 +858,8 @@ private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
CallerTrafficLightListenerManager.disableTrafficLight()
CallerHmiManager.disableWarningV2X(appId.toString())
isShowGreenWave = false
isShowRunRedLight = false
isYellowLight = false
// lightCountDownRed = 1
// lightCountDownGreen = 1
// lightCountDownYellow = 1
@@ -921,16 +867,9 @@ private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>
}
}
private var isRedLight = false
private var isGreenLight = false
private var isYellowLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
// private var lightCountDownRed : Int = 1
// private var lightCountDownGreen : Int = 1
// private var lightCountDownYellow : Int = 1
/**
* 修改红绿灯
@@ -956,7 +895,6 @@ private fun changeTrafficLightStatus(
1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
if (!isShowRunRedLight) {
isShowRunRedLight = true
CallerHmiManager.disableWarningV2X(1667.toString())
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"changeTrafficLightStatus 闯红灯 --------> "
@@ -981,11 +919,7 @@ private fun changeTrafficLightStatus(
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
null,
true,
5000L
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
@@ -993,7 +927,6 @@ private fun changeTrafficLightStatus(
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候
if (!isShowGreenWave) {
isShowGreenWave = true
CallerHmiManager.disableWarningV2X(1666.toString())
var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6)
var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6)
@@ -1034,15 +967,10 @@ private fun changeTrafficLightStatus(
sourceType = DataSourceType.OBU
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
null,
true,
5000L
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
@@ -1052,42 +980,38 @@ private fun changeTrafficLightStatus(
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.BLACK,
-1,
DataSourceType.OBU
)
}
// 红灯
2, 3 -> {
if (!isRedLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isRedLight = true
}
isGreenLight = false
isYellowLight = false
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED)
val red = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.RED,
red,
DataSourceType.OBU
)
}
// 绿灯
4, 5, 6 -> {
if (!isGreenLight) {
CallerHmiManager.disableWarningV2X(appId.toString())
isGreenLight = true
}
isRedLight = false
isYellowLight = false
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN)
val green = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.GREEN,
green,
DataSourceType.OBU
)
}
// 黄灯
7, 8 -> {
if (!isYellowLight) {
isYellowLight = true
}
isRedLight = false
isGreenLight = false
CallerHmiManager.disableWarningV2X(appId.toString())
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW)
val yellow = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.YELLOW,
yellow,
DataSourceType.OBU
)
}
}
}

View File

@@ -0,0 +1,62 @@
package com.mogo.eagle.core.function.datacenter.v2x
import android.content.Context
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.function.api.v2x.ILimitingVelocityListener
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
/**
* @author lixiaopeng
* @description 对多个限速进行调度maprsu ...
* @since: 2023/1/12
*/
class SpeedLimitDispatcher : ILimitingVelocityListener {
companion object {
const val TAG = "SpeedLimitDispatcher"
val INSTANCE: SpeedLimitDispatcher by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
SpeedLimitDispatcher()
}
}
private var mContext: Context? = null
//obu限速状态
private var hasObuStatus: Boolean = false
fun initLimit(context: Context) {
mContext = context
CallerLimitingVelocityListenerManager.addListener(TAG, this)
}
/**
* 地图限速数据
*/
// @BizConfig(FuncBizConfig.V2I, "", FuncBizConfig.BIZ_SLW) //todo arrow 重新考虑放的位置
override fun onUnion(limitingVelocity: Int, sourceType: DataSourceType) {
super.onUnion(limitingVelocity, sourceType)
when (sourceType) { // obu 优先级高于 map体现链路能力
DataSourceType.OBU -> {
hasObuStatus = limitingVelocity > 0
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
limitingVelocity,
sourceType
)
return
}
DataSourceType.MAP -> {
if (!hasObuStatus) {
CallerLimitingVelocityListenerManager.invokeOnLimitingVelocityChange(
limitingVelocity,
sourceType
)
}
}
else -> {}
}
}
fun destroy() {
CallerLimitingVelocityListenerManager.removeListener(TAG)
}
}

View File

@@ -0,0 +1,185 @@
package com.mogo.eagle.core.function.datacenter.v2x
import android.content.Context
import android.os.Handler
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.enums.TrafficLightEnum
import com.mogo.eagle.core.data.trafficlight.*
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.v2x.IMoGoTrafficLightListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import perception.TrafficLightOuterClass
import perception.TrafficLightOuterClass.TrafficLight
fun TrafficLightStatus.convert(): TrafficLightEnum {
return when {
this.isGreen() || this.isFlashGreen() -> TrafficLightEnum.GREEN
this.isYellow() -> TrafficLightEnum.YELLOW
this.isRed() -> TrafficLightEnum.RED
else -> TrafficLightEnum.BLACK
}
}
fun TrafficLight.convert(): TrafficLightEnum {
return when (this.state) {
TrafficLightOuterClass.LightState.STATE_GREEN -> TrafficLightEnum.GREEN
TrafficLightOuterClass.LightState.STATE_YELLOW -> TrafficLightEnum.YELLOW
TrafficLightOuterClass.LightState.STATE_RED -> TrafficLightEnum.RED
TrafficLightOuterClass.LightState.STATE_OFF -> TrafficLightEnum.BLACK
else -> TrafficLightEnum.BLACK
}
}
/**
* @author XuXinChao
* @description 对多个红绿灯信号来源进行统一调度AI云、工控机、OBU
* @优先级OBU,云,工控
* @since: 2022/4/28
*/
class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener {
companion object {
const val TAG = "TrafficLightDispatcher"
val INSTANCE: TrafficLightDispatcher by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
TrafficLightDispatcher()
}
}
private var mContext: Context? = null
//是否有AI获取红绿灯灯态
private var hasAiLightStatus: Boolean = false
//obu数据
private var hasObuLightStatus: Boolean = false
fun initServer(context: Context) {
mContext = context
//注册监听AI云.OBU路侧获取红绿灯状态
CallerTrafficLightListenerManager.addListener(TAG, this)
//注册监听工控机感知红绿灯
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
}
/**
* 工控机感知红绿灯
* @param trafficLights 感知红绿灯
*/
override fun onAutopilotPerceptionTrafficLight(trafficLights: TrafficLightOuterClass.TrafficLights?) {
if (!hasObuLightStatus) {
if (!hasAiLightStatus) {
trafficLights?.let { it ->
var light: TrafficLight? = null
if (it.hasStraight()) {
light = it.straight
} else if (it.hasLeft()) {
light = it.left
} else if (it.hasRight()) {
light = it.right
} else if (it.hasUTurn()) {
light = it.uTurn
}
if (light == null) {
//隐藏红绿灯显示
CallerTrafficLightListenerManager.disableTrafficLight()
} else {
onTrafficLightPlusSource(light.convert(), 0, DataSourceType.TELEMATIC)
}
}
}
}
}
/**
* AI云获取红绿灯状态
*/
override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) {
if (!hasObuLightStatus) {
hasAiLightStatus = true
updateTrafficLight(trafficLightResult)
}
}
/**
* 车辆进入路口回调
* @param enter true:进入路口false:离开路口
*/
override fun onEnterCrossRoad(enter: Boolean) {
if (!enter) {
Handler().postDelayed({
hasAiLightStatus = false
hasObuLightStatus = false
}, 5000)
//如果没有OBU灯态则进行隐藏如果有OBU灯态则交由OBU管理
CallerTrafficLightListenerManager.resetTrafficLightStatus(!hasObuLightStatus)
}
}
/**
* 红绿灯接口请求失败
*/
override fun onTrafficRequestError() {
hasAiLightStatus = false
CallerTrafficLightListenerManager.resetTrafficLightStatus(!hasObuLightStatus)
}
/**
* obu 红绿灯数据
*/
override fun onTrafficLightPlusSource(
light: TrafficLightEnum,
remain: Int,
lightSource: DataSourceType
) {
super.onTrafficLightPlusSource(light, remain, lightSource)
if (lightSource == DataSourceType.OBU) {
hasObuLightStatus = true //todo 会存在优先级高的数据没有回调,导致没有数据出现
}
CallerTrafficLightListenerManager.showTrafficLight(light, lightSource)
if (remain == -1) {
CallerTrafficLightListenerManager.disableTrafficLightCountDown()
return
}
when (light) {
TrafficLightEnum.GREEN -> {
CallerTrafficLightListenerManager.changeCountdownGreen(remain)
}
TrafficLightEnum.RED -> {
CallerTrafficLightListenerManager.changeCountdownRed(remain)
}
TrafficLightEnum.YELLOW -> {
CallerTrafficLightListenerManager.changeCountdownYellow(remain)
}
TrafficLightEnum.BLACK -> {
CallerTrafficLightListenerManager.disableTrafficLightCountDown()
}
}
}
private fun updateTrafficLight(trafficLightResult: TrafficLightResult) {
val currentTrafficLight = trafficLightResult.currentRoadTrafficLight()
currentTrafficLight?.let {
val remain = if (it.remain > 99) {
99
} else {
it.remain
}
onTrafficLightPlusSource(it.convert(), remain, DataSourceType.AICLOUD)
}
}
fun destroy() {
//取消注册监听AI云.OBU,路侧获取红绿灯状态
CallerTrafficLightListenerManager.removeListener(TAG)
//取消注册监听工控机感知红绿灯
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
}
}