socket消息接受类更名,待联调
This commit is contained in:
@@ -10,6 +10,7 @@ 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.module.v2x.listener.V2XMessageListener_402000;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_402001;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
@@ -34,7 +35,7 @@ public class V2XSocketManager {
|
||||
private V2XMessageListener_401009 v2XMessageListener_401009;
|
||||
private V2XMessageListener_401010 v2XMessageListener_401010;
|
||||
private V2XMessageListener_402000 mV2XMessageListener_402000;
|
||||
|
||||
private V2XMessageListener_402001 mV2XMessageListener402001;
|
||||
|
||||
private V2XSocketManager() {
|
||||
}
|
||||
@@ -65,6 +66,7 @@ public class V2XSocketManager {
|
||||
register401007();
|
||||
register401009();
|
||||
register401020();
|
||||
registerWarningMsg();
|
||||
|
||||
// TODO 这里是前瞻需求,量产版本需要注释
|
||||
register401003();
|
||||
@@ -72,6 +74,7 @@ public class V2XSocketManager {
|
||||
//register401006();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 反注册消息通道,不再进行接受
|
||||
*/
|
||||
@@ -225,6 +228,7 @@ public class V2XSocketManager {
|
||||
v2XMessageListener_401009
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 车路云—场景预警-V1.0
|
||||
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52829799
|
||||
@@ -241,6 +245,16 @@ public class V2XSocketManager {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 车路云—场景预警-V1.0
|
||||
* * http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52829799
|
||||
* * 弱势交通参与者
|
||||
*/
|
||||
public void registerWarningMsg() {
|
||||
mV2XMessageListener402001 = new V2XMessageListener_402001();
|
||||
V2XServiceManager.getMoGoSocketManager().registerOnMessageListener(402001, mV2XMessageListener402001);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* * 2.0.3
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.listener.V2XWarnMessageListener;
|
||||
import com.mogo.module.v2x.listener.V2XMessageListener_402001;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
@@ -22,7 +22,7 @@ public class V2XWaringManager {
|
||||
|
||||
private static V2XWaringManager mV2XWaringManager;
|
||||
//TODO 需要修改
|
||||
private V2XWarnMessageListener v2XWarnMessageListener;
|
||||
private V2XMessageListener_402001 mV2XMessageListener402001;
|
||||
|
||||
|
||||
private V2XWaringManager() {
|
||||
@@ -83,7 +83,7 @@ public class V2XWaringManager {
|
||||
|
||||
// 加载数据源
|
||||
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
|
||||
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(warningEntity);
|
||||
// V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(warningEntity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -94,10 +94,10 @@ public class V2XWaringManager {
|
||||
*/
|
||||
public void unregisterAdasSocketMessage() {
|
||||
Logger.w(V2XConst.LOG_NAME_WARN, "反注册Socket通道....");
|
||||
if (v2XWarnMessageListener != null) {
|
||||
if (mV2XMessageListener402001 != null) {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.unregisterOnMessageListener(401018, v2XWarnMessageListener);
|
||||
.unregisterOnMessageListener(401018, mV2XMessageListener402001);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,16 +105,16 @@ public class V2XWaringManager {
|
||||
* 道路预警 弱势群体事件,行人 TODO type
|
||||
*/
|
||||
private void registerWarnListener() {
|
||||
v2XWarnMessageListener = new V2XWarnMessageListener();
|
||||
mV2XMessageListener402001 = new V2XMessageListener_402001();
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.registerOnMessageListener(
|
||||
401018,
|
||||
v2XWarnMessageListener);
|
||||
mV2XMessageListener402001);
|
||||
}
|
||||
|
||||
public V2XWarnMessageListener getV2XMessageListener() {
|
||||
return v2XWarnMessageListener;
|
||||
public V2XMessageListener_402001 getV2XMessageListener() {
|
||||
return mV2XMessageListener402001;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,51 +1,48 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
|
||||
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 liujing
|
||||
* @description 车路云弱势交通参与者预警
|
||||
* @since: 2021/5/11
|
||||
* desc: 下发的云端预警数据
|
||||
*/
|
||||
public class V2XMessageListener_402001 implements IMogoOnMessageListener<V2XOptimalRouteDataRes> {
|
||||
|
||||
@Override
|
||||
public Class<V2XOptimalRouteDataRes> target() {
|
||||
return null;
|
||||
return V2XOptimalRouteDataRes.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(V2XOptimalRouteDataRes message) {
|
||||
// 将接收到的数据转换成弱势交通预警场景数据
|
||||
if (message != null
|
||||
&& message.getGd_locus_list() != null
|
||||
&& !message.getGd_locus_list().isEmpty()) {
|
||||
Logger.i(MODULE_NAME, "V2XMessageListener_402001:" + GsonUtil.jsonFromObject(message));
|
||||
|
||||
V2XMessageEntity<V2XOptimalRouteDataRes> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(message);
|
||||
// 控制展示状态
|
||||
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);
|
||||
}
|
||||
public void onMsgReceived(V2XOptimalRouteDataRes info) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived ---11---> ");
|
||||
//Logger.d(MODULE_NAME, "V2XMessageListener_401011==V2X地图气泡数据刷新:\n" + GsonUtil.jsonFromObject(response));
|
||||
V2XUtils.runOnBackgroundThread(() -> {
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (info != null) {
|
||||
// 解析存储道路事件 liyz
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived --22--> ");
|
||||
V2XMessageEntity<V2XOptimalRouteDataRes> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(info);
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
|
||||
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* desc: 下发的云端预警数据
|
||||
*
|
||||
*/
|
||||
public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarningEntity> {
|
||||
|
||||
@Override
|
||||
public Class<V2XWarningEntity> target() {
|
||||
return V2XWarningEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(V2XWarningEntity info) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived ---11---> ");
|
||||
//Logger.d(MODULE_NAME, "V2XMessageListener_401011==V2X地图气泡数据刷新:\n" + GsonUtil.jsonFromObject(response));
|
||||
V2XUtils.runOnBackgroundThread(() -> {
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (info != null) {
|
||||
// 解析存储道路事件 liyz
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived --22--> ");
|
||||
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(info);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,25 +78,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
public void drawPOI(Object entity) {
|
||||
try {
|
||||
mCloundWarningInfo = (V2XWarningEntity) entity;
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(mCloundWarningInfo.getLat());
|
||||
location.setLon(mCloundWarningInfo.getLon());
|
||||
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(mCloundWarningInfo.getLat())
|
||||
.longitude(mCloundWarningInfo.getLon())
|
||||
.anchor(0.5f, 0.5f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(mContext)));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
|
||||
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(mContext)));
|
||||
optimalMarker.showInfoWindow();
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
optimalMarker.hideInfoWindow();
|
||||
}, 8000);
|
||||
drawLineWithEntity(mCloundWarningInfo);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -110,13 +92,6 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
showTime = mCloundWarningInfo.getShowTime();
|
||||
pointsBetween();
|
||||
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
||||
|
||||
//顶部弹框
|
||||
if (mV2XScenario == null) {
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
}
|
||||
mV2XScenario.setWarningEntity(cloundWarningInfo);
|
||||
mV2XScenario.init(null);
|
||||
//预警蒙层
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
isSelfLineClear = false;
|
||||
|
||||
Reference in New Issue
Block a user