add mock data
This commit is contained in:
@@ -625,6 +625,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
boolean isUseAdasRecognize = intent.getBooleanExtra( "status", false );
|
||||
DebugConfig.setUseAdasRecognize( isUseAdasRecognize );
|
||||
break;
|
||||
case 54:
|
||||
mTimeTickCarHandler.sendEmptyMessageDelayed( 1, 0L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,6 +682,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
@@ -740,9 +744,28 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
roadSizeBr = null;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private Handler mLocationMockHandler1 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread1" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
@@ -780,6 +803,19 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
};
|
||||
|
||||
private Handler mTimeTickCarHandler = new Handler( WorkThreadHandler.newInstance( "loc-time-mock-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
mLocDelay += 50;
|
||||
if ( mLocDelay > 4_000L ) {
|
||||
mLocationMockHandler1.sendEmptyMessageDelayed( 1, 0L );
|
||||
}
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 8, 0L );
|
||||
mTimeTickCarHandler.sendEmptyMessageDelayed( 0, 50L );
|
||||
}
|
||||
};
|
||||
|
||||
private BufferedReader br;
|
||||
|
||||
private boolean handleMockLocationIntent() throws Exception {
|
||||
@@ -792,6 +828,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
throw new Exception( "end of file." );
|
||||
}
|
||||
JSONObject jo = new JSONObject( line );
|
||||
//改变rtk定位数据,触发自车移动
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo );
|
||||
Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo( jo );
|
||||
@@ -830,6 +867,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
|
||||
private BufferedReader[] readers = null;
|
||||
private BufferedReader[] readers2 = null;
|
||||
|
||||
private boolean handleMockAdasIntent() throws Exception {
|
||||
final long start = System.currentTimeMillis();
|
||||
@@ -858,6 +896,33 @@ public class MockIntentHandler implements IntentHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
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" ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
List< ADASRecognizedResult > allList = new ArrayList<>();
|
||||
for ( BufferedReader reader : readers2 ) {
|
||||
String line = reader.readLine();
|
||||
ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class );
|
||||
if ( adasRecognizedResult != null ) {
|
||||
allList.add( adasRecognizedResult );
|
||||
}
|
||||
}
|
||||
|
||||
AdasRec adasRec = new AdasRec();
|
||||
adasRec.models = allList;
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized( GsonUtil.jsonFromObject( adasRec ) );
|
||||
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class AdasRec{
|
||||
public String action = "view";
|
||||
public List<ADASRecognizedResult> models;
|
||||
|
||||
Reference in New Issue
Block a user