合并大唐高鸿obu,增加debug入口,去掉了vrMode按钮入口

This commit is contained in:
tongchenfei
2020-12-16 18:27:02 +08:00
parent 111ac63e38
commit 4231f006c1
18 changed files with 665 additions and 39 deletions

View File

@@ -1,7 +1,9 @@
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;
@@ -67,19 +69,24 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
private static final long DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY = 1500L;
private Handler handler = new Handler(this);
private final Handler handler = new Handler(this);
private final ObuTypeExchangeReceiver obuTypeExchangeReceiver = new ObuTypeExchangeReceiver();
private ObuManager obuManager;
public void init(Context context) {
Logger.d(MODULE_NAME, "obuManager初始化--");
ObuManager obuManager = new ObuManager();
obuManager = new ObuManager();
obuManager.init(context);
obuManager.registerObuDataChangedListener(this);
IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
context.registerReceiver(obuTypeExchangeReceiver, filter);
}
/**
* 用来处理30秒内不重复播报的情况
*/
private Map<String, Long> intervalMap = new ArrayMap<>();
private final Map<String, Long> intervalMap = new ArrayMap<>();
private int parseObuEvent(String type) {
switch (type) {
@@ -99,7 +106,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
}
}
private MogoLocation[] historyPath = new MogoLocation[2];
private final MogoLocation[] historyPath = new MogoLocation[2];
private float computeCarAngle(MogoLocation location) {
float angle = 0f;
@@ -177,7 +184,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
}
// int eventType = parseObuEvent(info.getTypeCode());
int eventType = info.getMogoEventId();
if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY && DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
// 加一个容错机制如果已经驶过绿波车速路口那么再收到绿波车速obu事件就不再上报
MogoLocation currentLocation = V2XLocationListener.getInstance().getLastCarLocation();
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
@@ -192,7 +199,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
return;
}
}
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME||DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME || DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
// 华砺智行obu暂时去掉此判断
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
@@ -254,17 +261,17 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
default:
break;
}
}else{
Logger.d(TAG,"未超过时限,不展示事件");
} else {
Logger.d(TAG, "未超过时限,不展示事件");
}
}
@Override
public void onLocationInfoCallback( MogoObuLocationInfo locationInfo) {
public void onLocationInfoCallback(MogoObuLocationInfo locationInfo) {
if (ObuConfig.useObuLocation) {
MogoLocation currentLocation = new MogoLocation();
double coor[] = CoordinateUtils.transformFromWGSToGCJ( locationInfo.getLat(), locationInfo.getLon() );
double coor[] = CoordinateUtils.transformFromWGSToGCJ(locationInfo.getLat(), locationInfo.getLon());
currentLocation.setLatitude(coor[0]);
currentLocation.setLongitude(coor[1]);
@@ -287,4 +294,12 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
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);
}
}
}