add new func of mockData
This commit is contained in:
@@ -35,6 +35,7 @@ import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.status.EnvStatusManager;
|
||||
import com.mogo.module.service.timedelay.TimeDelayUploadManager;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
@@ -617,6 +618,10 @@ public class MockIntentHandler implements IntentHandler {
|
||||
case 54:
|
||||
mTimeTickCarHandler.sendEmptyMessageDelayed(1, 0L);
|
||||
break;
|
||||
case 55:
|
||||
//开启模拟数据Mock,用于验证算法准确性
|
||||
TimeDelayUploadManager.getInstance().init(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.module.service.network.bean;
|
||||
|
||||
public class MockSocketReceiverData {
|
||||
|
||||
public static final int MOCK_RECEIVER_STATUS_START = 0;
|
||||
public static final int MOCK_RECEIVER_STATUS_STOP = 1;
|
||||
|
||||
private int status;
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double heading;
|
||||
private long systemTime;
|
||||
private long satelliteTime;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public long getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public long getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MockSocketReceiverData{" +
|
||||
"status=" + status +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", heading=" + heading +
|
||||
", systemTime=" + systemTime +
|
||||
", satelliteTime=" + satelliteTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,44 @@
|
||||
package com.mogo.module.service.timedelay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.network.bean.MockSocketReceiverData;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import static com.mogo.module.service.network.bean.MockSocketReceiverData.MOCK_RECEIVER_STATUS_START;
|
||||
|
||||
/**
|
||||
* 接收服务端模拟定位数据,对下发数据做实时Post上报,统计时延
|
||||
*/
|
||||
public class TimeDelayUploadManager implements IMogoOnMessageListener {
|
||||
public class TimeDelayUploadManager implements IMogoOnMessageListener<MockSocketReceiverData>, IMogoCloudOnMsgListener {
|
||||
|
||||
private static final String TAG = "TimeDelayUploadManager";
|
||||
|
||||
private volatile static TimeDelayUploadManager timeDelayUploadManager;
|
||||
private static final int MSG_SOCKET_TYPE = 403000;
|
||||
private static final int MOCK_MSG = 1;
|
||||
private boolean isMockData = false;
|
||||
private MockSocketReceiverData mMockData;
|
||||
private long mRecordSatelliteTime; //todo 后续多点模拟用
|
||||
|
||||
private TimeDelayUploadManager() {
|
||||
|
||||
}
|
||||
|
||||
public TimeDelayUploadManager getInstance() {
|
||||
public static TimeDelayUploadManager getInstance() {
|
||||
if (timeDelayUploadManager == null) {
|
||||
synchronized (TimeDelayUploadManager.class) {
|
||||
if (timeDelayUploadManager == null) {
|
||||
@@ -31,16 +52,71 @@ public class TimeDelayUploadManager implements IMogoOnMessageListener {
|
||||
public void init(Context mContext) {
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(mContext).registerOnMessageListener(MSG_SOCKET_TYPE,this);
|
||||
.getSocketManagerApi(mContext).registerOnMessageListener(MSG_SOCKET_TYPE, this);
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(this);
|
||||
}
|
||||
|
||||
private final Handler mockHandler = new Handler(WorkThreadHandler.newInstance("mock-algorithm-work-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MOCK_MSG) {
|
||||
//改变地图定位数据,触发自车移动
|
||||
JSONObject jo = new JSONObject();
|
||||
try {
|
||||
jo.put("lon", mMockData.getLon());
|
||||
jo.put("lat", mMockData.getLat());
|
||||
jo.put("heading", mMockData.getHeading());
|
||||
jo.put("systemTime", System.currentTimeMillis());
|
||||
jo.put("satelliteTime", System.currentTimeMillis());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Logger.d(TAG, "更改自车定位点");
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
|
||||
Logger.d(TAG, "同步定位信息,用于上报");
|
||||
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
|
||||
mockHandler.sendEmptyMessageDelayed(MOCK_MSG, 50);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Class<MockSocketReceiverData> target() {
|
||||
return MockSocketReceiverData.class;
|
||||
}
|
||||
|
||||
//接收socket数据
|
||||
@Override
|
||||
public void onMsgReceived(MockSocketReceiverData mockData) {
|
||||
Logger.d(TAG, "onMsgReceived obj : " + mockData.toString());
|
||||
if (mockData.getStatus() == MOCK_RECEIVER_STATUS_START) {
|
||||
isMockData = true;
|
||||
//开启定位模拟
|
||||
mMockData = mockData;
|
||||
mRecordSatelliteTime = mockData.getSatelliteTime();
|
||||
mockHandler.sendEmptyMessage(MOCK_MSG);
|
||||
} else {
|
||||
isMockData = false;
|
||||
//停止定位模拟
|
||||
if (mockHandler.hasMessages(MOCK_MSG)) {
|
||||
mockHandler.removeMessages(MOCK_MSG);
|
||||
mMockData = null;
|
||||
mRecordSatelliteTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class target() {
|
||||
return null;
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
}
|
||||
|
||||
//接收实时数据监听回调,用于给服务端上报时延
|
||||
@Override
|
||||
public void onMsgReceived(Object obj) {
|
||||
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
if (isMockData) {
|
||||
//接口数据上报
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user