Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map

This commit is contained in:
wangcongtao
2020-10-28 18:01:00 +08:00
26 changed files with 1565 additions and 124 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="SuppressionsComponent">

View File

@@ -40,6 +40,7 @@ dependencies {
implementation project(":foudations:mogo-utils")
implementation project(":foudations:mogo-commons")
implementation project(":services:mogo-service-api")
implementation project(':modules:mogo-module-common')
}
}

View File

@@ -139,6 +139,8 @@ public class V2XMessageEntity<T> implements Serializable {
int ALERT_ILLEGAL_PARK_WARNING = 1_008;
// 呼叫、请求直播事件
int ALERT_VOICE_CALL_FOR_LIVECAR_SHOW = 1_009;
// 推送VR消息展示
int ALERT_PUSH_VR_SHOW = 2_000;
// 自车求助
int ALERT_CAR_FOR_HELP = 8_000;
// obu事件
@@ -157,6 +159,7 @@ public class V2XMessageEntity<T> implements Serializable {
V2XTypeEnum.ALERT_ILLEGAL_PARK_WARNING,
V2XTypeEnum.ALERT_CAR_FOR_HELP,
V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW,
V2XTypeEnum.ALERT_PUSH_VR_SHOW,
V2XTypeEnum.ALERT_OBU_EVENT,
})
@Target({

View File

@@ -9,6 +9,7 @@ import com.mogo.module.extensions.utils.EntranceViewHolder;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.entrance.ButtonIndex;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.service.windowview.IMogoEntranceViewListener;
/**
* @author congtaowang
@@ -59,6 +60,16 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
EntranceViewHolder.getInstance().hideLeftNoticeByType(noticeType);
}
@Override
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
EntranceViewHolder.getInstance().addEntranceViewListener(listener);
}
@Override
public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
EntranceViewHolder.getInstance().removeEntranceViewListener(listener);
}
@Override
public void init( Context context ) {

View File

@@ -6,11 +6,13 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.mogo.map.location.IMogoLocationListener;
import com.mogo.map.location.MogoLocation;
import com.mogo.map.navi.MogoTraffic;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.CloudRoadData;
import com.mogo.module.common.entity.MogoSnapshotSetData;
@@ -31,54 +33,79 @@ import org.json.JSONObject;
* @author tongchenfei
*/
public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLocationListener,
Handler.Callback , IMogoOnWebSocketMessageListener<MogoSnapshotSetData> {
Handler.Callback, IMogoOnWebSocketMessageListener<MogoSnapshotSetData> {
private static final String TAG = "AdasNoticeHelper";
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_OBU = 1001;
private static final int MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD = 1002;
private static final int MSG_HIDE_LIMIT_SPEED = 1003;
private static final int MSG_REFRESH_CAR_STRATEGY = 1004;
private static final long HIDE_TRAFFIC_LIGHT_DELAY = 2_000L;
private static final long HIDE_LIMIT_SPEED_DELAY = 10_000L;
private static final long STRATEGY_DELAY = 1000L;
private Context context;
private AdasNoticeReceiver adasReceiver = new AdasNoticeReceiver();
private boolean isVrMode = false;
private volatile boolean isVrMode = false;
private TextView tvSelfSpeed, tvTrafficLight, tvLimitSpeed;
private int limitSpeed;
private int currentSpeed = 0;
private String lightStatus = "G";
private String surplusTime;
private Handler handler = new Handler(this);
private View selfCar;
private boolean lightCenter = false;
public void init(Context context) {
this.context = context;
if(!lightCenter) {
selfCar = LayoutInflater.from(context).inflate(R.layout.module_ext_item_self_car, null);
tvSelfSpeed = selfCar.findViewById(R.id.tvSelfSpeed);
tvTrafficLight = selfCar.findViewById(R.id.tvTrafficLight);
tvLimitSpeed = selfCar.findViewById(R.id.tvLimitSpeed);
}
Logger.d(TAG, "init====");
}
public void initView(View root) {
tvSelfSpeed = root.findViewById(R.id.tvSelfSpeed);
tvTrafficLight = root.findViewById(R.id.tvTrafficLight);
tvLimitSpeed = root.findViewById(R.id.tvLimitSpeed);
if(lightCenter) {
tvSelfSpeed = root.findViewById(R.id.tvSelfSpeed);
tvTrafficLight = root.findViewById(R.id.tvTrafficLight);
tvLimitSpeed = root.findViewById(R.id.tvLimitSpeed);
}
}
public void enterVrMode() {
isVrMode = true;
IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
context.registerReceiver(adasReceiver, filter);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
// debug code
tvSelfSpeed.setVisibility(View.VISIBLE);
tvTrafficLight.setVisibility(View.VISIBLE);
tvLimitSpeed.setVisibility(View.VISIBLE);
Logger.d(TAG, "enterVrMode===" + isVrMode);
if (!isVrMode) {
isVrMode = true;
IntentFilter filter = new IntentFilter("com.mogo.launcher.adas.app.biz");
context.registerReceiver(adasReceiver, filter);
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasWarnMessageCallback(this);
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerMogoLocationListener(TAG, this);
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(context).registerOnWebSocketMessageListener(this);
if(!lightCenter) {
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
}
// debug code
// tvSelfSpeed.setVisibility(View.VISIBLE);
// tvTrafficLight.setVisibility(View.VISIBLE);
// tvLimitSpeed.setVisibility(View.VISIBLE);
}
}
public void exitVrMode() {
if(isVrMode) {
Logger.d(TAG, "退出vr模式===" + isVrMode);
if (isVrMode) {
isVrMode = false;
handler.removeMessages(MSG_REFRESH_CAR_STRATEGY);
tvSelfSpeed.setVisibility(View.GONE);
tvTrafficLight.setVisibility(View.GONE);
tvLimitSpeed.setVisibility(View.GONE);
@@ -91,7 +118,7 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
@Override
public void onReceiveData(ADASWarnMessage msg) {
Logger.d(TAG, "收到adas warn message, isVrMode: "+isVrMode+" msg: " + msg);
Logger.d(TAG, "收到adas warn message, isVrMode: " + isVrMode + " msg: " + msg);
if (!isVrMode) {
return;
}
@@ -119,20 +146,49 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (!isVrMode) {
return;
}
int speed = (int) (location.getSpeed() * 3.6F);
if (tvSelfSpeed != null) {
tvSelfSpeed.post(() -> {
if (tvSelfSpeed.getVisibility() == View.GONE) {
tvSelfSpeed.setVisibility(View.VISIBLE);
}
tvSelfSpeed.setText("" + speed);
});
currentSpeed = (int) (location.getSpeed() * 3.6F);
if(lightCenter) {
if (tvSelfSpeed != null) {
tvSelfSpeed.post(() -> {
if (tvSelfSpeed.getVisibility() == View.GONE) {
tvSelfSpeed.setVisibility(View.VISIBLE);
}
tvSelfSpeed.setText("" + currentSpeed);
Logger.d(TAG, "onLocationChange: " + currentSpeed);
});
}
}
}
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case MSG_REFRESH_CAR_STRATEGY:
// 自车速度
tvSelfSpeed.setText("" + currentSpeed);
// 红绿灯
if (tvTrafficLight.getVisibility() == View.GONE) {
tvTrafficLight.setVisibility(View.VISIBLE);
}
// todo 设置字体颜色、背景颜色、leftDrawable
switch (lightStatus) {
case "Y":
// 黄灯
break;
case "R":
// 红灯
break;
default:
// 默认绿灯
break;
}
tvTrafficLight.setText(surplusTime + "S");
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showMyLocation(selfCar);
if (isVrMode) {
handler.sendEmptyMessageDelayed(MSG_REFRESH_CAR_STRATEGY, STRATEGY_DELAY);
}
return true;
case MSG_HIDE_LIMIT_SPEED:
tvLimitSpeed.setVisibility(View.GONE);
return true;
@@ -191,40 +247,62 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU);
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
drawTrafficLight(lightStatus, surplusTime);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU, HIDE_TRAFFIC_LIGHT_DELAY);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU,
HIDE_TRAFFIC_LIGHT_DELAY);
}
}
private void handleCloudTrafficLight(CloudRoadData roadData){
private void handleCloudTrafficLight(CloudRoadData roadData) {
if (tvTrafficLight != null && !handler.hasMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_OBU)) {
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
// todo drawTrafficLight
String lightStatus;
switch (roadData.getLightStatus()) {
case 1:
// 红灯
lightStatus = "R";
break;
case 3:
// 黄灯
lightStatus = "Y";
break;
default:
// 默认绿灯
lightStatus = "G";
break;
}
int diff = (int) ((System.currentTimeMillis() - roadData.getSystemTime()) / 1000);
int leftTime = roadData.getLightLeftTime() - diff;
drawTrafficLight(lightStatus, "" + leftTime);
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD,
HIDE_TRAFFIC_LIGHT_DELAY);
}
}
private void drawTrafficLight(String lightStatus, String surplusTime) {
tvTrafficLight.post(() -> {
if (tvTrafficLight.getVisibility() == View.GONE) {
tvTrafficLight.setVisibility(View.VISIBLE);
}
// todo 设置字体颜色、背景颜色、leftDrawable
switch (lightStatus) {
case "Y":
// 黄灯
break;
case "R":
//
break;
default:
// 默认绿
break;
}
tvTrafficLight.setText(surplusTime + "S");
Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime);
});
this.lightStatus = lightStatus;
this.surplusTime = surplusTime;
if(lightCenter) {
tvTrafficLight.post(() -> {
if (tvTrafficLight.getVisibility() == View.GONE) {
tvTrafficLight.setVisibility(View.VISIBLE);
}
// todo 设置字体颜色、背景颜色、leftDrawable
switch (lightStatus) {
case "Y":
//
break;
case "R":
//
break;
default:
// 默认绿灯
break;
}
tvTrafficLight.setText(surplusTime + "S");
Logger.d(TAG, "展示红绿灯信息: " + lightStatus + " time: " + surplusTime);
});
}
}
@Override
@@ -244,6 +322,8 @@ public class AdasNoticeHelper implements IMogoAdasWarnMessageCallback, IMogoLoca
if (roadData != null) {
Logger.d(TAG, "收到红绿灯数据");
handleCloudTrafficLight(roadData);
} else {
handler.sendEmptyMessage(MSG_HIDE_TRAFFIC_LIGHT_BY_CLOUD);
}
}
}

View File

@@ -11,6 +11,7 @@ import android.widget.TextView;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.extensions.R;
import com.mogo.module.extensions.bean.BottomLayerViewWrapper;
import com.mogo.service.windowview.IMogoEntranceViewListener;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
@@ -146,6 +147,9 @@ public class EntranceViewHolder {
}
public void forceHideNoticeView(){
for (IMogoEntranceViewListener listener : listeners) {
listener.onViewRemoved(currentShowNoticeType);
}
preAddLeftNoticeView = null;
currentShowNoticeType = 0;
if (leftNoticeContainer != null) {
@@ -156,6 +160,11 @@ public class EntranceViewHolder {
private int currentShowNoticeType = 0;
public void showLeftNoticeByType(int noticeType, int iconRes, String content){
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
if (currentShowNoticeType != noticeType && currentShowNoticeType != 0) {
for (IMogoEntranceViewListener listener : listeners) {
listener.onViewRemoved(currentShowNoticeType);
}
}
currentShowNoticeType = noticeType;
if (leftNoticeContainer != null) {
realShowLeftNoticeView(generateNoticeViewByType(noticeType, iconRes, content));
@@ -196,6 +205,9 @@ public class EntranceViewHolder {
leftNoticeContainer.removeAllViews();
leftNoticeContainer.addView(view);
preAddLeftNoticeView = null;
for (IMogoEntranceViewListener listener : listeners) {
listener.onViewAdded(currentShowNoticeType);
}
}
private void realHideLeftNoticeView(View view) {
@@ -203,6 +215,16 @@ public class EntranceViewHolder {
leftNoticeContainer.setVisibility(View.GONE);
}
private List<IMogoEntranceViewListener> listeners = new ArrayList<>();
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
listeners.add(listener);
}
public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
listeners.remove(listener);
}
public void release(){
rootViewGroup = null;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvSelfSpeed"
tools:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_speed_red_bg"
android:gravity="center"
android:text="72"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_red"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
app:layout_constraintRight_toLeftOf="@+id/tvTrafficLight"
app:layout_constraintTop_toTopOf="@+id/tvTrafficLight"/>
<TextView
android:id="@+id/tvTrafficLight"
tools:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/module_ext_vr_mode_traffic_light_green_bg"
android:gravity="center"
android:text="26S"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_green"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/ivSelfCar"
app:layout_constraintRight_toRightOf="@+id/ivSelfCar"
app:layout_constraintBottom_toTopOf="@+id/ivSelfCar"/>
<TextView
android:id="@+id/tvLimitSpeed"
tools:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_speed_white_bg"
android:gravity="center"
android:text="160"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_white"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
app:layout_constraintLeft_toRightOf="@+id/tvTrafficLight"
app:layout_constraintTop_toTopOf="@+id/tvTrafficLight"/>
<ImageView
android:id="@+id/ivSelfCar"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_ext_self_car" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -232,45 +232,46 @@
android:id="@+id/tvSelfSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_speed_red_bg"
android:gravity="center"
android:text="72"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_red"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
android:gravity="center"
tools:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintRight_toLeftOf="@+id/tvTrafficLight"
app:layout_constraintTop_toTopOf="@+id/tvTrafficLight"
tools:visibility="visible" />
<TextView
android:id="@+id/tvTrafficLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_traffic_light_green_bg"
android:text="26S"
android:gravity="center"
android:layout_marginStart="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:text="26S"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_green"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintLeft_toRightOf="@+id/tvSelfSpeed"
app:layout_constraintTop_toTopOf="@+id/tvSelfSpeed" />
app:layout_constraintRight_toLeftOf="@+id/tvLimitSpeed"
app:layout_constraintTop_toTopOf="@+id/tvLimitSpeed"
tools:visibility="visible" />
<TextView
android:id="@+id/tvLimitSpeed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:layout_marginTop="@dimen/module_ext_vr_mode_self_speed_margin_end"
android:background="@drawable/module_ext_vr_mode_speed_white_bg"
android:text="160"
tools:visibility="visible"
android:gravity="center"
android:text="160"
android:textColor="@color/module_ext_vr_mode_left_traffic_light_white"
android:textSize="@dimen/module_ext_vr_mode_traffic_light_text_size"
android:visibility="gone"
app:layout_constraintLeft_toRightOf="@+id/tvTrafficLight"
app:layout_constraintTop_toTopOf="@+id/tvTrafficLight" />
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ivUserHeadImg"
tools:visibility="visible" />
<Button
android:id="@+id/btnDebugCtrlTopView"

View File

@@ -11,8 +11,10 @@ import com.mogo.commons.debug.DebugConfig
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.obu.obu.HualiObu
import com.zhidao.mogo.module.obu.obu.IObu
import com.zhidao.mogo.module.obu.obu.*
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo
import com.zhidao.mogo.module.obu.socket.IUdpSocketCallback
import com.zhidao.smartv2x.listener.OnMessageReceiveListener
import com.zhidao.smartv2x.model.obu.CarEventInfo
import com.zhidao.smartv2x.model.obu.TrafficLightInfo
@@ -35,7 +37,7 @@ class MockUtil:Handler.Callback {
const val TAG = "MockUtil"
}
private var dataCallback: OnMessageReceiveListener? = null
private var dataCallback: IObuCallback? = null
private lateinit var intervalObs: Disposable
private lateinit var intervalObs2: Disposable
@@ -54,12 +56,13 @@ class MockUtil:Handler.Callback {
return false
}
fun init(context: Context,obu:HualiObu){
fun init(context: Context,obu:BaseObu){
Logger.d(TAG, "使用模拟obu数据===")
this.context = context
dataCallback = obu.callback
view = LayoutInflater.from(context).inflate(R.layout.mock_obu, null)
view.findViewById<Button>(R.id.btnVip).setOnClickListener {
val carEventInfo = CarEventInfo()
val carEventInfo = MogoObuEventInfo()
carEventInfo.type = "vip变灯提醒"
carEventInfo.typeCode = "vip变灯提醒"
val r = Random.nextInt(0, 2)
@@ -67,23 +70,33 @@ class MockUtil:Handler.Callback {
0 -> "已更改前方红绿灯状态,可优先通行"
else -> "已增加前方绿灯时间,可优先通行"
}
dataCallback?.showCarEventInfo(carEventInfo)
dataCallback?.onEventInfoCallback(carEventInfo)
}
view.findViewById<Button>(R.id.btnPersonCrash).setOnClickListener {
obu.onMessageReceived("{\"pedestrain_information\": {\"pedestrian_crash_alarm\": 1}}".toByteArray())
// view.findViewById<Button>(R.id.btnPersonCrash).setOnClickListener {
// obu.onMessageReceived("{\"pedestrain_information\": {\"pedestrian_crash_alarm\": 1}}".toByteArray())
// }
//
// view.findViewById<Button>(R.id.btnCrossCrash).setOnClickListener {
// obu.onMessageReceived("{\"intersection_crash\":{\"intersection_crash_alarm\":1}}".toByteArray())
// }
//
// view.findViewById<Button>(R.id.btnOptimizeSpeed).setOnClickListener {
// obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 1,\"advisory_speed\":40.0}]}}".toByteArray())
// }
//
// view.findViewById<Button>(R.id.btnRushRedLight).setOnClickListener {
// obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 0}]}}".toByteArray())
// }
view.findViewById<Button>(R.id.btnStartTrafficLight).setOnClickListener {
intervalMockData()
}
view.findViewById<Button>(R.id.btnCrossCrash).setOnClickListener {
obu.onMessageReceived("{\"intersection_crash\":{\"intersection_crash_alarm\":1}}".toByteArray())
}
view.findViewById<Button>(R.id.btnOptimizeSpeed).setOnClickListener {
obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 1,\"advisory_speed\":40.0}]}}".toByteArray())
}
view.findViewById<Button>(R.id.btnRushRedLight).setOnClickListener {
obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 0}]}}".toByteArray())
view.findViewById<Button>(R.id.btnStopTrafficLight).setOnClickListener {
if (intervalObs != null&&!intervalObs.isDisposed) {
intervalObs.dispose()
}
}
handler.sendEmptyMessageDelayed(1001, 10000)
@@ -138,7 +151,7 @@ class MockUtil:Handler.Callback {
private fun debugCarEvent() {
val random = Random.nextInt(0, 4)
Logger.d(TAG, "random====$random")
val carEventInfo = CarEventInfo()
val carEventInfo = MogoObuEventInfo()
when (random) {
0 -> {
// 绿波引导
@@ -150,21 +163,21 @@ class MockUtil:Handler.Callback {
1 -> "建议50km/h车速行驶"
else -> "建议30km/h ~ 50km/h 车速行驶"
}
dataCallback?.showCarEventInfo(carEventInfo)
dataCallback?.onEventInfoCallback(carEventInfo)
}
1 -> {
// 前方急刹预警
carEventInfo.type = "紧急制动预警"
carEventInfo.typeCode = "06"
carEventInfo.describe = "这个应该是随便写,反正也不用"
dataCallback?.showCarEventInfo(carEventInfo)
dataCallback?.onEventInfoCallback(carEventInfo)
}
2 -> {
// 行人碰撞预警
carEventInfo.type = "行人碰撞预警"
carEventInfo.typeCode = "39"
carEventInfo.describe = "这个应该是随便写,反正也不用"
dataCallback?.showCarEventInfo(carEventInfo)
dataCallback?.onEventInfoCallback(carEventInfo)
}
3 -> {
// vip变灯提醒
@@ -175,7 +188,7 @@ class MockUtil:Handler.Callback {
0 -> "已更改前方红绿灯状态,可优先通行"
else -> "已增加前方绿灯时间,可优先通行"
}
dataCallback?.showCarEventInfo(carEventInfo)
dataCallback?.onEventInfoCallback(carEventInfo)
}
else -> {
// 其他,不处理
@@ -187,13 +200,13 @@ class MockUtil:Handler.Callback {
Logger.d(TAG, "准备开始红绿灯模拟数据发送===")
Thread.sleep(20_000)
Logger.d(TAG, "开始红绿灯模拟数据发送===")
val trafficLightInfo = TrafficLightInfo()
val trafficLightInfo = MogoObuTrafficLightInfo()
trafficLightInfo.id = "12"
// 先来6秒红灯
trafficLightInfo.lightStatus = "R"
for (i in 0..5) {
trafficLightInfo.surplusTime = (5 - i).toString()
dataCallback?.showTrafficLightInfo(trafficLightInfo)
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
Thread.sleep(1000)
}
// 停5秒
@@ -202,7 +215,7 @@ class MockUtil:Handler.Callback {
trafficLightInfo.lightStatus = "Y"
for (i in 0..5) {
trafficLightInfo.surplusTime = (5 - i).toString()
dataCallback?.showTrafficLightInfo(trafficLightInfo)
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
Thread.sleep(1000)
}
// 停5秒
@@ -211,7 +224,7 @@ class MockUtil:Handler.Callback {
trafficLightInfo.lightStatus = "G"
for (i in 0..5) {
trafficLightInfo.surplusTime = (5 - i).toString()
dataCallback?.showTrafficLightInfo(trafficLightInfo)
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
Thread.sleep(1000)
}
Logger.d(TAG, "红绿灯模拟数据发送结束====")

View File

@@ -3,10 +3,8 @@ package com.zhidao.mogo.module.obu
import android.content.Context
import com.mogo.commons.debug.DebugConfig
import com.mogo.utils.logger.Logger
import com.zhidao.mogo.module.obu.obu.CidiObu
import com.zhidao.mogo.module.obu.obu.HualiObu
import com.zhidao.mogo.module.obu.obu.IObu
import com.zhidao.mogo.module.obu.obu.IObuCallback
import com.zhidao.mogo.module.obu.obu.*
import com.zhidao.mogo.module.obu.socket.IUdpSocketCallback
/**
* obu provider
@@ -21,9 +19,10 @@ class ObuManager {
// private var handler = Handler(Looper.getMainLooper(), this)
private lateinit var obu: IObu
private lateinit var context: Context
fun init(context: Context) {
Logger.d(TAG, "init=======")
this.context = context
obu = if (DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
CidiObu()
} else {
@@ -35,6 +34,10 @@ class ObuManager {
fun registerObuDataChangedListener(listener: IObuCallback?) {
if (listener != null) {
obu.registerObuCallback(listener)
if(DebugConfig.isUseMockObuData() ) {
val mockUtil = MockUtil()
mockUtil.init(context, obu as BaseObu)
}
}
}

View File

@@ -1,7 +1,7 @@
package com.zhidao.mogo.module.obu.obu
abstract class BaseObu : IObu {
protected var callback: IObuCallback? = null
var callback: IObuCallback? = null
override fun init() {
}

View File

@@ -69,7 +69,7 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
}
override fun onMessageReceived(msg: ByteArray) {
// 处理数据
// 接收到obu原始数据处理数据
// val m = String(msg)
// Logger.d(TAG, "onMessageReceived: $m")
// printByteArray(msg)
@@ -277,6 +277,9 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
}
}
/**
* 根据末位校验数据可用性
*/
private fun isAvailable(msg: ByteArray): Boolean {
val checkSum = msg.last()
var check = msg[0].xor(0xff.toByte())
@@ -299,6 +302,9 @@ class HualiObu : BaseObu(), IUdpSocketCallback {
Logger.d(TAG, arrayBuilder.toString())
}
/**
* byte数组转int
*/
private fun convertTwoUnSignInt(byteArray: ByteArray): Int =
(byteArray[0].toInt() shl 24) or (byteArray[1].toInt() and 0xFF) or (byteArray[2].toInt() shl 8) or (byteArray[3].toInt() and 0xFF)

View File

@@ -34,8 +34,16 @@
android:layout_height="wrap_content"
android:text="行人碰撞" />
<Button
android:id="@+id/btnStartTrafficLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始红绿灯倒计时" />
<Button
android:id="@+id/btnStopTrafficLight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止红绿灯倒计时" />
</GridLayout>

View File

@@ -124,23 +124,23 @@ public class V2XAlarmServer {
}
return null;
} else {
Logger.w(MODULE_NAME, "V2X预警--事件与车头角度夹角过大:" +
"\n角度" + eventAngle + "" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
);
// Logger.w(MODULE_NAME, "V2X预警--事件与车头角度夹角过大:" +
// "\n角度" + eventAngle + " 度" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
} else {
Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了" +
"\n距离" + v2XRoadEventEntity.getDistance() + "" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
);
// Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了" +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
} else {
Logger.w(MODULE_NAME,
"V2X预警--车头方向与事件方向角度不一致:" +
"\n车头方向 " + currentLocation.getBearing() +
"\n事件方向" + v2XRoadEventEntity.getLocation().getAngle()
);
// Logger.w(MODULE_NAME,
// "V2X预警--车头方向与事件方向角度不一致:" +
// "\n车头方向 " + currentLocation.getBearing() +
// "\n事件方向" + v2XRoadEventEntity.getLocation().getAngle()
// );
}
}
}

View File

@@ -101,10 +101,6 @@ public class V2XMessageListener_401003 implements IMogoOnMessageListener<V2XPush
showTip(alarmMessage.getTts());
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;
//以下为V推送场景
case "200006"://对向来车
showTip(alarmMessage.getTts());
break;
default:
ADASUtils.broadcastToADAS_TTS(V2XServiceManager.getContext(), alarmMessage);
break;

View File

@@ -15,6 +15,7 @@ import com.mogo.module.v2x.scenario.scene.livecar.V2XPushLiveCarScenario;
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveScenario;
import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
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.utils.V2XUtils;
@@ -99,6 +100,9 @@ public class V2XScenarioManager implements IV2XScenarioManager {
case V2XMessageEntity.V2XTypeEnum.ALERT_VOICE_CALL_FOR_LIVECAR_SHOW:
mV2XScenario = V2XVoiceCallLiveScenario.getInstance();
break;
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
mV2XScenario = V2XPushVREventScenario.getInstance();
break;
default:
Logger.e(MODULE_NAME, "当前V2X消息类型未定义。");
TipToast.tip("当前V2X消息类型未定义");

View File

@@ -0,0 +1,78 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerExploreWayItem;
import com.mogo.module.common.entity.MarkerLocation;
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.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XMarkerClickListener;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.utils.MarkerUtils;
import java.util.ArrayList;
import java.util.List;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : 推送VR场景
* version: 1.0
*/
public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
@Override
public void drawPOI(V2XPushMessageEntity entity) {
try {
// 清除道路事件
V2XServiceManager
.getMoGoV2XMarkerManager().clearALLPOI();
// 位置信息
MarkerLocation markerLocation = new MarkerLocation();
markerLocation.setLon(entity.getLon());
markerLocation.setLat(entity.getLat());
// 进行数据转换用于Marker展示
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
v2XRoadEventEntity.setLocation(markerLocation);
// 探路目前只有上报拥堵
v2XRoadEventEntity.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
MarkerExploreWay markerNoveltyInfo = new MarkerExploreWay();
List<MarkerExploreWayItem> items = new ArrayList<>();
MarkerExploreWayItem exploreWayItem = new MarkerExploreWayItem();
exploreWayItem.setThumbnail(entity.getMsgImgUrl());
items.add(exploreWayItem);
markerNoveltyInfo.setPoiType(V2XPoiTypeEnum.ALERT_TRAFFIC_EXPRESS);
markerNoveltyInfo.setItems(items);
markerNoveltyInfo.setUploadType("1");
v2XRoadEventEntity.setNoveltyInfo(markerNoveltyInfo);
v2XRoadEventEntity.setExpireTime(20000);
V2XServiceManager
.getMoGoV2XMarkerManager()
.drawableAlarmPOI(V2XServiceManager.getContext(),
v2XRoadEventEntity,
V2XMarkerClickListener.getInstance());
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearPOI() {
// 锁车就是将地图视图移植中心点,因为行驶中的车和地图要相对的跟随
MarkerUtils.resetMapZoom(16);
// 移除线
V2XServiceManager.getMoGoV2XPolylineManager().clearLine();
// 移除事件POI
V2XServiceManager.getMoGoV2XMarkerManager().clearAlarmPOI();
// 绘制上次的数据
V2XServiceManager.getMoGoV2XMarkerManager().drawableLastAllPOI();
}
}

View File

@@ -0,0 +1,143 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.view.View;
import androidx.annotation.Nullable;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/5/15 5:37 PM
* desc : 推送VR场景控制
* version: 1.0
*/
public class V2XPushVREventScenario
extends AbsV2XScenario<V2XPushMessageEntity>
implements IMogoTopViewStatusListener {
private String TAG = "V2XPushVREventWindow";
private static V2XPushVREventScenario mV2XPushEventScenario;
private V2XPushVREventScenario() {
}
public static V2XPushVREventScenario getInstance() {
if (mV2XPushEventScenario == null) {
synchronized (V2XPushVREventScenario.class) {
if (mV2XPushEventScenario == null) {
mV2XPushEventScenario = new V2XPushVREventScenario();
mV2XPushEventScenario.setV2XMarker(new V2XPushVREventMarker());
mV2XPushEventScenario.setV2XWindow(new V2XPushVREventWindow());
}
}
}
return mV2XPushEventScenario;
}
@Override
public void init(@Nullable V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity) {
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "处理推送VR场景" + GsonUtil.jsonFromObject(v2XMessageEntity));
if (!isSameScenario(v2XMessageEntity)
&& V2XServiceManager.getMoGoStatusManager().isMainPageLaunched()) {
setV2XMessageEntity(v2XMessageEntity);
show();
} else {
closeWindow();
setV2XMessageEntity(v2XMessageEntity);
show();
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "要处理的场景已经存在,丢弃这次初始化");
}
}
@Override
public void show() {
if (getV2XMessageEntity() != null && getV2XMessageEntity().getContent() != null) {
speakTTSVoice(getV2XMessageEntity().getContent().getTts(), null);
drawPOI();
showWindow();
}
}
@Override
public void showWindow() {
if (getV2XWindow() != null) {
getV2XWindow().show(getV2XMessageEntity().getContent());
}
}
@Override
public void closeWindow() {
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
if (getV2XWindow() != null) {
getV2XWindow().close();
}
}
@Override
public void showButton() {
if (getV2XButton() != null) {
getV2XButton().show();
}
}
@Override
public void closeButton() {
if (getV2XButton() != null) {
getV2XButton().close();
}
}
@Override
public void drawPOI() {
if (getV2XMarker() != null) {
getV2XMarker().drawPOI(getV2XMessageEntity().getContent());
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, true);
}
}
@Override
public void clearPOI() {
if (getV2XMarker() != null) {
getV2XMarker().clearPOI();
}
V2XServiceManager.getMoGoV2XStatusManager().setPushPOIShow(TAG, false);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onViewAdded(View view) {
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 动画结束");
}
@Override
public void onViewRemoved(View view) {
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 动画结束");
}
@Override
public void beforeViewAddAnim(View view) {
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "展示 Window 开始");
}
@Override
public void beforeViewRemoveAnim(View view) {
Logger.d(V2XConst.MODULE_NAME + "_" + TAG, "关闭 Window 开始");
V2XServiceManager.getMoGoV2XStatusManager().setPushWindowShow(TAG, false);
// 重置场景提示的消息
setV2XMessageEntity(null);
clearPOI();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}

View File

@@ -0,0 +1,93 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.os.Handler;
import android.view.View;
import com.mogo.module.common.entity.V2XPushMessageEntity;
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.view.IV2XWindow;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020/4/14 2:37 PM
* desc :
* TODO 只有VR演示场景使用
* version: 1.0
*/
public class V2XPushVREventWindow implements IV2XWindow<V2XPushMessageEntity> {
private String TAG = "V2XPushVREventWindow";
// 处理道路事件30秒倒计时
private Handler handlerV2XEvent = new Handler();
private Runnable runnableV2XEvent;
private int mExpireTime = 30000;
/**
* 展示道路事件详情Windows
*/
@Override
public void show(V2XPushMessageEntity entity) {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息:展示 Window=\n" + entity);
V2XServiceManager
.getMogoEntranceButtonController()
.showLeftNoticeByType(
IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED,
R.drawable.module_v2x_left_notice_seek_help,
entity.getAlarmContent());
countDownV2XEvent();
}
/**
* 关闭详情展示框
*/
@Override
public void close() {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=关闭Window");
V2XServiceManager
.getMogoEntranceButtonController()
.hideLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_CONGESTION_RECOMMENDED);
// 停止倒计时
if (handlerV2XEvent != null && runnableV2XEvent != null) {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
runnableV2XEvent = null;
}
}
@Override
public View getView() {
return null;
}
@Override
public void setWindowStatusListener(V2XWindowStatusListener listener) {
}
/**
* 窗体倒计时
*/
public void countDownV2XEvent() {
// 倒计时
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=30秒倒计时结束。。。");
// 移出Window详细信息
close();
};
} else {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
}
Logger.d(MODULE_NAME + "_" + TAG, "V2X==VR=推送消息 Window 展示开始倒计时:" + mExpireTime);
handlerV2XEvent.postDelayed(runnableV2XEvent, mExpireTime);
}
}

View File

@@ -220,7 +220,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
* 逆向车辆路线预判
* */
btnTriggerReverseVehicleRoutePrediction.setOnClickListener(v -> {
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2XMessageEntity =
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarionVRReverseCarData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
@@ -253,7 +253,12 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
*拥堵路线推荐
* */
btnTriggerCongestedRouteRecommendation.setOnClickListener(v -> {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushVR();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
});
/*

View File

@@ -327,7 +327,7 @@ public class TestOnLineCarUtils {
/**
* 逆向车辆路线预判
*/
public static V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> getV2XScenarionVRReverseCarData() {
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarionVRReverseCarData() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
@@ -341,14 +341,46 @@ public class TestOnLineCarUtils {
inputStream.close();
// 加载数据源
V2XSpecialCarRes v2xRoadEventEntity =
GsonUtil.objectFromJson(baos.toString(), V2XSpecialCarRes.class);
V2XPushMessageEntity v2xRoadEventEntity = GsonUtil.objectFromJson(baos.toString(), V2XPushMessageEntity.class);
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2xMessageEntity = new V2XMessageEntity<>();
V2XMessageEntity<V2XPushMessageEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_WINDOW_WARNING);
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity.getCoordinates());
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 模拟H5推送场景---推送VR场景信息
*/
public static V2XMessageEntity<V2XPushMessageEntity> getV2XScenarioPushVR() {
try {
InputStream inputStream = V2XUtils.getApp()
.getResources()
.openRawResource(R.raw.scenario_push_vr_event_data_yongdu);
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_PUSH_VR_SHOW);
// 设置数据
v2xMessageEntity.setContent(v2xRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
return v2xMessageEntity;

View File

@@ -0,0 +1,820 @@
{
"sceneId": "200006",
"alarmContent": "及时发现前方障碍物并告知车主,降低事故发生概率",
"expireTime": 30000,
"sceneCategory": 0,
"sceneDescription": "利用用户分享数据以及单车识别能力将障碍物告知其他通过车主,从而降低事故发生概率",
"sceneName": "障碍物绕行",
"sceneLevel": 0,
"sceneChannel": "",
"sceneSn": "",
"tts": "前方发现障碍物注意避让",
"zoom": false,
"zoomScale": 15,
"lat": 40.968678,
"lon": 116.405467,
"userHead": "",
"msgImgUrl": "",
"polyline": [
[
116.737779,
40.196461
],
[
116.737689,
40.196462
],
[
116.737545,
40.196464
],
[
116.737396,
40.196465
],
[
116.737215,
40.196466
],
[
116.737064,
40.196467
],
[
116.736875,
40.196468
],
[
116.736744,
40.196468
],
[
116.736602,
40.196469
],
[
116.736458,
40.19647
],
[
116.736304,
40.196471
],
[
116.736175,
40.196472
],
[
116.736044,
40.196472
],
[
116.735883,
40.196473
],
[
116.735228,
40.196477
],
[
116.735117,
40.196478
],
[
116.734994,
40.196478
],
[
116.734878,
40.196479
],
[
116.734748,
40.19648
],
[
116.734636,
40.196481
],
[
116.734557,
40.196481
],
[
116.734472,
40.196481
],
[
116.734392,
40.196482
],
[
116.734293,
40.196482
],
[
116.734226,
40.196482
],
[
116.734138,
40.196483
],
[
116.733983,
40.196484
],
[
116.733862,
40.196485
],
[
116.733725,
40.196486
],
[
116.7336,
40.196486
],
[
116.733432,
40.196485
],
[
116.733331,
40.196484
],
[
116.733259,
40.196482
],
[
116.733173,
40.19648
],
[
116.733106,
40.196477
],
[
116.733002,
40.196471
],
[
116.732923,
40.196467
],
[
116.73282,
40.196459
],
[
116.732724,
40.19645
],
[
116.73263,
40.196441
],
[
116.732529,
40.19643
],
[
116.732431,
40.196419
],
[
116.732376,
40.196413
],
[
116.732295,
40.196403
],
[
116.732215,
40.196391
],
[
116.732154,
40.196382
],
[
116.732076,
40.196371
],
[
116.731991,
40.196356
],
[
116.731927,
40.196345
],
[
116.731847,
40.19633
],
[
116.73177,
40.196316
],
[
116.731728,
40.196307
],
[
116.731664,
40.196294
],
[
116.731571,
40.196274
],
[
116.731509,
40.19626
],
[
116.731435,
40.196244
],
[
116.731357,
40.196224
],
[
116.7313,
40.196211
],
[
116.731226,
40.196191
],
[
116.731148,
40.196171
],
[
116.731076,
40.19615
],
[
116.731016,
40.196133
],
[
116.730949,
40.196113
],
[
116.730892,
40.196096
],
[
116.730827,
40.196075
],
[
116.730761,
40.196053
],
[
116.730675,
40.196025
],
[
116.730616,
40.196005
],
[
116.730549,
40.195981
],
[
116.730353,
40.195908
],
[
116.730214,
40.195852
],
[
116.730081,
40.195798
],
[
116.729945,
40.195742
],
[
116.729836,
40.195699
],
[
116.729727,
40.195659
],
[
116.729611,
40.195616
],
[
116.729486,
40.195572
],
[
116.72935,
40.195529
],
[
116.729181,
40.195479
],
[
116.729013,
40.195434
],
[
116.728924,
40.195412
],
[
116.72877,
40.195374
],
[
116.728622,
40.195341
],
[
116.728469,
40.195308
],
[
116.728325,
40.195281
],
[
116.728174,
40.195254
],
[
116.728018,
40.195229
],
[
116.727794,
40.1952
],
[
116.727599,
40.195179
],
[
116.727432,
40.195165
],
[
116.727299,
40.195156
],
[
116.727073,
40.195145
],
[
116.72695,
40.195142
],
[
116.726733,
40.195139
],
[
116.726488,
40.19514
],
[
116.726312,
40.195141
],
[
116.726115,
40.195143
],
[
116.725869,
40.195148
],
[
116.725651,
40.195155
],
[
116.72537,
40.195161
],
[
116.725188,
40.195163
],
[
116.725092,
40.195162
],
[
116.725091,
40.195123
],
[
116.725335,
40.195123
],
[
116.725499,
40.195123
],
[
116.72602,
40.195109
],
[
116.726235,
40.195106
],
[
116.726424,
40.195105
],
[
116.726658,
40.195104
],
[
116.726733,
40.195105
],
[
116.72688,
40.195106
],
[
116.72704,
40.195109
],
[
116.727217,
40.195115
],
[
116.727388,
40.195124
],
[
116.727562,
40.195136
],
[
116.727735,
40.195155
],
[
116.727887,
40.195174
],
[
116.727979,
40.195186
],
[
116.728056,
40.195198
],
[
116.728165,
40.195216
],
[
116.728237,
40.195228
],
[
116.728345,
40.195247
],
[
116.728411,
40.19526
],
[
116.728533,
40.195283
],
[
116.728589,
40.195295
],
[
116.728694,
40.195318
],
[
116.728761,
40.195334
],
[
116.728868,
40.19536
],
[
116.728918,
40.195372
],
[
116.729088,
40.195416
],
[
116.729262,
40.195462
],
[
116.729424,
40.195512
],
[
116.729547,
40.195553
],
[
116.729584,
40.195566
],
[
116.729692,
40.195606
],
[
116.729739,
40.195624
],
[
116.729844,
40.195661
],
[
116.730011,
40.195726
],
[
116.73014,
40.195778
],
[
116.730309,
40.195849
],
[
116.730467,
40.195911
],
[
116.730608,
40.195962
],
[
116.730673,
40.195984
],
[
116.730766,
40.196015
],
[
116.730831,
40.196036
],
[
116.730935,
40.196069
],
[
116.730993,
40.196087
],
[
116.731086,
40.196113
],
[
116.731164,
40.196135
],
[
116.731285,
40.196165
],
[
116.731315,
40.196173
],
[
116.731434,
40.196202
],
[
116.731486,
40.196214
],
[
116.731586,
40.196238
],
[
116.731652,
40.196253
],
[
116.731749,
40.196273
],
[
116.731818,
40.196287
],
[
116.731924,
40.196305
],
[
116.731991,
40.196317
],
[
116.732108,
40.196336
],
[
116.732269,
40.196361
],
[
116.732333,
40.19637
],
[
116.732464,
40.196385
],
[
116.732507,
40.19639
],
[
116.732628,
40.196404
],
[
116.732678,
40.196409
],
[
116.732784,
40.196418
],
[
116.732851,
40.196424
],
[
116.732985,
40.196433
],
[
116.73314,
40.196439
],
[
116.733198,
40.196441
],
[
116.733379,
40.196445
],
[
116.733548,
40.196445
],
[
116.733722,
40.196445
],
[
116.733903,
40.196445
],
[
116.734081,
40.196447
],
[
116.734251,
40.196446
],
[
116.734439,
40.196445
],
[
116.734624,
40.196444
],
[
116.734805,
40.196442
],
[
116.734982,
40.196442
],
[
116.735164,
40.196441
],
[
116.735329,
40.19644
],
[
116.735519,
40.196438
],
[
116.735682,
40.196437
],
[
116.735855,
40.196437
],
[
116.736034,
40.196436
],
[
116.73621,
40.196435
],
[
116.736385,
40.196433
],
[
116.736566,
40.196433
],
[
116.736742,
40.196431
],
[
116.736926,
40.196431
],
[
116.737046,
40.19643
],
[
116.737173,
40.19643
],
[
116.737298,
40.196429
],
[
116.737449,
40.196427
],
[
116.737582,
40.196427
],
[
116.737662,
40.196425
],
[
116.737748,
40.196425
],
[
116.73778,
40.196424
]
]
}

View File

@@ -1,5 +1,5 @@
{
"sceneId": "200006",
"sceneId": "200007",
"alarmContent": "展现行人预测、提前预警能力",
"expireTime": 30000,
"sceneCategory": 0,

View File

@@ -4,6 +4,7 @@ import android.view.View;
import android.widget.TextView;
import com.alibaba.android.arouter.facade.template.IProvider;
import com.mogo.service.windowview.IMogoEntranceViewListener;
/**
* @author congtaowang
@@ -56,6 +57,11 @@ public interface IMogoEntranceButtonController extends IProvider {
*/
int NOTICE_TYPE_OBSTACLE_CAR_WARN = 1010;
/**
* 拥堵路线推荐
*/
int NOTICE_TYPE_CONGESTION_RECOMMENDED = 1011;
/**
* 获取入口按钮实例
*
@@ -110,4 +116,16 @@ public interface IMogoEntranceButtonController extends IProvider {
* @param noticeType {@link #NOTICE_TYPE_SUDDENLY_BREAK}...
*/
void hideLeftNoticeByType(int noticeType);
/**
* 添加view状态回调监听
* @param listener 回调监听
*/
void addEntranceViewListener(IMogoEntranceViewListener listener);
/**
* 移除view状态回调监听
* @param listener 回调监听
*/
void removeEntranceViewListener(IMogoEntranceViewListener listener);
}

View File

@@ -0,0 +1,40 @@
package com.mogo.service.windowview;
import android.view.View;
/**
* EntranceView状态监听
*
* @author tongchenfei
*/
public interface IMogoEntranceViewListener {
/**
* 新view展示
* 只针对左侧提示LeftNotice
* @param type 展示的类型
*/
void onViewAdded(int type);
/**
* view移除
* 只针对左侧提示LeftNotice
* @param type 移除的type
*/
void onViewRemoved(int type);
/**
* view添加动画开始之前
* @param view 添加的view
* @deprecated 暂时没用
*/
@Deprecated
void beforeViewAddAnim(View view);
/**
* view 移除动画开始之前
* @param view 移除的view
* @deprecated 暂时没用
*/
@Deprecated
void beforeViewRemoveAnim(View view);
}