diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/IdentifyDataDrawer.java similarity index 99% rename from modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java rename to core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/IdentifyDataDrawer.java index 60e29e4d97..8c989e773c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/IdentifyDataDrawer.java @@ -1,4 +1,4 @@ -package com.mogo.module.common.drawer; +package com.mogo.eagle.core.function.map; import android.content.Context; diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapIdentifySubscriber.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapIdentifySubscriber.kt index 1c280489aa..5eb0df67c8 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapIdentifySubscriber.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapIdentifySubscriber.kt @@ -5,7 +5,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.base.IMoGoSubscriber 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 mogo.telematics.pad.MessagePad import mogo.telematics.pad.MessagePad.TrackedObject diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java index eb90dc70dc..dd8d8c62d5 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java @@ -25,14 +25,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public /** * @author congtaowang * @since 2020/10/28 *

* 描述 */ -class MarkerDrawer { +public class MarkerDrawer { public static final int MARKER_Z_INDEX_HIGH = 100; public static final int MARKER_Z_INDEX_LOW = 2; diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java deleted file mode 100644 index 2f3e6a9c13..0000000000 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java +++ /dev/null @@ -1,515 +0,0 @@ -package com.mogo.module.common.drawer; - -import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_DATA; - -import android.os.Build; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageView; - -import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.cloud.socket.entity.SocketDownData; -import com.mogo.cloud.socket.entity.SocketDownDataHelper; -import com.mogo.commons.AbsMogoApplication; -import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.util.ViewUtils; -import com.mogo.map.MogoMarkerManager; -import com.mogo.map.marker.IMogoMarker; -import com.mogo.map.marker.IMogoMarkerClickListener; -import com.mogo.map.marker.MogoMarkerOptions; -import com.mogo.module.common.MogoApisHandler; -import com.mogo.module.common.R; -import com.mogo.module.common.constants.DataTypes; -import com.mogo.module.common.utils.Trigonometric; -import com.mogo.service.statusmanager.IMogoStatusChangedListener; -import com.mogo.service.statusmanager.StatusDescriptor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -/** - * @author congtaowang - * @since 2020/10/28 - *

- * 云端数据绘制 - */ -public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListener, IMogoStatusChangedListener { - - private static final String TAG = "SnapshotSetDataDrawer"; - - private static volatile SnapshotSetDataDrawer sInstance; - - private boolean mChangeCarModeStatus; - - private SnapshotSetDataDrawer() { - super(); - MogoApisHandler.getInstance().getApis() - .getStatusManagerApi() - .registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this); - } - - public static SnapshotSetDataDrawer getInstance() { - if (sInstance == null) { - synchronized (SnapshotSetDataDrawer.class) { - if (sInstance == null) { - sInstance = new SnapshotSetDataDrawer(); - } - } - } - return sInstance; - } - - public synchronized void release() { - sInstance = null; - } - - /** - * 上一帧数据的缓存 - */ - private static final Map mMarkersCaches = new ConcurrentHashMap<>(); - - private final Map mLastPositions = new ConcurrentHashMap<>(); - - /** - * 注册StatusDescriptor.VR_MODE类型,VR_MODE状态改变回调 - * - * @param descriptor 状态类型 - * @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show - */ - @Override - public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) { - mChangeCarModeStatus = true; - sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches); - removeUselessMarker(mMarkersCaches); - mLastPositions.clear(); - } - - public boolean isChangeCarModeStatus() { - return mChangeCarModeStatus; - } - - public void setChangeCarModeStatus(boolean mChangeCarModeStatus) { - this.mChangeCarModeStatus = mChangeCarModeStatus; - } - - /** - * 清除旧数据操作 - * - * @param data 自车周边数据 - * @return 清除结果 - */ - private boolean clear(SocketDownData.LauncherSnapshotProto data) { - if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched()) { - if (mMarkersCaches == null) { - return false; - } - mMarkersCaches.clear(); - mLastPositions.clear(); - sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA); - return true; - } - if (data == null || ( - (data.getAllListList() == null || data.getAllListList().isEmpty()) && - (data.getNearListList() == null || data.getNearListList().isEmpty()))) { - if (mMarkersCaches != null) { - mMarkersCaches.clear(); - } - mLastPositions.clear(); - sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA); - return true; - } - return false; - } - - /** - * 绘制来自云端的 mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆 - * - * @param data 自车周边数据 - */ -// @ChainLog(linkCode = CHAIN_LINK_CLOUD_SHOW, -// endpoint = TracingConstants.Endpoint.PAD, -// nodeAliasCode = "PAD_YINGYAN_SHOW", -// paramIndexes = {0}, -// clientPkFileName = "sn") - public void renderSnapshotData(SocketDownData.LauncherSnapshotProto data) { - final long start = System.nanoTime(); - if (clear(data)) { - return; - } - if (!MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - return; - } - - List allDatumsList = new ArrayList<>(); - prepareData(data.getAllListList(), allDatumsList); - - Map newMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size()); - List newDiffSet = new ArrayList<>(); - for (SocketDownData.CloudRoadDataProto cloudRoadData : allDatumsList) { - - if (isUselessValue(cloudRoadData)) { - continue; - } - String uniqueKey = cloudRoadData.getUuid(); - IMogoMarker marker = mMarkersCaches.remove(uniqueKey); - if (marker != null && !marker.isDestroyed()) { - updateCacheMarkerRes(marker, cloudRoadData); - renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches); - } else { - newDiffSet.add(cloudRoadData); - } - } - // 需要新增的 marker 数量 - int newDiffSetSize = newDiffSet.size(); - // 复用过期 marker - if (newDiffSetSize > 0) { - // 复用过后还需新增的 marker - for (int i = 0; i < newDiffSetSize; i++) { - SocketDownData.CloudRoadDataProto cloudRoadData = newDiffSet.get(i); - String uniqueKey = cloudRoadData.getUuid(); - IMogoMarker marker = drawSnapshotDataMarker(cloudRoadData); - if (marker == null) { - continue; - } - renderSnapshotOneFrame(marker, uniqueKey, cloudRoadData, newMarkersCaches); - } - } - mMarkersCaches.putAll(newMarkersCaches); - // 移除超时 marker - delayRemoveUselessMarker(); - removeUselessLastRecord(); - CallerLogger.INSTANCE.d("云端数据延时绘制", "render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms"); - } - - /** - * todo 后面涉及到此类变化的数据均改动 - * - * @param marker {@link IMogoMarker} - * @param cloudRoadDataProto {@link SocketDownData.CloudRoadDataProto} - */ - private void updateCacheMarkerRes(IMogoMarker marker, SocketDownData.CloudRoadDataProto cloudRoadDataProto) { - String resIdVal; - int resId = getModelRes(cloudRoadDataProto.getType()); - resIdVal = resId + ""; - String resName = mMarkerCachesResMd5Values.get(resIdVal); - if (!TextUtils.isEmpty(resName)) { - if (!TextUtils.equals(resName, marker.getMarkerResName())) { - marker.use3DResource(resName); - } - } else { - resName = marker.use3DResource(resId); - mMarkerCachesResMd5Values.put(resIdVal, resName); - } - } - - private void delayRemoveUselessMarker() { - if (mMarkersCaches.isEmpty()) { - return; - } - Iterator iterator = mMarkersCaches.values().iterator(); - while (iterator.hasNext()) { - IMogoMarker result = iterator.next(); - SocketDownData.CloudRoadDataProto proto = ((SocketDownData.CloudRoadDataProto) result.getObject()); - if (proto == null) { // 后续有业务数据在操作,更新数据,不做处理 - continue; - } - long internal = getCurSatelliteTime() - proto.getSatelliteTime(); - CallerLogger.INSTANCE.d("MogoArrow", "delayRemoveUselessMarker uuid : " + proto.getUuid() - + " localTime : " + getCurSatelliteTime() - + " originTime : " + proto.getSatelliteTime() - + " internal : " + internal); - if (internal > 5000) { - iterator.remove(); - result.destroy(); - } - } - } - - private void removeUselessLastRecord() { // todo 最好重新设计一个数据结构,用于多线程数据过期失效的场景,参见redis数据过期 - if (mLastPositions.isEmpty()) { - return; - } - Iterator iterator = mLastPositions.values().iterator(); - while (iterator.hasNext()) { - SocketDownData.CloudRoadDataProto result = iterator.next(); - long internal = getCurSatelliteTime() - result.getSatelliteTime(); - if (internal > 3000) { - iterator.remove(); - } - } - } - - /** - * 判断类型、uuid 等 - * - * @param cloudRoadData {@link SocketDownData.CloudRoadDataProto} - * @return isUselessValue - */ - private boolean isUselessValue(SocketDownData.CloudRoadDataProto cloudRoadData) { - if (cloudRoadData == null) { - return true; - } - if (nonRenderType(cloudRoadData.getType())) { - return true; - } - - String uniqueKey = cloudRoadData.getUuid(); - return TextUtils.isEmpty(uniqueKey); - } - - /** - * 绘制某个物体的一个数据 - * - * @param cloudRoadData {@link SocketDownData.CloudRoadDataProto} - * @param newSnapshotCaches 缓存数据 - */ - private void renderSnapshotOneFrame(IMogoMarker marker, String uniqueKey, SocketDownData.CloudRoadDataProto cloudRoadData, Map newSnapshotCaches) { - final long start = System.nanoTime(); - SocketDownData.CloudRoadDataProto lastPosition = mLastPositions.remove(uniqueKey); - // 道路吸附 -// double lastLon = -1; -// double lastLat = -1; -// if (lastPosition != null) { -// lastLon = lastPosition.getWgslon(); -// lastLat = lastPosition.getWgslat(); -// } -// double[] matchLonLat = getMatchLonLat(cloudRoadData.getUuid(), cloudRoadData.getWgslon(), cloudRoadData.getWgslat(), cloudRoadData.getHeading(), lastLon, lastLat); -// SocketDownData.CloudRoadDataProto.Builder builder = cloudRoadData.toBuilder(); -// builder.setWgslon(matchLonLat[0]); -// builder.setWgslat(matchLonLat[1]); -// cloudRoadData = builder.build(); - - mLastPositions.put(uniqueKey, cloudRoadData); - long interval = 45; - if (lastPosition != null) { - interval = computeAnimDuration(lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime()); - } - final MogoLatLng point = new MogoLatLng(cloudRoadData.getWgslat(), cloudRoadData.getWgslon()); - long cost = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start); - final long intervalRef = interval - cost; - marker.addDynamicAnchorPosition(point, (float) cloudRoadData.getHeading(), intervalRef); - marker.setAnchorColor(getModelRenderColor(cloudRoadData.getType(), cloudRoadData.getFromType(), 1)); - newSnapshotCaches.put(uniqueKey, marker); -// if (shouldShowSpeed(cloudRoadData.getType())) { -// Message msg = mRenderThreadHandler.obtainMessage(); -// msg.obj = new SpeedData(marker -// , cloudRoadData.getSpeed() -// , cloudRoadData.getUuid() -// , cloudRoadData.getType() -// , cloudRoadData.getHeading() -// , MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()); -// msg.what = MSG_DISPLAY_SPEED; -// msg.sendToTarget(); -// } - CallerLogger.INSTANCE.d("云端数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start))); - } - - /** - * 过滤数据,对数据补点 - * - * @param in 输入集合 - * @param out 输出集合 - */ - private void prepareData(List in, List out) { -// foreCastPoint(in, out); - out.addAll(in); - } - - private final static String FORECAST = "snapshotForecast"; - - /** - * 基于云平台下发的数据点速度预测当前位置和距离自车距离 - * - * @param in 数据源 - */ - private void foreCastPoint(List in, List out) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - for (SocketDownData.CloudRoadDataProto proto : in) { - SocketDownData.CloudRoadDataProto.Builder builder = proto.toBuilder(); - CallerLogger.INSTANCE.d(FORECAST, "ready to foreCast current uuid : " + proto.getUuid()); - long internal = getCurSatelliteTime() - builder.getSatelliteTime(); - if (internal <= 0) { - CallerLogger.INSTANCE.d(FORECAST, "time internal less than 0 , uuid : " + proto.getUuid()); - out.add(proto); - continue; - } - long startTime = System.currentTimeMillis(); - // 预测点 - CallerLogger.INSTANCE.d(FORECAST, "time internal : " + internal + " speed : " + proto.getSpeed()); - double foreCastDistance = proto.getSpeed() * internal / 1000; - CallerLogger.INSTANCE.d(FORECAST, "foreCastDistance : " + foreCastDistance); - MogoLatLng mogoLatLng = new MogoLatLng(proto.getWgslat(), proto.getWgslon()); - MogoLatLng foreCastMogoLatLon = Trigonometric.getNewLocation(mogoLatLng, foreCastDistance, proto.getHeading()); - - // 计算与自车距离 - float distanceFromSelf = CoordinateUtils.calculateLineDistance(getCurCoordinates()[0], getCurCoordinates()[1] - , foreCastMogoLatLon.getLon(), foreCastMogoLatLon.getLat()); - - long foreCastInternal = System.currentTimeMillis() - startTime; - CallerLogger.INSTANCE.d(FORECAST, "foreCastInternal :" + foreCastInternal); //todo 耗时1~2毫秒 需要测试是否由于补点算法造成 - - builder.setWgslat(foreCastMogoLatLon.getLat()); - builder.setWgslon(foreCastMogoLatLon.getLon()); - builder.setSatelliteTime(getCurSatelliteTime() - foreCastInternal); - builder.setDistance(distanceFromSelf); - proto = builder.build(); - out.add(proto); - } - } - } - - /** - * 绑定点击事件 - */ - public void bindClickListener(IMogoMarker marker) { - if (marker == null || marker.isDestroyed()) { - return; - } - marker.setOnMarkerClickListener(this); - } - - /** - * 绘制 marker - * - * @param data 道路数据 - * @return {@link IMogoMarker} - */ - public IMogoMarker drawSnapshotDataMarker(SocketDownData.CloudRoadDataProto data) { - long start = System.nanoTime(); - if (data == null) { - return null; - } - - MogoMarkerOptions options = new MogoMarkerOptions() - .owner(TYPE_MARKER_CLOUD_DATA) - .anchor(0.5f, 0.5f) - .rotate((float) data.getHeading()) - .data(data) - .gps(true) - .controlAngle(true) - .position(new MogoLatLng(data.getWgslat(), data.getWgslon())); - String resIdVal; - if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - options.set3DMode(true); - options.anchorColor(getModelRenderColor(data.getType(), data.getFromType(), 1)); - int resId = getModelRes(data.getType()); - resIdVal = resId + ""; - options.resName(mMarkerCachesResMd5Values.get(resIdVal)); - options.icon3DRes(resId); - } else { - options.set3DMode(false); - View view = inflateView(data); - options.icon(view); - resIdVal = view.getId() + ""; - } - IMogoMarker marker = MogoMarkerManager.getInstance(mContext).addMarker(TYPE_MARKER_CLOUD_DATA, options); - cacheMarkerIconResMd5Val(resIdVal, marker); - - if (!TextUtils.isEmpty(data.getSn())) { - bindClickListener(marker); - } - CallerLogger.INSTANCE.d("云端数据延时", "创建一个新 marker cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start))); - return marker; - } - - public String get3DCacheId(String resIdVal) { - return mMarkerCachesResMd5Values.get(resIdVal); - } - - /** - * 生成 2d marker 资源 - * - * @param data 道路数据 - * @return marker - */ - public View inflateView(SocketDownData.CloudRoadDataProto data) { - View rootView = LayoutInflater.from(AbsMogoApplication.getApp()).inflate(R.layout.module_commons_layout_car, null); - ImageView iv = rootView.findViewById(R.id.module_commons_marker_car_model); - int viewIdLike = get2DModel(data); - iv.setImageResource(viewIdLike); - rootView.setId(viewIdLike); - return rootView; - } - - /** - * 获取车辆2d贴图 - * - * @param data 道路数据 - * @return 2D贴图id - */ - private int get2DModel(SocketDownData.CloudRoadDataProto data) { - switch (data.getFromType()) { - case SocketDownDataHelper.FROM_ADAS: - case SocketDownDataHelper.FROM_ROAD_UNIT: - case SocketDownDataHelper.FROM_MY_LOCATION: - default: - return R.drawable.icon_map_marker_car_gray; - } - } - - @Override - public boolean onMarkerClicked(IMogoMarker marker) { - if (marker != null && !marker.isDestroyed()) { - if (marker.getObject() instanceof SocketDownData.CloudRoadDataProto) { - showCarCallPanel(((SocketDownData.CloudRoadDataProto) marker.getObject())); - } - } - return true; - } - - /** - * 展示用户信息面版 - * - * @param data 道路数据 - */ - private void showCarCallPanel(SocketDownData.CloudRoadDataProto data) { - - /* MogoDriverInfo driverInfo = new MogoDriverInfo(); - driverInfo.setLat(data.getLat()); - driverInfo.setLon(data.getLon()); - driverInfo.setSn(data.getSn()); - ICarsChattingProvider carChatting = CallChatApi.getInstance().getApiProvider(); - - if (carChatting != null) { - try { - carChatting.showUserWindow(TAG, driverInfo, mContext); - } catch (Exception e) { - CallerLogger.INSTANCE.e(TAG, e, "showCarCallPanel"); - } - }*/ - } - - public void changeIconResourceIfNecessary(SocketDownData.CloudRoadDataProto cloudRoadData, IMogoMarker marker) { - if (isChangeCarModeStatus()) { - setChangeCarModeStatus(false); - if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - marker.getMogoMarkerOptions().set3DMode(true); - int resId = getModelRes(cloudRoadData.getType()); - String resName = get3DCacheId(resId + ""); - if (TextUtils.isEmpty(resName)) { - marker.use3DResource(resId); - cacheMarkerIconResMd5Val(resId + "", marker); - } else { - marker.use3DResource(resName); - } - } else { - marker.getMogoMarkerOptions().set3DMode(false); - View view = inflateView(cloudRoadData); - int resId = view.getId(); - String resName = get3DCacheId(resId + ""); - if (TextUtils.isEmpty(resName)) { - marker.setIcon(ViewUtils.fromView(view)); - cacheMarkerIconResMd5Val(resId + "", marker); - } else { - marker.use2DResource(resName); - } - } - } - } -} diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java index 53d0def666..80fcc60ed8 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java @@ -9,16 +9,12 @@ import android.os.Message; import android.text.TextUtils; import com.mogo.cloud.commons.utils.CoordinateUtils; -import com.mogo.cloud.socket.entity.SocketDownData; -import com.mogo.cloud.socket.entity.SocketDownDataHelper; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.voice.AIAssist; import com.mogo.eagle.core.data.autopilot.AutopilotCarStateInfo; -import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.data.traffic.TrafficData; import com.mogo.eagle.core.function.api.map.IMogoMapFrameController; import com.mogo.eagle.core.function.call.base.CallerBase; import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; @@ -38,8 +34,6 @@ import com.mogo.map.search.geo.MogoRegeocodeResult; import com.mogo.map.search.geo.query.MogoRegeocodeQuery; import com.mogo.module.common.constants.DataTypes; import com.mogo.module.common.dialog.WMDialog; -import com.mogo.module.common.drawer.IdentifyDataDrawer; -import com.mogo.module.common.drawer.SnapshotSetDataDrawer; import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.R; @@ -483,30 +477,6 @@ public class MockIntentHandler implements IntentHandler { mLocationMockHandler.sendEmptyMessageDelayed(100, 50L); } - /** - * 处理路侧模拟数据意图 - */ - private void handleRoadSideMockDataIntent() throws Exception { - if (roadSizeBr == null) { - roadSizeBr = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("roadSide.txt"))); //todo 需要重新模拟一个test数据 - } - String carsLine = roadSizeBr.readLine(); - SocketDownData.LauncherSnapshotProto.Builder data = SocketDownData.LauncherSnapshotProto.newBuilder(); - List allList = GsonUtil.arrayFromJson(carsLine, SocketDownData.CloudRoadDataProto.class); - if (allList == null || allList.size() == 0) { - return; - } - for (SocketDownData.CloudRoadDataProto cloudRoadData : allList) { - cloudRoadData.toBuilder() - .setWgslat(cloudRoadData.getLon()) - .setWgslon(cloudRoadData.getLon()) - .setFromType(SocketDownDataHelper.FROM_ROAD_UNIT); - } - data.addAllAllList(allList); - SnapshotSetDataDrawer.getInstance().renderSnapshotData(data.build()); - mLocationMockHandler.sendEmptyMessageDelayed(101, 100L); - } - public void onAdasCarDataCallback(AutopilotCarStateInfo stateInfo) { if (stateInfo != null && stateInfo.getValues() != null) { @@ -549,23 +519,6 @@ public class MockIntentHandler implements IntentHandler { br = null; } } - // 模拟ADAS数据 - else if (msg.what == 3) { - try { - handleMockAdasIntent(); - } catch (Exception e) { - try { - if (readers != null) { - for (BufferedReader reader : readers) { - if (reader != null) reader.close(); - } - } - } catch (IOException ex) { - ex.printStackTrace(); - } - readers = null; - } - } // 模拟单个车数据 else if (msg.what == 100) { try { @@ -574,38 +527,6 @@ public class MockIntentHandler implements IntentHandler { e.printStackTrace(); } } - // 处理路侧模拟数据意图 - else if (msg.what == 101) { - try { - handleRoadSideMockDataIntent(); - } catch (Exception e) { - try { - roadSizeBr.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - roadSizeBr = null; - } - } - // 处理模拟Adas汽车意图 - else if (msg.what == 8) { - try { - handleMockAdasCarIntent(); - } catch (Exception e) { - try { - if (readers2 != null) { - for (BufferedReader reader : readers2) { - if (reader != null) { - reader.close(); - } - } - } - } catch (IOException ex) { - ex.printStackTrace(); - } - readers2 = null; - } - } } }; @@ -685,76 +606,4 @@ public class MockIntentHandler implements IntentHandler { private BufferedReader[] readers = null; private BufferedReader[] readers2 = null; - /** - * 处理模拟ADAS数据意图 - */ - private boolean handleMockAdasIntent() throws Exception { - final long start = System.currentTimeMillis(); - - if (readers == null) { - readers = new BufferedReader[10]; - for (int i = 0; i < 10; i++) { - readers[i] = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("adas" + i + ".txt"))); - } - } - - ArrayList trafficData = new ArrayList<>(); - for (BufferedReader reader : readers) { - String line = reader.readLine(); - TrafficData adasRecognizedResult = GsonUtil.objectFromJson(line, TrafficData.class); - if (adasRecognizedResult != null) { - trafficData.add(adasRecognizedResult); - } - } - - try { - if (FunctionBuildConfig.isDrawIdentifyData) { -// ThreadUtils.getSinglePool().execute(() -> -// IdentifyDataDrawer.getInstance().renderAdasRecognizedResult(trafficData) -// ); - } else { - IdentifyDataDrawer.getInstance().clearOldMarker(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return true; - } - - /** - * 处理模拟Adas汽车意图 - */ - private boolean handleMockAdasCarIntent() throws Exception { - final long start = System.currentTimeMillis(); - - if (readers2 == null) { - readers2 = new BufferedReader[3]; - for (int i = 0; i < 3; i++) { - readers2[i] = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("adascar" + i + ".txt"))); - } - } - - ArrayList trafficData = new ArrayList<>(); - for (BufferedReader reader : readers2) { - String line = reader.readLine(); - TrafficData adasRecognizedResult = GsonUtil.objectFromJson(line, TrafficData.class); - if (adasRecognizedResult != null) { - trafficData.add(adasRecognizedResult); - } - } - - try { - if (FunctionBuildConfig.isDrawIdentifyData) { -// ThreadUtils.getSinglePool().execute(() -> -// IdentifyDataDrawer.getInstance().renderAdasRecognizedResult(trafficData) -// ); - } else { - IdentifyDataDrawer.getInstance().clearOldMarker(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return true; - } - }