[Delete]
删除mogo-module-obu 场景 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -149,8 +149,7 @@ public class V2XModuleProvider implements
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
|
||||
|
||||
// obu数据转发初始化
|
||||
V2XObuManager.getInstance().init(context);
|
||||
|
||||
if (V2XServiceManager.getMoGoStatusManager().isTopContainerReady()) {
|
||||
V2XServiceManager.getV2XRefreshModel().queryRoadData(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
|
||||
@@ -1,395 +0,0 @@
|
||||
package com.mogo.module.v2x;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.ObuManager;
|
||||
import com.zhidao.mogo.module.obu.obu.IObuCallback;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuLocationInfo;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
import static com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario.ACTION_LAUNCHER_ADAS_APP_BIZ;
|
||||
|
||||
//import com.zhidao.support.nebulaobu.NebulaObuClient;
|
||||
//import com.zhidao.support.nebulaobu.OnObuListener;
|
||||
//import com.zhidao.support.nebulaobu.model.ActiveSafetyInfo;
|
||||
//import com.zhidao.support.nebulaobu.model.ObuInfo;
|
||||
//import com.zhidao.support.nebulaobu.model.ObuInfoMore;
|
||||
|
||||
/**
|
||||
* obu数据管理类封装
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuManager implements IObuCallback, Handler.Callback {
|
||||
private static final String TAG = V2XObuManager.class.getSimpleName();
|
||||
|
||||
private static final long DEFAULT_INTERVAL_TIME = 30_000L;
|
||||
|
||||
private V2XObuManager() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuManager instance = null;
|
||||
|
||||
public static V2XObuManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
|
||||
private static final long DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY = 1500L;
|
||||
private final Handler handler = new Handler(this);
|
||||
private final ObuTypeExchangeReceiver obuTypeExchangeReceiver = new ObuTypeExchangeReceiver();
|
||||
private ObuManager obuManager;
|
||||
final String icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710";
|
||||
|
||||
public void init(Context context) {
|
||||
Logger.d(MODULE_NAME, "obuManager初始化--");
|
||||
//之前内部对接的obu
|
||||
obuManager = new ObuManager();
|
||||
obuManager.init(context);
|
||||
obuManager.registerObuDataChangedListener(this);
|
||||
|
||||
//使用adas部门obu sdk (星云)
|
||||
// NebulaObuClient.getInstance().init(context);
|
||||
// NebulaObuClient.getInstance().registerObu(100);
|
||||
// NebulaObuClient.getInstance().registerObuListener(listener);
|
||||
|
||||
IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
|
||||
context.registerReceiver(obuTypeExchangeReceiver, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 星云obu数据监听
|
||||
*/
|
||||
// private OnObuListener listener = new OnObuListener() {
|
||||
// @Override
|
||||
// public void onRegister() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onConnectFail(boolean isNeedReconnect) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onUnregister() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onObuInfo(ObuInfo info) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onWarningInfo(List<ActiveSafetyInfo> infoList) {
|
||||
// if (infoList != null) {
|
||||
// if (infoList.size() > 0) { //一般只有一个
|
||||
// ActiveSafetyInfo info = infoList.get(0);
|
||||
// Logger.d("liyz", "onWarningInfo type ------> " + info.getWarningtype() + "--size = " + infoList.size());
|
||||
// if (info.getWarningtype() == 3) {
|
||||
// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
// handleSdkObu(2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
private void handleSdkObu(int type) {
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
|
||||
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
|
||||
if (type == ObuConstant.TYPE_CROSS_COLLISION_WARNING) { //交叉路口碰撞预警
|
||||
urgencyEvent.setType(ObuConstant.TYPE_CROSS_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_CROING_WARN_TEXT);
|
||||
} else if (type == ObuConstant.TYPE_URGENCY_COLLISION_WARNING) { // 前车紧急制动预警
|
||||
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
} else { //TODO
|
||||
// urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
// urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
}
|
||||
|
||||
messageEntity.setContent(urgencyEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用来处理30秒内不重复播报的情况
|
||||
*/
|
||||
private final Map<String, Long> intervalMap = new ArrayMap<>();
|
||||
|
||||
private int parseObuEvent(String type) {
|
||||
switch (type) {
|
||||
case "06":
|
||||
// 紧急制动预警
|
||||
return ObuConstant.TYPE_URGENCY_COLLISION_WARNING;
|
||||
case "13":
|
||||
// 绿波车速引导
|
||||
return ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY;
|
||||
case "39":
|
||||
// 行人碰撞预警
|
||||
return ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING;
|
||||
case "vip变灯提醒":
|
||||
return ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private final MogoLocation[] historyPath = new MogoLocation[2];
|
||||
|
||||
private float computeCarAngle(MogoLocation location) {
|
||||
float angle = 0f;
|
||||
if (historyPath[0] != null) {
|
||||
historyPath[1] = historyPath[0];
|
||||
}
|
||||
historyPath[0] = location;
|
||||
|
||||
if (historyPath[1] != null && historyPath[0] != null) {
|
||||
double carAngle =
|
||||
DrivingDirectionUtils.getCarAngle(
|
||||
historyPath[1].getLatitude(), historyPath[1].getLongitude(),
|
||||
historyPath[0].getLatitude(), historyPath[0].getLongitude()
|
||||
);
|
||||
// 这里是真实的车辆角度
|
||||
angle = (float) carAngle;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
private static final String CALL_ADAS_SHOW_TRAFFIC_LIGHT = "2";
|
||||
private static final String CALL_ADAS_HIDE_TRAFFIC_LIGHT = "1";
|
||||
|
||||
private void sendTrafficLightStatusToAdas(String status, MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
if (V2XObuEventScenario.getInstance().isInChangeLightForVip()) {
|
||||
status = CALL_ADAS_HIDE_TRAFFIC_LIGHT;
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
// String action "1" - 隐藏 "2" - 显示
|
||||
json.put("action", status);
|
||||
if (trafficLightInfo != null) {
|
||||
if (trafficLightInfo.getLightStatus() == null) {
|
||||
json.put("lightStatus", "G");
|
||||
} else {
|
||||
json.put("lightStatus", trafficLightInfo.getLightStatus());
|
||||
}
|
||||
if (trafficLightInfo.getSurplusTime() == null) {
|
||||
json.put("surplusTime", "0");
|
||||
} else {
|
||||
json.put("surplusTime", trafficLightInfo.getSurplusTime());
|
||||
}
|
||||
JSONArray lightJsonArray = new JSONArray(trafficLightInfo.getLightArray());
|
||||
JSONArray surplusTimeJsonArray = new JSONArray(trafficLightInfo.getSurplusTimeArray());
|
||||
json.put("lightArray", lightJsonArray);
|
||||
json.put("surplusTimeArray", surplusTimeJsonArray);
|
||||
}
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送红绿灯广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 2);
|
||||
getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送红绿灯广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_HIDE_TRAFFIC_LIGHT) {
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventInfoCallback(MogoObuEventInfo info) {
|
||||
//Logger.d("V2X_OBU_EVENT", "carEventInfo==" + info);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
//Logger.d("V2X_OBU_EVENT", "vr模式下不展示obu事件");
|
||||
return;
|
||||
}
|
||||
Long last = intervalMap.get(info.getTypeCode());
|
||||
if (last == null) {
|
||||
last = 0L;
|
||||
}
|
||||
// int eventType = parseObuEvent(info.getTypeCode());
|
||||
int eventType = info.getMogoEventId();
|
||||
if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY && DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 加一个容错机制,如果已经驶过绿波车速路口,那么再收到绿波车速obu事件,就不再上报
|
||||
MogoLocation currentLocation = V2XLocationListener.getInstance().getLastCarLocation();
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLon(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
if (0 > eventAngle || eventAngle > 20) {
|
||||
Logger.e(MODULE_NAME, "超出绿波引导点范围,不处理此次事件===" + eventAngle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME || DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
|
||||
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
|
||||
// 华砺智行obu暂时去掉此判断
|
||||
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
switch (eventType) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
V2XObuEventEntity optimalEvent = new V2XObuEventEntity();
|
||||
optimalEvent.setType(ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY);
|
||||
optimalEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(optimalEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车紧急制动预警
|
||||
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
|
||||
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
messageEntity.setContent(urgencyEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
V2XServiceManager.getMogoEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SUDDENLY_BREAK, R.drawable.module_v2x_suddenly_break, "前车急刹,保持车距");
|
||||
break;
|
||||
case ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING:
|
||||
// 行人预警,给adas发送广播即可
|
||||
V2XPushMessageEntity entity = new V2XPushMessageEntity();
|
||||
// 盲区行人预警的sceneId-100003
|
||||
entity.setSceneId("100003");
|
||||
entity.setTts("前方行人,注意减速");
|
||||
entity.setExpireTime(30_000);
|
||||
entity.setAlarmContent("前方行人,注意减速");
|
||||
ADASUtils.broadcastToADAS(getContext(), entity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
V2XObuEventEntity changeLightEvent = new V2XObuEventEntity();
|
||||
changeLightEvent.setType(ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP);
|
||||
changeLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(changeLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
// 闯红灯预警
|
||||
V2XObuEventEntity rushRedLightEvent = new V2XObuEventEntity();
|
||||
rushRedLightEvent.setType(ObuConstant.TYPE_RUSH_RED_LIGHT);
|
||||
rushRedLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(rushRedLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CROSS_COLLISION_WARNING:
|
||||
// 交叉口碰撞预警
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioCrossCrash();
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
break;
|
||||
case ObuConstant.TYPE_BLIND_ASSIST_WARN:
|
||||
case ObuConstant.TYPE_HAS_RUSH_RED_LIGHT:
|
||||
case ObuConstant.TYPE_LANE_CONVERGE_WARN:
|
||||
case ObuConstant.TYPE_LIMIT_SPEED_WARN:
|
||||
case ObuConstant.TYPE_PRESSING_CAR_WARN:
|
||||
case ObuConstant.TYPE_TRAFFIC_SIGN_INFO:
|
||||
case ObuConstant.TYPE_BLOCK_WARN:
|
||||
case ObuConstant.TYPE_FRONT_COLLISION_WARNING:
|
||||
case ObuConstant.TYPE_UNUSUAL_CAR_WARN:
|
||||
case ObuConstant.TYPE_UNUSUAL_ROAD_WARN:
|
||||
// 暂无设计图,先简单显示
|
||||
V2XObuEventEntity tmpEvent = new V2XObuEventEntity();
|
||||
tmpEvent.setType(eventType);
|
||||
tmpEvent.setDesc(info.getType() + "--" + info.getDescribe());
|
||||
messageEntity.setContent(tmpEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "未超过时限,不展示事件");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationInfoCallback(MogoObuLocationInfo locationInfo) {
|
||||
if (ObuConfig.useObuLocation) {
|
||||
MogoLocation currentLocation = new MogoLocation();
|
||||
|
||||
double coor[] = CoordinateUtils.transformWgsToGcj(locationInfo.getLat(), locationInfo.getLon());
|
||||
|
||||
currentLocation.setLatitude(coor[1]);
|
||||
currentLocation.setLongitude(coor[0]);
|
||||
currentLocation.setBearing(computeCarAngle(currentLocation));
|
||||
|
||||
V2XObuEventScenario.getInstance().updateLocation(currentLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrafficLightInfoCallback(MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT);
|
||||
if (trafficLightInfo == null) {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据为空===");
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
} else {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据==" + trafficLightInfo);
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT,
|
||||
DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY);
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_SHOW_TRAFFIC_LIGHT, trafficLightInfo);
|
||||
}
|
||||
}
|
||||
|
||||
class ObuTypeExchangeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int obuType = intent.getIntExtra("obuType", DebugConfig.OBU_TYPE_CIDI);
|
||||
obuManager.resetObuType(obuType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
@@ -27,12 +29,10 @@ import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.observer.CarLocationSubject;
|
||||
import com.mogo.module.v2x.observer.V2XOptimalRouteObserver;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.module.v2x.utils.TrackUtils;
|
||||
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -41,8 +41,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -222,10 +220,6 @@ public class V2XLocationListener
|
||||
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
|
||||
}
|
||||
}
|
||||
if (!ObuConfig.useObuLocation) {
|
||||
// 绿波车速引导刷新划线
|
||||
V2XObuEventScenario.getInstance().updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLocation getLastCarLocation() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.v2x.scenario.scene.help;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
@@ -23,8 +25,6 @@ import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* @ProjectName: MoGoModulSafeDriving
|
||||
* @Package: com.mogo.module.v2x.scenario.scene
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
|
||||
/**
|
||||
* 绿波车速的marker
|
||||
*/
|
||||
class OptimalSpeedMarker implements IV2XMarker<MogoLatLng> {
|
||||
|
||||
private IMogoMarker optimalMarker = null;
|
||||
|
||||
@Override
|
||||
public void drawPOI(MogoLatLng entity) {
|
||||
Logger.d(MODULE_NAME, "绘制绿波marker===" + entity);
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(entity.getLat())
|
||||
.longitude(entity.getLon())
|
||||
.anchor(0.5f, 0.9f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_OPTIMAL_SPEED_MARKER, optionsRipple);
|
||||
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new OptimalSpeedMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker.showInfoWindow();
|
||||
} else {
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new OptimalSpeedMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_OPTIMAL_SPEED_MARKER, optionsRipple);
|
||||
}
|
||||
if (optimalMarker != null) {
|
||||
optimalMarker.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
Logger.d(MODULE_NAME, "准备清除绿波marker");
|
||||
if (optimalMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除绿波marker===" + optimalMarker);
|
||||
optimalMarker.remove();
|
||||
optimalMarker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.v2x.V2XObuManager;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
|
||||
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu场景界面管理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventScenario extends AbsV2XScenario<V2XObuEventEntity> implements Handler.Callback {
|
||||
|
||||
public static final String URGENCY_COLLISION_WARN_TEXT_ONE = "前车急刹,注意保持安全距离!";
|
||||
public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹";
|
||||
public static final String URGENCY_CROING_WARN_TEXT = "注意交叉路口车辆";
|
||||
|
||||
private static final int MSG_CLOSE_OBU_WINDOW = 1001;
|
||||
private static final int DEFAULT_EXPIRE_TIME = 20_000;
|
||||
|
||||
private static final float DEFAULT_VIP_CROSSING_DISTANCE = 100F;
|
||||
|
||||
/**
|
||||
* 可以关闭绿波引导的距离路口的最大距离,单位是米
|
||||
*/
|
||||
private static final float DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL = 10F;
|
||||
|
||||
private IMogoPolyline optimalLine = null;
|
||||
private MogoLatLng defaultTarget = new MogoLatLng(39.969326, 116.407788);
|
||||
|
||||
private MogoLatLng optimalCrossing = new MogoLatLng(40.196431,116.738011);
|
||||
// private MogoLatLng vipCrossing = new MogoLatLng(40.200467,116.745498);
|
||||
|
||||
|
||||
private MogoLatLng vipCrossing1 = new MogoLatLng(40.200467,116.745498);
|
||||
private MogoLatLng vipCrossing2 = new MogoLatLng(40.200491,116.738535);
|
||||
private List<MogoLatLng> vipCrossingList = Arrays.asList(vipCrossing1, vipCrossing2);
|
||||
|
||||
private V2XObuEventScenario() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuEventScenario instance = null;
|
||||
|
||||
public static V2XObuEventScenario getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuEventScenario.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuEventScenario();
|
||||
instance.setV2XWindow(new V2XObuEventWindow(V2XServiceManager.getContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private V2XMessageEntity<V2XObuEventEntity> lastMessage = null;
|
||||
|
||||
private OptimalSpeedMarker optimalSpeedMarker = null;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper(), this);
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XObuEventEntity> v2XMessageEntity) {
|
||||
Logger.d(MODULE_NAME, "obu场景初始化: " + v2XMessageEntity);
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 如果需要区分路口,就在这里做一下判断,给默认目标点赋值
|
||||
defaultTarget = optimalCrossing;
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
// vip变灯提醒
|
||||
isInChangeLightForVip = true;
|
||||
V2XObuManager.getInstance().onTrafficLightInfoCallback(null);
|
||||
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CROSS_COLLISION_WARNING && !isCrossWarning) {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_CROING_WARN_TEXT);
|
||||
isCrossWarning = true;
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_URGENCY_COLLISION_WARNING && !isUrgenchyWarning) {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE);
|
||||
isUrgenchyWarning = true;
|
||||
}
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
private boolean isCrossWarning;
|
||||
private boolean isUrgenchyWarning;
|
||||
|
||||
|
||||
/**
|
||||
* 展示场景
|
||||
* <p>
|
||||
* 此场景需要语音提示和弹窗
|
||||
*/
|
||||
@Override
|
||||
public void show() {
|
||||
// AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE);
|
||||
showWindow();
|
||||
if (handler.hasMessages(MSG_CLOSE_OBU_WINDOW)) {
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(MSG_CLOSE_OBU_WINDOW, DEFAULT_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示Window
|
||||
*/
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "上一条消息是绿波,发送隐藏广播===");
|
||||
// 上一条信息是绿波,需要隐藏上一条信息
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
}
|
||||
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"上一条是vip变灯,需要先把线隐藏===");
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = getV2XMessageEntity();
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
getV2XWindow().setWindowStatusListener(new V2XWindowStatusListener() {
|
||||
@Override
|
||||
public void onViewShow() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewClose() {
|
||||
// 只在上滑关闭topview的时候回调
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗,隐藏line");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
});
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
// 给adas发送显示绿波的广播
|
||||
Logger.d(MODULE_NAME, "收到绿波时间,发送广播给adas");
|
||||
sendBroadcastToAdas(CALL_ADAS_SHOW_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"收到vip变灯,画线");
|
||||
drawLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Window
|
||||
*/
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
Logger.d(MODULE_NAME, "obu场景关闭window");
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
getV2XWindow().close();
|
||||
// 给adas发送隐藏绿波的广播
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示按钮
|
||||
*/
|
||||
@Override
|
||||
public void showButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭按钮
|
||||
*/
|
||||
@Override
|
||||
public void closeButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制POI
|
||||
*/
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "绘制obu Poi点");
|
||||
optimalSpeedMarker.drawPOI(defaultTarget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除POI
|
||||
*/
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除obu Poi点");
|
||||
optimalSpeedMarker.clearPOI();
|
||||
optimalSpeedMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当定位发生变化时,调用此方法,在此方法中,根据当前状态判断是否需要消费此定位事件
|
||||
* <p>
|
||||
* 主要目的是更新绿波速度引导的划线
|
||||
*
|
||||
* @param currentLocation 更新后的定位信息
|
||||
*/
|
||||
public void updateLocation(MogoLocation currentLocation) {
|
||||
MogoLatLng currentLatLng = new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
if (optimalLine != null) {
|
||||
float distance = Utils.calculateLineDistance(defaultTarget, currentLatLng);
|
||||
if (distance <= DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL) {
|
||||
// 目标点和自身点小于DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL的时候,隐藏绿波车速
|
||||
closeWindow();
|
||||
} else {
|
||||
// 线不为空就更新位置,线为空了,也就隐藏了
|
||||
optimalLine.setPoints(Arrays.asList(currentLatLng, defaultTarget));
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前位置与vip点的距离,来判断是否触发vip通行
|
||||
for (MogoLatLng crossing : vipCrossingList) {
|
||||
float distance = Utils.calculateLineDistance(currentLatLng, crossing);
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
crossing.getLon(),
|
||||
crossing.getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
//Logger.d("V2X_OBU_VIP", "监测是否需要进行vip弹框提醒\ndistance: " + distance + "\neventAngle: " + eventAngle + "\ntarget: " + crossing + "\ncurrent: " + currentLatLng);
|
||||
if (distance <= DEFAULT_VIP_CROSSING_DISTANCE && 0 <= eventAngle && eventAngle <= 20) {
|
||||
//距离小于DEFAULT_VIP_CROSSING_DISTANCE,且夹角在0~20(说明在前方),则触发vip通行
|
||||
defaultTarget = crossing;
|
||||
handler.post(() -> {
|
||||
MogoObuEventInfo eventInfo = new MogoObuEventInfo();
|
||||
eventInfo.setType("vip变灯提醒");
|
||||
eventInfo.setTypeCode("vip变灯提醒");
|
||||
eventInfo.setDescribe("将为您变灯,vip车辆可优先通行");
|
||||
V2XObuManager.getInstance().onEventInfoCallback(eventInfo);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg A {@link Message Message} object
|
||||
* @return True if no further handling is desired
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_CLOSE_OBU_WINDOW) {
|
||||
Logger.d(MODULE_NAME, "V2X Obu scenario expire===");
|
||||
closeWindow();
|
||||
isCrossWarning = false;
|
||||
isUrgenchyWarning = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final String ACTION_LAUNCHER_ADAS_APP_BIZ = "com.mogo.launcher.adas.app.biz";
|
||||
private static final String CALL_ADAS_SHOW_OPTIMAL = "2";
|
||||
private static final String CALL_ADAS_HIDE_OPTIMAL = "1";
|
||||
|
||||
private void sendBroadcastToAdas(String status) {
|
||||
if (status.equals(CALL_ADAS_SHOW_OPTIMAL)) {
|
||||
// 给adas发送显示绿波的广播,同时自己也要开始划线
|
||||
if(DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
drawLine();
|
||||
}
|
||||
} else {
|
||||
// 给adas发送隐藏绿波的广播,同时自己也需要结束划线动画
|
||||
hideLine();
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("action", status);
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送绿波广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 1);
|
||||
V2XServiceManager.getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送绿波广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLatLng getOptimalCrossing(){
|
||||
return optimalCrossing;
|
||||
}
|
||||
public float cacheZoomLevel = 16f;
|
||||
/**
|
||||
* 开始划线,同时添加marker,调整地图比例尺
|
||||
*/
|
||||
private void drawLine() {
|
||||
Logger.d(MODULE_NAME, "绘制绿波车速的线=====");
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
}
|
||||
// 绘制marker
|
||||
drawPOI();
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(16).useGradient(true).colorValues(Arrays.asList(Color.parseColor("#FF1DAAA5"), Color.parseColor("#3337DED9")));
|
||||
|
||||
// 当前车辆位置
|
||||
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (carLocation != null) {
|
||||
options.add(carLocation);
|
||||
} else {
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
}
|
||||
// 目标车辆位置
|
||||
options.add(defaultTarget);
|
||||
|
||||
// 绘制线的对象
|
||||
optimalLine = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
cacheZoomLevel = V2XServiceManager.getMapUIController().getZoomLevel();
|
||||
Logger.d(MODULE_NAME, "V2xObuEventScenario cacheZoomLevel==" + cacheZoomLevel);
|
||||
V2XServiceManager.getMapUIController().changeZoom(16);
|
||||
// V2XServiceManager.getMapUIController().changeZoom(17);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束划线,同时隐藏marker
|
||||
*/
|
||||
private void hideLine() {
|
||||
Logger.d(MODULE_NAME, "隐藏绿波车速的线====");
|
||||
clearPOI();
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
optimalLine = null;
|
||||
}
|
||||
V2XServiceManager.getMapUIController().changeZoom(cacheZoomLevel);
|
||||
}
|
||||
|
||||
private volatile boolean isInChangeLightForVip = false;
|
||||
|
||||
/**
|
||||
* 是否在显示vip通行
|
||||
* @return true - 在显示vip通行
|
||||
*/
|
||||
public boolean isInChangeLightForVip(){
|
||||
return isInChangeLightForVip;
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
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.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu事件window
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuEventEntity> {
|
||||
public V2XObuEventWindow(@NonNull Context context) {
|
||||
this(context,null);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs,0);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private ImageView ivTypeIcon;
|
||||
private TextView tvType, tvDesc;
|
||||
|
||||
private void initView(Context context){
|
||||
Logger.d(MODULE_NAME,"初始化obu场景view");
|
||||
LayoutInflater.from(context).inflate(R.layout.window_simple_obu_event_detail_vr, this);
|
||||
ivTypeIcon = findViewById(R.id.ivObuTypeIcon);
|
||||
tvType = findViewById(R.id.tvObuType);
|
||||
tvDesc = findViewById(R.id.tvObuDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示1/2窗口
|
||||
*
|
||||
* 目前只处理如下obu事件
|
||||
* 绿波车速: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_OPTIMAL_SPEED_ADVISORY}
|
||||
* 前车急刹: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_URGENCY_COLLISION_WARNING}
|
||||
* vip车辆变灯提示(暂无回调,暂不处理)
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void show(V2XObuEventEntity entity) {
|
||||
Logger.d(MODULE_NAME, "ObuEventWindow show " + entity);
|
||||
switch (entity.getType()) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_optimal_speed);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("车速引导");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车急刹预警 v2x_icon_obu_urgency_collision
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_ahead_car_brake);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("前车急刹");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_CROSS_COLLISION_WARNING:
|
||||
// 交叉路口碰撞预警
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_car_collide_warning);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("交叉路口碰撞预警");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_traffic_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("优先通行");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_rush_red_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("红灯警告");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_BLIND_ASSIST_WARN:
|
||||
case ObuConstant.TYPE_HAS_RUSH_RED_LIGHT:
|
||||
case ObuConstant.TYPE_LANE_CONVERGE_WARN:
|
||||
case ObuConstant.TYPE_LIMIT_SPEED_WARN:
|
||||
case ObuConstant.TYPE_PRESSING_CAR_WARN:
|
||||
case ObuConstant.TYPE_TRAFFIC_SIGN_INFO:
|
||||
case ObuConstant.TYPE_BLOCK_WARN:
|
||||
case ObuConstant.TYPE_FRONT_COLLISION_WARNING:
|
||||
case ObuConstant.TYPE_UNUSUAL_CAR_WARN:
|
||||
case ObuConstant.TYPE_UNUSUAL_ROAD_WARN:
|
||||
// 暂无设计图,先简单显示
|
||||
String[] descInfo = entity.getDesc().split("--");
|
||||
String t = null;
|
||||
String d = null;
|
||||
if (descInfo.length == 2) {
|
||||
t = descInfo[0];
|
||||
d = descInfo[1];
|
||||
}else{
|
||||
t = "未知类型";
|
||||
d = entity.getDesc();
|
||||
}
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_urgency_collision);
|
||||
tvDesc.setText(d);
|
||||
tvType.setText(t);
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
default:
|
||||
Logger.w(MODULE_NAME, "其他obu类型,暂不处理: " + entity.getType());
|
||||
break;
|
||||
}
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 210);
|
||||
V2XServiceManager.getMogoTopViewManager().addView(this, params,topViewStatusListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭1/2窗口
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
V2XServiceManager.getMogoTopViewManager().removeView(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回窗体
|
||||
*
|
||||
* @return 当前窗体
|
||||
*/
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private V2XWindowStatusListener statusListener = null;
|
||||
|
||||
/**
|
||||
* 设置Window状态监听
|
||||
*
|
||||
* @param listener 监听器
|
||||
*/
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
statusListener = listener;
|
||||
}
|
||||
|
||||
private IMogoTopViewStatusListener topViewStatusListener = new IMogoTopViewStatusListener() {
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
if (statusListener != null) {
|
||||
statusListener.onViewClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.mogo.module.v2x.R;
|
||||
*/
|
||||
public class V2XEventPanelHistoryCountView extends LinearLayout {
|
||||
private RelativeLayout mLlEventMore;
|
||||
private ImageView mBtnShowOrHidePanels;
|
||||
private TextView mTvEventCount;
|
||||
|
||||
public V2XEventPanelHistoryCountView(Context context) {
|
||||
@@ -37,9 +36,8 @@ public class V2XEventPanelHistoryCountView extends LinearLayout {
|
||||
super(context, attrs, defStyleAttr);
|
||||
LayoutInflater.from(context).inflate(R.layout.view_event_panel_history_count, this);
|
||||
|
||||
mLlEventMore = (RelativeLayout) findViewById(R.id.llEventMore);
|
||||
mBtnShowOrHidePanels = (ImageView) findViewById(R.id.btnShowOrHidePanels);
|
||||
mTvEventCount = (TextView) findViewById(R.id.tvEventCount);
|
||||
mLlEventMore = findViewById(R.id.llEventMore);
|
||||
mTvEventCount = findViewById(R.id.tvEventCount);
|
||||
|
||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
mLlEventMore.setVisibility(VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user