Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk
This commit is contained in:
@@ -145,6 +145,14 @@ public class V2XMessageEntity<T> implements Serializable {
|
||||
int ALERT_RECOMMEND_ROUTE = 1_011;
|
||||
// 基于预判目的地违章高发停车场推荐
|
||||
int ALERT_RECOMMEND_PARKING = 1_012;
|
||||
// 前方碰撞预警
|
||||
int ALERT_THE_FRONT_CRASH_WARNING_TOP = 1_0013;
|
||||
// 左前方碰撞预警
|
||||
int ALERT_THE_FRONT_CRASH_WARNING_LEFT = 1_0014;
|
||||
// 右前方碰撞预警
|
||||
int ALERT_THE_FRONT_CRASH_WARNING_RIGHT = 1_0015;
|
||||
// 后方碰撞预警
|
||||
int ALERT_THE_FRONT_CRASH_WARNING_BOTTOM = 1_0016;
|
||||
// 推送VR消息展示
|
||||
int ALERT_PUSH_VR_SHOW = 2_000;
|
||||
// 自车求助
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -29,6 +30,7 @@ import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.v2x.IV2XListener;
|
||||
import com.mogo.skin.support.SkinMode;
|
||||
import com.mogo.utils.NetworkUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -64,6 +66,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
protected FrameLayout mLeftPanelLayout;
|
||||
protected View mLeftShadowFrame;
|
||||
|
||||
protected ImageView mWarningTop;
|
||||
protected ImageView mWarningLeft;
|
||||
protected ImageView mWarningRight;
|
||||
protected ImageView mWarningBottom;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
if ( !DebugConfig.isMapBased() ) {
|
||||
@@ -103,6 +110,11 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
mLeftPanelLayout = findViewById( R.id.module_main_id_left_panel_fragment_container );
|
||||
mHistoryMessagePanel = findViewById( R.id.module_main_id_message_history_fragment_container );
|
||||
|
||||
mWarningTop = findViewById(R.id.warning_top);
|
||||
mWarningLeft = findViewById(R.id.warning_left);
|
||||
mWarningRight = findViewById(R.id.warning_right);
|
||||
mWarningBottom = findViewById(R.id.warning_bottom);
|
||||
|
||||
// 避免事件穿透导致地图被滑动
|
||||
mLeftShadowFrame.setOnClickListener( view -> {
|
||||
} );
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:endColor="#00F03232"
|
||||
android:startColor="#A5F03232"
|
||||
android:type="linear"></gradient>
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="0"
|
||||
android:endColor="#00F03232"
|
||||
android:startColor="#A5F03232"
|
||||
android:type="linear"></gradient>
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="180"
|
||||
android:endColor="#00F03232"
|
||||
android:startColor="#A5F03232"
|
||||
android:type="linear"></gradient>
|
||||
</shape>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#00FF0606"
|
||||
android:startColor="#8CFF0606"
|
||||
android:type="linear"></gradient>
|
||||
</shape>
|
||||
@@ -2,8 +2,8 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/module_main_window_background_color"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/module_main_window_background_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 地图-->
|
||||
@@ -12,6 +12,36 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_390"
|
||||
android:background="@drawable/module_main_warning_bkg_top"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_left"
|
||||
android:layout_width="@dimen/dp_390"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/module_main_warning_bkg_left"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_right"
|
||||
android:layout_width="@dimen/dp_390"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/module_main_id_warning_view_marginLeft"
|
||||
android:background="@drawable/module_main_warning_bkg_right"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_390"
|
||||
android:layout_marginTop="@dimen/dp_690"
|
||||
android:background="@drawable/module_main_warning_bkg_bottom"
|
||||
android:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_main_id_map_left_shadow_frame"
|
||||
android:layout_width="@dimen/module_main_map_left_shadow_frame_width"
|
||||
|
||||
@@ -32,4 +32,6 @@
|
||||
<dimen name="module_main_event_panel_fragment_paddingBottom">18px</dimen>
|
||||
<dimen name="module_main_event_panel_fragment_paddingLeft">18px</dimen>
|
||||
<dimen name="module_main_event_panel_fragment_paddingRight">18px</dimen>
|
||||
|
||||
<dimen name="module_main_id_warning_view_marginLeft">1530px</dimen>
|
||||
</resources>
|
||||
36
modules/mogo-module-obu/doc/obu.md
Normal file
36
modules/mogo-module-obu/doc/obu.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# OBU
|
||||
|
||||
## 基本介绍
|
||||
OBU:安装在车上的车载单元,一台车安装一个
|
||||
RSU:路测单元,装在路边杆子上的
|
||||
|
||||
obu模块入口类是ObuManager
|
||||
|
||||
## 基本通信流程
|
||||
RSU与OBU可互相通信,OBU与OBU可互相通信,对于我们是黑盒,可以不用关心;
|
||||
OBU对外暴露两种通信方式:
|
||||
1. 以OBU为wifi热点,车机连接OBU后,与OBU进行通信,使用这种通信方式,分体机无法和工控机进行通信,而且分体机也没有网,无法和服务端进行通信,所以这种方式基本无用;
|
||||
2. 先用OBU连接车载路由,分体机也连接车载路由,拿到OBU的IP地址后,可与此IP(OBU)进行通信,使用这种通信方式,需要在车载路由上配置OBU的IP地址,__使其固定__,这样每次都连接同一IP地址即可,__目前使用的就是这种方式__;
|
||||
|
||||
## 需要处理的数据
|
||||
目前将obu返回的数据封装成了三种类型:
|
||||
1. 道路事件 MogoObuEventInfo
|
||||
2. 红绿灯信息 MogoObuTrafficLightInfo
|
||||
3. 自车定位 MogoObuLocationInfo
|
||||
目前只用到了道路事件和红绿灯信息,自车定位没有使用。
|
||||
|
||||
## 数据展示
|
||||
收到obu数据后,是在v2x模块进行的展示,关键类是V2XObuManager和v2x包下scenario/scene/obu下的类,其中一部分是在v2x展示,一部分是通过adas展示,但是在鹰眼模式可能都需要在智慧交通展示,所以做了一个中间类接收给adas的广播,用来处理在鹰眼模式下的展示,关键类AdasNoticeHelper;
|
||||
|
||||
## 通信方式
|
||||
通信方式分两种:__TCP通信__和__UDP通信__,不同的OBU通信方式也不一样。
|
||||
|
||||
### Cidi 希迪 obu
|
||||
cidi是接的sdk进行通信,由于sdk封装了ip地址设置这一步,也就是说ip地址在sdk层就已经固定了,无法修改,如果想有修改的话,需要需要把核心sdk抽取出来,重新封装sdk,此步骤可查阅源码进行分析,固定的IP地址为192.168.8.121;
|
||||
关键类是CidiObu;
|
||||
|
||||
### 华砺智行 obu
|
||||
目前应用在了苏州演示项目,采用tcp通信方式,关键类HualiObu,通信关键类是SimpleSocketManager;
|
||||
|
||||
### 大唐高鸿 obu
|
||||
目前应用在了国展演示项目,采用udp通信方式,关键类是NetCarObu,通信关键类是UdpSocketManager;
|
||||
@@ -26,6 +26,7 @@ import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.v2x.IV2XProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.CallChattingProviderConstant;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
@@ -59,6 +60,8 @@ public class MarkerServiceHandler {
|
||||
private static IMogoLauncher sLauncher;
|
||||
private static IMogoFragmentManager sFragmentManager;
|
||||
private static ICarsChattingProvider sCarChatting;
|
||||
private static IV2XProvider sIV2XProvider;
|
||||
|
||||
// private static IMogoGpsSimulatorManager sGpsSimulatorManager;
|
||||
|
||||
public static synchronized void init( final Context context ) {
|
||||
@@ -86,6 +89,7 @@ public class MarkerServiceHandler {
|
||||
sFragmentManager = sApis.getFragmentManagerApi();
|
||||
|
||||
sCarChatting = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context );
|
||||
sIV2XProvider = sApis.getV2XListenerManager();
|
||||
|
||||
MapMarkerManager.getInstance().init( context );
|
||||
|
||||
|
||||
@@ -26,10 +26,16 @@ public interface RefreshApiService {
|
||||
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotAsync" )
|
||||
Observable< BaseData > refreshData( @FieldMap Map< String, Object > parameters );
|
||||
|
||||
/*
|
||||
* 大而全
|
||||
* */
|
||||
@FormUrlEncoded
|
||||
@POST( "/yycp-launcherSnapshot/launcherSnapshot/querySnapshotSync" )
|
||||
Observable< MarkerResponse > refreshDataSync( @FieldMap Map< String, Object > parameters );
|
||||
|
||||
/*
|
||||
* 周边在线车辆
|
||||
* */
|
||||
@FormUrlEncoded
|
||||
@POST( "/yycp-launcherSnapshot/user/queryOnLineCarWithRoute" )
|
||||
Observable< MarkerResponse > queryOnLineCarWithRoute( @FieldMap Map< String, Object > parameters );
|
||||
|
||||
@@ -63,6 +63,9 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
// 同行者 查询xxx堵不堵发送的广播
|
||||
public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo";
|
||||
|
||||
//车路云—场景预警
|
||||
public static final String ACTION_V2X_FRONT_WARNING = "ACTION_V2X_FRONT_WARNING";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
|
||||
@@ -31,4 +31,12 @@ public class MoGoV2XServicePaths {
|
||||
@Keep
|
||||
public static final String PATH_V2X_POLYLINE_MANAGER = "/v2xPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 道路事件与车辆的连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_WARN_POLYLINE_MANAGER = "/v2xWarnPolylineManager/api";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.mogo.module.v2x.alarm.V2XCalculateServer;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XStatusManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.module.v2x.network.V2XRefreshModel;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
@@ -96,6 +97,7 @@ public class V2XServiceManager {
|
||||
private static IMoGoV2XMarkerManager moGoV2XMarkerManager;
|
||||
private static IMoGoV2XPolylineManager moGoV2XPolylineManager;
|
||||
private static IMoGoV2XStatusManager moGoV2XStatusManager;
|
||||
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
|
||||
|
||||
private V2XServiceManager() {
|
||||
|
||||
@@ -147,6 +149,8 @@ public class V2XServiceManager {
|
||||
|
||||
moGoV2XMarkerManager = (IMoGoV2XMarkerManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context);
|
||||
moGoV2XPolylineManager = (IMoGoV2XPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_POLYLINE_MANAGER).navigation(context);
|
||||
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
|
||||
|
||||
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
|
||||
}
|
||||
}
|
||||
@@ -239,6 +243,10 @@ public class V2XServiceManager {
|
||||
return moGoV2XPolylineManager;
|
||||
}
|
||||
|
||||
public static IMoGoWarnPolylineManager getMoGoWarnPolylineManager() {
|
||||
return moGoWarnPolylineManager;
|
||||
}
|
||||
|
||||
public static IMoGoV2XStatusManager getMoGoV2XStatusManager() {
|
||||
if (moGoV2XStatusManager == null) {
|
||||
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(V2XUtils.getApp());
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.v2x.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线
|
||||
*/
|
||||
public interface IMoGoWarnPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,目标车,与当前车辆间连线
|
||||
*
|
||||
* @param context
|
||||
* @param roadEventEntity
|
||||
*/
|
||||
void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoWarnPolyline();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mogo.module.v2x.manager.impl;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前车辆与道路事件的连接线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER)
|
||||
public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
private static final String TAG = "MoGoWarnPolylineManager";
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
//TODO liyz
|
||||
@Override
|
||||
public void drawableWarnPolyline(Context context, V2XRoadEventEntity roadEventEntity) {
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
if ((V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|
||||
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
|
||||
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
switch (roadEventEntity.getPoiType()) {
|
||||
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_SUGGEST:
|
||||
case V2XPoiTypeEnum.ALERT_TRAFFIC_LIGHT_WARNING:
|
||||
case V2XPoiTypeEnum.FOURS_BLOCK_UP:
|
||||
case V2XPoiTypeEnum.ALERT_CAR_TROUBLE_WARNING + "":
|
||||
colors.add(0xFFFFA31A);
|
||||
colors.add(0xFFFFA31A);
|
||||
break;
|
||||
default:
|
||||
colors.add(0xFFE32F46);
|
||||
colors.add(0xFFE32F46);
|
||||
break;
|
||||
}
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(10).useGradient(true).colorValues(colors);
|
||||
|
||||
// 当前车辆位置
|
||||
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (carLocation != null) {
|
||||
options.add(carLocation);
|
||||
} else {
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
}
|
||||
// 目标车辆位置
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng());
|
||||
|
||||
// 绘制线的对象
|
||||
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 绘制连接线的对象
|
||||
*/
|
||||
@Override
|
||||
public IMogoPolyline getMogoWarnPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.v2x.scenario.impl;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
@@ -21,6 +20,7 @@ import com.mogo.module.v2x.scenario.scene.pushVR.V2XPushVREventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.ugc.V2XEventUgcScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.warning.V2XFrontWarningScenario;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -75,8 +75,8 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_SEEK_WARNING:
|
||||
mV2XScenario = new V2XSeekHelpScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING :
|
||||
case ALERT_RECOMMEND_PARKING :
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_FATIGUE_DRIVING:
|
||||
case ALERT_RECOMMEND_PARKING:
|
||||
mV2XScenario = new V2XFatigueDrivingScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING:
|
||||
@@ -106,6 +106,12 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
|
||||
mV2XScenario = new V2XPushVREventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_RIGHT:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_BOTTOM:
|
||||
mV2XScenario = new V2XFrontWarningScenario();
|
||||
break;
|
||||
default:
|
||||
mV2XScenario = null;
|
||||
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
|
||||
|
||||
@@ -51,6 +51,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
private Button mBtnTriggerRoadEvent;
|
||||
private Button mBtnClearRoadEvent;
|
||||
private Button mBtnTriggerPushEvent;
|
||||
private Button mBtnTriggerWarningEvent;
|
||||
private Button mBtnTriggerPushLiveCarEvent;
|
||||
private Button mBtnTriggerAnimationEvent;
|
||||
private Button mBtnbtnFrontCarLiveEvent;
|
||||
@@ -112,6 +113,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
|
||||
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
|
||||
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
|
||||
mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent);
|
||||
mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent);
|
||||
mBtnTriggerPushLiveCarEvent = findViewById(R.id.btnTriggerPushLiveCarEvent);
|
||||
mBtnTriggerAnimationEvent = findViewById(R.id.btnTriggerAnimationEvent);
|
||||
@@ -213,6 +215,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
|
||||
|
||||
});
|
||||
|
||||
//车路云—场景预警-V1.0 碰撞预警
|
||||
mBtnTriggerWarningEvent.setOnClickListener(v->{
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
|
||||
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
});
|
||||
|
||||
mBtnTriggerPushEvent.setOnClickListener(v -> {
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioPushEventData();
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.mogo.module.v2x.scenario.scene.warning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.MogoServices;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.impl.MogoServiceApis;
|
||||
import com.mogo.service.impl.v2x.V2XManager;
|
||||
import com.mogo.service.v2x.IV2XListener;
|
||||
import com.mogo.service.v2x.IV2XProvider;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 车路云—场景预警-V1.0 前车/行人/摩托车/盲区碰撞预警
|
||||
* @since: 2021/3/24
|
||||
*/
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopViewStatusListener {
|
||||
private int type;
|
||||
private IV2XListener mIV2XListener;
|
||||
private List<V2XSpecialCarRes.V2XMarkerEntity> mMarkerEntity;
|
||||
private V2XPushMessageEntity mV2XPushMessageEntity;
|
||||
|
||||
public V2XFrontWarningScenario() {
|
||||
setV2XWindow(new V2XWarningWindow());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity v2XMessageEntity) {
|
||||
type = v2XMessageEntity.getType();
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithType(type, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
try {
|
||||
if (V2XServiceManager.getMoGoStatusManager().isMainPageOnResume()) {
|
||||
if (getV2XMessageEntity() != null &&
|
||||
!V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpWindowShow()) {
|
||||
show();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
showWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showWindow() {
|
||||
// if (getV2XWindow() != null && mMarkerEntity != null) {
|
||||
View view = getV2XWindow().getView();
|
||||
//Logger.d(MODULE_NAME, "添加window= " + view);
|
||||
ViewGroup.LayoutParams layoutParams =
|
||||
new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
(int) V2XUtils.getApp().getResources().getDimension(R.dimen.module_v2x_fatigue_driving_window_height_ground));
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.addView(getV2XWindow().getView(), layoutParams, this);
|
||||
getV2XWindow().show(mV2XPushMessageEntity);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showButton() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeButton() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.mogo.module.v2x.scenario.scene.warning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.module.v2x.R;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.scene.V2XBasWindow;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XWindow;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 车路云—场景预警 http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=52829799
|
||||
* @since: 2021/3/25
|
||||
*/
|
||||
public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
|
||||
|
||||
private ImageView typeImage;
|
||||
private TextView warningTextView;
|
||||
private TextView distance;
|
||||
|
||||
//倒计时3s弹框取消
|
||||
private static Handler handlerV2XEvent = new Handler();
|
||||
private static Runnable runnableV2XEvent;
|
||||
private static final int COUNT_DOWN_TIMER = 1_000;
|
||||
private static final int ALL_EXPIRE_TIMER = 3_000;
|
||||
private static int EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
|
||||
public V2XWarningWindow() {
|
||||
this(V2XServiceManager.getContext(), null);
|
||||
}
|
||||
|
||||
public V2XWarningWindow(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public V2XWarningWindow(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LayoutInflater.from(context).inflate(R.layout.v2x_road_front_warning_vr, this);
|
||||
typeImage = findViewById(R.id.warning_type_image);
|
||||
warningTextView = findViewById(R.id.warning_content_text);
|
||||
distance = findViewById(R.id.warning_distance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Object entity) {
|
||||
if (entity != null) {
|
||||
|
||||
}
|
||||
if (runnableV2XEvent == null) {
|
||||
runnableV2XEvent = () -> {
|
||||
EXPIRE_TIMER = EXPIRE_TIMER - COUNT_DOWN_TIMER;
|
||||
if (EXPIRE_TIMER > 0) {
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
} else {
|
||||
stopCountDown();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
}
|
||||
handlerV2XEvent.postDelayed(runnableV2XEvent, COUNT_DOWN_TIMER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
stopCountDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
|
||||
}
|
||||
|
||||
private void stopCountDown() {
|
||||
if (handlerV2XEvent != null && runnableV2XEvent != null) {
|
||||
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
|
||||
runnableV2XEvent = null;
|
||||
EXPIRE_TIMER = ALL_EXPIRE_TIMER;
|
||||
}
|
||||
//移除窗体
|
||||
V2XServiceManager
|
||||
.getMogoTopViewManager()
|
||||
.removeView(this);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,35 @@ public class TestOnLineCarUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioPushFrontWarningEventData() {
|
||||
try {
|
||||
InputStream inputStream = V2XUtils.getApp()
|
||||
.getResources()
|
||||
.openRawResource(R.raw.scenario_warning_event_data);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int len = -1;
|
||||
byte[] buffer = new byte[1024];
|
||||
while ((len = inputStream.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, len);
|
||||
}
|
||||
inputStream.close();
|
||||
|
||||
// 加载数据源
|
||||
V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class);
|
||||
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
|
||||
// 控制类型
|
||||
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
|
||||
// 设置数据
|
||||
v2xMessageEntity.setContent(v2xRoadEventEntity);
|
||||
// 控制展示状态
|
||||
v2xMessageEntity.setShowState(true);
|
||||
return v2xMessageEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟H5推送直播数据
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--<selector xmlns:android="http://schemas.android.com/apk/res/android">-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:angle="135"
|
||||
android:endColor="#CC000000"
|
||||
android:startColor="#CC000000"
|
||||
android:type="linear" />
|
||||
<corners android:radius="@dimen/dp_20" />
|
||||
</shape>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="@dimen/dp_470"
|
||||
android:layout_height="@dimen/dp_140"
|
||||
android:layout_marginLeft="@dimen/dp_190"
|
||||
android:background="@drawable/v2x_front_warning_bg"
|
||||
android:layout_marginTop="@dimen/dp_20">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/warning_type_image"
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_marginLeft="@dimen/dp_28"
|
||||
android:layout_marginTop="@dimen/dp_20"
|
||||
android:src="@drawable/v2x_road_front_car_warning" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/warning_distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="@dimen/dp_28"
|
||||
android:maxWidth="@dimen/dp_100"
|
||||
android:text="1.2米"
|
||||
android:textColor="@color/v2x_FF3036"
|
||||
android:textSize="@dimen/dp_32" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/warning_content_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+id/warning_distance"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/dp_20"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
android:layout_toRightOf="@+id/warning_type_image"
|
||||
android:text="前车碰撞预警"
|
||||
android:textColor="@color/v2x_FFF_333"
|
||||
android:textSize="@dimen/dp_32" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -239,6 +239,20 @@
|
||||
android:textSize="@dimen/dp_22"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTriggerWarningEvent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:background="#FF0606"
|
||||
android:padding="@dimen/dp_10"
|
||||
android:text="前车碰撞预警"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/dp_22"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTriggerPushEvent"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"systemTime":1615529739389,
|
||||
"satelliteTime":1615529739389,
|
||||
"lon":116.411360351446,
|
||||
"lat":39.9760799115428,
|
||||
"alt":34.4648361206054,
|
||||
"heading":359.939618623258,
|
||||
"speed":11.108121,
|
||||
"type":3,
|
||||
"uuid":"2_1",
|
||||
"direction": "0"
|
||||
}
|
||||
@@ -17,5 +17,5 @@
|
||||
<color name="v2x_000_FFF">#000000</color>
|
||||
<color name="v2x_FFF_2896FF">#FFF</color>
|
||||
<color name="v2x_share_des_title_color">#4DFFFFFF</color>
|
||||
|
||||
<color name="v2x_FF3036">#FF3036</color>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user