add mogo obu
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -20,7 +20,7 @@
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="VisualizationToolProject">
|
||||
|
||||
@@ -66,6 +66,8 @@ dependencies {
|
||||
implementation project(':modules:mogo-module-common')
|
||||
}
|
||||
|
||||
implementation rootProject.ext.dependencies.mogoobu
|
||||
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -17,7 +17,11 @@ public class MoGoObuProvider implements IMoGoObuProvider {
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG, "初始化蘑菇自研OBU……");
|
||||
Logger.d(MogoObuConst.MOGO_OBU, "初始化蘑菇自研OBU……");
|
||||
|
||||
MogoSelfObuManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.mogo.module.obu.mogo;
|
||||
|
||||
/**
|
||||
* author : lxiiaopeng
|
||||
* date : 2021-08-4
|
||||
* desc : 常量
|
||||
*/
|
||||
public class MogoObuConst {
|
||||
|
||||
/**
|
||||
* 自研obu的tag
|
||||
*/
|
||||
public static final String TAG_MOGO_OBU = "MogoObu";
|
||||
|
||||
/**
|
||||
* 前碰撞预警,暂时不知道是干啥的
|
||||
*/
|
||||
public static final int TYPE_FRONT_COLLISION_WARNING = 101;
|
||||
|
||||
/**
|
||||
* 交叉路口碰撞预警
|
||||
*/
|
||||
public static final int TYPE_CROSS_COLLISION_WARNING = 102;
|
||||
|
||||
/**
|
||||
* 紧急制动预警
|
||||
*/
|
||||
public static final int TYPE_URGENCY_COLLISION_WARNING = 105;
|
||||
|
||||
/**
|
||||
* 绿波车速引导
|
||||
*/
|
||||
public static final int TYPE_OPTIMAL_SPEED_ADVISORY = 109;
|
||||
|
||||
/**
|
||||
* 行人碰撞预警
|
||||
*/
|
||||
public static final int TYPE_ROAD_USER_COLLISION_WARNING = 115;
|
||||
|
||||
/**
|
||||
* 为vip车辆变灯提醒
|
||||
*/
|
||||
public static final int TYPE_CHANGE_LIGHT_FOR_VIP = 116;
|
||||
|
||||
/**
|
||||
* 闯红灯预警
|
||||
*/
|
||||
public static final int TYPE_RUSH_RED_LIGHT = 117;
|
||||
/**
|
||||
* 盲区辅助
|
||||
*/
|
||||
public static final int TYPE_BLIND_ASSIST_WARN = 118;
|
||||
/**
|
||||
* 异常车辆预警
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_CAR_WARN = 119;
|
||||
/**
|
||||
* 道路危险情况预警
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_ROAD_WARN = 120;
|
||||
/**
|
||||
* 交通标牌提示
|
||||
*/
|
||||
public static final int TYPE_TRAFFIC_SIGN_INFO = 121;
|
||||
/**
|
||||
* 前方拥堵提醒
|
||||
*/
|
||||
public static final int TYPE_BLOCK_WARN = 122;
|
||||
/**
|
||||
* 紧急车辆提示预警
|
||||
*/
|
||||
public static final int TYPE_PRESSING_CAR_WARN = 123;
|
||||
/**
|
||||
* 已闯红灯提示
|
||||
*/
|
||||
public static final int TYPE_HAS_RUSH_RED_LIGHT = 124;
|
||||
/**
|
||||
* 车道汇合预警
|
||||
*/
|
||||
public static final int TYPE_LANE_CONVERGE_WARN = 125;
|
||||
|
||||
/**
|
||||
* 限速预警
|
||||
*/
|
||||
public static final int TYPE_LIMIT_SPEED_WARN = 126;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
package com.mogo.module.obu.mogo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.support.obu.MogoObuManager;
|
||||
import com.zhidao.support.obu.OnMogoObuListener;
|
||||
import com.zhidao.support.obu.constants.ObuConstants;
|
||||
import com.zhidao.support.obu.model.CvxAppInitIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxHvCarIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxHvInfoIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxRvInfoIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxSetConfigCfmInfo;
|
||||
import com.zhidao.support.obu.model.CvxV2vThreatIndInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.obu.mogo.MogoObuConst.TAG_MOGO_OBU;
|
||||
|
||||
|
||||
/**
|
||||
* obu数据管理类封装
|
||||
*
|
||||
* @author lixiaopeng
|
||||
*/
|
||||
public class MogoSelfObuManager {
|
||||
private static final String TAG = MogoSelfObuManager.class.getSimpleName();
|
||||
|
||||
private static final long DEFAULT_INTERVAL_TIME = 30_000L;
|
||||
|
||||
private List<ADASRecognizedResult> resultList = null;
|
||||
|
||||
private MogoSelfObuManager() {
|
||||
}
|
||||
|
||||
private volatile static MogoSelfObuManager instance = null;
|
||||
|
||||
public static MogoSelfObuManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (MogoSelfObuManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new MogoSelfObuManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
|
||||
final String icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710";
|
||||
|
||||
|
||||
public void init(Context context) {
|
||||
Logger.d(TAG_MOGO_OBU, "obuManager初始化--");
|
||||
|
||||
//自研obu
|
||||
MogoObuManager.getInstance().init(context);
|
||||
MogoObuManager.getInstance().connect("192.168.1.199");
|
||||
MogoObuManager.getInstance().registerListener(mogoObuListener);
|
||||
|
||||
//TODO 测试
|
||||
// UiThreadHandler.postDelayed( () -> {
|
||||
//// MogoObuManager.getInstance().test(icw_data);
|
||||
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(3, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
// handleSdkObu(105);
|
||||
//
|
||||
// }, 5_000L );
|
||||
|
||||
}
|
||||
|
||||
private OnMogoObuListener mogoObuListener = new OnMogoObuListener() {
|
||||
@Override
|
||||
public void onConnected() {
|
||||
//OBU连接成功
|
||||
Logger.d(TAG_MOGO_OBU, "onConnected ------> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFail(boolean isNeedReconnect) {
|
||||
Logger.d(TAG_MOGO_OBU, "onConnectFail ------> ");
|
||||
//OBU连接失败
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
Logger.d(TAG_MOGO_OBU, "onDisconnect ------> ");
|
||||
//OBU断开连接
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveOriginData(String data) {
|
||||
super.onReceiveOriginData(data);
|
||||
Logger.d(TAG_MOGO_OBU, "onReceiveOriginData ------> data = " + data);
|
||||
//接收到的原始数据
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendData(byte[] bytes) {
|
||||
super.onSendData(bytes);
|
||||
//发送的数据
|
||||
Logger.d(TAG_MOGO_OBU, "onSendData ------> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxAppInitIndInfo(CvxAppInitIndInfo info) {
|
||||
super.onCvxAppInitIndInfo(info);
|
||||
Logger.d(TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> " + info.toString());
|
||||
//CV2X系统信息
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxSetConfigCfm(CvxSetConfigCfmInfo info) {
|
||||
super.onCvxSetConfigCfm(info);
|
||||
Logger.d(TAG_MOGO_OBU, "onCvxSetConfigCfm ------> " + info.toString());
|
||||
//设置CV2X系统的配置确认
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxHvCarIndInfo(CvxHvCarIndInfo info) {
|
||||
//主车车辆信息
|
||||
Logger.d(TAG_MOGO_OBU, "onCvxHvCarIndInfo ------> " + info.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxHvInfoIndInfo(CvxHvInfoIndInfo info) {
|
||||
//主车信息
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxRvInfoIndInfo(CvxRvInfoIndInfo info) {
|
||||
//远车信息
|
||||
Logger.d(TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> " + info.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxV2vThreatIndInfo(CvxV2vThreatIndInfo info) {
|
||||
//预警信息,预警类型 threat_level 3
|
||||
if (info != null) {
|
||||
Logger.e(TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> " + info.toString());
|
||||
if (info.getThreat_info() != null) {
|
||||
if (info.getThreat_info().getThreat_level() == 2 &&
|
||||
info.getThreat_info().getThreat_level() == 3) { //看看2的情况
|
||||
//预警方位
|
||||
int direction = info.getExt_info().getTarget_classification();
|
||||
Logger.d(TAG_MOGO_OBU, "direction = " + direction + "----" + getMessage(direction));
|
||||
|
||||
//显示警告弹框 TODO
|
||||
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(getMessage(direction), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
//处理预警类型
|
||||
int appId = info.getThreat_info().getApp_id();
|
||||
handleSdkObu(getEventType(appId));
|
||||
}
|
||||
|
||||
//预警数据的组装,车辆实时移动和变色 TODO 这里需要obu提供他车列表 暂时不做
|
||||
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(getResultList(info));
|
||||
|
||||
} else {
|
||||
Logger.e(TAG_MOGO_OBU, "info == null ");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private int getMessage(int targetClassification) {
|
||||
switch (targetClassification) {
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT:
|
||||
return 1;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT:
|
||||
return 2;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT:
|
||||
return 3;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT:
|
||||
return 4;
|
||||
default:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private int getEventType(int appid) {
|
||||
if (appid == ObuConstants.USE_CASE_ID.EBW) {
|
||||
return MogoObuConst.TYPE_URGENCY_COLLISION_WARNING;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.ICW) {
|
||||
return MogoObuConst.TYPE_CROSS_COLLISION_WARNING;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private List<ADASRecognizedResult> getResultList(CvxV2vThreatIndInfo info) {
|
||||
if (resultList == null) {
|
||||
resultList = new ArrayList<>();
|
||||
}
|
||||
|
||||
ADASRecognizedResult adasRecognizedResult = new ADASRecognizedResult();
|
||||
adasRecognizedResult.uuid = info.getVehicle_id();
|
||||
if (info.getBasic_info() != null && info.getBasic_info().getPosition() != null) {
|
||||
adasRecognizedResult.lat = info.getBasic_info().getPosition().getLatitude();
|
||||
adasRecognizedResult.lon = info.getBasic_info().getPosition().getLongitude();
|
||||
}
|
||||
adasRecognizedResult.type = 3; //小轿车
|
||||
adasRecognizedResult.heading = info.getBasic_info().getHeading();
|
||||
adasRecognizedResult.speed = info.getBasic_info().getSpeed();
|
||||
|
||||
resultList.add(adasRecognizedResult);
|
||||
|
||||
return resultList;
|
||||
|
||||
}
|
||||
|
||||
// public void release() {
|
||||
// NebulaObuClient.getInstance().unregisterObu();
|
||||
// NebulaObuClient.getInstance().unregisterObuListener();
|
||||
// MogoObuManager.getInstance().unregisterListener();
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景
|
||||
*
|
||||
* @param type TODO
|
||||
*/
|
||||
private void handleSdkObu(int type) {
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
|
||||
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
|
||||
if (type == MogoObuConst.TYPE_CROSS_COLLISION_WARNING) { //交叉路口碰撞预警
|
||||
urgencyEvent.setType(MogoObuConst.TYPE_CROSS_COLLISION_WARNING);
|
||||
// urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_CROING_WARN_TEXT);
|
||||
} else if (type == MogoObuConst.TYPE_URGENCY_COLLISION_WARNING) { // 前车紧急制动预警
|
||||
urgencyEvent.setType(MogoObuConst.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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -94,7 +94,6 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation project(':modules:mogo-module-obu')
|
||||
// implementation rootProject.ext.dependencies.mebulaobu
|
||||
implementation rootProject.ext.dependencies.mogoobu
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,32 +8,23 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
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.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
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.module.v2x.utils.ToastUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.ObuManager;
|
||||
@@ -41,33 +32,22 @@ 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 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;
|
||||
|
||||
import com.zhidao.support.obu.MogoObuManager;
|
||||
import com.zhidao.support.obu.OnMogoObuListener;
|
||||
import com.zhidao.support.obu.constants.ObuConstants;
|
||||
import com.zhidao.support.obu.model.CvxAppInitIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxHvCarIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxHvInfoIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxRvInfoIndInfo;
|
||||
import com.zhidao.support.obu.model.CvxSetConfigCfmInfo;
|
||||
import com.zhidao.support.obu.model.CvxV2vThreatIndInfo;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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数据管理类封装
|
||||
*
|
||||
@@ -113,187 +93,10 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
|
||||
// NebulaObuClient.getInstance().registerObu(100);
|
||||
// NebulaObuClient.getInstance().registerObuListener(listener);
|
||||
|
||||
//自研obu
|
||||
MogoObuManager.getInstance().init(context);
|
||||
MogoObuManager.getInstance().connect("192.168.1.199");
|
||||
MogoObuManager.getInstance().registerListener(mogoObuListener);
|
||||
|
||||
//TODO 测试
|
||||
// UiThreadHandler.postDelayed( () -> {
|
||||
//// MogoObuManager.getInstance().test(icw_data);
|
||||
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(3, MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
// handleSdkObu(105);
|
||||
//
|
||||
// }, 5_000L );
|
||||
|
||||
IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
|
||||
context.registerReceiver(obuTypeExchangeReceiver, filter);
|
||||
}
|
||||
|
||||
private OnMogoObuListener mogoObuListener = new OnMogoObuListener() {
|
||||
@Override
|
||||
public void onConnected() {
|
||||
//OBU连接成功
|
||||
Logger.d("liyz", "onConnected ------> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectFail(boolean isNeedReconnect) {
|
||||
Logger.d("liyz", "onConnectFail ------> ");
|
||||
//OBU连接失败
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
Logger.d("liyz", "onDisconnect ------> ");
|
||||
//OBU断开连接
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceiveOriginData(String data) {
|
||||
super.onReceiveOriginData(data);
|
||||
Logger.d("liyz", "onReceiveOriginData ------> data = " + data);
|
||||
//接收到的原始数据
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendData(byte[] bytes) {
|
||||
super.onSendData(bytes);
|
||||
//发送的数据
|
||||
Logger.d("liyz", "onSendData ------> ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxAppInitIndInfo(CvxAppInitIndInfo info) {
|
||||
super.onCvxAppInitIndInfo(info);
|
||||
Logger.d("liyz", "onCvxAppInitIndInfo ------> " + info.toString());
|
||||
//CV2X系统信息
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxSetConfigCfm(CvxSetConfigCfmInfo info) {
|
||||
super.onCvxSetConfigCfm(info);
|
||||
Logger.d("liyz", "onCvxSetConfigCfm ------> " + info.toString());
|
||||
//设置CV2X系统的配置确认
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxHvCarIndInfo(CvxHvCarIndInfo info) {
|
||||
//主车车辆信息
|
||||
Logger.d("liyz", "onCvxHvCarIndInfo ------> " + info.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxHvInfoIndInfo(CvxHvInfoIndInfo info) {
|
||||
//主车信息
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxRvInfoIndInfo(CvxRvInfoIndInfo info) {
|
||||
//远车信息
|
||||
Logger.d("liyz", "onCvxRvInfoIndInfo ------> " + info.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCvxV2vThreatIndInfo(CvxV2vThreatIndInfo info) {
|
||||
//预警信息
|
||||
Logger.e("liyz", "onCvxV2vThreatIndInfo ------> " + info.toString());
|
||||
//预警类型 threat_level 3
|
||||
if (info != null) {
|
||||
if (info.getThreat_info() != null && info.getThreat_info().getThreat_level() == 2 &&
|
||||
info.getThreat_info().getThreat_level() == 3) { //看看2的情况
|
||||
//预警方位
|
||||
int direction = info.getExt_info().getTarget_classification();
|
||||
Logger.d("liyz", "direction = " + direction + "----" + getMessage(direction));
|
||||
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(getMessage(direction), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
//处理预警类型
|
||||
int appId = info.getThreat_info().getApp_id();
|
||||
handleSdkObu(getEventType(appId));
|
||||
}
|
||||
|
||||
//预警数据的组装,车辆实时移动和变色 TODO 这里需要obu提供他车列表 暂时不做
|
||||
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(getResultList(info));
|
||||
} else {
|
||||
Logger.e("liyz", "info == null ");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private int getMessage(int targetClassification) {
|
||||
switch (targetClassification) {
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT:
|
||||
return 1;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT:
|
||||
return 2;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT:
|
||||
return 3;
|
||||
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT:
|
||||
return 4;
|
||||
default:
|
||||
case ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED:
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getEventType(int appid) {
|
||||
if (appid == ObuConstants.USE_CASE_ID.EBW) {
|
||||
return ObuConstant.TYPE_URGENCY_COLLISION_WARNING;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.ICW) {
|
||||
return ObuConstant.TYPE_CROSS_COLLISION_WARNING;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private List<ADASRecognizedResult> resultList = null;
|
||||
|
||||
private List<ADASRecognizedResult> getResultList(CvxV2vThreatIndInfo info) {
|
||||
if (resultList == null) {
|
||||
resultList = new ArrayList<>();
|
||||
}
|
||||
|
||||
ADASRecognizedResult adasRecognizedResult = new ADASRecognizedResult();
|
||||
adasRecognizedResult.uuid = info.getVehicle_id();
|
||||
if (info.getBasic_info() != null && info.getBasic_info().getPosition() != null) {
|
||||
adasRecognizedResult.lat = info.getBasic_info().getPosition().getLatitude();
|
||||
adasRecognizedResult.lon = info.getBasic_info().getPosition().getLongitude();
|
||||
}
|
||||
adasRecognizedResult.type = 3; //小轿车
|
||||
adasRecognizedResult.heading = info.getBasic_info().getHeading();
|
||||
adasRecognizedResult.speed = info.getBasic_info().getSpeed();
|
||||
|
||||
resultList.add(adasRecognizedResult);
|
||||
|
||||
return resultList;
|
||||
|
||||
}
|
||||
|
||||
// public void release() {
|
||||
// NebulaObuClient.getInstance().unregisterObu();
|
||||
// NebulaObuClient.getInstance().unregisterObuListener();
|
||||
// MogoObuManager.getInstance().unregisterListener();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 星云obu数据监听
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user