add mogo obu

This commit is contained in:
lixiaopeng
2021-08-04 14:14:19 +08:00
parent 35fe7c1355
commit 4877290a17
7 changed files with 367 additions and 206 deletions

View File

@@ -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数据监听
*/