wait to finish of mockdata

This commit is contained in:
zhongchao
2021-06-16 17:28:24 +08:00
parent d54d4f51e2
commit c598b44866
4 changed files with 86 additions and 9 deletions

View File

@@ -27,14 +27,15 @@ import java.io.OutputStreamWriter;
*/
public class FileUtils {
public static boolean createFileDir(String fileDir) {
if (TextUtils.isEmpty(fileDir)) {
return false;
}
try {
File dir = new File(fileDir);
return dir.exists() || dir.mkdir();
if(!dir.exists()){
return dir.mkdirs();
}
return dir.exists();
} catch (Exception e) {
return false;
}

View File

@@ -617,6 +617,10 @@ public class MockIntentHandler implements IntentHandler {
case 55:
//开启模拟数据Mock用于验证算法准确性
TimeDelayUploadManager.getInstance().init(context);
break;
case 56:
// 开启数据采集 自车定位和视觉识别
break;
}
}

View File

@@ -0,0 +1,75 @@
package com.mogo.module.service.mocktools;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import com.mogo.utils.WorkThreadHandler;
import java.io.File;
public class DataCollectionHandler {
private static volatile DataCollectionHandler handler;
private static final byte[] obj = new byte[0];
private volatile boolean openDataCollect = false;
private Handler mLocationDataCollectHandler;
private Handler mRecognizeDataCollectHandler;
private static final String WRITE_FILE_PATH = Environment.getExternalStorageDirectory().getPath() + File.separator + "mockWrite";
private DataCollectionHandler() {
}
public static DataCollectionHandler getInstance() {
if (handler == null) {
synchronized (obj) {
if (handler == null) {
handler = new DataCollectionHandler();
}
}
}
return handler;
}
public void start() {
openDataCollect = true;
}
public boolean canCollectData() {
return openDataCollect;
}
public void collectLocationDataToFile(String locationData) {
if (mLocationDataCollectHandler == null) {
mLocationDataCollectHandler = new Handler(WorkThreadHandler.newInstance("data-collect-thread").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
}
};
}
}
public void collectRecogniseDataToFile() {
if (mRecognizeDataCollectHandler == null) {
mRecognizeDataCollectHandler = new Handler(WorkThreadHandler.newInstance("recognize-collect-thread").getLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
}
};
}
}
public void stop() {
openDataCollect = false;
mLocationDataCollectHandler = null;
mRecognizeDataCollectHandler = null;
}
}

View File

@@ -142,6 +142,9 @@ public class MogoADASController implements IMogoADASController {
public void handleMessage(Message msg) {
super.handleMessage(msg);
final long start = System.currentTimeMillis();
ADASCarStateInfo stateInfo = GsonUtil.objectFromJson(((String) msg.obj), ADASCarStateInfo.class);
if (stateInfo == null || stateInfo.getValues() == null) {
Logger.d(TAG, "ADAS-LOC-timer", "upd 到 aidl 传输数据 stateInfo or stateInfo.getValues() is null");
@@ -673,15 +676,9 @@ public class MogoADASController implements IMogoADASController {
}
}
private static final String TEST_SN = "ZD802B1932L00617";
private String currentSn = TEST_SN;
private void requestCarModelList() {
Map<String, String> params = new HashMap<>(8);
params.put("sn", MoGoAiCloudClientConfig.getInstance().getSn());
// currentSn = useTestSn ? TEST_SN : MoGoAiCloudClientConfig.getInstance().getSn();
// params.put("sn", currentSn);
SingletonsHolder.get(IMogoNetwork.class).create(CarModelInfoNetApiServices.class, CarModelInfoNetApiServices.getBaseUrl()).
requestCarModelList(params).
subscribeOn(Schedulers.io()).