增加了需求
2.1,前方轨迹匹配 http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42308582
This commit is contained in:
@@ -7,6 +7,7 @@ import com.mogo.module.v2x.listener.V2XMessageListener_401007;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_401009;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_401010;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_401011;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_401012;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
@@ -22,7 +23,8 @@ public class V2XSocketManager {
|
||||
|
||||
private static V2XSocketManager mV2XSocketManager;
|
||||
|
||||
private V2XMessageListener_401011 v2XMessageListener_401001;
|
||||
private V2XMessageListener_401011 v2XMessageListener_401011;
|
||||
private V2XMessageListener_401012 v2XMessageListener_401012;
|
||||
private V2XMessageListener_401003 v2XMessageListener_401003;
|
||||
private V2XMessageListener_401005 v2XMessageListener_401005;
|
||||
private V2XMessageListener_401006 v2XMessageListener_401006;
|
||||
@@ -52,6 +54,7 @@ public class V2XSocketManager {
|
||||
public void registerSocketMessage() {
|
||||
Logger.d(MODULE_NAME, "开始注册Socket通道....");
|
||||
register401011();
|
||||
register401012();
|
||||
register401005();
|
||||
register401007();
|
||||
register401009();
|
||||
@@ -66,10 +69,15 @@ public class V2XSocketManager {
|
||||
*/
|
||||
public void unregisterSocketMessage() {
|
||||
Logger.w(MODULE_NAME, "反注册Socket通道....");
|
||||
if (v2XMessageListener_401001 != null) {
|
||||
if (v2XMessageListener_401011 != null) {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.unregisterOnMessageListener(401011, v2XMessageListener_401001);
|
||||
.unregisterOnMessageListener(401011, v2XMessageListener_401011);
|
||||
}
|
||||
if (v2XMessageListener_401012 != null) {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.unregisterOnMessageListener(401012, v2XMessageListener_401012);
|
||||
}
|
||||
if (v2XMessageListener_401003 != null) {
|
||||
V2XServiceManager
|
||||
@@ -102,13 +110,27 @@ public class V2XSocketManager {
|
||||
* 道路事件,在线车辆绘制
|
||||
*/
|
||||
private void register401011() {
|
||||
v2XMessageListener_401001 = new V2XMessageListener_401011();
|
||||
v2XMessageListener_401011 = new V2XMessageListener_401011();
|
||||
// 道路事件,在线车辆绘制
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.registerOnMessageListener(
|
||||
401011,
|
||||
v2XMessageListener_401001
|
||||
v2XMessageListener_401011
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道路事件,服务端下发
|
||||
*/
|
||||
private void register401012() {
|
||||
v2XMessageListener_401012 = new V2XMessageListener_401012();
|
||||
// 道路事件,在线车辆绘制
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.registerOnMessageListener(
|
||||
401012,
|
||||
v2XMessageListener_401012
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -200,37 +200,28 @@ public class V2XRoadEventDetailVH extends V2XBaseViewHolder {
|
||||
tvEventTime.setText(eventTime);
|
||||
}
|
||||
|
||||
// 事件距离车辆小于50米的时候可以用户纠错
|
||||
if (mV2XRoadEventEntity.getDistance() < 50) {
|
||||
ivEventReportTrue.setVisibility(VISIBLE);
|
||||
ivEventReportErr.setVisibility(VISIBLE);
|
||||
|
||||
ivEventLive.setVisibility(GONE);
|
||||
ivEventZan.setVisibility(GONE);
|
||||
if (!ArrayUtils.isEmpty(mV2XEventShowEntity.getV2XLiveCarList())) {
|
||||
ivEventLive.setVisibility(VISIBLE);
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_LIVE_ROAD,
|
||||
v2XVoiceOpenLiveListener)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_LIVE_UN_WAKEUP,
|
||||
v2XVoiceOpenLiveListener);
|
||||
ivEventLive.setOnClickListener(v -> {
|
||||
showLiveCar(v2XEventShowEntity);
|
||||
});
|
||||
} else {
|
||||
if (!ArrayUtils.isEmpty(mV2XEventShowEntity.getV2XLiveCarList())) {
|
||||
ivEventLive.setVisibility(VISIBLE);
|
||||
V2XVoiceManager.INSTANCE
|
||||
.registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_LIVE_ROAD,
|
||||
v2XVoiceOpenLiveListener)
|
||||
.registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_OPEN_LIVE_UN_WAKEUP,
|
||||
v2XVoiceOpenLiveListener);
|
||||
ivEventLive.setOnClickListener(v -> {
|
||||
showLiveCar(v2XEventShowEntity);
|
||||
});
|
||||
} else {
|
||||
ivEventLive.setVisibility(GONE);
|
||||
}
|
||||
ivEventLive.setVisibility(GONE);
|
||||
}
|
||||
|
||||
ivEventReportTrue.setVisibility(GONE);
|
||||
ivEventReportErr.setVisibility(GONE);
|
||||
ivEventZan.setVisibility(VISIBLE);
|
||||
ivEventReportTrue.setVisibility(GONE);
|
||||
ivEventReportErr.setVisibility(GONE);
|
||||
ivEventZan.setVisibility(VISIBLE);
|
||||
|
||||
// 用户上报的才会展示拨打电话
|
||||
if (!TextUtils.isEmpty(mNoveltyInfo.getUploadType())
|
||||
&& mNoveltyInfo.getUploadType().equals("1")) {
|
||||
requestUserInfo(mNoveltyInfo);
|
||||
}
|
||||
// 用户上报的才会展示拨打电话
|
||||
if (!TextUtils.isEmpty(mNoveltyInfo.getUploadType())
|
||||
&& mNoveltyInfo.getUploadType().equals("1")) {
|
||||
requestUserInfo(mNoveltyInfo);
|
||||
}
|
||||
|
||||
ivEventReportTrue.setOnClickListener(v -> {
|
||||
|
||||
@@ -52,7 +52,6 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
public class V2XAlarmServer {
|
||||
// 记录道路播报的事件
|
||||
private static HashMap<V2XRoadEventEntity, String> mAlertRoadEventList = new HashMap<>();
|
||||
private static HashSet<V2XRoadEventEntity> mAlertRoadEventCorrectionList = new HashSet<>();
|
||||
|
||||
// 记录违章停车播报事件
|
||||
private static HashMap<MarkerExploreWay, String> mAlertIllegalParkEventList = new HashMap<>();
|
||||
@@ -112,13 +111,6 @@ public class V2XAlarmServer {
|
||||
isAlreadyAlert = true;
|
||||
}
|
||||
}
|
||||
// 判断是否是纠错,如果是纠错就忽略掉带有时间段的道路提醒
|
||||
if (v2XRoadEventEntity.getDistance() <= 50) {
|
||||
if (!mAlertRoadEventCorrectionList.contains(v2XRoadEventEntity)) {
|
||||
mAlertRoadEventCorrectionList.add(v2XRoadEventEntity);
|
||||
isAlreadyAlert = false;
|
||||
}
|
||||
}
|
||||
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
|
||||
// "\n距离:" + v2XRoadEventEntity.getDistance() + "米" +
|
||||
// "\n是否已经提醒:" + isAlreadyAlert +
|
||||
|
||||
@@ -68,11 +68,9 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
@Override
|
||||
public void onLocationChanged(MogoLocation location) {
|
||||
try {
|
||||
Logger.d(V2XConst.MODULE_NAME, "V2X预警--onLocationChanged: " + GsonUtil.jsonFromObject(location));
|
||||
|
||||
//Logger.d(V2XConst.MODULE_NAME, "V2X预警--onLocationChanged: " + GsonUtil.jsonFromObject(location));
|
||||
// 刷新角度
|
||||
getCurrentCarAngle(location);
|
||||
|
||||
// 只有车速大于 5 的时候进行计算
|
||||
if (location.getSpeed() >= 5) {
|
||||
refreshCurrentCarState(location);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
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.utils.V2XUtils;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/1 10:23 AM
|
||||
* desc : 道路事件服务端下发触发
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XMessageListener_401012 implements IMogoOnMessageListener<MarkerCardResult> {
|
||||
|
||||
@Override
|
||||
public Class<MarkerCardResult> target() {
|
||||
return MarkerCardResult.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
|
||||
@Override
|
||||
public void handlerMessage(V2XMessageEntity v2XMessageEntity) {
|
||||
Logger.w(MODULE_NAME, "处理V2X场景:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
Logger.d(MODULE_NAME, "处理V2X场景:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
synchronized (V2XScenarioManager.class) {
|
||||
// 展示
|
||||
V2XUtils.runOnUiThread(() -> {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
@Override
|
||||
public void init(V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity) {
|
||||
try {
|
||||
Logger.w(V2XConst.MODULE_NAME, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
Logger.d(V2XConst.MODULE_NAME, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
|
||||
V2XRoadEventEntity v2XRoadEventEntity = v2XMessageEntity.getContent();
|
||||
if (v2XRoadEventEntity != null) {
|
||||
@@ -79,14 +79,8 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
@Override
|
||||
public void show() {
|
||||
if (mV2XMessageEntity != null && mV2XMessageEntity.getContent() != null) {
|
||||
// 如果道路事件小于50米的时候需要用户反馈
|
||||
if (mV2XMessageEntity.getContent().getDistance() < 50) {
|
||||
// 设置TTS
|
||||
mV2XMessageEntity.getContent().getTtsWithFeedback();
|
||||
} else {
|
||||
// 设置TTS
|
||||
mV2XMessageEntity.getContent().getTts(false);
|
||||
}
|
||||
// 设置TTS
|
||||
mV2XMessageEntity.getContent().getTts(false);
|
||||
// 广播给ADAS
|
||||
ADASUtils.broadcastToADAS(
|
||||
V2XServiceManager.getContext(),
|
||||
@@ -96,6 +90,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
showWindow();
|
||||
}
|
||||
}
|
||||
String json = "{\"exploreWay\":[{\"addr\":\"东城区小黄庄北街2号靠近中国银行(北京安贞桥支行)\",\"userInfo\":{\"userName\":\"玉涛1\",\"sn\":\"E841CC2018PZD20143\",\"userHead\":\"http://img.zhidaohulian.com/fileServer/api/prod/user_info/726761827601/914019cfda5ab4b618e7f00e093eda82.jpg\",\"safeLabelType\":0,\"userId\":726761827601},\"cityName\":\"北京市\",\"uploadType\":\"0\",\"type\":\"CARD_TYPE_ROAD_CONDITION\",\"poiType\":\"10015\",\"infoId\":\"56280492\",\"items\":[{\"url\":\"http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/CarPad/com.zhidao.roadcondition/E841CC2018PZD20143/E841CC2018PZD20143_20200722112917/PhotoFront_20200722_112918.JPG?sign\\u003dq-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1595388896%3B1595396096%26q-key-time%3D1595388896%3B1595396096%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D2301fa50ff90f5b34f7f7c05a13a15f39abde9eb\",\"illegalCount\":0.0}],\"location\":{\"address\":\"东城区小黄庄北街2号靠近中国银行(北京安贞桥支行)\",\"angle\":0.0,\"lat\":39.968223,\"lon\":116.410857},\"generateTime\":1595388559153,\"distance\":47.0,\"fileType\":0,\"direction\":0,\"canLive\":false}]}";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,7 @@ public class V2XRoadEventWindow extends RelativeLayout
|
||||
* 初始化视图
|
||||
*/
|
||||
private void initView(Context context) {
|
||||
Logger.w(MODULE_NAME, "V2X===初始化道路事件小窗口View。。。。。");
|
||||
Logger.d(MODULE_NAME, "V2X===初始化道路事件小窗口View。。。。。");
|
||||
// 填充布局
|
||||
LayoutInflater.from(context).inflate(R.layout.window_road_event_detail, this);
|
||||
// 详情列表
|
||||
|
||||
Reference in New Issue
Block a user