This commit is contained in:
zhongchao
2022-03-31 20:36:35 +08:00
parent d02ce90e32
commit 2bc4a8b6ee
156 changed files with 19912 additions and 2719 deletions

View File

@@ -60,7 +60,6 @@ import com.mogo.service.statusmanager.IMogoStatusChangedListener
import com.mogo.service.statusmanager.StatusDescriptor
import com.mogo.service.statusmanager.StatusDescriptor.ACC_STATUS
import com.mogo.service.statusmanager.StatusDescriptor.SEEK_HELPING
import com.mogo.service.statusmanager.StatusDescriptor.TOP_CONTAINER_READY
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.v2x.V2XManager
import com.mogo.v2x.callback.IV2XCallback
@@ -84,7 +83,8 @@ import java.lang.IllegalStateException
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallback, IMogoMapListener, IMogoStatusChangedListener {
object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallback,
IMogoMapListener, IMogoStatusChangedListener {
private const val TAG = "V2XEventManager"
@@ -105,7 +105,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
it.aiCloudConfig(MoGoAiCloudClientConfig.getInstance())
it.context(context)
it.distanceForTriggerRefresh(200f) //行驶超过200包含刷新道路周边信息短链请求
it.durationForTriggerRefresh(60, TimeUnit.SECONDS) // 每隔1分钟根据自车定位刷新道路周边信息短链请求
it.durationForTriggerRefresh(
60,
TimeUnit.SECONDS
) // 每隔1分钟根据自车定位刷新道路周边信息短链请求
it.executor(ThreadUtils.getIoPool()) //用到的线程池IO类型
it.staticParams(ParamsUtil.getStaticParams())
}.build())
@@ -130,16 +133,17 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
CallerMapLocationListenerManager.addListener(TAG, this)
BridgeApi.registerCenter()?.let {
it.registerMogoMapListener(MODULE_NAME, this)
it.registerMogoMarkerClickListener(ModuleNames.CARD_TYPE_ROAD_CONDITION, object : IMogoMarkerClickListener {
override fun onMarkerClicked(marker: IMogoMarker?): Boolean {
handleRoadConditionMarkerClick(marker)
return false
}
})
it.registerMogoMarkerClickListener(
ModuleNames.CARD_TYPE_ROAD_CONDITION,
object : IMogoMarkerClickListener {
override fun onMarkerClicked(marker: IMogoMarker?): Boolean {
handleRoadConditionMarkerClick(marker)
return false
}
})
}
BridgeApi.statusManager()?.let {
it.registerStatusChangedListener(MODULE_NAME, ACC_STATUS, this)
it.registerStatusChangedListener(MODULE_NAME, TOP_CONTAINER_READY, this)
it.registerStatusChangedListener(MODULE_NAME, SEEK_HELPING, this)
}
}
@@ -154,18 +158,19 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
}
BridgeApi.statusManager()?.let {
it.unregisterStatusChangedListener(MODULE_NAME, ACC_STATUS, this)
it.unregisterStatusChangedListener(MODULE_NAME, TOP_CONTAINER_READY, this)
it.unregisterStatusChangedListener(MODULE_NAME, SEEK_HELPING, this)
}
}
private fun initData() {
try { // 查询ACC状态
SharedPrefsMgr.getInstance(Utils.getApp()).putBoolean("descriptor_ACC_STATUS", isAccOn())
SharedPrefsMgr.getInstance(Utils.getApp())
.putBoolean("descriptor_ACC_STATUS", isAccOn())
if (isAccOn()) { // 记录开机时间
FatigueDrivingUtils.refreshAccOnTime()
} else { // 记录关机时间
SharedPrefsMgr.getInstance(Utils.getApp()).putString(V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString())
SharedPrefsMgr.getInstance(Utils.getApp())
.putString(V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString())
}
} catch (e: Exception) {
e.printStackTrace()
@@ -202,7 +207,8 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
val location = it.location
roadEventEntity.location = location
val v2XMessageEntity: V2XMessageEntity<V2XRoadEventEntity> = V2XMessageEntity<V2XRoadEventEntity>()
val v2XMessageEntity: V2XMessageEntity<V2XRoadEventEntity> =
V2XMessageEntity<V2XRoadEventEntity>()
v2XMessageEntity.type = V2XTypeEnum.ALERT_ROAD_WARNING
v2XMessageEntity.isShowState = true
v2XMessageEntity.isOnlyShow = true
@@ -251,19 +257,14 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
FatigueDrivingUtils.refreshAccOnTime()
initCarForHelpStatus()
BridgeApi.statusManager()?.let {
if (it.isTopContainerReady) {
V2XManager.forceRefresh()
}
V2XManager.forceRefresh()
}
} else { // 记录关机时间
SharedPrefsMgr.getInstance(Utils.getApp()).putString(V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString())
SharedPrefsMgr.getInstance(Utils.getApp())
.putString(V2X_ACC_OFF_TIME_STR, TimeUtils.getNowString())
}
} else if (descriptor == SEEK_HELPING) {
refreshMeSeekHelp(isTrue)
} else if (descriptor == TOP_CONTAINER_READY) {
if (isTrue) {
V2XManager.forceRefresh()
}
}
}
@@ -287,7 +288,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
BridgeApi.refreshModel().getHelpSignal(object : V2XRefreshCallback<V2XSeekHelpRes?> {
override fun onSuccess(result: V2XSeekHelpRes?) {
if (result != null) {
val resultBean = result.result
val resultBean = result.result
if (resultBean != null) {
CallerLogger.d("$M_V2X$TAG", "刷新自车求助状态 resultBean$resultBean")
val vehicleType: Int = resultBean.vehicleType //故障车
@@ -312,9 +313,11 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
override fun onSuccess(result: V2XStrategyPushRes?) { //CallerLogger.w("$M_V2X$TAG", "V2X疲劳驾驶配置数据更新" + GsonUtil.jsonFromObject(result));
val resultBean = result?.result
if (resultBean != null) { // 更新本地的v2x提醒策略
SharedPrefsMgr.getInstance(Utils.getApp()).putString(V2X_STRATEGY_PUSH, GsonUtil.jsonFromObject(resultBean))
SharedPrefsMgr.getInstance(Utils.getApp())
.putString(V2X_STRATEGY_PUSH, GsonUtil.jsonFromObject(resultBean))
}
}
override fun onFail(msg: String?) {}
})
}
@@ -323,7 +326,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
location ?: return
BridgeApi.location.set(location)
if (V2XManager.hasInit()) {
V2XManager.onLocationChanged(longitude = location.longitude, latitude = location.latitude)
V2XManager.onLocationChanged(
longitude = location.longitude,
latitude = location.latitude
)
}
V2XOptimalRouteObserver.getInstance().update(location)
refreshCarState(location)
@@ -347,7 +353,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
//CallerLogger.d("$M_V2X$TAG", "当前地图的缩放比例为:" + zoomLevel);
val zoomLevel: Float = CallerMapUIServiceManager.getMapUIController()?.zoomLevel ?: 0.0f
//CallerLogger.d("$M_V2X$TAG", "当前地图的缩放比例为:" + zoomLevel);
if (zoomLevel > 0 && zoomLevel <= 17 && BridgeApi.v2xStatus()?.isRoadEventWindowShow == false) { // 缩放地图
if (zoomLevel > 0 && zoomLevel <= 17 && BridgeApi.v2xStatus()?.isRoadEventWindowShow == false) { // 缩放地图
val context: Context = context()
MapUtils.zoomMap(v2xStatusManager.targetMoGoLatLng, context)
}
@@ -371,7 +377,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
// }
// 巡航处理
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(BridgeApi.v2xMarker()?.v2XRoadEventEntityList, V2XStatusManager.getInstance().location) // 距离是否大于10米 && 消息是否不为空
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(
BridgeApi.v2xMarker()?.v2XRoadEventEntityList,
V2XStatusManager.getInstance().location
) // 距离是否大于10米 && 消息是否不为空
// 距离是否大于10米 && 消息是否不为空
if (v2XRoadEventEntity != null && v2XRoadEventEntity.distance >= 5) { // CallerLogger.w("$M_V2X$TAG",
// //"\nV2X预警--当前导航状态:" + V2XServiceManager.getNavi().isNaviing() +
@@ -401,7 +410,11 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
private fun saveLocalStory(scenarioType: Int, v2XRoadEventEntity: MarkerExploreWay) {
ThreadUtils.getIoPool().execute {
try {
V2XSQLiteUtils.saveLocalStory(scenarioType, v2XRoadEventEntity, v2XRoadEventEntity.hashCode())
V2XSQLiteUtils.saveLocalStory(
scenarioType,
v2XRoadEventEntity,
v2XRoadEventEntity.hashCode()
)
} catch (e: Exception) {
e.printStackTrace()
CallerLogger.e("$M_V2X$TAG", "$e")
@@ -417,7 +430,12 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
historyPath[0] = location
if (historyPath[1] != null && historyPath[0] != null) {
val carAngle: Double = DrivingDirectionUtils.getCarAngle(historyPath[1]!!.latitude, historyPath[1]!!.longitude, historyPath[0]!!.latitude, historyPath[0]!!.longitude).toDouble()
val carAngle: Double = DrivingDirectionUtils.getCarAngle(
historyPath[1]!!.latitude,
historyPath[1]!!.longitude,
historyPath[0]!!.latitude,
historyPath[0]!!.longitude
).toDouble()
//CallerLogger.d("$M_V2X$TAG",
// "\n车辆经纬度" + Arrays.toString(historyPath) +
@@ -477,7 +495,8 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
}
private fun handleOptimalRouteEvent(event: V2XEvent.OptimalRoute) {
val v2xMessageEntity: V2XMessageEntity<V2XOptimalRoute> = V2XMessageEntity<V2XOptimalRoute>() // 控制类型
val v2xMessageEntity: V2XMessageEntity<V2XOptimalRoute> =
V2XMessageEntity<V2XOptimalRoute>() // 控制类型
v2xMessageEntity.type = V2XTypeEnum.ALERT_PUSH_VR_SHOW // 设置数据
v2xMessageEntity.content = event.data // 控制展示状态
v2xMessageEntity.isShowState = true
@@ -520,7 +539,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
// 交叉路口碰撞预警
changeVisualAngle = true
appId = EventTypeEnum.TYPE_USECASE_ID_BSW.poiType.toInt()
tts = String.format(EventTypeEnum.TYPE_USECASE_ID_BSW.tts, getWarningDirection())
tts = String.format(
EventTypeEnum.TYPE_USECASE_ID_BSW.tts,
getWarningDirection()
)
content = EventTypeEnum.TYPE_USECASE_ID_BSW.content
}
1006 -> {
@@ -549,19 +571,28 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
}
}
// 显示弹框,语音提示
CallerHmiManager.showWarningV2X(appId, content, tts, "$appId", object : IMoGoWarningStatusListener {
val change = changeVisualAngle
override fun onShow() {
if (change) {
CallerVisualAngleManager.changeVisualAngle(TooClose)
CallerHmiManager.showWarningV2X(
appId,
content,
tts,
"$appId",
object : IMoGoWarningStatusListener {
val change = changeVisualAngle
override fun onShow() {
if (change) {
CallerVisualAngleManager.changeVisualAngle(TooClose)
}
}
}
override fun onDismiss() {
if (change) {
CallerVisualAngleManager.changeVisualAngle(Default())
override fun onDismiss() {
if (change) {
CallerVisualAngleManager.changeVisualAngle(Default())
}
}
}
}, true, 5000L)
},
true,
5000L
)
TrafficMarkerDrawer.updateITrafficInfo(trafficData)
}
2 -> {
@@ -607,7 +638,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
override fun onError(code: Int, msg: String?) {}
fun onDestroy() {
if (hasInit.compareAndSet(true,false)) {
if (hasInit.compareAndSet(true, false)) {
try {
scope.cancel()
} catch (e: Throwable) {