Merge branch 'dev_robotaxi-d-app-module_251_220125_2.5.1' into dev_MogoAP_eagle-220_211207_8.0.17_merge

# Conflicts:
#	app/build.gradle
#	core/function-impl/mogo-core-function-autopilot/build.gradle
#	core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/adapter/MoGoAdasListenerImpl.java
#	modules/mogo-module-adas/build.gradle
This commit is contained in:
donghongyu
2022-02-09 10:59:31 +08:00
57 changed files with 604 additions and 1613 deletions

View File

@@ -51,16 +51,25 @@ dependencies {
kapt rootProject.ext.dependencies.aroutercompiler
// implementation rootProject.ext.dependencies.adasHigh
implementation rootProject.ext.dependencies.mogoami
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogo_core_data
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.mogo_core_utils
implementation rootProject.ext.dependencies.mogo_core_network
implementation rootProject.ext.dependencies.mogo_core_function_api
implementation rootProject.ext.dependencies.mogo_core_function_call
implementation rootProject.ext.dependencies.adasHigh
} else {
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-service')
implementation project(':core:mogo-core-data')
implementation project(':core:mogo-core-utils')
implementation project(':core:mogo-core-network')
implementation project(':core:mogo-core-function-api')
implementation project(':core:mogo-core-function-call')
implementation project(':libraries:mogo-adas')

View File

@@ -6,13 +6,17 @@ import androidx.annotation.RequiresPermission
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.autopilot.AutopilotControlCmdParameter
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MoGoConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotProvider
import com.mogo.eagle.core.function.autopilot.adapter.MoGoAdasListenerImpl
import com.mogo.eagle.core.function.autopilot.adapter.MoGoAdasMsgConnectStatusListenerImpl
import com.mogo.eagle.core.function.autopilot.adapter.MoGoHandAdasMsgManager
import com.mogo.eagle.core.function.autopilot.server.AsyncDataToAutopilotServer
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.GsonUtils
import com.mogo.eagle.core.utilcode.util.LogUtils
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.zhidao.support.adas.high.AdasManager
import com.zhidao.support.adas.high.bean.IPCUpgradeInfo
@@ -34,9 +38,27 @@ class MoGoAutopilotProvider :
get() = TAG
override fun init(context: Context) {
MoGoHandAdasMsgManager.getInstance();
Logger.d(TAG, "初始化工控机连接……")
mContext = context
// 初始化ADAS 域控制器
//AdasManager.getInstance().create(context)
CupidLogUtils.setEnableLog(false)
CupidLogUtils.setIsWriteLog(false)
// TODO 临时方案根据不同的身份标识连接不同的工控机IP
when (FunctionBuildConfig.appIdentityMode) {
0 -> // 司机
AdasManager.getInstance().create(context, "192.168.1.102")
1 -> // 乘客
AdasManager.getInstance().create(context, "192.168.1.103")
else -> // 默认采用UDP寻址方式
AdasManager.getInstance().create(context)
}
//////////////////////////////////注意先后顺序AdasManager.getInstance().create后才可以设置监听/////////////////////////////////////////////
// 监听 adas 连接状态
AdasManager.getInstance().setOnAdasConnectStatusListener(MoGoAdasMsgConnectStatusListenerImpl())
// 监听ADAS-SDK获取到的工控机数据
AdasManager.getInstance().setOnAdasListener(MoGoAdasListenerImpl())
// 同步数据给工控机的服务
AsyncDataToAutopilotServer.INSTANCE.initServer()
}
@@ -72,7 +94,7 @@ class MoGoAutopilotProvider :
val parameter = AutopilotControlCmdParameter("aiCloudToStartAutopilot", result)
AdasManager.getInstance().aiCloudToAdasData(GsonUtils.toJson(parameter))
} else {
LogUtils.eTag(TAG, "车机与工控机链接失败,无法开启自动驾驶")
Logger.e(TAG, "车机与工控机链接失败,无法开启自动驾驶")
}
}
@@ -84,7 +106,7 @@ class MoGoAutopilotProvider :
if (AdasManager.getInstance().isSocketConnect) {
AdasManager.getInstance().controlAutopilotCarHead()
} else {
LogUtils.eTag(TAG, "车机与工控机链接失败,无法断开自动驾驶")
Logger.e(TAG, "车机与工控机链接失败,无法断开自动驾驶")
}
}

View File

@@ -0,0 +1,368 @@
package com.mogo.eagle.core.function.autopilot.adapter;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ARRIVE;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_GUARDIAN;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_RECORD;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ROUTE;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_STATUS;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAJECTORY;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_WARN;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA;
import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_ADAS;
import android.util.Log;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.data.traffic.TrafficData;
import com.mogo.eagle.core.function.autopilot.utils.AdasObjectConvertUtils;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.timedelay.TimeDelayUploadManager;
import com.zhidao.support.adas.high.AdasManager;
import com.zhidao.support.adas.high.OnAdasListener;
import com.zhidao.support.adas.high.bean.AutopilotRoute;
import com.zhidao.support.adas.high.bean.AutopilotStatus;
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
import com.zhidao.support.adas.high.bean.CarLaneInfo;
import com.zhidao.support.adas.high.bean.CarStateInfo;
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
import com.zhidao.support.adas.high.bean.LightStatueInfo;
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
import com.zhidao.support.adas.high.bean.RectInfo;
import com.zhidao.support.adas.high.bean.SSHResult;
import com.zhidao.support.adas.high.bean.TrajectoryInfo;
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo;
import com.zhidao.support.adas.high.bean.record.AutopilotRecordResult;
import com.zhidao.support.obu.ami.AmiClientManager;
import com.zhjt.service.chain.ChainLog;
import com.zhjt.service.chain.TracingConstants;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* @author congtaowang
* @since 2020/10/22
* <p>
* 适配ADAS 回调监听分发
*/
public class MoGoAdasListenerImpl implements OnAdasListener {
private final String TAG = "OnAdasListenerAdapter";
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_RECT_DATA,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onRectData(RectInfo rectInfo) {
if (HdMapBuildConfig.isMapLoaded) {
ArrayList<TrafficData> recognizedListResults = AdasObjectConvertUtils.INSTANCE.regroupTrafficDataData(rectInfo.getModels());
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotIdentifyDataUpdate(recognizedListResults);
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_CAR_STATE,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onCarStateData(CarStateInfo carStateInfo) {
if (HdMapBuildConfig.isMapLoaded) {
// Logger.d(TAG, "--------carStateInfo.toString() = " + carStateInfo.toString());
//can数据转发
CarStateInfo.ValuesBean bean = carStateInfo.getValues();
// Log.w("DHY-location", bean.getLon() + "," + bean.getLat() + " OnAdasListenerAdapter-onCarStateData");
if (bean != null) {
int turnLight = bean.getTurnLightOften(); //转向灯状态 0是正常 1是左转 2是右转
AmiClientManager.getInstance().setTurnLightState(turnLight);
int brakeLight = bean.getBrake_light(); //TODO
// Logger.d(TAG, "onCarStateData ---- turnLight = " + turnLight + "---brakeLight = " + brakeLight);
//设置转向灯
CallerHmiManager.INSTANCE.showTurnLight(turnLight);
//设置刹车信息
CallerHmiManager.INSTANCE.showBrakeLight(brakeLight);
} else {
Logger.e(TAG, "bean == null ");
}
AutopilotCarStateInfo autopilotCarStateInfo = AdasObjectConvertUtils.INSTANCE.fromAdasCarStateInfoObject(carStateInfo);
// 将数据通过数据中心分发出去
CallerAutopilotCarStatusListenerManager.INSTANCE.invokeAutopilotCarStateData(autopilotCarStateInfo);
// 同步给MAP地图
adasCarDataCallback(autopilotCarStateInfo);
}
}
public void adasCarDataCallback(@Nullable AutopilotCarStateInfo stateInfo) {
//模拟数据时,不更新由工控机传输的自车位置
if (TimeDelayUploadManager.getInstance().isMock()) {
return;
}
if (stateInfo != null && stateInfo.getValues() != null) {
//Logger.d(TAG,"同步自车数据给地图……");
MogoApisHandler.getInstance().getApis().getAdasControllerApi().setLastLat(stateInfo.getValues().getLat());
MogoApisHandler.getInstance().getApis().getAdasControllerApi().setLastLon(stateInfo.getValues().getLon());
MogoApisHandler.getInstance().getApis().getAdasControllerApi().setSatelliteTime(stateInfo.getValues().getSatelliteTime());
JSONObject data = new JSONObject();
try {
data.putOpt("lon", stateInfo.getValues().getLon());
data.putOpt("lat", stateInfo.getValues().getLat());
data.putOpt("alt", stateInfo.getValues().getAlt());
data.putOpt("speed", stateInfo.getValues().getGnss_speed());
data.putOpt("heading", stateInfo.getValues().getHeading());
data.putOpt("acceleration", stateInfo.getValues().getAcceleration());
data.putOpt("yawRate", stateInfo.getValues().getYaw_rate());
data.putOpt("gpsProvider", 1);
try {
data.putOpt("systemTime", Long.parseLong(stateInfo.getValues().getSystemTime()));
} catch (Exception e) {
// e.printStackTrace();
}
try {
data.putOpt("satelliteTime", Long.parseLong(stateInfo.getValues().getSatelliteTime()));
} catch (Exception e) {
e.printStackTrace();
}
try {
data.putOpt("receiverDataTime", Long.parseLong(stateInfo.getValues().getReceiverDataTime()));
} catch (Exception e) {
// e.printStackTrace();
}
try {
data.putOpt("adasSatelliteTime", Long.parseLong(stateInfo.getValues().getAdasSatelliteTime()));
} catch (Exception e) {
// e.printStackTrace();
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(data);
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(data);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_STATUS,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void autopilotStatus(AutopilotStatus autopilotStatus) {
if (HdMapBuildConfig.isMapLoaded) {
AutopilotStatus.ValuesBean autopilotStatusValues = autopilotStatus.getValues();
if (autopilotStatusValues != null) {
// 初始化自动驾驶状态信息
AutopilotStatusInfo autopilotStatusInfo = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo();
autopilotStatusInfo.setState(autopilotStatusValues.getState());
autopilotStatusInfo.setPilotmode(autopilotStatusValues.getPilotmode());
autopilotStatusInfo.setControl_pilotmode(autopilotStatusValues.getControl_pilotmode());
autopilotStatusInfo.setReason(autopilotStatusValues.getReason());
autopilotStatusInfo.setCamera(autopilotStatusValues.getCamera());
autopilotStatusInfo.setRtk(autopilotStatusValues.getRtk());
autopilotStatusInfo.setRadar(autopilotStatusValues.getRadar());
autopilotStatusInfo.setSpeed(autopilotStatusValues.getSpeed());
// 初始化自动驾驶状态信息
autopilotStatusInfo.setVersion(AdasManager.getInstance().getAdasConfig().getVersion());
autopilotStatusInfo.setConnectIP(AdasManager.getInstance().getAdasConfig().getAddress());
autopilotStatusInfo.setDockVersion(AdasManager.getInstance().getAdasConfig().getDockVersion());
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutoPilotStatus();
}
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ARRIVE,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void autopilotArrive(AutopilotWayArrive autopilotWayArrive) {
if (HdMapBuildConfig.isMapLoaded) {
Logger.d(TAG, "autopilotArrive : " + autopilotWayArrive);
if (autopilotWayArrive != null) {
AutopilotWayArrive.ResultBean result = autopilotWayArrive.getResult();
if (result != null) {
AutopilotWayArrive.ResultBean.EndLatLonBean endLatLon = result.getEndLatLon();
if (endLatLon != null) {
AutopilotStationInfo stationInfo = new AutopilotStationInfo(result.getCarType(), endLatLon.getLon(), endLatLon.getLat());
CallerAutoPilotStatusListenerManager.INSTANCE.invokeArriveAtStation(stationInfo);
}
}
}
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_ROUTE,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onAutopilotRoute(AutopilotRoute route) {
if (HdMapBuildConfig.isMapLoaded) {
Logger.d(TAG, "onAutopilotRoute : " + route.toString());
AutopilotRouteInfo autopilotRoute = AdasObjectConvertUtils.INSTANCE.fromAdasAutopilotRoute(route);
CallerAutopilotPlanningListenerManager.INSTANCE.invokeAutopilotRotting(autopilotRoute);
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_TRAJECTORY,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onAutopilotTrajectory(List<TrajectoryInfo> trajectoryList) {
if (HdMapBuildConfig.isMapLoaded) {
Logger.d(TAG, "onAutopilotTrajectory : " + trajectoryList);
ArrayList<ADASTrajectoryInfo> trajectoryInfoArrayList = new ArrayList<>();
if (trajectoryList != null && trajectoryList.size() > 0) {
for (TrajectoryInfo trajectory : trajectoryList) {
ADASTrajectoryInfo adasTrajectoryInfo = new ADASTrajectoryInfo();
adasTrajectoryInfo.setLat(trajectory.getLat());
adasTrajectoryInfo.setLon(trajectory.getLon());
adasTrajectoryInfo.setAcceleration(trajectory.getAcceleration());
adasTrajectoryInfo.setAccumulatedDis(trajectory.getAccumulatedDis());
adasTrajectoryInfo.setTime(trajectory.getTime());
adasTrajectoryInfo.setVelocity(trajectory.getVelocity());
adasTrajectoryInfo.setAlt(trajectory.getAlt());
adasTrajectoryInfo.setKappa(trajectory.getKappa());
adasTrajectoryInfo.setTheta(trajectory.getTheta());
trajectoryInfoArrayList.add(adasTrajectoryInfo);
}
Log.e(TAG, "time:" + System.currentTimeMillis() + "trajectoryInfoArrayList:" + trajectoryInfoArrayList);
}
CallerAutopilotPlanningListenerManager.INSTANCE.invokeAutopilotTrajectory(trajectoryInfoArrayList);
}
}
@Override
public void onAutopilotSNRequest() {
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotSNRequest();
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_GUARDIAN,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onAutopilotGuardian(AutopilotGuardianInfo guardianInfo) {
if (HdMapBuildConfig.isMapLoaded) {
AutopilotGuardianStatusInfo autopilotRoute = AdasObjectConvertUtils.INSTANCE.fromAutopilotGuardianInfo(guardianInfo);
CallerAutoPilotStatusListenerManager.INSTANCE.invokeAutopilotGuardian(autopilotRoute);
}
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_RECORD,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onAutopilotRecord(AutopilotRecordResult result) {
if (result != null) {
AutoPilotRecordResult real = new AutoPilotRecordResult();
real.setDiskFree(result.getDiskFree());
real.setId(result.getId());
real.setDuration(result.getDuration());
real.setNote(result.getNote());
real.setTotal(result.getTotalSize());
real.setType(result.getType());
real.setFileName(result.getFilename());
real.setKey(result.getKey());
real.setStat(result.getStat());
real.setTimestamp(result.getTimestamp());
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotRecordResult(real);
}
}
@Override
public void onLightStateData(LightStatueInfo lightStatueInfo) {
}
@Override
public void onObstaclesInfo(ObstaclesInfo obstaclesInfo) {
}
@Override
public void onCarLaneInfo(CarLaneInfo carLaneInfo) {
}
@ChainLog(linkCode = CHAIN_LINK_ADAS,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_ADAS_MESSAGE_AUTOPILOT_WARN,
paramIndexes = {0},
clientPkFileName = "sn")
@Override
public void onWarnMessage(WarnMessageInfo warnMessageInfo) {
final AutopilotWarnMessage warnMessage = AdasObjectConvertUtils.INSTANCE.fromAdasObject(warnMessageInfo);
CallerAutopilotIdentifyListenerManager.INSTANCE.invokeAutopilotWarnMessage(warnMessage);
}
@Override
public void onVideoSize(int width, int height) {
}
/**
* 工控机升级状态
*
* @param info 工控机升级状态
*/
@Override
public void onUpgradeStateInfo(IPCUpgradeStateInfo info) {
if (info != null) {
Logger.d(TAG, "onUpgradeStateInfo " +
" upgrade mode=" + info.getUpgradeMode() +
" download status=" + info.getDownloadStatus() +
" download progress current=" + info.getProgress().getCurrent() +
" download progress total=" + info.getProgress().getTotal() +
" download version=" + info.getImages() +
" upgrade status=" + info.getUpgradeStatus());
CallerHmiManager.INSTANCE.showAdUpgradeStatus(info.getUpgradeMode(), info.getDownloadStatus(), info.getProgress().getCurrent(),
info.getProgress().getTotal(), info.getImages(), info.getUpgradeStatus());
} else {
Logger.d(TAG, "onUpgradeStateInfo : upgrade state info is null");
}
}
@Override
public void onSSHResult(SSHResult info) {
}
}

View File

@@ -0,0 +1,100 @@
package com.mogo.eagle.core.function.autopilot.adapter
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.autopilot.network.AdasServiceModel
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhidao.support.adas.high.AdasManager
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener
import com.zhidao.support.adas.high.bean.BasicInfo
import io.reactivex.Flowable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* ADAS-SDK与工控机连接状态回调
*
* @author donghongyu
*/
class MoGoAdasMsgConnectStatusListenerImpl : OnAdasMsgConnectStatusListener, IMoGoAutopilotStatusListener {
private val TAG = "MoGoAdasMsgConnectStatusListenerImpl"
//自动驾驶状态
private var mCurrentAutopilotStatus = -1
//自动驾驶车速度
private var mCurrentAutopilotSpeed = 0f
override fun onWebSocketConnectSuccess() {
Logger.d(TAG, "webSocket 连接成功")
// 初始化自动驾驶状态信息
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP = AdasManager.getInstance().adasConfig.address
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = true
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
// 同步SN给工控机
syncBasicInfoToAutopilot()
// 开启轮训上传自动驾驶状态
updateDriveStatusTask()
}
override fun onWebSocketConnectFailed(reason: String) {
Logger.d(TAG, "webSocket 连接失败 reason:$reason")
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP = AdasManager.getInstance().adasConfig.address
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = false
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
}
/**
* 工控机获取SN
*/
override fun onAutopilotSNRequest() {
syncBasicInfoToAutopilot()
}
override fun onAutopilotArriveAtStation(autopilotWayArrive: AutopilotStationInfo?) {
if (autopilotWayArrive != null) {
val lon = autopilotWayArrive.lon
val lat = autopilotWayArrive.lat
AdasServiceModel.getInstance().reportSite(lon, lat)
}
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
val state = autoPilotStatusInfo.state
val speed = autoPilotStatusInfo.speed
mCurrentAutopilotStatus = state
mCurrentAutopilotSpeed = speed
}
/**
* 同步SN信息给工控机
*/
private fun syncBasicInfoToAutopilot() {
Logger.d(TAG, "同步PAD的SN给工控机……")
val info = BasicInfo()
info.setSn(MoGoAiCloudClientConfig.getInstance().sn)
AdasManager.getInstance().setBasicInfo(info)
}
/**
* 上传自动驾驶状态任务
*/
private fun updateDriveStatusTask() {
Logger.d(TAG, "updateDriveStatusTask")
Flowable.interval(0, 5, TimeUnit.SECONDS)
.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { aLong: Long? ->
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
}
}
}

View File

@@ -1,38 +0,0 @@
package com.mogo.eagle.core.function.autopilot.adapter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
/**
* @author xiaoyuzhou
* @date 2021/10/20 1:02 下午
* 自动驾驶状态回调用
*/
public class MoGoAutopilotStatusListenerImpl implements IMoGoAutopilotStatusListener {
@Override
public void onAutopilotStatusResponse(@NonNull AutopilotStatusInfo autoPilotStatusInfo) {
}
@Override
public void onAutopilotArriveAtStation(@Nullable AutopilotStationInfo autopilotWayArrive) {
}
@Override
public void onAutopilotSNRequest() {
}
@Override
public void onAutopilotGuardian(@Nullable AutopilotGuardianStatusInfo guardianInfo) {
}
}

View File

@@ -0,0 +1,83 @@
package com.mogo.eagle.core.function.autopilot.adapter;
import androidx.annotation.Nullable;
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult;
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo;
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.traffic.TrafficData;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.module.common.drawer.IdentifyDataDrawer;
import com.zhidao.support.obu.ami.AmiClientManager;
import java.util.ArrayList;
public class MoGoHandAdasMsgManager implements
IMoGoAutopilotIdentifyListener,
IMoGoAutopilotCarStateListener {
private final String TAG = "AdasEventManager";
private static volatile MoGoHandAdasMsgManager moGoHandAdasMsgManager;
private MoGoHandAdasMsgManager() {
CallerAutopilotIdentifyListenerManager.INSTANCE.addListener(TAG, this);
CallerAutopilotCarStatusListenerManager.INSTANCE.addListener(TAG, this);
}
public static MoGoHandAdasMsgManager getInstance() {
if (moGoHandAdasMsgManager == null) {
synchronized (MoGoHandAdasMsgManager.class) {
if (moGoHandAdasMsgManager == null) {
moGoHandAdasMsgManager = new MoGoHandAdasMsgManager();
}
}
}
return moGoHandAdasMsgManager;
}
@Override
public void onAutopilotCarStateData(@Nullable AutopilotCarStateInfo autoPilotCarStateInfo) {
// 获取的自动驾驶车辆信息不是空的时候
if (autoPilotCarStateInfo != null) {
//can数据转发
AutopilotCarStateInfo.ValuesBean bean = autoPilotCarStateInfo.getValues();
if (bean != null) {
//转向灯状态 0是正常 1是左转 2是右转
int turnLight = bean.getTurn_light();
AmiClientManager.getInstance().setTurnLightState(turnLight);
}
}
}
@Override
public void onAutopilotIdentifyDataUpdate(@Nullable ArrayList<TrafficData> trafficData) {
try {
if (FunctionBuildConfig.isDrawIdentifyData) {
ThreadUtils.getSinglePool().execute(() ->
IdentifyDataDrawer.getInstance().renderAdasRecognizedResult(trafficData)
);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onAutopilotWarnMessage(@Nullable AutopilotWarnMessage autopilotWarnMessage) {
}
@Override
public void onAutopilotRecordResult(AutoPilotRecordResult result) {
}
}

View File

@@ -0,0 +1,41 @@
package com.mogo.eagle.core.function.autopilot.entity;
/**
* Created by XuYong on 2021/5/28 16:12
*/
public class AutonomousDriveStatusBean {
private String sn;
private int status;
private float vehicleSpeed;
public AutonomousDriveStatusBean(String sn, int status, float vehicleSpeed) {
this.sn = sn;
this.status = status;
this.vehicleSpeed = vehicleSpeed;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public float getVehicleSpeed() {
return vehicleSpeed;
}
public void setVehicleSpeed(float vehicleSpeed) {
this.vehicleSpeed = vehicleSpeed;
}
}

View File

@@ -0,0 +1,40 @@
package com.mogo.eagle.core.function.autopilot.entity;
/**
* Created by XuYong on 2021/5/31 16:24
*/
public class ReportSiteBean {
private String sn;
private double lon;
private double lat;
public ReportSiteBean(String sn, double lon, double lat) {
this.sn = sn;
this.lon = lon;
this.lat = lat;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
}

View File

@@ -0,0 +1,98 @@
package com.mogo.eagle.core.function.autopilot.network;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.context.ContextHolderUtil;
import com.mogo.eagle.core.data.BaseData;
import com.mogo.eagle.core.function.autopilot.entity.AutonomousDriveStatusBean;
import com.mogo.eagle.core.function.autopilot.entity.ReportSiteBean;
import com.mogo.eagle.core.network.RequestOptions;
import com.mogo.eagle.core.network.SubscribeImpl;
import com.mogo.eagle.core.network.utils.GsonUtil;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.HostConst;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* 将自动驾驶状态及站点信息上传给云平台,云平台会根据此数据做路线的绘制
*
* @author dongghongyu
*/
public class AdasServiceModel {
private static final String TAG = "AdasServiceModel";
private static volatile AdasServiceModel instance;
private static final byte[] obj = new byte[0];
private final IAdasApiService mAdasApiService;
private AdasServiceModel() {
this.mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IAdasApiService.class, HostConst.DATA_SERVICE_HOST);
}
public static AdasServiceModel getInstance() {
if (instance == null) {
synchronized (obj) {
if (instance == null) {
instance = new AdasServiceModel();
}
}
}
return instance;
}
public void updateDriveStatus(int autoPilotStatus, float autoPilotSpeed) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
AutonomousDriveStatusBean request = new AutonomousDriveStatusBean(sn, autoPilotStatus, autoPilotSpeed);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mAdasApiService.updateAutonomousDriveStatus(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "updateDriveStatus success");
}
});
}
public void reportSite(double lon, double lat) {
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
ReportSiteBean reportSiteBean = new ReportSiteBean(sn, lon, lat);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(reportSiteBean));
mAdasApiService.updateReportSite(requestBody).
subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(ContextHolderUtil.getContext())) {
@Override
public void onError(String message, int code) {
super.onError(message, code);
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
@Override
public void onSuccess(BaseData o) {
super.onSuccess(o);
Logger.d(TAG, "autopilotArrive success");
}
});
}
}

View File

@@ -0,0 +1,31 @@
package com.mogo.eagle.core.function.autopilot.network;
import com.mogo.eagle.core.data.BaseData;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
public interface IAdasApiService {
/**
* 上传自动驾驶状态接口
* @param requestBody
* @return
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/dataService/autonomousDrive/updateAutonomousDriveStatus")
Observable<BaseData> updateAutonomousDriveStatus(@Body RequestBody requestBody);
/**
* 站点上报 用于网约车业务 云平台绘制路线使用
* @param requestBody
* @return
*/
@Headers({"Content-Type:application/json;charset=UTF-8"})
@POST("/dataService/autonomousDrive/reportSite")
Observable<BaseData> updateReportSite(@Body RequestBody requestBody);
}

View File

@@ -1,10 +1,102 @@
package com.mogo.eagle.core.function.autopilot.utils
import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo
import com.mogo.eagle.core.data.autopilot.AutopilotWarnMessage
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
import com.mogo.eagle.core.data.traffic.TrafficData
import com.zhidao.support.adas.high.bean.AutopilotRoute
import com.zhidao.support.adas.high.bean.CarStateInfo
import com.zhidao.support.adas.high.bean.RectInfo
import com.zhidao.support.adas.high.bean.WarnMessageInfo
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo
import com.zhidao.utils.common.GsonUtil
/**
* @author xiaoyuzhou
* @date 2021/10/18 1:32 下午
*/
class AdasObjectConvertUtils {
object AdasObjectConvertUtils {
val TAG = "AdasObjectConvertUtils"
fun fromAutopilotGuardianInfo(autopilotGuardianInfo: AutopilotGuardianInfo): AutopilotGuardianStatusInfo? {
return GsonUtil.objectFromJson(
GsonUtil.jsonFromObject(autopilotGuardianInfo),
AutopilotGuardianStatusInfo::class.java
)
}
fun fromAdasAutopilotRoute(carStateInfo: AutopilotRoute): AutopilotRouteInfo? {
return GsonUtil.objectFromJson(
GsonUtil.jsonFromObject(carStateInfo),
AutopilotRouteInfo::class.java
)
}
fun fromAdasCarStateInfoObject(carStateInfo: CarStateInfo): AutopilotCarStateInfo? {
return GsonUtil.objectFromJson(
GsonUtil.jsonFromObject(carStateInfo),
AutopilotCarStateInfo::class.java
)
}
fun fromAdasObject(info: WarnMessageInfo?): AutopilotWarnMessage? {
if (info == null) {
return null
}
val warnMessage = AutopilotWarnMessage()
warnMessage.content = info.content
warnMessage.level = info.level
try {
warnMessage.type = info.type.toInt()
} catch (e: NumberFormatException) {
return null
}
warnMessage.value = info.value
return warnMessage
}
fun regroupTrafficDataData(datums: List<RectInfo.RectBean?>?): ArrayList<TrafficData>? {
if (datums == null || datums.isEmpty()) {
return null
}
val recognizedListResults: ArrayList<TrafficData> = ArrayList()
for (model in datums) {
if (model == null) {
continue
}
val recognizedListResult = fromAdasTrafficDataObject(model)
if (recognizedListResult != null) {
recognizedListResults.add(recognizedListResult)
}
}
return recognizedListResults
}
fun fromAdasTrafficDataObject(model: RectInfo.RectBean?): TrafficData? {
if (model == null) {
return null
}
val result = TrafficData()
result.uuid = model.uuid
result.lat = model.lat
result.lon = model.lon
result.type = TrafficTypeEnum.getType(model.type.toInt())
result.heading = model.heading
result.systemTime = model.systemTime.toLong()
result.satelliteTime = model.satelliteTime.toLong()
result.alt = model.alt
result.speed = model.speed
result.carId = model.carId
result.dataAccuracy = model.dataAccuracy
result.distance = model.distance
result.threatLevel = model.drawlevel
//Log.d(TAG, "TrafficData = $result")
return result
}
}

View File

@@ -70,7 +70,6 @@ dependencies {
api rootProject.ext.dependencies.mogoservice
api rootProject.ext.dependencies.moduleshare
api rootProject.ext.dependencies.moduleextensions
api rootProject.ext.dependencies.moduleADAS
api rootProject.ext.dependencies.callchat
api rootProject.ext.dependencies.callchatprovider
api rootProject.ext.dependencies.mapcustom
@@ -98,7 +97,6 @@ dependencies {
api project(':modules:mogo-module-common')
api project(':modules:mogo-module-service')
api project(':modules:mogo-module-extensions')
api project(':modules:mogo-module-adas')
api project(':modules:mogo-module-carchatting')
api project(':modules:mogo-module-carchattingprovider')
api project(':libraries:map-custom')

View File

@@ -328,8 +328,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_CHECK, "CheckProvider"));
// 推送模块
MogoModulePaths.addModule(new MogoModule(PushUIConstants.PATH, "PUSH_UI"));
// ADAS模块慢慢被 域控制器模块 替换掉)
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_ADAS, "AdasProvider"));
if (!DebugConfig.isLauncher()) {
PersistentManager

View File

@@ -43,75 +43,6 @@ public interface IMoGoV2XMarkerManager extends IProvider {
*/
void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult);
/**
* 绘制V2X 地图点事件
*
* @param markerCardResult 大而全中过滤出来的点事件
*/
void drawableV2XMarker(MarkerCardResult markerCardResult);
/**
* 绘制 在线车辆 POI
*
* @param markerOnlineCars
* @param clickListener
*/
void drawableOnlineCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener);
/**
* 清除 在线车辆 POI
*/
void clearOnlineCarPOI();
/**
* 绘制可以直播的在线车辆
*
* @param markerOnlineCars
* @param clickListener
*/
void drawableLiveCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener);
/**
* 清除 可以直播的在线车辆 POI
*/
void clearLiveCarPOI();
/**
* 绘制 探路
*
* @param exploreWayList
* @param clickListener
*/
void drawableExplorePOI(List<MarkerExploreWay> exploreWayList, IMogoMarkerClickListener clickListener);
/**
* 清除 探路 POI
*/
void clearExplorePOI();
/**
* 绘制 新鲜事儿
*
* @param noveltyInfoList
* @param clickListener
*/
void drawableNoveltyPOI(List<MarkerNoveltyInfo> noveltyInfoList, IMogoMarkerClickListener clickListener);
/**
* 清除 新鲜事儿 POI
*/
void clearNoveltyPOI();
/**
* 绘制Marker上面调用的都是这个方法
*
* @param context
* @param markerShowEntity
* @param clickListener
*/
void drawableMarker(Context context, MarkerShowEntity markerShowEntity, IMogoMarkerClickListener clickListener);
/**
* 展开气泡

View File

@@ -25,58 +25,16 @@ public interface IMoGoV2XStatusManager extends IProvider {
*/
boolean isRoadEventWindowShow();
/**
* 头部 V2X的道路直播 UI 是否在展示
*/
boolean isRoadLiveCarWindowShow();
/**
* 头部 他人车辆故障求助 UI 是否在展示
*/
boolean isOtherSeekHelpWindowShow();
/**
* 地图区域 自身的道路求助按钮 是否在展示
*/
boolean isMeSeekHelpButtonShow();
/**
* 地图区域 他人车辆故障求助POI 是否在展示
*/
boolean isOtherSeekHelpPOIShow();
/**
* 前瞻需求
* 右侧2/3 V2X 场景动画 UI 是否在展示
*/
boolean isV2XAnimationShow();
/**
* 前瞻需求
* 右侧2/3 左下角 模拟直播车机 UI 是否在展示
*/
boolean isLeftLiveVideoShow();
/**
* 推送弹窗的状态
*/
boolean isPushWindowShow();
/**
* 推送的 POI 状态
*/
boolean isPushPOIShow();
/**
* 疲劳驾驶 状态
*/
boolean isFatigueDrivingWindowShow();
/**
* 事件面板状态 状态
*/
boolean isEventPanelWindowShow();
/**
* 设置 V2X道路预警POI 是否在展示
*
@@ -117,22 +75,6 @@ public interface IMoGoV2XStatusManager extends IProvider {
*/
void setOtherSeekHelpWindowShow(String tag, boolean show);
/**
* 地图区域 自身的道路求助按钮 是否在展示
*
* @param tag
* @param show
*/
void setMeSeekHelpButtonShow(String tag, boolean show);
/**
* 地图区域 他人车辆故障求助POI 是否在展示
*
* @param tag
* @param show
*/
void setOtherSeekHelpPOIShow(String tag, boolean show);
/**
* 设置 右侧2/3 全屏 V2X 场景动画 是否在展示
*
@@ -177,30 +119,4 @@ public interface IMoGoV2XStatusManager extends IProvider {
* @param show
*/
void setFatigueDrivingWindowShow(String tag, boolean show);
/**
* 事件面板状态 是否在展示
*
* @param tag
* @param show
*/
void setEventPanelWindowShow(String tag, boolean show);
/**
* 注册监听
*
* @param tag 业务类型
* @param descriptor 监听类型
* @param listener 监听回调
*/
void registerStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener);
/**
* 注销
*
* @param tag 业务类型
* @param descriptor 注销类型
* @param listener 注销回调
*/
void unregisterStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener);
}

View File

@@ -38,11 +38,6 @@ public enum V2XStatusDescriptor {
*/
OtherSeekHelpWindow_UI,
/**
* 头部 自身的道路求助按钮 UI 是否在展示
*/
MeSeekHelpButton_UI,
/**
* 右侧2/3 V2X 场景动画 UI 是否在展示
*/
@@ -71,10 +66,5 @@ public enum V2XStatusDescriptor {
/**
* 疲劳驾驶弹窗
*/
FatigueDrivingWindow_UI,
/**
* 事件面板状态
*/
EventPanelWindow_UI,
FatigueDrivingWindow_UI
}

View File

@@ -12,7 +12,6 @@ import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
import com.mogo.eagle.core.function.v2x.events.listener.V2XMarkerClickListener;
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XStatusManager;
@@ -31,11 +30,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.entity.MarkerCardResult;
import com.mogo.module.common.entity.MarkerExploreWay;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerNoveltyInfo;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.common.enums.EventTypeEnum;
@@ -173,266 +169,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
}
}
@Override
public void drawableV2XMarker(MarkerCardResult markerCardResult) {
boolean isShowEventWindow = false;
boolean isShowEventButton = false;
boolean isOtherSeekHelpWindowShow = false;
IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
if (v2xStatus != null) {
//预警Window状态
isShowEventWindow = v2xStatus.isRoadEventWindowShow();
//预警按钮状态
isShowEventButton = v2xStatus.isRoadEventButtonShow();
//道路求助的window
isOtherSeekHelpWindowShow = v2xStatus.isOtherSeekHelpWindowShow();
}
try {
//当没有预警提示的时候重新绘制地图POI点
if (!isShowEventWindow && !isShowEventButton && !isOtherSeekHelpWindowShow) {
// 清除上次的道路事件TODO 这里注意,道路事件的触发和这里是异步操作会触发异常
//mV2XRoadEventEntityArrayList.clear();
// 清除原来的大而全的新鲜事儿
try {
clearALLPOI();
} catch (Exception e) {
e.printStackTrace();
}
// 清除连接线
IMoGoV2XPolylineManager polylineManager = BridgeApi.INSTANCE.v2xPolyline();
if (polylineManager != null) {
polylineManager.clearLine();
}
if (markerCardResult != null) {
// 绘制新的地图气泡
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
drawableOnlineCarPOI(onlineCarList, V2XMarkerClickListener.getInstance());
drawableExplorePOI(exploreWayList, V2XMarkerClickListener.getInstance());
drawableNoveltyPOI(noveltyInfoList, V2XMarkerClickListener.getInstance());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void drawableOnlineCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener) {
try {
if (markerOnlineCars != null) {
for (MarkerOnlineCar markerOnlineCar : markerOnlineCars) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerOnlineCar);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(markerOnlineCar.getType());
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getSafeLabel());
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
drawableMarker(BridgeApi.INSTANCE.context(), markerShowEntity, clickListener);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearOnlineCarPOI() {
IMogoMarkerManager marker = BridgeApi.INSTANCE.marker();
if (marker != null) {
marker.removeMarkers(V2XConst.V2X_CARD_TYPE_USER_DATA);
}
}
@Override
public void drawableLiveCarPOI(List<MarkerOnlineCar> markerOnlineCars, IMogoMarkerClickListener clickListener) {
try {
Logger.w(MODULE_NAME, "V2X===事件周边的直播车机:" + markerOnlineCars);
if (markerOnlineCars != null) {
for (MarkerOnlineCar markerOnlineCar : markerOnlineCars) {
// 设置车类型
markerOnlineCar.getUserInfo().setSafeLabelType(4);
markerOnlineCar.getCarInfo().setVehicleType(0);
MarkerLocation markerLocation = markerOnlineCar.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerOnlineCar);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(V2XConst.V2X_MARKER_LIVE_CAR);
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getSafeLabel());
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
drawableMarker(
BridgeApi.INSTANCE.context(),
markerShowEntity,
clickListener);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearLiveCarPOI() {
IMogoMarkerManager marker = BridgeApi.INSTANCE.marker();
if (marker != null) {
marker.removeMarkers(V2XConst.V2X_MARKER_LIVE_CAR);
}
}
@Override
public void drawableExplorePOI(List<MarkerExploreWay> exploreWayList, IMogoMarkerClickListener clickListener) {
try {
if (exploreWayList != null) {
for (MarkerExploreWay markerExploreWay : exploreWayList) {
// 因为目前探路卡片不支持直播,所以这里做了过滤 @李小鹏
if (!markerExploreWay.getCanLive()) {
MarkerLocation markerLocation = markerExploreWay.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(markerExploreWay);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(markerExploreWay.getType());
markerShowEntity.setTextContent(markerExploreWay.getAddr());
drawableMarker(
BridgeApi.INSTANCE.context(),
markerShowEntity,
clickListener);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearExplorePOI() {
IMogoMarkerManager marker = BridgeApi.INSTANCE.marker();
if (marker != null) {
marker.removeMarkers(V2XConst.V2X_CARD_TYPE_ROAD_CONDITION);
}
}
@Override
public void drawableNoveltyPOI(List<MarkerNoveltyInfo> noveltyInfoList, IMogoMarkerClickListener clickListener) {
try {
if (noveltyInfoList != null) {
for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
MarkerLocation markerLocation = noveltyInfo.getLocation();
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setBindObj(noveltyInfo);
markerShowEntity.setMarkerLocation(markerLocation);
markerShowEntity.setMarkerType(noveltyInfo.getType());
markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
// 这里只绘制道路事件相关
if (EventTypeEnum.TRAFFIC_CHECK.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.ROAD_CLOSED.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ROAD_WORK.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_BLOCK_UP.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_PONDING.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_PARKING.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ICE.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_FOG.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT_01.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT_02.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT_03.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT_04.getPoiType().equals(noveltyInfo.getPoiType())
|| EventTypeEnum.FOURS_ACCIDENT_05.getPoiType().equals(noveltyInfo.getPoiType())) {
drawableMarker(BridgeApi.INSTANCE.context(), markerShowEntity, clickListener);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void clearNoveltyPOI() {
IMogoMarkerManager marker = BridgeApi.INSTANCE.marker();
if (marker != null) {
marker.removeMarkers(V2XConst.V2X_CARD_TYPE_NOVELTY);
}
}
@Override
public void drawableMarker(Context context, MarkerShowEntity markerShowEntity, IMogoMarkerClickListener clickListener) {
// Logger.i(MODULE_NAME, "绘制Marker====drawMapMarker" + markerShowEntity);
try {
if (markerShowEntity.getMarkerLocation() != null) {
MogoMarkerOptions options = new MogoMarkerOptions()
.data(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
// 这里对Marker做下持有者转换与大而全的区分开由于绘制的时候用到了低层能力所以不去修改markerShowEntity中的type
switch (markerShowEntity.getMarkerType()) {
case ServiceConst.CARD_TYPE_USER_DATA:
options.owner(V2XConst.V2X_CARD_TYPE_USER_DATA);
break;
case ServiceConst.CARD_TYPE_NOVELTY:
options.owner(V2XConst.V2X_CARD_TYPE_NOVELTY);
break;
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
options.owner(V2XConst.V2X_CARD_TYPE_ROAD_CONDITION);
break;
case V2XConst.V2X_MARKER_SPECIAL_CAR:
options.owner(V2XConst.V2X_MARKER_SPECIAL_CAR);
break;
case V2XConst.V2X_MARKER_LIVE_CAR:
options.owner(V2XConst.V2X_MARKER_LIVE_CAR);
break;
default:
options.owner(markerShowEntity.getMarkerType());
break;
}
IMogoMarker marker = null;
Bitmap bitmap;
if (markerShowEntity.getMarkerType().equals(ServiceConst.CARD_TYPE_USER_DATA)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_SPECIAL_CAR)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_LIVE_CAR)
|| markerShowEntity.getMarkerType().equals(V2XConst.V2X_MARKER_EXPRESS)
) {
bitmap = V2XMarkerAdapter.getV2XCarMarkerView(context, markerShowEntity);
options.icon(bitmap);
IMogoMarkerManager markerManager = BridgeApi.INSTANCE.marker();
if (markerManager != null) {
marker = markerManager.addMarker(markerShowEntity.getMarkerType(), options);
}
} else {
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(context, markerShowEntity, options);
bitmap = ViewUtils.fromView(iMarkerView.getView());
options.icon(bitmap);
IMogoMarkerManager markerManager = BridgeApi.INSTANCE.marker();
if (markerManager != null) {
marker = markerManager.addMarker(markerShowEntity.getMarkerType(), options);
}
iMarkerView.setMarker(marker);
}
//marker.setOnMarkerClickListener(clickListener);
} else {
Logger.e(MODULE_NAME, "Location 必须进行初始化!!!!!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public IMogoMarker openMarker(Context context, IMogoMarker currentMarker) {

View File

@@ -63,56 +63,16 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
return get_bool_val(V2XStatusDescriptor.RoadEventWindow_UI);
}
@Override
public boolean isRoadLiveCarWindowShow() {
return get_bool_val(V2XStatusDescriptor.RoadLiveCarWindow_UI);
}
@Override
public boolean isOtherSeekHelpWindowShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public boolean isMeSeekHelpButtonShow() {
return get_bool_val(V2XStatusDescriptor.MeSeekHelpButton_UI);
}
@Override
public boolean isOtherSeekHelpPOIShow() {
return get_bool_val(V2XStatusDescriptor.OtherSeekHelpPOI_UI);
}
@Override
public boolean isV2XAnimationShow() {
return get_bool_val(V2XStatusDescriptor.V2XAnimationWindow_UI);
}
@Override
public boolean isLeftLiveVideoShow() {
return get_bool_val(V2XStatusDescriptor.LiveCarWindow_UI);
}
@Override
public boolean isPushWindowShow() {
return get_bool_val(V2XStatusDescriptor.PushWindow_UI);
}
@Override
public boolean isPushPOIShow() {
return get_bool_val(V2XStatusDescriptor.PushWindowPOI_UI);
}
@Override
public boolean isFatigueDrivingWindowShow() {
return get_bool_val(V2XStatusDescriptor.FatigueDrivingWindow_UI);
}
@Override
public boolean isEventPanelWindowShow() {
return get_bool_val(V2XStatusDescriptor.EventPanelWindow_UI);
}
@Override
public void setRoadEventPOIShow(String tag, boolean show) {
IMogoStatusManager statusManager = BridgeApi.INSTANCE.statusManager();
@@ -152,24 +112,6 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
recordStatusModifier(tag, V2XStatusDescriptor.OtherSeekHelpWindow_UI);
}
@Override
public void setMeSeekHelpButtonShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.MeSeekHelpButton_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.MeSeekHelpButton_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.MeSeekHelpButton_UI);
}
@Override
public void setOtherSeekHelpPOIShow(String tag, boolean show) {
IMogoStatusManager statusManager = BridgeApi.INSTANCE.statusManager();
if (statusManager != null) {
statusManager.setV2XUIShow(V2XConst.MODULE_NAME, show);
}
mStatus.put(V2XStatusDescriptor.OtherSeekHelpPOI_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.OtherSeekHelpPOI_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.OtherSeekHelpPOI_UI);
}
@Override
public void setV2XAnimationWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.V2XAnimationWindow_UI, show);
@@ -213,40 +155,7 @@ public class MoGoV2XStatusManager implements IMoGoV2XStatusManager {
recordStatusModifier(tag, V2XStatusDescriptor.FatigueDrivingWindow_UI);
}
@Override
public void setEventPanelWindowShow(String tag, boolean show) {
mStatus.put(V2XStatusDescriptor.EventPanelWindow_UI, show);
invokeStatusChangedListener(V2XStatusDescriptor.EventPanelWindow_UI, show);
recordStatusModifier(tag, V2XStatusDescriptor.EventPanelWindow_UI);
}
@Override
public void registerStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener) {
if (listener == null || descriptor == null) {
return;
}
if (!mListeners.containsKey(descriptor)) {
mListeners.put(descriptor, new ArrayList<>());
}
if (mListeners.get(descriptor) == null) {
mListeners.put(descriptor, new ArrayList<>());
}
List<IMoGoV2XStatusChangedListener> listeners = mListeners.get(descriptor);
if (listeners != null) {
listeners.add(listener);
}
}
@Override
public void unregisterStatusChangedListener(String tag, V2XStatusDescriptor descriptor, IMoGoV2XStatusChangedListener listener) {
List<IMoGoV2XStatusChangedListener> listeners = mListeners.get(descriptor);
if (listeners != null) {
listeners.remove(listener);
}
}
/**
/**
* 调用所有存储的监听
*
* @param descriptor