mock loc intent data

This commit is contained in:
zhongchao
2021-07-15 16:43:16 +08:00
parent 5a2433a13d
commit c523f0f22c
13 changed files with 231 additions and 34 deletions

View File

@@ -1 +0,0 @@
[{"lat":26.820175208327566,"lng":0.0,"lon":112.57748204198309},{"lat":26.82009891465042,"lng":0.0,"lon":112.57735739748664},{"lat":26.820022750763542,"lng":0.0,"lon":112.57723266155585},{"lat":26.81994655656347,"lng":0.0,"lon":112.57710795477944},{"lat":26.81987031666393,"lng":0.0,"lon":112.57698328267305},{"lat":26.819793988171348,"lng":0.0,"lon":112.57685866945901},{"lat":26.819717530408877,"lng":0.0,"lon":112.57673414980971},{"lat":26.819635079638967,"lng":0.0,"lon":112.57661462149986},{"lat":26.819532022659132,"lng":0.0,"lon":112.5765234581422},{"lat":26.819488197195188,"lng":0.0,"lon":112.5764835085963},{"lat":26.81947053563866,"lng":0.0,"lon":112.57645743645142},{"lat":26.81945285740347,"lng":0.0,"lon":112.5764313389555},{"lat":26.81941584428336,"lng":0.0,"lon":112.57637074918446},{"lat":26.819355855639404,"lng":0.0,"lon":112.57626774620917},{"lat":26.8193352833325,"lng":0.0,"lon":112.57623094969783},{"lat":26.819315738575742,"lng":0.0,"lon":112.57619587959701},{"lat":26.81929619389902,"lng":0.0,"lon":112.5761608096667},{"lat":26.819276064037396,"lng":0.0,"lon":112.5761245744324},{"lat":26.819221654527443,"lng":0.0,"lon":112.5760208132482},{"lat":26.819153675938914,"lng":0.0,"lon":112.5758903945585},{"lat":26.8190859083974,"lng":0.0,"lon":112.57576035026403},{"lat":26.81904791926707,"lng":0.0,"lon":112.57568644394968},{"lat":26.819047477540156,"lng":0.0,"lon":112.57568591545105},{"lat":26.819047035811135,"lng":0.0,"lon":112.57568538694994},{"lat":26.819046594080046,"lng":0.0,"lon":112.57568485844635},{"lat":26.81902999052958,"lng":0.0,"lon":112.57568137976324},{"lat":26.818966668056316,"lng":0.0,"lon":112.57572279587626},{"lat":26.81896660310204,"lng":0.0,"lon":112.57572518130716},{"lat":26.81896683258833,"lng":0.0,"lon":112.57572606581252},{"lat":26.81896706207354,"lng":0.0,"lon":112.57572695031374},{"lat":26.818971211272444,"lng":0.0,"lon":112.57573544393973},{"lat":26.819027657144368,"lng":0.0,"lon":112.57584589447032},{"lat":26.819095546341085,"lng":0.0,"lon":112.57597644303986},{"lat":26.8191650468231,"lng":0.0,"lon":112.57610591408428},{"lat":26.819236806047,"lng":0.0,"lon":112.5762338575302},{"lat":26.819310184480436,"lng":0.0,"lon":112.57636063880027},{"lat":26.819384451187933,"lng":0.0,"lon":112.5764867800095},{"lat":26.819460642360763,"lng":0.0,"lon":112.57661149583805},{"lat":26.819536878267925,"lng":0.0,"lon":112.57673619431976},{"lat":26.819613220428206,"lng":0.0,"lon":112.57686079387894},{"lat":26.819689146973122,"lng":0.0,"lon":112.57698570087358},{"lat":26.819765257290772,"lng":0.0,"lon":112.57711047564952},{"lat":26.81984156841068,"lng":0.0,"lon":112.57723510283108},{"lat":26.819916608456698,"lng":0.0,"lon":112.57735767331373},{"lat":26.819990868286688,"lng":0.0,"lon":112.57747918205983},{"lat":26.82006704845146,"lng":0.0,"lon":112.57760363217366},{"lat":26.820142688927376,"lng":0.0,"lon":112.57772676391022},{"lat":26.820220480866162,"lng":0.0,"lon":112.57784947830805},{"lat":26.82029609426984,"lng":0.0,"lon":112.57797111160743},{"lat":26.820372540342063,"lng":0.0,"lon":112.57809575812311},{"lat":26.820449035279513,"lng":0.0,"lon":112.57822036992494},{"lat":26.82052479395364,"lng":0.0,"lon":112.5783432083879},{"lat":26.820600741070034,"lng":0.0,"lon":112.57846626552721},{"lat":26.820676451505513,"lng":0.0,"lon":112.57858892597905},{"lat":26.820750627333855,"lng":0.0,"lon":112.57870908764811},{"lat":26.820788099971104,"lng":0.0,"lon":112.57876896886103},{"lat":26.82079340880141,"lng":0.0,"lon":112.57877600898784},{"lat":26.82079871765643,"lng":0.0,"lon":112.57878304914836},{"lat":26.820804096213536,"lng":0.0,"lon":112.57879017489086},{"lat":26.820866626548845,"lng":0.0,"lon":112.5788587003478},{"lat":26.820983640738305,"lng":0.0,"lon":112.57893123552938},{"lat":26.82111632395692,"lng":0.0,"lon":112.57893777257203},{"lat":26.82117204164965,"lng":0.0,"lon":112.57891747212024},{"lat":26.821184743761496,"lng":0.0,"lon":112.57890962148315},{"lat":26.821197445813166,"lng":0.0,"lon":112.5789017

View File

@@ -56,6 +56,8 @@ dependencies {
api project(":foudations:mogo-commons")
api project(':services:mogo-service-api')
}
annotationProcessor 'com.elegant.spi:compiler:1.0.3'
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -1,2 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.common" />
package="com.mogo.module.common" >
<application>
<receiver android:name=".datacenter.receiver.SnapShotMockTestPanelBroadCastReceiver">
<intent-filter>
<action android:name="com.loc.test_panel_control" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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) {
}
}
}

View File

@@ -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;
}

View File

@@ -35,7 +35,7 @@ import com.mogo.module.common.MogoModulePaths;
import com.mogo.module.common.entity.MarkerResponse;
import com.mogo.module.common.map.MapCenterPointStrategy;
import com.mogo.module.common.map.Scene;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.autopilot.AutoPilotRemoteController;
import com.mogo.module.service.handler.MainLooperHandler;
import com.mogo.module.service.handler.RefreshWorkThreadHandler;
@@ -1003,7 +1003,7 @@ public class MogoServices implements IMogoMapListener,
e.printStackTrace();
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}

View File

@@ -4,7 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.carinfo.CarStateInfo;
@@ -73,7 +73,7 @@ class ADASStatusIntentHandler implements IntentHandler {
data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() );
data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() );
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data );
SnapshotLocationController.getInstance().syncAdasLocationInfo( data );
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo( data );
} catch ( Exception e ) {
e.printStackTrace();
}

View File

@@ -33,7 +33,7 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.dialog.WMDialog;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.R;
import com.mogo.module.service.status.EnvStatusManager;
@@ -852,7 +852,7 @@ public class MockIntentHandler implements IntentHandler {
//改变rtk定位数据触发自车移动
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
Log.i("mock-timer-loc-map", "cost " + (System.currentTimeMillis() - start) + "ms");
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
Log.i("mock-timer-loc", "cost " + (System.currentTimeMillis() - start) + "ms");
Log.i("mock-timer-loc-info", jo.toString());
return true;

View File

@@ -9,7 +9,7 @@ import android.os.Bundle;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.service.locationinfo.CloudLocationInfo;
import com.mogo.utils.logger.Logger;
@@ -74,7 +74,7 @@ public class MogoRTKLocation {
cloudLocationInfo.setSystemTime(System.currentTimeMillis());
cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController()
.getTileId(location.getLongitude(), location.getLatitude())));
SnapshotLocationController.getInstance().syncLocationInfo(cloudLocationInfo);
SnapshotLocationDataCenter.getInstance().syncLocationInfo(cloudLocationInfo);
}
} else {
Logger.e(TAG, "location == null");

View File

@@ -13,7 +13,7 @@ import com.mogo.cloud.socket.entity.SocketDownData;
import com.mogo.commons.data.BaseData;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.uploadintime.SnapshotLocationController;
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.network.TimeDelayApiService;
import com.mogo.module.service.network.bean.MockSocketReceiverData;
@@ -100,7 +100,7 @@ public class TimeDelayUploadManager implements IMogoOnMessageListener<MockSocket
e.printStackTrace();
}
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
SnapshotLocationController.getInstance().syncAdasLocationInfo(jo);
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
mockHandler.sendEmptyMessageDelayed(MOCK_MSG, 50);
}
}