Merge remote-tracking branch 'origin/feature/feature_mogo_obu' into feature/feature_mogo_obu
This commit is contained in:
@@ -19,7 +19,8 @@ public class MoGoObuProvider implements IMoGoObuProvider {
|
||||
public void init(Context context) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "初始化蘑菇自研OBU……");
|
||||
|
||||
MogoPrivateObuManager.getInstance().init(context);
|
||||
// MogoPrivateObuManager.getInstance().init(context);
|
||||
MogoPrivateObuManager.Companion.getINSTANCE().init(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,24 +16,32 @@ public class MogoObuConst {
|
||||
* 前碰撞预警
|
||||
*/
|
||||
public static final int TYPE_FRONT_COLLISION_WARNING = 101;
|
||||
public static final String TYPE_FRONT_COLLISION_WARNING_TEXT = "前车碰撞预警";
|
||||
public static final String TYPE_FRONT_COLLISION_WARNING_VOICE_TEXT = "前车碰撞预警";
|
||||
|
||||
/**
|
||||
* 交叉路口碰撞预警
|
||||
*/
|
||||
public static final int TYPE_CROSS_COLLISION_WARNING = 102;
|
||||
public static final String TYPE_CROSS_COLLISION_WARNING_TEXT = "交叉路口碰撞预警";
|
||||
public static final String TYPE_CROSS_COLLISION_WARNING_VOICE_TEXT = "注意交叉路口车辆";
|
||||
|
||||
/**
|
||||
* 左转辅助
|
||||
*/
|
||||
public static final int TYPE_TURN_LEFT_WARN = 103;
|
||||
public static final String TYPE_TURN_LEFT_WARN_TEXT = "左转碰撞预警";
|
||||
public static final String TYPE_TURN_LEFT_WARN_VOICE_TEXT = "注意左前车辆";
|
||||
|
||||
/**
|
||||
* 盲区预警
|
||||
* 盲区预警 -1
|
||||
*/
|
||||
public static final int TYPE_BLIND_ASSIST_WARN = 104;
|
||||
public static final String TYPE_BLIND_ASSIST_WARN_TEXT = "盲区碰撞预警";
|
||||
public static final String TYPE_BLIND_ASSIST_WARN_VOICE_TEXT = "注意左后车辆/注意右后车辆";
|
||||
|
||||
/**
|
||||
* 变道预警
|
||||
* 变道预警 -2
|
||||
*/
|
||||
public static final int TYPE_CHANGE_LANES_WARN = 105;
|
||||
|
||||
@@ -41,62 +49,80 @@ public class MogoObuConst {
|
||||
* 逆向超车预警
|
||||
*/
|
||||
public static final int TYPE_REVERSE_OVERTAKING_WARN = 106;
|
||||
public static final String TYPE_REVERSE_OVERTAKING_WARN_TEXT = "逆向超车预警";
|
||||
public static final String TYPE_REVERSE_OVERTAKING_WARN_VOICE_TEXT = "注意逆向车道车辆";
|
||||
|
||||
/**
|
||||
* 紧急制动预警
|
||||
* 紧急制动预警/前车急刹
|
||||
*/
|
||||
public static final int TYPE_URGENCY_COLLISION_WARNING = 107;
|
||||
public static final String TYPE_URGENCY_COLLISION_WARNING_TEXT = "前车急刹车";
|
||||
public static final String TYPE_URGENCY_COLLISION_WARNING_VOICE_TEXT = "前车急刹车";
|
||||
|
||||
/**
|
||||
* 异常车辆预警
|
||||
* 异常车辆预警 -1
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_CAR_WARN = 108;
|
||||
public static final String TYPE_UNUSUAL_CAR_WARN_TEXT = "前车异常";
|
||||
public static final String TYPE_UNUSUAL_CAR_WARN_VOICE_TEXT = "前车异常";
|
||||
|
||||
|
||||
/**
|
||||
* 车辆失控预警
|
||||
* 车辆失控预警 -1
|
||||
*/
|
||||
public static final int TYPE_CAR_OUT_OF_CONTROL_WARN = 109;
|
||||
public static final String TYPE_CAR_OUT_OF_CONTROL_WARN_TEXT = "前车失控预警";
|
||||
public static final String TYPE_CAR_OUT_OF_CONTROL_WARN_VOICE_TEXT = "前车失控预警";
|
||||
|
||||
/**
|
||||
* 限速预警
|
||||
* 限速预警 -1 ?
|
||||
*/
|
||||
public static final int TYPE_LIMIT_SPEED_WARN = 110;
|
||||
public static final String TYPE_LIMIT_SPEED_WARN_TEXT = "用户已超速";
|
||||
public static final String TYPE_LIMIT_SPEED_WARN_VOICE_TEXT = "前车失控预警";
|
||||
|
||||
|
||||
/**
|
||||
* 闯红灯预警
|
||||
* 闯红灯预警 ?
|
||||
*/
|
||||
public static final int TYPE_RUSH_RED_LIGHT = 111;
|
||||
|
||||
/**
|
||||
* 行人碰撞预警
|
||||
* 行人/摩托车 碰撞预警 -1 根据类型判断
|
||||
*/
|
||||
public static final int TYPE_ROAD_USER_COLLISION_WARNING = 112;
|
||||
|
||||
|
||||
/**
|
||||
* 绿波车速引导
|
||||
* 绿波车速引导 -1?
|
||||
*/
|
||||
public static final int TYPE_OPTIMAL_SPEED_ADVISORY = 113;
|
||||
|
||||
/**
|
||||
* 道路危险情况预警
|
||||
* 道路危险情况预警 -1
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_ROAD_WARN = 114;
|
||||
public static final String TYPE_UNUSUAL_ROAD_WARN_TEXT = "道路危险情况预警";
|
||||
public static final String TYPE_UNUSUAL_ROAD_WARN_VOICE_TEXT = "前方路况危险";
|
||||
|
||||
/**
|
||||
* 交通标牌提示
|
||||
* 交通标牌提示 ?
|
||||
*/
|
||||
public static final int TYPE_TRAFFIC_SIGN_INFO = 115;
|
||||
|
||||
/**
|
||||
* 前方拥堵提醒
|
||||
* 前方拥堵提醒 ?
|
||||
*/
|
||||
public static final int TYPE_BLOCK_WARN = 116;
|
||||
public static final String TYPE_BLOCK_WARN_TEXT = "前方道路拥堵";
|
||||
public static final String TYPE_BLOCK_WARN_VOICE_TEXT = "前方X米道路拥堵,请减速慢行";
|
||||
|
||||
/**
|
||||
* 紧急车辆提示预警
|
||||
*/
|
||||
public static final int TYPE_PRESSING_CAR_WARN = 117;
|
||||
|
||||
public static final String TYPE_PRESSING_CAR_WARN_TEXT = "请避让特种车辆";
|
||||
public static final String TYPE_PRESSING_CAR_WARN_VOICE_TEXT = "后方存在特殊车辆,请安排避让";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,292 +0,0 @@
|
||||
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 MogoPrivateObuManager {
|
||||
final String icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710";
|
||||
|
||||
private List<ADASRecognizedResult> resultList = null;
|
||||
|
||||
private MogoPrivateObuManager() {
|
||||
}
|
||||
|
||||
private volatile static MogoPrivateObuManager instance = null;
|
||||
|
||||
public static MogoPrivateObuManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (MogoPrivateObuManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new MogoPrivateObuManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
//TODO 他车是否一直出现
|
||||
@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) {
|
||||
//预警方位
|
||||
int direction = info.getExt_info().getTarget_classification();
|
||||
|
||||
//显示警告弹框 TODO
|
||||
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(getMessage(direction), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
//处理预警类型
|
||||
int appId = info.getThreat_info().getApp_id();
|
||||
Logger.d(TAG_MOGO_OBU, "direction = " + direction + "----" + getMessage(direction) + "--appId = " + appId);
|
||||
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;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) {//左转辅助
|
||||
return MogoObuConst.TYPE_TURN_LEFT_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.BSW) { //盲区预警
|
||||
return MogoObuConst.TYPE_BLIND_ASSIST_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LCW) { //变道预警
|
||||
return MogoObuConst.TYPE_CHANGE_LANES_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.DNPW) { //逆向超车预警
|
||||
return MogoObuConst.TYPE_REVERSE_OVERTAKING_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.FCW) { //前向碰撞预警
|
||||
return MogoObuConst.TYPE_FRONT_COLLISION_WARNING;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.AVW) { //异常车辆预警
|
||||
return MogoObuConst.TYPE_UNUSUAL_CAR_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.CLW) { //车辆失控预警
|
||||
return MogoObuConst.TYPE_CAR_OUT_OF_CONTROL_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.SLW) { //限速预警
|
||||
return MogoObuConst.TYPE_LIMIT_SPEED_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) { //闯红灯预警 ---
|
||||
return MogoObuConst.TYPE_RUSH_RED_LIGHT;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.VRUCW) { //行人碰撞预警 ---
|
||||
return MogoObuConst.TYPE_ROAD_USER_COLLISION_WARNING;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) { //绿波车速引导 ---
|
||||
return MogoObuConst.TYPE_OPTIMAL_SPEED_ADVISORY;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.HLW) { //道路危险情况预警
|
||||
return MogoObuConst.TYPE_UNUSUAL_ROAD_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.IVS) { //交通标牌提示
|
||||
return MogoObuConst.TYPE_TRAFFIC_SIGN_INFO;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.TJW) { //前方拥堵提醒
|
||||
return MogoObuConst.TYPE_BLOCK_WARN;
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.EVW) { //紧急车辆提示预警
|
||||
return MogoObuConst.TYPE_PRESSING_CAR_WARN;
|
||||
}
|
||||
|
||||
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() {
|
||||
MogoObuManager.getInstance().unregisterListener();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @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);
|
||||
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.mogo.module.obu.mogo
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult
|
||||
import com.mogo.service.warning.IMoGoWaringProvider
|
||||
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.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @description
|
||||
*
|
||||
* @author lixiaopeng
|
||||
* @since 2021/8/8
|
||||
*/
|
||||
class MogoPrivateObuManager private constructor() {
|
||||
companion object {
|
||||
val INSTANCE : MogoPrivateObuManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoPrivateObuManager()
|
||||
}
|
||||
}
|
||||
|
||||
private var resultList: MutableList<ADASRecognizedResult>? = null
|
||||
private var mMogoServiceApis: IMogoServiceApis? = null
|
||||
private var mIMoGoWaringProvider: IMoGoWaringProvider? = null
|
||||
val icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710"
|
||||
|
||||
|
||||
fun init(context: Context?) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
|
||||
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
|
||||
.navigation(context) as IMogoServiceApis
|
||||
// 获取预警模块的接口
|
||||
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
|
||||
|
||||
//自研obu
|
||||
MogoObuManager.getInstance().init(context)
|
||||
MogoObuManager.getInstance().connect("192.168.1.199")
|
||||
MogoObuManager.getInstance().registerListener(mogoObuListener)
|
||||
|
||||
//TODO 测试
|
||||
// UiThreadHandler.postDelayed({
|
||||
//// MogoObuManager.getInstance().test(icw_data)
|
||||
// handleSdkObu(107)
|
||||
// }, 5000L)
|
||||
}
|
||||
|
||||
private val mogoObuListener: OnMogoObuListener = object : OnMogoObuListener() {
|
||||
override fun onConnected() {
|
||||
//OBU连接成功
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnected ------> ")
|
||||
}
|
||||
|
||||
override fun onConnectFail(isNeedReconnect: Boolean) {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onConnectFail ------> ")
|
||||
//OBU连接失败
|
||||
}
|
||||
|
||||
override fun onDisconnect() {
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onDisconnect ------> ")
|
||||
//OBU断开连接
|
||||
}
|
||||
|
||||
override fun onReceiveOriginData(data: String) {
|
||||
super.onReceiveOriginData(data)
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onReceiveOriginData ------> data = $data")
|
||||
//接收到的原始数据
|
||||
}
|
||||
|
||||
override fun onSendData(bytes: ByteArray) {
|
||||
super.onSendData(bytes)
|
||||
//发送的数据
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onSendData ------> ")
|
||||
}
|
||||
|
||||
override fun onCvxAppInitIndInfo(info: CvxAppInitIndInfo) {
|
||||
super.onCvxAppInitIndInfo(info)
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxAppInitIndInfo ------> $info")
|
||||
//CV2X系统信息
|
||||
}
|
||||
|
||||
override fun onCvxSetConfigCfm(info: CvxSetConfigCfmInfo) {
|
||||
super.onCvxSetConfigCfm(info)
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxSetConfigCfm ------> $info")
|
||||
//设置CV2X系统的配置确认
|
||||
}
|
||||
|
||||
override fun onCvxHvCarIndInfo(info: CvxHvCarIndInfo) {
|
||||
//主车车辆信息
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxHvCarIndInfo ------> $info")
|
||||
}
|
||||
|
||||
override fun onCvxHvInfoIndInfo(info: CvxHvInfoIndInfo) {
|
||||
//主车信息
|
||||
}
|
||||
|
||||
override fun onCvxRvInfoIndInfo(info: CvxRvInfoIndInfo) {
|
||||
//远车信息,
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxRvInfoIndInfo ------> $info")
|
||||
}
|
||||
|
||||
//TODO 他车是否一直出现
|
||||
override fun onCvxV2vThreatIndInfo(info: CvxV2vThreatIndInfo) {
|
||||
//预警信息,预警类型 threat_level 3
|
||||
if (info != null) {
|
||||
Logger.e(MogoObuConst.TAG_MOGO_OBU, "onCvxV2vThreatIndInfo ------> $info")
|
||||
if (info.threat_info != null) {
|
||||
if (info.threat_info.threat_level == 2 ||
|
||||
info.threat_info.threat_level == 3) {
|
||||
//预警方位
|
||||
val direction = info.ext_info.target_classification
|
||||
|
||||
//显示警告弹框 TODO
|
||||
// MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(getMessage(direction), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
||||
|
||||
//处理预警类型
|
||||
val appId = info.threat_info.app_id
|
||||
Logger.d(MogoObuConst.TAG_MOGO_OBU, "direction = " + direction + "----" + getMessage(direction) + "--appId = " + appId)
|
||||
handleSdkObu(getEventType(appId))
|
||||
}
|
||||
|
||||
//预警数据的组装,车辆实时移动和变色 TODO 这里需要obu提供他车列表 暂时不做
|
||||
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult(getResultList(info));
|
||||
} else {
|
||||
Logger.e(MogoObuConst.TAG_MOGO_OBU, "info == null ")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getMessage(targetClassification: Int): Int {
|
||||
return when (targetClassification) {
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT -> 1
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 2
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT -> 3
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT, ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT -> 4
|
||||
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> 1
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
|
||||
private fun getEventType(appid: Int): Int {
|
||||
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
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) { //左转辅助
|
||||
return MogoObuConst.TYPE_TURN_LEFT_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.BSW) { //盲区预警
|
||||
return MogoObuConst.TYPE_BLIND_ASSIST_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LCW) { //变道预警
|
||||
return MogoObuConst.TYPE_CHANGE_LANES_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.DNPW) { //逆向超车预警
|
||||
return MogoObuConst.TYPE_REVERSE_OVERTAKING_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.FCW) { //前向碰撞预警
|
||||
return MogoObuConst.TYPE_FRONT_COLLISION_WARNING
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.AVW) { //异常车辆预警
|
||||
return MogoObuConst.TYPE_UNUSUAL_CAR_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.CLW) { //车辆失控预警
|
||||
return MogoObuConst.TYPE_CAR_OUT_OF_CONTROL_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.SLW) { //限速预警
|
||||
return MogoObuConst.TYPE_LIMIT_SPEED_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) { //闯红灯预警 ---
|
||||
return MogoObuConst.TYPE_RUSH_RED_LIGHT
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.VRUCW) { //行人碰撞预警 ---
|
||||
return MogoObuConst.TYPE_ROAD_USER_COLLISION_WARNING
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.LTA) { //绿波车速引导 ---
|
||||
return MogoObuConst.TYPE_OPTIMAL_SPEED_ADVISORY
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.HLW) { //道路危险情况预警
|
||||
return MogoObuConst.TYPE_UNUSUAL_ROAD_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.IVS) { //交通标牌提示
|
||||
return MogoObuConst.TYPE_TRAFFIC_SIGN_INFO
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.TJW) { //前方拥堵提醒
|
||||
return MogoObuConst.TYPE_BLOCK_WARN
|
||||
} else if (appid == ObuConstants.USE_CASE_ID.EVW) { //紧急车辆提示预警
|
||||
return MogoObuConst.TYPE_PRESSING_CAR_WARN
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
private fun getResultList(info: CvxV2vThreatIndInfo): List<ADASRecognizedResult?>? {
|
||||
if (resultList == null) {
|
||||
resultList = ArrayList<ADASRecognizedResult>()
|
||||
}
|
||||
val adasRecognizedResult = ADASRecognizedResult()
|
||||
adasRecognizedResult.uuid = info.vehicle_id
|
||||
if (info.basic_info != null && info.basic_info.position != null) {
|
||||
adasRecognizedResult.lat = info.basic_info.position.latitude
|
||||
adasRecognizedResult.lon = info.basic_info.position.longitude
|
||||
}
|
||||
adasRecognizedResult.type = 3 //小轿车
|
||||
adasRecognizedResult.heading = info.basic_info.heading
|
||||
adasRecognizedResult.speed = info.basic_info.speed
|
||||
|
||||
resultList!!.add(adasRecognizedResult)
|
||||
|
||||
return resultList
|
||||
}
|
||||
|
||||
|
||||
fun release() {
|
||||
MogoObuManager.getInstance().unregisterListener()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @param type TODO
|
||||
*/
|
||||
private fun handleSdkObu(type: Int) {
|
||||
var alertContent: String = ""
|
||||
var ttsContent: String = ""
|
||||
|
||||
if (type == MogoObuConst.TYPE_CROSS_COLLISION_WARNING) { //交叉路口碰撞预警
|
||||
alertContent = MogoObuConst.TYPE_CROSS_COLLISION_WARNING_TEXT
|
||||
ttsContent = MogoObuConst.TYPE_CROSS_COLLISION_WARNING_VOICE_TEXT
|
||||
} else if (type == MogoObuConst.TYPE_URGENCY_COLLISION_WARNING) { // 前车紧急制动预警
|
||||
alertContent = MogoObuConst.TYPE_URGENCY_COLLISION_WARNING_TEXT
|
||||
ttsContent = MogoObuConst.TYPE_URGENCY_COLLISION_WARNING_VOICE_TEXT
|
||||
}
|
||||
|
||||
//显示弹框
|
||||
mIMoGoWaringProvider!!.showWarningV2X(
|
||||
type,
|
||||
alertContent,
|
||||
ttsContent,
|
||||
type.toString()
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user