优化显示逻辑
This commit is contained in:
@@ -416,7 +416,7 @@ public class DebugConfig {
|
||||
DebugConfig.sIsNotSmooth = sIsNotSmooth;
|
||||
}
|
||||
|
||||
public static boolean isOCHModule(){
|
||||
public static boolean isOCHModule() {
|
||||
return sProductFlavor != null && sProductFlavor.startsWith( "foch" );
|
||||
}
|
||||
|
||||
@@ -429,4 +429,39 @@ public class DebugConfig {
|
||||
public static int getSelfCarSpeedYOffset() {
|
||||
return sSelfCarSpeedYOffset;
|
||||
}
|
||||
|
||||
// 环境状态
|
||||
public static final int sLocation = 0;
|
||||
public static final int sAdasRecognized = 1;
|
||||
public static final int sDownloadSnapshot = 2;
|
||||
public static final int sAutoPilotStatus = 3;
|
||||
public static final int sDownloadLink = 4;
|
||||
|
||||
public static String[] sStatus = new String[]{
|
||||
"false",
|
||||
"false",
|
||||
"false",
|
||||
"0",
|
||||
"false"
|
||||
};
|
||||
|
||||
public synchronized static void setStatus( int type, boolean status ) {
|
||||
sStatus[type] = String.valueOf( status );
|
||||
}
|
||||
|
||||
public synchronized static void setAutoPilotStatus( String status ) {
|
||||
sStatus[sAutoPilotStatus] = status;
|
||||
}
|
||||
|
||||
public synchronized static String getAutoPilotStatus() {
|
||||
return sStatus[sAutoPilotStatus];
|
||||
}
|
||||
|
||||
public synchronized static String getStatus( int type, boolean set2False ) {
|
||||
String result = sStatus[type];
|
||||
if ( set2False ) {
|
||||
sStatus[type] = "false";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ class DialogImpl implements IWindowManagerView {
|
||||
public void update(WindowManagerView.WMViewParams params) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
/*
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.mogo.module.common.wm;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
interface IWindowManagerView {
|
||||
public interface IWindowManagerView {
|
||||
/**
|
||||
* 初始化
|
||||
*
|
||||
@@ -33,12 +33,17 @@ interface IWindowManagerView {
|
||||
*/
|
||||
void update(WindowManagerView.WMViewParams params);
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
*/
|
||||
void update();
|
||||
|
||||
/**
|
||||
* 隐藏
|
||||
*/
|
||||
void hide();
|
||||
|
||||
interface OnViewClickListener {
|
||||
public interface OnViewClickListener {
|
||||
void onClick( View view, float xPos, float yPos );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,13 @@ class WindowManagerImpl implements IWindowManagerView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if ( isShowing ) {
|
||||
mWindowManager.updateViewLayout(rootView,mLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
if ( isShowing && mParams != null ) {
|
||||
|
||||
@@ -127,4 +127,10 @@ public class WindowManagerView {
|
||||
}
|
||||
}
|
||||
|
||||
public void update(){
|
||||
if ( mManagerView != null) {
|
||||
mManagerView.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.status.EnvStatusManager;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
@@ -623,6 +624,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 100, 0L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 101, 1000L );
|
||||
break;
|
||||
case 52:
|
||||
EnvStatusManager.getInstance().showPanel( context );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,11 +138,12 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(new IMogoCloudOnMsgListener() {
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
DebugConfig.setStatus( DebugConfig.sDownloadLink, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(MogoSnapshotSetData mogoSnapshotSetData) {
|
||||
DebugConfig.setStatus( DebugConfig.sDownloadSnapshot, true );
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData(mogoSnapshotSetData);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.mogo.module.service.status;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/17
|
||||
*
|
||||
* 环境状态
|
||||
*/
|
||||
class EnvStatusManager {
|
||||
|
||||
private static volatile EnvStatusManager sInstance;
|
||||
|
||||
private EnvStatusManager() {
|
||||
}
|
||||
|
||||
public static EnvStatusManager getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( EnvStatusManager.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new EnvStatusManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WindowManagerView mPanelView;
|
||||
private TextView mStatusTv;
|
||||
private Handler mMainHandler = new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( mPanelView.isShowing() ) {
|
||||
renderStatus();
|
||||
mMainHandler.sendEmptyMessageDelayed( MSG, 5_000L );
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final int MSG = 10000;
|
||||
|
||||
private void renderStatus() {
|
||||
String[] sStatusName = {
|
||||
"定位",
|
||||
"近景",
|
||||
"下发",
|
||||
"AUTO",
|
||||
"长链"
|
||||
};
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for ( int i = 0; i < sStatusName.length; i++ ) {
|
||||
stringBuilder.append( sStatusName[i] ).append( ":" );
|
||||
if ( i != 3 ) {
|
||||
stringBuilder.append( "true".equals( DebugConfig.getStatus( i, true ) ) ? "正常" : "异常" ).append( "\n" );
|
||||
} else {
|
||||
stringBuilder.append( DebugConfig.getAutoPilotStatus() ).append( "\n" );
|
||||
}
|
||||
}
|
||||
mStatusTv.setText( stringBuilder );
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
mStatusTv.setTextColor( Color.WHITE );
|
||||
} else {
|
||||
if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi()
|
||||
.getCurrentSkinMode() == EnumMapUI.Type_Light ) {
|
||||
mStatusTv.setTextColor( Color.BLACK );
|
||||
} else {
|
||||
mStatusTv.setTextColor( Color.WHITE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showPanel( Context context ) {
|
||||
if ( mPanelView == null ) {
|
||||
mPanelView = new WindowManagerView.Builder( context )
|
||||
.contentView( R.layout.module_services_status_panel )
|
||||
.position( 0, 100 )
|
||||
.size( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT )
|
||||
.gravity( Gravity.TOP )
|
||||
.showInWindowManager();
|
||||
mPanelView.attachTouchEvent( ( ( view, xPos, yPos ) -> {
|
||||
closePanel();
|
||||
} ) );
|
||||
mPanelView.findViewById( R.id.module_services_status_iv ).setOnClickListener( view -> {
|
||||
closePanel();
|
||||
} );
|
||||
mStatusTv = mPanelView.findViewById( R.id.module_services_status_tv );
|
||||
mMainHandler.sendEmptyMessageDelayed( MSG, 0L );
|
||||
}
|
||||
mPanelView.show();
|
||||
}
|
||||
|
||||
public void closePanel() {
|
||||
if ( mPanelView != null ) {
|
||||
mPanelView.dismiss();
|
||||
mMainHandler.removeMessages( MSG );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.module.service.uploadintime;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.realtime.entity.CloudLocationInfo;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -74,6 +75,7 @@ class SnapshotLocationController {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
DebugConfig.setStatus( DebugConfig.sLocation, true );
|
||||
Logger.d( TAG, "同步到rtk数据" );
|
||||
double lon = data.optDouble( "lon", -1 );
|
||||
double lat = data.optDouble( "lat", -1 );
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="90px"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_services_status_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="90px"
|
||||
android:textColor="#000"
|
||||
android:textSize="40px" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_services_status_iv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:src="@drawable/module_common_icon_close_vr" />
|
||||
</FrameLayout>
|
||||
@@ -112,49 +112,17 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
private IMogoAdasCarDataCallback mMogoAdasCarDataCallback;
|
||||
|
||||
private List< AdasAIDLOwnerCarRectModel > mLastFrameData;
|
||||
private List< AdasAIDLOwnerCarRectModel > mLastFrameDatums;
|
||||
|
||||
/**
|
||||
* 接收 adas 识别数据线程
|
||||
*/
|
||||
private Handler mAdasRecognizedRecHandler = new Handler( WorkThreadHandler.newInstance( "AdasRecognizedRecThread" ).getLooper() ){
|
||||
private Handler mAdasRecognizedRecHandler = new Handler( WorkThreadHandler.newInstance( "AdasRecognizedRecThread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.obj instanceof RectInfo ) {
|
||||
RectInfo rectInfo = ( ( RectInfo ) msg.obj );
|
||||
List< AdasAIDLOwnerCarRectModel > data = new ArrayList<>();
|
||||
if ( rectInfo != null && rectInfo.getModels() != null && !rectInfo.getModels().isEmpty() ) {
|
||||
List< RectInfo.RectBean > beans = rectInfo.getModels();
|
||||
for ( RectInfo.RectBean bean : beans ) {
|
||||
if ( bean == null ) {
|
||||
continue;
|
||||
}
|
||||
AdasAIDLOwnerCarRectModel model = new AdasAIDLOwnerCarRectModel();
|
||||
model.setId( bean.getId() );
|
||||
model.setXl( bean.getXl() );
|
||||
model.setXr( bean.getXr() );
|
||||
model.setYb( bean.getYb() );
|
||||
model.setYt( bean.getYt() );
|
||||
model.setDistance_x( bean.getDistance_x() );
|
||||
model.setDistance_y( bean.getDistance_y() );
|
||||
model.setType( bean.getType() );
|
||||
model.setLat( bean.getLat() );
|
||||
model.setLon( bean.getLon() );
|
||||
model.setHeading( bean.getHeading() );
|
||||
model.setSystemTime( bean.getSystemTime() );
|
||||
model.setSatelliteTime( bean.getSatelliteTime() );
|
||||
model.setAlt( bean.getAlt() );
|
||||
model.setCarId( bean.getCarId() );
|
||||
model.setUuid( bean.getUuid() );
|
||||
model.setColor( bean.getColor() );
|
||||
model.setSpeed( bean.getSpeed() );
|
||||
model.setDataAccuracy( bean.getDataAccuracy() );
|
||||
model.setDistance( bean.getDistance() );
|
||||
data.add( model );
|
||||
}
|
||||
}
|
||||
mAutopolitDataCallBack.notifyOwnerCarRect( data );
|
||||
if ( msg.obj instanceof List ) {
|
||||
mAutopolitDataCallBack.notifyOwnerCarRect( ( List< AdasAIDLOwnerCarRectModel > ) msg.obj );
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -162,7 +130,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
/**
|
||||
* 接收 adas 定位数据线程
|
||||
*/
|
||||
private Handler mAdasLocationRecHandler = new Handler( WorkThreadHandler.newInstance( "AdasLocationRecThread" ).getLooper() ){
|
||||
private Handler mAdasLocationRecHandler = new Handler( WorkThreadHandler.newInstance( "AdasLocationRecThread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
@@ -185,9 +153,52 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void onRectData( RectInfo rectInfo ) {
|
||||
|
||||
List< AdasAIDLOwnerCarRectModel > data = new ArrayList<>();
|
||||
if ( rectInfo != null && rectInfo.getModels() != null && !rectInfo.getModels().isEmpty() ) {
|
||||
List< RectInfo.RectBean > beans = rectInfo.getModels();
|
||||
for ( RectInfo.RectBean bean : beans ) {
|
||||
if ( bean == null ) {
|
||||
continue;
|
||||
}
|
||||
AdasAIDLOwnerCarRectModel model = new AdasAIDLOwnerCarRectModel();
|
||||
model.setId( bean.getId() );
|
||||
model.setXl( bean.getXl() );
|
||||
model.setXr( bean.getXr() );
|
||||
model.setYb( bean.getYb() );
|
||||
model.setYt( bean.getYt() );
|
||||
model.setDistance_x( bean.getDistance_x() );
|
||||
model.setDistance_y( bean.getDistance_y() );
|
||||
model.setType( bean.getType() );
|
||||
model.setLat( bean.getLat() );
|
||||
model.setLon( bean.getLon() );
|
||||
model.setHeading( bean.getHeading() );
|
||||
model.setSystemTime( bean.getSystemTime() );
|
||||
model.setSatelliteTime( bean.getSatelliteTime() );
|
||||
model.setAlt( bean.getAlt() );
|
||||
model.setCarId( bean.getCarId() );
|
||||
model.setUuid( bean.getUuid() );
|
||||
model.setColor( bean.getColor() );
|
||||
model.setSpeed( bean.getSpeed() );
|
||||
model.setDataAccuracy( bean.getDataAccuracy() );
|
||||
model.setDistance( bean.getDistance() );
|
||||
data.add( model );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mLastFrameDatums == null ) {
|
||||
mLastFrameDatums = new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
mLastFrameDatums.addAll( data );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
|
||||
Message message = mAdasRecognizedRecHandler.obtainMessage();
|
||||
message.obj = rectInfo;
|
||||
message.obj = data;
|
||||
message.sendToTarget();
|
||||
DebugConfig.setStatus( DebugConfig.sAdasRecognized, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -400,6 +411,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
@Override
|
||||
public void notifyAutopilotState( AdasAIDLAutopilotStateModel autopilotStateModel ) {
|
||||
Logger.d( TAG, "notifyAutopilotState: " + autopilotStateModel );
|
||||
DebugConfig.setAutoPilotStatus( autopilotStateModel.getState() + "" );
|
||||
if ( mAdasOCHCallback != null ) {
|
||||
mAdasOCHCallback.onStateChanged( autopilotStateModel.getState(), autopilotStateModel.getReason() );
|
||||
}
|
||||
@@ -421,14 +433,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
// 物体识别返回
|
||||
Logger.d( TAG, "ADAS-REC-received data: size = %s", ownerCarStateRectList == null ? 0 : ownerCarStateRectList.size() );
|
||||
final long start = System.currentTimeMillis();
|
||||
if ( mLastFrameData == null ) {
|
||||
mLastFrameData = new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
mLastFrameData.addAll( ownerCarStateRectList );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if ( !SingletonsHolder.get( IMogoStatusManager.class ).isVrMode() ) {
|
||||
return;
|
||||
@@ -706,12 +710,12 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public List< ADASRecognizedResult > getLastADASRecognizedResult() {
|
||||
if ( mLastFrameData == null ) {
|
||||
if ( mLastFrameDatums == null ) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
List< AdasAIDLOwnerCarRectModel > data = new ArrayList<>( mLastFrameData );
|
||||
mLastFrameData = null;
|
||||
List< AdasAIDLOwnerCarRectModel > data = mLastFrameDatums;
|
||||
mLastFrameDatums = null;
|
||||
List< ADASRecognizedResult > recognizedResultList;
|
||||
recognizedResultList = AdasObjectUtils.regroupData( data );
|
||||
return recognizedResultList;
|
||||
|
||||
Reference in New Issue
Block a user