mock loc intent data
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
public class RealTimeData {
|
||||
|
||||
private static volatile RealTimeData realTimeData;
|
||||
private static final byte[] bytes = new byte[0];
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
private double heading;
|
||||
private int speed;
|
||||
private long satelliteTime;
|
||||
|
||||
private RealTimeData() {
|
||||
|
||||
}
|
||||
|
||||
public static RealTimeData getInstance() {
|
||||
if (realTimeData == null) {
|
||||
synchronized (bytes) {
|
||||
if (realTimeData == null) {
|
||||
realTimeData = new RealTimeData();
|
||||
}
|
||||
}
|
||||
}
|
||||
return realTimeData;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public void setSatelliteTime(long satelliteTime) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public long getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,30 @@
|
||||
package com.mogo.module.common.uploadintime;
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.locationinfo.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 实时坐标数据处理中心
|
||||
/**
|
||||
* 定位坐标同步数据中心
|
||||
* 接收来自工控机实际定位数据
|
||||
*/
|
||||
public class SnapshotLocationController {
|
||||
public class SnapshotLocationDataCenter {
|
||||
|
||||
private static final String TAG = "SnapshotLocationController";
|
||||
private static volatile SnapshotLocationDataCenter sInstance;
|
||||
|
||||
private static volatile SnapshotLocationController sInstance;
|
||||
|
||||
private SnapshotLocationController() {
|
||||
private SnapshotLocationDataCenter() {
|
||||
}
|
||||
|
||||
public static SnapshotLocationController getInstance() {
|
||||
public static SnapshotLocationDataCenter getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (SnapshotLocationController.class) {
|
||||
synchronized (SnapshotLocationDataCenter.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new SnapshotLocationController();
|
||||
sInstance = new SnapshotLocationDataCenter();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +47,7 @@ public class SnapshotLocationController {
|
||||
private double mCurSpeed;
|
||||
private double mCurLon;
|
||||
private double mCurLat;
|
||||
private long mSatelliteTime = 0;
|
||||
|
||||
/**
|
||||
* 同步从定位来的数据(也可能是rtk)
|
||||
@@ -81,7 +77,6 @@ public class SnapshotLocationController {
|
||||
//测试面板状态同步
|
||||
DebugConfig.setStatus(DebugConfig.sLocation, true);
|
||||
|
||||
// Logger.d(TAG, "同步到rtk数据");
|
||||
double lon = data.optDouble("lon", -1);
|
||||
double lat = data.optDouble("lat", -1);
|
||||
double alt = data.optDouble("alt", -1);
|
||||
@@ -111,6 +106,7 @@ public class SnapshotLocationController {
|
||||
mCurSpeed = cloudLocationInfo.getSpeed();
|
||||
mCurLon = cloudLocationInfo.getLon();
|
||||
mCurLat = cloudLocationInfo.getLat();
|
||||
mSatelliteTime = cloudLocationInfo.getSatelliteTime();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +139,6 @@ public class SnapshotLocationController {
|
||||
if (list.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
//Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() );
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -153,7 +148,6 @@ public class SnapshotLocationController {
|
||||
* @return 精度
|
||||
*/
|
||||
public int getDataAccuracy() {
|
||||
//Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
|
||||
return mDataAccuracy;
|
||||
}
|
||||
|
||||
@@ -168,4 +162,8 @@ public class SnapshotLocationController {
|
||||
public double getCurLat() {
|
||||
return mCurLat;
|
||||
}
|
||||
|
||||
public long getSatelliteTime(){
|
||||
return mSatelliteTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.module.common.datacenter;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.SocketReceiveDataProto3;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
|
||||
@Service(value = IRealTimeProvider.class)
|
||||
public class SpiRealTimeProvider implements IRealTimeProvider {
|
||||
|
||||
@Override
|
||||
public SocketReceiveDataProto3.SocketReceiveDataProto getLocationMsg() {
|
||||
|
||||
double lat = RealTimeData.getInstance().getLat();
|
||||
double lon = RealTimeData.getInstance().getLon();
|
||||
if (lat == 0.0f || lon == 0.0f) {
|
||||
return null;
|
||||
}
|
||||
double heading = RealTimeData.getInstance().getHeading();
|
||||
int speed = RealTimeData.getInstance().getSpeed();
|
||||
long satelliteTime = RealTimeData.getInstance().getSatelliteTime();
|
||||
long mortonCode = MortonCode.encodeMorton(lon, lat);
|
||||
|
||||
SocketReceiveDataProto3.LocationInfoProto locationInfoProto =
|
||||
SocketReceiveDataProto3.LocationInfoProto.newBuilder()
|
||||
.setLat(lat)
|
||||
.setLon(lon)
|
||||
.setHeading(heading)
|
||||
.setSystemTime(System.currentTimeMillis())
|
||||
.setSatelliteTime(satelliteTime)
|
||||
.setAlt(0)
|
||||
.setDataAccuracy(1)
|
||||
.setSpeed(speed)
|
||||
.setMortonCode(mortonCode)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.MyLocationReq myLocationReq =
|
||||
SocketReceiveDataProto3.MyLocationReq.newBuilder()
|
||||
.setLastCoordinate(locationInfoProto)
|
||||
.setDataAccuracy(1)
|
||||
.setMortonCode(mortonCode)
|
||||
.setFromType(0)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.OnePerSecondSendReqProto self =
|
||||
SocketReceiveDataProto3.OnePerSecondSendReqProto.newBuilder()
|
||||
.setSelf(myLocationReq)
|
||||
.build();
|
||||
return SocketReceiveDataProto3.SocketReceiveDataProto.newBuilder()
|
||||
.setIPCSn(MoGoAiCloudClientConfig.getInstance().getSn() + "xavier")
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.setData(self)
|
||||
.setMsgType(MSG_TYPE_UPLINK_CAR_DATA.getMsgType())
|
||||
.setSeq(System.currentTimeMillis()).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mogo.module.common.datacenter.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.module.common.datacenter.RealTimeData;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public class SnapShotMockTestPanelBroadCastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "SnapShotMockTestPanelBroadCastReceiver";
|
||||
|
||||
/**
|
||||
* 定位模拟测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
* 定位模拟分发场景中,需要case自己处理数据,以生产者消费者模式来提供 RealTimeData 所需字段,详见mockCase package
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
Logger.d(TAG, "sceneType=" + sceneType);
|
||||
if (sceneType == 1) {
|
||||
//模拟顺义固定位置
|
||||
RealTimeData.getInstance().setLat(39.968309);
|
||||
RealTimeData.getInstance().setLon(116.410871);
|
||||
RealTimeData.getInstance().setHeading(120);
|
||||
RealTimeData.getInstance().setSpeed(30);
|
||||
long satelliteTime = SnapshotLocationDataCenter.getInstance().getSatelliteTime();
|
||||
if (satelliteTime == 0) {
|
||||
satelliteTime = System.currentTimeMillis();
|
||||
}
|
||||
RealTimeData.getInstance().setSatelliteTime(satelliteTime);
|
||||
} else if (sceneType == 2) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -255,7 +255,7 @@ class BaseDrawer {
|
||||
protected double getCurSpeed() {
|
||||
double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
|
||||
if (speed <= 0) {
|
||||
speed = SnapshotLocationController.getInstance().getCurSpeed();
|
||||
speed = SnapshotLocationDataCenter.getInstance().getCurSpeed();
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
@@ -271,8 +271,8 @@ class BaseDrawer {
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
};
|
||||
if (coordinates[0] <= 0) {
|
||||
coordinates[0] = SnapshotLocationController.getInstance().getCurLon();
|
||||
coordinates[1] = SnapshotLocationController.getInstance().getCurLat();
|
||||
coordinates[0] = SnapshotLocationDataCenter.getInstance().getCurLon();
|
||||
coordinates[1] = SnapshotLocationDataCenter.getInstance().getCurLat();
|
||||
}
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user