adas数据通路完善
This commit is contained in:
@@ -16,7 +16,7 @@ import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.adas.AdasListenerAdapter;
|
||||
import com.mogo.module.adas.AdasDataListener;
|
||||
import com.mogo.module.adas.AdasProvider;
|
||||
import com.mogo.module.adas.AdasStatusListener;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
@@ -48,12 +48,12 @@ import com.zhidao.adasconfig.common.config.EnumCarChatIncognitoMode;
|
||||
import com.zhidao.adasconfig.common.config.EnumCarHeading;
|
||||
import com.zhidao.adasconfig.common.config.EnumSkinStyle;
|
||||
import com.zhidao.autopilot.support.api.AutopilotServiceManage;
|
||||
import com.zhidao.autopilot.support.api.IAutopilotServiceStatusListener;
|
||||
import com.zhidao.autopilot.support.api.IAutopolitDataCallBack;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotArriveModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLAutopilotStateModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarRectModel;
|
||||
import com.zhidao.autopilotservice.model.AdasAIDLOwnerCarStateModel;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.msg.MyMessageFactory;
|
||||
@@ -94,7 +94,8 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
private boolean mIsReleased = true;
|
||||
|
||||
private IAutopolitDataCallBack mAutopolitDataCallBack;
|
||||
//private IAutopolitDataCallBack mAutopolitDataCallBack;
|
||||
private AdasDataListener mAdasDataListener;
|
||||
|
||||
/**
|
||||
* 获取adas前车距离
|
||||
@@ -123,9 +124,9 @@ public class MogoADASController implements IMogoADASController {
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.obj instanceof List ) {
|
||||
mAutopolitDataCallBack.notifyOwnerCarRect( ( List< AdasAIDLOwnerCarRectModel > ) msg.obj );
|
||||
mAdasDataListener.notifyOwnerCarRect( ( List< AdasAIDLOwnerCarRectModel > ) msg.obj );
|
||||
} else if(msg.obj == null ){
|
||||
mAutopolitDataCallBack.notifyOwnerCarRect( null );
|
||||
mAdasDataListener.notifyOwnerCarRect( null );
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -158,8 +159,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
};
|
||||
|
||||
//private final OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
|
||||
private final AdasListenerAdapter mOnAdasListener = new AdasListenerAdapter() {
|
||||
private final OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
|
||||
|
||||
@Override
|
||||
public void onRectData( RectInfo rectInfo ) {
|
||||
@@ -325,6 +325,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
} );*/
|
||||
invokeShowADASOperation();
|
||||
|
||||
/*
|
||||
if ( mAutopolitDataCallBack == null ) {
|
||||
mAutopolitDataCallBack = new IAutopolitDataCallBack() {
|
||||
@Override
|
||||
@@ -468,6 +469,151 @@ public class MogoADASController implements IMogoADASController {
|
||||
}
|
||||
};
|
||||
AutopilotServiceManage.getInstance().registerAutopilotDataListener( mAutopolitDataCallBack );
|
||||
*/
|
||||
|
||||
if ( mAdasDataListener == null ) {
|
||||
mAdasDataListener = new AdasDataListener() {
|
||||
@Override
|
||||
public void sendMsg( String msg ) {
|
||||
for ( IMogoAdasDataCallback callback : mAdasDataCallbackList ) {
|
||||
try {
|
||||
callback.onAdasDataCallback( msg );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "sendMsg" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cameraEyeDetectResult( String detectResult ) {
|
||||
|
||||
try {
|
||||
JSONObject jsonObjectWs = new JSONObject( detectResult );
|
||||
String action = jsonObjectWs.optString( "action" );
|
||||
if ( TextUtils.isEmpty( action ) ) {
|
||||
Logger.w( TAG, "--->action is null" );
|
||||
return;
|
||||
}
|
||||
//识别的他车移动操作
|
||||
mAdasMessageFactory.createMessage( action ).handlerMsg( GsonUtil.getGson(), mOnAdasListener, detectResult );
|
||||
} catch ( JSONException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectCarModelUrl( String carStyleUrl ) {
|
||||
Logger.d( TAG, "selectCarModelUrl: " + carStyleUrl );
|
||||
needEmphasizeMyLocation = true;
|
||||
// 修改自车图标展示
|
||||
SharedPrefsMgr.getInstance( context ).putString( "MY_LOCATION_CONFIG", carStyleUrl );
|
||||
SingletonsHolder.get( IMogoDataManager.class ).syncData( "ADAS", carStyleUrl );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestGetCarModelListInfo() {
|
||||
if ( DebugConfig.isMapBased() ) {
|
||||
Logger.d( TAG, "requestGetCarModelListInfo" );
|
||||
// 向adas发送车模list
|
||||
String carModelList = SharedPrefsMgr.getInstance( context ).getString( "CAR_MODEL_LIST", "" );
|
||||
if ( carModelList != null && !carModelList.isEmpty() ) {
|
||||
AutopilotServiceManage.getInstance().settingCarModelListInfo( carModelList );
|
||||
}
|
||||
// 此处进行网络请求,请求成功后再通知一次adas
|
||||
requestCarModelList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clickSettingBack() {
|
||||
if ( needEmphasizeMyLocation ) {
|
||||
SingletonsHolder.get( IMogoDataManager.class ).syncData( "ADAS", null );
|
||||
}
|
||||
needEmphasizeMyLocation = false;
|
||||
|
||||
useTestSn = !useTestSn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showToast( String msg ) {
|
||||
UiThreadHandler.post( () -> TipToast.tip( msg ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autopilotArrive( AdasAIDLAutopilotArriveModel autopilotArriveModel ) {
|
||||
if ( autopilotArriveModel == null ) {
|
||||
return;
|
||||
}
|
||||
if ( mAdasOCHCallback != null ) {
|
||||
mAdasOCHCallback.onArriveAt( new AdasOCHData(
|
||||
autopilotArriveModel.getCarType(),
|
||||
autopilotArriveModel.getLon(),
|
||||
autopilotArriveModel.getLat() )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ownerCarStateInfo( String ownerCarStateInfo ) {
|
||||
Message message = mAdasLocationRecHandler.obtainMessage();
|
||||
message.obj = ownerCarStateInfo;
|
||||
message.sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOwnerCarState( AdasAIDLOwnerCarStateModel ownerCarStateModel ) {
|
||||
ADASCarStateInfo stateInf = new ADASCarStateInfo();
|
||||
stateInf.setAction( "state" );
|
||||
ADASCarStateInfo.ValuesBean bean = new ADASCarStateInfo.ValuesBean();
|
||||
bean.setSatelliteTime( ownerCarStateModel.getSatelliteTime() );
|
||||
bean.setAcceleration( ownerCarStateModel.getAcceleration() );
|
||||
bean.setAlt( ownerCarStateModel.getAlt() );
|
||||
bean.setGnss_speed( ownerCarStateModel.getGnss_speed() );
|
||||
bean.setHeading( ownerCarStateModel.getHeading() );
|
||||
bean.setLat( ownerCarStateModel.getLat() );
|
||||
bean.setLon( ownerCarStateModel.getLon() );
|
||||
bean.setReceiverDataTime( ownerCarStateModel.getReceiverDataTime() );
|
||||
bean.setSystemTime( ownerCarStateModel.getSystemTime() );
|
||||
bean.setYaw_rate( ownerCarStateModel.getYaw_rate() );
|
||||
stateInf.setValues( bean );
|
||||
mLastLon = ownerCarStateModel.getLon();
|
||||
mLastLat = ownerCarStateModel.getLat();
|
||||
mSpeed = ownerCarStateModel.getGnss_speed();
|
||||
if ( mMogoAdasCarDataCallback != null ) {
|
||||
mMogoAdasCarDataCallback.onAdasCarDataCallback( stateInf );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAutopilotState( AdasAIDLAutopilotStateModel autopilotStateModel ) {
|
||||
Logger.d( TAG, "notifyAutopilotState: " + autopilotStateModel );
|
||||
DebugConfig.setAutoPilotStatus( autopilotStateModel.getState() + "" );
|
||||
if ( mAdasOCHCallback != null ) {
|
||||
mAdasOCHCallback.onStateChanged( autopilotStateModel.getState(), autopilotStateModel.getReason() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOwnerCarRect( List< AdasAIDLOwnerCarRectModel > ownerCarStateRectList ) {
|
||||
// 物体识别返回
|
||||
Logger.d( TAG, "ADAS-REC-received data: size = %s", ownerCarStateRectList == null ? 0 : ownerCarStateRectList.size() );
|
||||
final long start = System.currentTimeMillis();
|
||||
// 仅在 vr 模式下显示 adas 识别车辆
|
||||
if ( !SingletonsHolder.get( IMogoStatusManager.class ).isVrMode() ) {
|
||||
return;
|
||||
}
|
||||
if ( !SingletonsHolder.get( IMogoStatusManager.class ).isMainPageLaunched() ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
handleAdasRecognizedData( ownerCarStateRectList );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Logger.i( "ADAS-REC-timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
}
|
||||
};
|
||||
adasProvider.addAdasEventListener(mAdasDataListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,7 +839,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
@Override
|
||||
public void release() {
|
||||
mIsReleased = true;
|
||||
AutopilotServiceManage.getInstance().unRegisterAutopilotDataListener( mAutopolitDataCallBack );
|
||||
//AutopilotServiceManage.getInstance().unRegisterAutopilotDataListener( mAutopolitDataCallBack );
|
||||
AutopilotServiceManage.getInstance().release();
|
||||
}
|
||||
|
||||
@@ -861,6 +1007,6 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void mockAdasRecognized( String json ) {
|
||||
mAutopolitDataCallBack.cameraEyeDetectResult( json );
|
||||
mAdasDataListener.cameraEyeDetectResult( json );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.service.impl.adas;
|
||||
|
||||
import com.mogo.module.adas.AdasListenerAdapter;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
|
||||
|
||||
Reference in New Issue
Block a user