This commit is contained in:
tongchenfei
2021-03-12 16:11:54 +08:00
parent 9b79efff72
commit 0608a0d3f7
6 changed files with 19029 additions and 6 deletions

View File

@@ -559,10 +559,11 @@ public class MockIntentHandler implements IntentHandler {
SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) );
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 500L );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 4000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 31, 2000L );
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
break;
case 48:
@@ -690,6 +691,17 @@ public class MockIntentHandler implements IntentHandler {
}
br3 = null;
}
} else if( msg.what == 31 ){
try {
handleMockAdasIntent3();
} catch ( Exception e ) {
try {
br31.close();
} catch ( IOException ex ) {
ex.printStackTrace();
}
br31 = null;
}
} else if ( msg.what == 5 ) {
try {
handleMockAdasLocIntent();
@@ -720,7 +732,7 @@ public class MockIntentHandler implements IntentHandler {
private boolean handleMockLocationIntent() throws Exception {
if ( br == null ) {
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) );
br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc5.txt" ) ) );
}
final long start = System.currentTimeMillis();
String line = br.readLine();
@@ -734,7 +746,42 @@ public class MockIntentHandler implements IntentHandler {
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" );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 100L );
mLocationMockHandler.sendEmptyMessageDelayed( 1, 50L );
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;
}
@@ -760,6 +807,7 @@ public class MockIntentHandler implements IntentHandler {
private BufferedReader br2;
private long last = 0;
private long lastLoc = 0;
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
@@ -826,11 +874,12 @@ 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( "adas.txt" ) ) );
br3 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas2.txt" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
@@ -845,12 +894,103 @@ public class MockIntentHandler implements IntentHandler {
// adasRecognizedResult.lon = coor[0];
// adasRecognizedResult.lat = coor[1];
allList.add( adasRecognizedResult );
ADASRecognizedResult next = handleMockAdasIntent3();
if(next != null){
allList.add(next);
}
final long start = System.currentTimeMillis();
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
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;
}
private ADASRecognizedResult handleMockAdasIntent3() throws Exception {
if ( br31 == null ) {
br31 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas3.txt" ) ) );
}
String line = br31.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
}
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" ) ) );
}
String line = br3.readLine();
if ( line == null ) {
throw new Exception( "end of file 3." );
}
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 );
if ( adasRecognizedResult == null ) {
return false;
}
// 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;
}