优化ADAS的tts播报,以及道路事件下发的存储

This commit is contained in:
董宏宇
2020-07-27 11:09:43 +08:00
parent 5cc0fb86a4
commit a6399aa4a6
3 changed files with 50 additions and 32 deletions

View File

@@ -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<V2XRoadEventEntity, String> mAlertRoadEventList = new HashMap<>();
public static ConcurrentHashMap<V2XRoadEventEntity, String> mAlertRoadEventList = new ConcurrentHashMap<>();
// 记录违章停车播报事件
private static HashMap<MarkerExploreWay, String> mAlertIllegalParkEventList = new HashMap<>();

View File

@@ -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<MarkerC
public void onMsgReceived(MarkerCardResult response) {
Logger.d(MODULE_NAME, "V2XMessageListener_401012==V2X服务端下发\n"
+ GsonUtil.jsonFromObject(response));
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);
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<V2XRoadEventEntity> 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<V2XRoadEventEntity> 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();
}
}

View File

@@ -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<List<MarkerExploreWay
//弹框
// 设置要展开的违章停车事件
//((V2XIllegalParkMarker) mV2XMarker).setOpenPoiId(markerExploreWay.getInfoId());
// 广播给ADAS
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setAlarmContent("违章停车");
v2XRoadEventEntity.setExpireTime(20000);
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.ALERT_ILLEGAL_PARK);
if (V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
speakTTSVoice(markerExploreWay.getAddr() + "可能被罚违章停车,您可以说,有用或没用来帮助其它车友。", null);
v2XRoadEventEntity.setTts(markerExploreWay.getAddr() + "可能被罚违章停车,您可以说,有用或没用来帮助其它车友。");
((V2XIllegalParkWindow) mV2XWindow).show(markerExploreWay, true);
TrackUtils.trackV2xRoadShow(markerExploreWay.getInfoId(), V2XPoiTypeEnum.ALERT_ILLEGAL_PARK, "1");
} else {
speakTTSVoice(markerExploreWay.getAddr() + "可能被罚违章停车", null);
v2XRoadEventEntity.setTts(markerExploreWay.getAddr() + "可能被罚违章停车");
TrackUtils.trackV2xRoadShow(markerExploreWay.getInfoId(), V2XPoiTypeEnum.ALERT_ILLEGAL_PARK, "2");
}
ADASUtils.broadcastToADAS(V2XServiceManager.getContext(), v2XRoadEventEntity);
}
}