This commit is contained in:
zhongchao
2021-04-23 18:42:34 +08:00
10 changed files with 200 additions and 69 deletions

View File

@@ -45,9 +45,7 @@ public class V2XConst {
/**
* V2X 测试控制面板广播Action
*/
public static final String BROADCAST_TEST_PANEL_CONTROL_ACTION = "com.v2x.com.v2x.test_panel_control";
public static final String BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY = "TextPanelOpenStatus";
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "TextPanelOpenType";
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";

View File

@@ -33,6 +33,7 @@ import java.util.List;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
/**
@@ -81,13 +82,12 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
mV2XScenario.setWarningEntity(cloundWarningInfo);
mV2XScenario.init(null);
//预警蒙层
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
isSelfLineClear = false;
isFirstLocation = false;
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
if (cloundWarningInfo.getDirection() == 1) { //前方 TODO
if (cloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) { //前方 TODO
middleLocationInStopLine = getMiddleLocationInStopLine();
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, cloundWarningInfo.getAngle());
//停止线前方画线
@@ -276,7 +276,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == 1 自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
*/
private void drawSlefCarLine(double lon, double lat, float bearing) {
if (!isSelfLineClear) {
@@ -292,8 +292,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
//自车位置
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == 1 ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
startLatlng = new MogoLatLng(lat, lon);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));

View File

@@ -19,6 +19,8 @@ import com.mogo.realtime.entity.ADASRecognizedResult;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP;
/**
* 当前车辆与道路事件的连接线
*/
@@ -42,7 +44,7 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
MogoPolylineOptions options = new MogoPolylineOptions();
List<Integer> colors = new ArrayList<>();
if (info.getDirection() == 1) {
if (info.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP) {
colors.add(0x0D3036FF);
colors.add(0xD93036FF);
colors.add(0x0D3036FF);

View File

@@ -4,10 +4,26 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XPushMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.scenario.scene.test.V2XTestConsoleWindow;
import com.mogo.module.v2x.entity.net.V2XOptimalRouteDataRes;
import com.mogo.module.v2x.entity.net.V2XSpecialCarRes;
import com.mogo.module.v2x.scenario.scene.livecar.V2XVoiceCallLiveBiz;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.carchattingprovider.MogoDriverInfo;
import java.util.List;
import static android.text.style.TtsSpan.GENDER_MALE;
/**
* V2X 测试面板广播接收,目的是可以通过广播调用起来面板
@@ -17,22 +33,147 @@ import com.mogo.utils.logger.Logger;
public class TestPanelBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = V2XConst.MODULE_NAME + "_TestPanelBroadcastReceiver";
private Context mContext;
@Override
public void onReceive(Context context, Intent intent) {
try {
boolean textPanelOpenStatus = intent.getBooleanExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_EXTRA_KEY, false);
int textPanelOpenType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
Logger.d(TAG, "textPanelOpenStatus:" + textPanelOpenStatus);
Logger.d(TAG, "textPanelOpenType:" + textPanelOpenType);
if (textPanelOpenStatus) {
V2XServiceManager
.getIMogoWindowManager()
.addView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType), 0, 0, false);
} else {
V2XServiceManager
.getIMogoWindowManager()
.removeView(V2XTestConsoleWindow.getInstance(context, textPanelOpenType));
this.mContext = context;
int sceneType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
Logger.d(TAG, "textPanelOpenType:" + sceneType);
// 分发场景
dispatchSceneTest(sceneType);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 分发处理场景
*
* @param sceneType 场景类型
*/
private void dispatchSceneTest(int sceneType) {
Logger.d(TAG, "sceneType=" + sceneType);
if (sceneType == 0) {//打开用户信息
MogoDriverInfo mogoDriverInfo = new MogoDriverInfo();
mogoDriverInfo.setAge(24);
mogoDriverInfo.setGender(GENDER_MALE);
mogoDriverInfo.setSn("12345678");
mogoDriverInfo.setUserName("测试");
mogoDriverInfo.setUserHead("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600872867592&di=994e371880ca6ae2814f553e0d0e4139&imgtype=0&src=http%3A%2F%2Fp3.ssl.cdn.btime.com%2Ft014c5d8a1e5cef12ba.jpg%3Fsize%3D506x543");
if (V2XServiceManager.getCarsChattingProvider() != null) {
V2XServiceManager.getCarsChattingProvider().showUserWindow("CAR_CALL_USER_TO_" + V2XConst.MODULE_NAME, mogoDriverInfo, mContext);
}
} else if (sceneType == 1) {// 触发道路事件
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioRoadEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
// 存储本地,出行动态作展示
saveLocalStory(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING,
v2XMessageEntity.getContent().getNoveltyInfo());
} else if (sceneType == 2) {//车路云—场景预警-V1.0 碰撞预警
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 3) {//触发H5推送事件
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 4) {//触发H5推送直播事件
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushLiveEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 5) {//H5推送触发V2X动画
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioAnimationEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 6) {//查看前车直播
V2XVoiceCallLiveBiz.getInstance().getFrontCarLive();
} else if (sceneType == 7) {//查看前车直播
V2XVoiceCallLiveBiz.getInstance().getOpenRoadCameraLive();
} else if (sceneType == 8) {//触发疲劳驾驶
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioFatigueDrivingData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 9) {//触发他人发起道路求助事件
V2XMessageEntity<List<V2XSpecialCarRes.V2XMarkerEntity>> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioSeekHelpData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 10) {//触发事件UGC
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioRoadEventUGCData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 11) {//触发违章停车事件
V2XMessageEntity<List<MarkerExploreWay>> v2XMessageEntity =
TestOnLineCarUtils.getV2XIllegalParkData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
} else if (sceneType == 12) {//车路云场景预警-右侧
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "right");
mContext.sendBroadcast(intent);
} else if (sceneType == 13) {//车路云场景预警-左侧
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "left");
mContext.sendBroadcast(intent);
} else if (sceneType == 14) {//行人预警,行人路线预测 车路云预警-前方行人
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "pedestrians");
mContext.sendBroadcast(intent);
} else if (sceneType == 15) {// 交通状况查询
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
} else if (sceneType == 16) {//触发基于目的地预测的线路推荐
V2XServiceManager.getV2XRefreshModel().queryRoadData("F803EB2046PZD00149");
} else if (sceneType == 17) {//最优路线推荐
V2XMessageEntity<V2XOptimalRouteDataRes> v2XMessageEntity =
TestOnLineCarUtils.getV2XOptimalRoute();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
}
}
/**
* 存储本地数据
*
* @param v2XRoadEventEntity 要存储的场景
*/
public void saveLocalStory(int scenarioType, MarkerExploreWay v2XRoadEventEntity) {
try {
V2XSQLiteUtils.saveLocalStory(scenarioType, v2XRoadEventEntity, v2XRoadEventEntity.hashCode());
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -43,6 +43,7 @@ import static android.text.style.TtsSpan.GENDER_MALE;
* desc : 用来测试的控制台 Window
* version: 1.0
*/
@Deprecated
public class V2XTestConsoleWindow extends ConstraintLayout {
private static V2XTestConsoleWindow mV2XTestConsoleWindow;
@@ -312,7 +313,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
mBtnAdasDataWarn.setOnClickListener(v -> {
Intent intent = new Intent(V2XConst.BROADCAST_ADAS_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "23");
intent.putExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY, "right");
getContext().sendBroadcast(intent);
});

View File

@@ -81,6 +81,7 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow {
}
distance.setText(String.valueOf(mV2XWarningEntity.getDistance()) + "");
warningTextView.setText(mV2XWarningEntity.getWarningContent());
mV2XWarningEntity.setTts(0);
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice(mV2XWarningEntity.getTts());
}
//3秒后移除提示弹框

View File

@@ -30,7 +30,7 @@
"lat":39.969055,
"lon":116.410811
},
"poiType":"10003",
"poiType":"10010",
"type":"CARD_TYPE_ROAD_CONDITION",
"uploadType":"2",
"userInfo":{
@@ -41,5 +41,5 @@
"userName":"零下的雨"
}
},
"poiType":"10003"
"poiType":"10010"
}

View File

@@ -1,32 +1,28 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417886,
"lat": 26.88299257,
"lon": 112.5642132,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"collisionLat": 26.88299257,
"collisionLon": 112.5642132,
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
"lat": 26.88299297,
"lon": 112.5642142
},
{
"lat": 39.976858,
"lon": 116.417683
"lat": 26.88299287,
"lon": 112.5642132
}
],
"from": 1,
"angle": 0,
"direction": 3,
"direction": 10015,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983
}
}
"roadwidth": 4.0
}

View File

@@ -1,32 +1,28 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417478,
"lat": 26.88299257,
"lon": 112.5642132,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"collisionLat": 26.88299257,
"collisionLon": 112.5642132,
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
"lat": 26.88299297,
"lon": 112.5642142
},
{
"lat": 39.976874,
"lon": 116.417757
"lat": 26.88299287,
"lon": 112.5642132
}
],
"from": 1,
"angle": 0,
"direction": 3,
"direction": 10014,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983
}
"roadwidth": 4.0
}

View File

@@ -1,32 +1,28 @@
{
"type": 10013,
"lat": 39.977148,
"lon": 116.417886,
"lat": 26.88299257,
"lon": 112.5642132,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"collisionLat": 26.88299257,
"collisionLon": 112.5642132,
"stopLines": [
{
"lat": 39.976858,
"lon": 116.417651
"lat": 26.88299297,
"lon": 112.5642142
},
{
"lat": 39.976858,
"lon": 116.417683
"lat": 26.88299287,
"lon": 112.5642132
}
],
"from": 1,
"angle": 0,
"direction": 1,
"direction": 10013,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 60,
"warningContent": "小心行人",
"heading": 0,
"showTime": 8000,
"roadwidth": 4.0,
"carLocation": {
"lat": 39.97665425,
"lon": 116.41769983
}
"roadwidth": 4.0
}