diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java index ffc2ec230b..2fdd7b412f 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java @@ -35,6 +35,7 @@ import com.mogo.utils.network.utils.GsonUtil; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import static com.mogo.module.v2x.V2XConst.MODULE_NAME; @@ -51,7 +52,7 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME; */ public class V2XAlarmServer { // 记录道路播报的事件 - private static HashMap mAlertRoadEventList = new HashMap<>(); + public static ConcurrentHashMap mAlertRoadEventList = new ConcurrentHashMap<>(); // 记录违章停车播报事件 private static HashMap mAlertIllegalParkEventList = new HashMap<>(); diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java index b9f92b387b..38b9fab0a3 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java @@ -14,6 +14,8 @@ import com.mogo.module.common.entity.V2XRoadEventEntity; import com.mogo.module.service.Utils; import com.mogo.module.v2x.V2XConst; import com.mogo.module.v2x.V2XServiceManager; +import com.mogo.module.v2x.alarm.V2XAlarmServer; +import com.mogo.module.v2x.utils.TimeUtils; import com.mogo.module.v2x.utils.V2XUtils; import com.mogo.service.connection.IMogoOnMessageListener; import com.mogo.utils.logger.Logger; @@ -39,35 +41,42 @@ public class V2XMessageListener_401012 implements IMogoOnMessageListener 0) { - MarkerExploreWay markerExploreWay = response.getExploreWay().get(0); - MarkerLocation markerLocation = markerExploreWay.getLocation(); - // 记录道路事件 - V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); - v2XRoadEventEntity.setLocation(markerLocation); - // 探路目前只有上报拥堵 - v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType()); - // 当前车辆数据 - MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation(); - float calculateDistance = Utils.calculateLineDistance( - new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()), - new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()) - ); - v2XRoadEventEntity.setDistance(calculateDistance); - v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); - v2XRoadEventEntity.setExpireTime(20000); + try { + if (response.getExploreWay() != null && response.getExploreWay().size() > 0) { + MarkerExploreWay markerExploreWay = response.getExploreWay().get(0); + MarkerLocation markerLocation = markerExploreWay.getLocation(); + // 记录道路事件 + V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); + v2XRoadEventEntity.setLocation(markerLocation); + // 探路目前只有上报拥堵 + v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType()); + // 当前车辆数据 + MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation(); + float calculateDistance = Utils.calculateLineDistance( + new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()), + new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()) + ); + v2XRoadEventEntity.setDistance(calculateDistance); + v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); + v2XRoadEventEntity.setExpireTime(20000); - V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); - // 控制类型 - v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING); - // 设置数据 - v2xMessageEntity.setContent(v2XRoadEventEntity); - // 控制展示状态 - v2xMessageEntity.setShowState(true); + // 记录播报过的道路事件 + V2XAlarmServer.mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString()); - Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION); - intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity); - LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent); + V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); + // 控制类型 + v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING); + // 设置数据 + v2xMessageEntity.setContent(v2XRoadEventEntity); + // 控制展示状态 + v2xMessageEntity.setShowState(true); + + Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION); + intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity); + LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent); + } + } catch (Exception e) { + e.printStackTrace(); } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/park/V2XIllegalParkScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/park/V2XIllegalParkScenario.java index 9bd5603dbe..2e9c1b008b 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/park/V2XIllegalParkScenario.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/park/V2XIllegalParkScenario.java @@ -3,12 +3,14 @@ package com.mogo.module.v2x.scenario.scene.park; import androidx.annotation.Nullable; import com.mogo.module.common.entity.MarkerExploreWay; +import com.mogo.module.common.entity.V2XMessageEntity; +import com.mogo.module.common.entity.V2XPoiTypeEnum; +import com.mogo.module.common.entity.V2XRoadEventEntity; import com.mogo.module.v2x.V2XServiceManager; import com.mogo.module.v2x.V2XStatusManager; import com.mogo.module.v2x.alarm.V2XAlarmServer; -import com.mogo.module.common.entity.V2XMessageEntity; -import com.mogo.module.common.entity.V2XPoiTypeEnum; import com.mogo.module.v2x.scenario.impl.AbsV2XScenario; +import com.mogo.module.v2x.utils.ADASUtils; import com.mogo.module.v2x.utils.TrackUtils; import java.util.ArrayList; @@ -67,14 +69,20 @@ public class V2XIllegalParkScenario extends AbsV2XScenario