优化显示逻辑

This commit is contained in:
wangcongtao
2021-03-16 16:25:44 +08:00
parent 5e0d18dbc2
commit 71e809a8ba
15 changed files with 277 additions and 27343 deletions

View File

@@ -614,10 +614,47 @@ public class MockIntentHandler implements IntentHandler {
.rotate( ( float ) 358.526123 );
IMogoMarker marker3 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options3 );
break;
case 50:
DebugConfig.setSelfCarSpeedYOffset( intent.getIntExtra( "yOffset", 20 ) );
break;
case 51:
mLocationMockHandler.sendEmptyMessageDelayed( 100, 0L );
mLocationMockHandler.sendEmptyMessageDelayed( 101, 1000L );
break;
}
}
private BufferedReader roadSizeBr;
private JSONObject locJo = null;
private void handleMockSingleLocDataIntent() throws Exception{
if ( locJo == null ) {
String locLine = "{\"systemTime\":1615529718585,\"satelliteTime\":1615529718585,\"lon\":116.73573385415098,\"lat\":40.19907712731953,\"alt\":34.4018669128417,\"heading\":0.342695406938048,\"speed\":0.003303937}";
locJo = new JSONObject( locLine );
locJo.put( "satelliteTime", System.currentTimeMillis() );
locJo.put( "systemTime", System.currentTimeMillis() );
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( locJo );
mLocationMockHandler.sendEmptyMessageDelayed( 100, 50L );
}
private void handleRoadSideMockDataIntent() throws Exception{
if ( roadSizeBr == null ) {
roadSizeBr = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "roadSide.txt" ) ) );
}
String carsLine = roadSizeBr.readLine();
MogoSnapshotSetData data = new MogoSnapshotSetData();
List<CloudRoadData> allList = GsonUtil.arrayFromJson( carsLine, CloudRoadData.class );
for ( CloudRoadData cloudRoadData : allList ) {
cloudRoadData.setWgslat( cloudRoadData.getLat() );
cloudRoadData.setWgslon( cloudRoadData.getLon() );
cloudRoadData.setFromType( CloudRoadData.FROM_ROAD_UNIT );
}
data.setAllList( allList );
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
mLocationMockHandler.sendEmptyMessageDelayed( 101, 100L );
}
public void onAdasCarDataCallback( ADASCarStateInfo stateInfo ) {
if ( stateInfo != null && stateInfo.getValues() != null ) {
JSONObject data = new JSONObject();
@@ -684,10 +721,18 @@ public class MockIntentHandler implements IntentHandler {
} catch ( Exception e ) {
try {
br3.close();
br31.close();
br32.close();
br33.close();
br34.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br3 = null;
br31 = null;
br32 = null;
br33 = null;
br34 = null;
}
} else if( msg.what == 31 ){
try {
@@ -700,18 +745,7 @@ public class MockIntentHandler implements IntentHandler {
}
br31 = null;
}
} else if ( msg.what == 5 ) {
try {
handleMockAdasLocIntent();
} catch ( Exception e ) {
try {
br5.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br5 = null;
}
} else if ( msg.what == 48 ) {
}else if ( msg.what == 48 ) {
try {
handleMockLocationIntent48();
} catch ( Exception e ) {
@@ -722,6 +756,23 @@ public class MockIntentHandler implements IntentHandler {
}
br48 = null;
}
}else if ( msg.what == 100 ) {
try {
handleMockSingleLocDataIntent();
} catch ( Exception e ) {
e.printStackTrace();
}
}else if ( msg.what == 101 ) {
try {
handleRoadSideMockDataIntent();
} catch ( Exception e ) {
try {
roadSizeBr.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
roadSizeBr = null;
}
}
}
};
@@ -748,41 +799,6 @@ public class MockIntentHandler implements IntentHandler {
return true;
}
private boolean handleMockLocation4Intent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc4.csv" ) ) );
}
final long start = System.currentTimeMillis();
String line = br.readLine();
if ( line == null ) {
throw new Exception( "end of file." );
}
String[] lineInfo = line.split(",");
// {"systemTime":1611556780918,"satelliteTime":1611556780918,"lon":116.411180361079,"lat":39.980735708079,
// "alt":34.58304214,"heading":357.5486755,"speed":12.132635}
// 1615283773276 ,116.411321995561 ,39.978070895874 ,34.296333 ,0.971988 ,0.841514 ,4.4176307 ,0.1555639 ,1615283773214 ,1615283773481
JSONObject jo = new JSONObject();
long time = Long.parseLong(lineInfo[lineInfo.length - 1].trim());
jo.put( "satelliteTime", time );
jo.put( "systemTime", time );
jo.put("lon", Double.parseDouble(lineInfo[1].trim()));
jo.put("lat",Double.parseDouble(lineInfo[2].trim()));
jo.put("alt", Double.parseDouble(lineInfo[3].trim()));
jo.put("heading", Double.parseDouble(lineInfo[4].trim()));
jo.put("speed", Double.parseDouble(lineInfo[6].trim()));
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
SnapshotLocationController.getInstance().syncAdasLocationInfo( jo );
Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if (lastLoc != 0){
delay = time - lastLoc;
}
lastLoc = time;
mLocationMockHandler.sendEmptyMessageDelayed( 1, 50L );
return true;
}
private BufferedReader br48;
int count = 0;
@@ -805,7 +821,6 @@ public class MockIntentHandler implements IntentHandler {
private BufferedReader br2;
private long last = 0;
private long lastLoc = 0;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
@@ -821,9 +836,6 @@ public class MockIntentHandler implements IntentHandler {
if ( cloudRoadData == null ) {
return false;
}
// double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
// cloudRoadData.setLon( coor[0] );
// cloudRoadData.setLat( coor[1] );
cloudRoadData.setWgslat( cloudRoadData.getLat() );
cloudRoadData.setWgslon( cloudRoadData.getLon() );
allList.add( cloudRoadData );
@@ -857,10 +869,7 @@ public class MockIntentHandler implements IntentHandler {
if ( cloudRoadData == null ) {
return false;
}
// double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
cloudRoadData.setUuid( "1_21" );
// cloudRoadData.setLon( coor[0] );
// cloudRoadData.setLat( coor[1] );
allList.add( cloudRoadData );
data.setAllList( allList );
@@ -873,12 +882,23 @@ public class MockIntentHandler implements IntentHandler {
private BufferedReader br3;
private BufferedReader br31;
private long lastTime = 0;
private boolean handleMockAdasIntent() throws Exception {
if ( br3 == null ) {
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas2.txt" ) ) );
}
if ( br31 == null ) {
br31 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3.txt" ) ) );
}
if ( br32 == null ) {
br32 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas4.txt" ) ) );
}
if ( br33 == null ) {
br33 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas5.txt" ) ) );
}
if ( br34 == null ) {
br34 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas6.txt" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
@@ -888,15 +908,23 @@ public class MockIntentHandler implements IntentHandler {
if ( adasRecognizedResult == null ) {
return false;
}
// double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
// adasRecognizedResult.lon = coor[0];
// adasRecognizedResult.lat = coor[1];
allList.add( adasRecognizedResult );
// ADASRecognizedResult next = handleMockAdasIntent3();
// if(next != null){
// allList.add(next);
// }
ADASRecognizedResult next = handleMockAdasIntent3();
if(next != null){
allList.add(next);
}
next = handleMockAdasIntent4();
if(next != null){
allList.add(next);
}
next = handleMockAdasIntent5();
if(next != null){
allList.add(next);
}
next = handleMockAdasIntent6();
if(next != null){
allList.add(next);
}
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
@@ -912,102 +940,79 @@ public class MockIntentHandler implements IntentHandler {
return true;
}
private ADASRecognizedResult handleMockAdasIntent3() throws Exception {
if ( br31 == null ) {
br31 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3.txt" ) ) );
private ADASRecognizedResult handleMockAdasIntent3() {
String line = null;
try {
line = br31.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
String line = br31.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
return null;
}
List< ADASRecognizedResult > allList = new ArrayList<>();
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
// double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
// adasRecognizedResult.lon = coor[0];
// adasRecognizedResult.lat = coor[1];
adasRecognizedResult.uuid = "2_2";
return adasRecognizedResult;
// allList.add( adasRecognizedResult );
//
// final long start = System.currentTimeMillis();
//
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
// Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
// long delay = 100;
// if (last != 0){
// delay = adasRecognizedResult.satelliteTime - last;
// }
// last = adasRecognizedResult.satelliteTime;
//
// Log.d("send-delay", "delay: " + delay);
// mLocationMockHandler.sendEmptyMessageDelayed( 31, 50L );
// return true;
}
private boolean handleMockAdasIntent2() throws Exception {
if ( br3 == null ) {
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc4.csv" ) ) );
private BufferedReader br32;
private ADASRecognizedResult handleMockAdasIntent4() {
String line = null;
try {
line = br32.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
return null;
}
List< ADASRecognizedResult > allList = new ArrayList<>();
String[] lineInfo = line.split(",");
JSONObject jo = new JSONObject();
long time = Long.parseLong(lineInfo[lineInfo.length - 1].trim());
jo.put( "satelliteTime", time );
jo.put( "systemTime", time );
jo.put("lon", Double.parseDouble(lineInfo[1].trim()));
jo.put("lat",Double.parseDouble(lineInfo[2].trim()));
jo.put("alt", Double.parseDouble(lineInfo[3].trim()));
jo.put("heading", Double.parseDouble(lineInfo[4].trim()));
jo.put("speed", Double.parseDouble(lineInfo[6].trim()));
jo.put("type", 3);
jo.put("uuid", "2_1");
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( jo.toString(), ADASRecognizedResult.class );
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return false;
return null;
}
// double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
// adasRecognizedResult.lon = coor[0];
// adasRecognizedResult.lat = coor[1];
allList.add( adasRecognizedResult );
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
long delay = 100;
if (last != 0){
delay = adasRecognizedResult.satelliteTime - last;
}
last = adasRecognizedResult.satelliteTime;
Log.d("send-delay", "delay: " + delay);
mLocationMockHandler.sendEmptyMessageDelayed( 3, 50L );
return true;
adasRecognizedResult.uuid = "2_3";
return adasRecognizedResult;
}
private BufferedReader br5;
private boolean handleMockAdasLocIntent() throws Exception {
if ( br5 == null ) {
br5 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas-loc.txt" ) ) );
private BufferedReader br33;
private ADASRecognizedResult handleMockAdasIntent5() {
String line = null;
try {
line = br33.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
String line = br5.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
return null;
}
MogoApisHandler.getInstance()
.getApis()
.getAdasControllerApi()
.mockAdasLoc( line );
mLocationMockHandler.sendEmptyMessageDelayed( 5, 50L );
return true;
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_4";
return adasRecognizedResult;
}
private BufferedReader br34;
private ADASRecognizedResult handleMockAdasIntent6() {
String line = null;
try {
line = br34.readLine();
} catch ( IOException e ) {
e.printStackTrace();
}
if ( line == null ) {
return null;
}
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
if ( adasRecognizedResult == null ) {
return null;
}
adasRecognizedResult.uuid = "2_5";
return adasRecognizedResult;
}
}