[add] SnapshotUploadInTime 类 缺少外部调用接口

This commit is contained in:
liujing
2021-01-21 11:34:55 +08:00
parent b00e553fd4
commit 787ca69217
5 changed files with 97 additions and 22 deletions

View File

@@ -25,6 +25,7 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation project(path: ':foudations:mogo-passport')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

View File

@@ -0,0 +1,31 @@
package com.mogo.realtime.InterfaceManager;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*/
public final class RealTimeApisHandler {
private static volatile RealTimeApisHandler sInstance;
private static volatile RealTimeServiceApis sApis;
public static RealTimeApisHandler getInstance() {
if (sInstance == null) {
synchronized (RealTimeApisHandler.class) {
sInstance = new RealTimeApisHandler();
}
}
return sInstance;
}
public RealTimeServiceApis getApis(){
if (sApis == null){
synchronized (this){
// sApis = new RealTimeServiceApis();
}
}
return sApis;
}
}

View File

@@ -0,0 +1,15 @@
package com.mogo.realtime.InterfaceManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
import java.util.List;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*/
public interface RealTimeServiceApis {
RecognizedResultProvider getRecognizedResultManager();
}

View File

@@ -0,0 +1,19 @@
package com.mogo.realtime.InterfaceManager;
import com.mogo.realtime.entity.ADASRecognizedResult;
import java.util.List;
/**
* @author liujing
* @description 描述
* @since: 2021/1/21
*/
public interface RecognizedResultProvider {
/**
* 获取 adas 识别列表
*
* @return
*/
List<ADASRecognizedResult> getLastADASRecognizedResult();
}

View File

@@ -1,7 +1,11 @@
package com.mogo.realtime.constant;
import android.content.Context;
import android.util.Log;
import com.mogo.cloud.passport.MoGoAiCloudClient;
import com.mogo.realtime.InterfaceManager.RealTimeApisHandler;
import com.mogo.realtime.InterfaceManager.RealTimeServiceApis;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.realtime.entity.CloudLocationInfo;
import com.mogo.realtime.location.LocationResult;
@@ -16,7 +20,7 @@ import java.util.logging.Logger;
/**
* @author congtaowang
* @since 2020/12/14
*
* <p>
* 实时上报坐标、识别物体
*/
public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener {
@@ -30,9 +34,9 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
}
public static SnapshotUploadInTime getInstance() {
if ( sInstance == null ) {
synchronized ( SnapshotUploadInTime.class ) {
if ( sInstance == null ) {
if (sInstance == null) {
synchronized (SnapshotUploadInTime.class) {
if (sInstance == null) {
sInstance = new SnapshotUploadInTime();
}
}
@@ -49,9 +53,9 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
return sInstance;
}
public void start( Context context ) {
public void start(Context context) {
mContext = context.getApplicationContext();
MogoRTKLocation.getInstance().registerRTKLocationListener( this );
MogoRTKLocation.getInstance().registerRTKLocationListener(this);
}
public void stop() {
@@ -60,51 +64,54 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
}
@Override
public void onLocationChanged( List< CloudLocationInfo > cloudLocationInfos ) {
startSendCarLocationAndAdasRecognizedResult2Server( cloudLocationInfos );
public void onLocationChanged(List<CloudLocationInfo> cloudLocationInfos) {
startSendCarLocationAndAdasRecognizedResult2Server(cloudLocationInfos);
}
private CloudLocationInfo mLastInfo;
private void startSendCarLocationAndAdasRecognizedResult2Server( List< CloudLocationInfo > cloudLocationInfo ) {
private void startSendCarLocationAndAdasRecognizedResult2Server(List<CloudLocationInfo> cloudLocationInfo) {
CloudLocationInfo lastInfo = null;
// 如果数组内容不为空,就用数组最后一个值
if ( cloudLocationInfo != null && !cloudLocationInfo.isEmpty() ) {
lastInfo = cloudLocationInfo.get( cloudLocationInfo.size() - 1 );
if (cloudLocationInfo != null && !cloudLocationInfo.isEmpty()) {
lastInfo = cloudLocationInfo.get(cloudLocationInfo.size() - 1);
mLastInfo = lastInfo;
}
if ( lastInfo == null ) {
if (lastInfo == null) {
lastInfo = mLastInfo;
}
LocationResult locationResult = null;
if ( lastInfo != null ) {
if (lastInfo != null) {
// 定位点预测纠偏
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct( lastInfo );
lastInfo = SimpleLocationCorrectStrategy.getInstance().correct(lastInfo);
locationResult = new LocationResult();
if ( lastInfo != null ) {
if (lastInfo != null) {
locationResult.lastCoordinate = lastInfo;
locationResult.mortonCode = MortonCode.wrapEncodeMorton( lastInfo.getLon(), lastInfo.getLat() );
locationResult.mortonCode = MortonCode.wrapEncodeMorton(lastInfo.getLon(), lastInfo.getLat());
}
// locationResult.coordinates = new ArrayList<>();
locationResult.sn = com.mogo.commons.network.Utils.getSn();
locationResult.sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
// if ( cloudLocationInfo == null ) {
// locationResult.coordinates.addAll( new ArrayList<>() );
// } else {
// locationResult.coordinates.addAll( cloudLocationInfo );
// }
}
List<ADASRecognizedResult> recognizedResults = null;//MarkerServiceHandler.getADASController().getLastADASRecognizedResult();//外显接口返回
List<ADASRecognizedResult> recognizedResults = RealTimeApisHandler.getInstance().getApis().getRecognizedResultManager().getLastADASRecognizedResult();//外显接口返回
OnePerSecondSendContent content = new OnePerSecondSendContent();
content.self = locationResult;
content.adas = recognizedResults;
if ( content.self == null &&
( content.adas == null || content.adas.isEmpty() ) ) {
Logger.d( TAG, "no information 2 sent" );
if (content.self == null &&
(content.adas == null || content.adas.isEmpty())) {
Log.d(TAG, "no information 2 sent");
return;
}
//备注
/*
等钟超SocketManagerSDK
*
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext ).sendMsg( content, new IMogoOnWebSocketMessageListener() {
@Override
public WebSocketMsgType getDownLinkType() {
@@ -116,5 +123,7 @@ public class SnapshotUploadInTime implements MogoRTKLocation.RTKLocationListener
return WebSocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
}
} );
*/
}
}