This commit is contained in:
wangcongtao
2021-03-01 20:44:27 +08:00
parent cc5313d64d
commit 4db21e57da
6 changed files with 124 additions and 26 deletions

View File

@@ -76,12 +76,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
boolean machineVision,
double curSpeed ) {
if ( resultList == null || resultList.isEmpty() ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi()
.getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_ADAS );
mAdasRecognizedMarkersCaches.clear();
mLastPositions.clear();
clearOldMarker();
return;
}
@@ -166,9 +161,17 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
}
public void notifyVrModeChanged() {
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mAdasRecognizedMarkersCaches );
mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
mLastPositions.clear();
clearOldMarker();
}
private void clearOldMarker() {
if ( mAdasRecognizedMarkersCaches != null ) {
mAdasRecognizedMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS );
}
}

View File

@@ -8,11 +8,13 @@ import android.os.Message;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.CoordinatesTransformer;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.AdasRecognizedType;
import com.mogo.module.common.constants.CarModelType;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.constants.SafeType;
import com.mogo.utils.WorkThreadHandler;
@@ -39,7 +41,6 @@ class BaseDrawer {
// 移除过期的 marker
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
public static final int MSG_REMOVE_SNAPSHOT_MARKERS = 9991;
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
public BaseDrawer() {
@@ -64,6 +65,11 @@ class BaseDrawer {
if ( msg.what == MSG_REMOVE_DIRTY_MARKERS ) {
if ( msg.obj instanceof Map ) {
removeDirtyMarkers( ( ( Map ) msg.obj ) );
} else if ( msg.obj instanceof String ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi()
.getMarkerManager( AbsMogoApplication.getApp() )
.removeMarkers( ( ( String ) msg.obj ) );
}
}
}

View File

@@ -2,6 +2,7 @@ package com.mogo.module.common.drawer;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -103,23 +104,27 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
private boolean clear( MogoSnapshotSetData data ) {
if ( !MogoApisHandler.getInstance().getApis().getStatusManagerApi().isMainPageLaunched() ) {
if ( mCloudSnapshotMarkersCaches == null ) {
return true;
return false;
}
MogoApisHandler.getInstance().getApis()
.getMapServiceApi().getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
mCloudSnapshotMarkersCaches.clear();
mLastPositions.clear();
if ( mCloudSnapshotMarkersCaches != null ) {
mCloudSnapshotMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
return true;
}
if ( data == null || (
( data.getAllList() == null || data.getAllList().isEmpty() ) &&
( data.getNearList() == null || data.getNearList().isEmpty() ) ) ) {
MogoApisHandler.getInstance().getApis()
.getMapServiceApi().getMarkerManager( mContext )
.removeMarkers( DataTypes.TYPE_MARKER_CLOUD_DATA );
mCloudSnapshotMarkersCaches.clear();
mLastPositions.clear();
if ( mCloudSnapshotMarkersCaches != null ) {
mCloudSnapshotMarkersCaches.clear();
}
if ( mLastPositions != null ) {
mLastPositions.clear();
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_CLOUD_DATA );
return true;
}
return false;
@@ -159,6 +164,7 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
continue;
}
long start = System.currentTimeMillis();
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
if ( marker == null || marker.isDestroyed() ) {
@@ -170,12 +176,14 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
bindClickListener( marker );
}
}
Log.i( "mock-snapshot-timer2", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
start = System.currentTimeMillis();
newAdasRecognizedMarkersCaches.put( uniqueKey, marker );
if ( mChangeCarModeStatus ) {
mChangeCarModeStatus = false;
mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
mChangeCarModeStatus = false;
if ( mIsVrMode ) {
Logger.d( TAG, "3D模型-%s", uniqueKey );
marker.getMogoMarkerOptions().set3DMode( true );
@@ -215,7 +223,8 @@ class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClickListen
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
}
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), mIsVrMode );
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
Log.i( "mock-snapshot-timer3", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,7 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -31,6 +32,7 @@ import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.realtime.entity.MogoSnapshotSetData;
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
import com.mogo.service.adas.entity.ADASCarStateInfo;
@@ -44,9 +46,11 @@ import com.mogo.utils.storage.SharedPrefsMgr;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -549,6 +553,10 @@ public class MockIntentHandler implements IntentHandler {
String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}";
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ), false );
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
break;
}
}
@@ -572,15 +580,85 @@ public class MockIntentHandler implements IntentHandler {
}
}
private Handler mLocationMockHandler = new Handler(WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper()){
private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) {
@Override
public void handleMessage( Message msg ) {
super.handleMessage( msg );
if ( msg.what == 1 ) {
try {
if ( !handleMockLocationIntent() ) {
br.close();
br = null;
}
} catch ( Exception e ) {
try {
br.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br = null;
}
} else if ( msg.what == 2 ) {
try {
handleMockSnapshotIntent();
} catch ( Exception e ) {
try {
br2.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br2 = null;
}
}
}
};
private void handleMockLocationIntent(){
private BufferedReader br;
private boolean handleMockLocationIntent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) );
}
String line = br.readLine();
if ( line == null ) {
throw new Exception( "end of file." );
}
JSONObject jo = new JSONObject( line );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
return true;
}
private BufferedReader br2;
private int count = 1;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
throw new Exception( "end of file 2." );
}
MogoSnapshotSetData data = new MogoSnapshotSetData();
List< CloudRoadData > allList = new ArrayList<>();
if ( ++count % 300 != 0 ) {
CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class );
if ( cloudRoadData == null ) {
return false;
}
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
cloudRoadData.setLon( coor[0] );
cloudRoadData.setLat( coor[1] );
allList.add( cloudRoadData );
}
data.setAllList( allList );
final long start = System.currentTimeMillis();
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
Log.i("mock-snapshot-timer", "cost " + (System.currentTimeMillis() - start) + "ms");
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
return true;
}
}