dev
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.mogo.service.impl.adas;
|
||||
|
||||
import com.mogo.commons.utils.MortonCode;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/25
|
||||
*
|
||||
* 对象转换类
|
||||
*/
|
||||
class AdasObjectUtils {
|
||||
|
||||
public static ADASWarnMessage fromAdasObject( WarnMessageInfo info ) {
|
||||
if ( info == null ) {
|
||||
return null;
|
||||
}
|
||||
ADASWarnMessage warnMessage = new ADASWarnMessage();
|
||||
warnMessage.content = info.getContent();
|
||||
warnMessage.level = info.getLevel();
|
||||
try {
|
||||
warnMessage.type = Integer.valueOf( info.getType() );
|
||||
} catch ( NumberFormatException e ) {
|
||||
return null;
|
||||
}
|
||||
warnMessage.value = info.getValue();
|
||||
return warnMessage;
|
||||
}
|
||||
|
||||
public static List< ADASRecognizedResult > fromAdasObject( RectInfo rectInfo ) {
|
||||
if ( rectInfo == null
|
||||
|| rectInfo.getModels() == null
|
||||
|| rectInfo.getModels().isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List< ADASRecognizedResult > recognizedResults = new ArrayList<>();
|
||||
for ( RectInfo.RectBean model : rectInfo.getModels() ) {
|
||||
try {
|
||||
ADASRecognizedResult result = fromAdasObject( model );
|
||||
if ( result != null ) {
|
||||
recognizedResults.add( result );
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return recognizedResults;
|
||||
}
|
||||
|
||||
public static ADASRecognizedResult fromAdasObject( RectInfo.RectBean rectBean ) {
|
||||
if ( rectBean == null ) {
|
||||
return null;
|
||||
}
|
||||
ADASRecognizedResult result = new ADASRecognizedResult();
|
||||
result.uuid = rectBean.getUuid();
|
||||
result.lat = rectBean.getLat();
|
||||
result.lon = rectBean.getLon();
|
||||
result.type = Integer.valueOf( rectBean.getType() );
|
||||
result.heading = rectBean.getHeading();
|
||||
result.systemTime = Long.valueOf( rectBean.getSystemTime() );
|
||||
result.satelliteTime = Long.valueOf( rectBean.getSatelliteTime() );
|
||||
result.alt = rectBean.getAlt();
|
||||
result.color = rectBean.getColor();
|
||||
result.speed = rectBean.getSpeed();
|
||||
result.cardId = rectBean.getCarId();
|
||||
result.mortonCode = MortonCode.encodeMorton( result.lon, result.lat );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,10 @@ import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.adas.IMogoAdasDataCallback;
|
||||
import com.mogo.service.adas.IMogoAdasWarnMessageCallback;
|
||||
import com.mogo.service.adas.RemoteControlAutoPilotParameters;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
import com.mogo.service.adas.entity.ADASWarnMessage;
|
||||
import com.mogo.service.impl.singleton.SingletonsHolder;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
@@ -36,7 +39,9 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static com.mogo.module.common.utils.SPConst.getSpGuide;
|
||||
|
||||
@@ -65,7 +70,18 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
private boolean mIsReleased = true;
|
||||
|
||||
private List< IMogoAdasDataCallback > mAdasDataCallbackList = new ArrayList<>();
|
||||
/**
|
||||
* 获取adas前车距离
|
||||
*/
|
||||
private List< IMogoAdasDataCallback > mAdasDataCallbackList = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* adas 报警数据回调
|
||||
*/
|
||||
private List< IMogoAdasWarnMessageCallback > mMogoAdasWarnMessageCallbackList = new CopyOnWriteArrayList<>();
|
||||
|
||||
|
||||
private RectInfo mLastFrameData;
|
||||
|
||||
private OnAdasListener mOnAdasListener = new OnAdasListenerAdapter() {
|
||||
|
||||
@@ -73,16 +89,35 @@ public class MogoADASController implements IMogoADASController {
|
||||
public void onRectData( RectInfo rectInfo ) {
|
||||
// 物体识别返回
|
||||
Logger.d( TAG, "onRectData = %s", rectInfo.toString() );
|
||||
mLastFrameData = rectInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarnMessage( WarnMessageInfo warnMessageInfo ) {
|
||||
if ( warnMessageInfo == null ) {
|
||||
return;
|
||||
}
|
||||
// 警告消息
|
||||
Logger.d( TAG, "onWarnMessage = %s", warnMessageInfo.toString() );
|
||||
if ( mMogoAdasWarnMessageCallbackList.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
final ADASWarnMessage warnMessage = AdasObjectUtils.fromAdasObject( warnMessageInfo );
|
||||
if ( warnMessage == null ) {
|
||||
return;
|
||||
}
|
||||
UiThreadHandler.post( () -> {
|
||||
Iterator< IMogoAdasWarnMessageCallback > iMogoAdasWarnMessageCallbackIterator = mMogoAdasWarnMessageCallbackList.iterator();
|
||||
while ( iMogoAdasWarnMessageCallbackIterator.hasNext() ) {
|
||||
IMogoAdasWarnMessageCallback callback = iMogoAdasWarnMessageCallbackIterator.next();
|
||||
if ( callback != null ) {
|
||||
callback.onReceiveData( warnMessage );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private MyMessageFactory mAdasMessageFactory;
|
||||
private IAutopolitDataCallBack mAutoPilotDataCallBack = new IAutopolitDataCallBack() {
|
||||
@Override
|
||||
@@ -297,11 +332,44 @@ public class MogoADASController implements IMogoADASController {
|
||||
|
||||
@Override
|
||||
public void addAdasDataCallback( IMogoAdasDataCallback callback ) {
|
||||
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mAdasDataCallbackList.contains( callback ) ) {
|
||||
mAdasDataCallbackList.add( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAdasDataCallback( IMogoAdasDataCallback callback ) {
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
mAdasDataCallbackList.remove( callback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdasWarnMessageCallback( IMogoAdasWarnMessageCallback callback ) {
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !mMogoAdasWarnMessageCallbackList.contains( callback ) ) {
|
||||
mMogoAdasWarnMessageCallbackList.add( callback );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAdasWarnMessageCallback( IMogoAdasWarnMessageCallback callback ) {
|
||||
if ( callback == null ) {
|
||||
return;
|
||||
}
|
||||
mMogoAdasWarnMessageCallbackList.remove( callback );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< ADASRecognizedResult > getLastADASRecognizedResult() {
|
||||
RectInfo rectInfo = mLastFrameData;
|
||||
List< ADASRecognizedResult > recognizedResultList = AdasObjectUtils.fromAdasObject( rectInfo );
|
||||
return recognizedResultList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ public class MogoStatusManager implements IMogoStatusManager {
|
||||
return get_bool_val( StatusDescriptor.VOICE_UI );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVrMode() {
|
||||
return get_bool_val(StatusDescriptor.VR_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isADASShow() {
|
||||
return get_bool_val( StatusDescriptor.ADAS_UI );
|
||||
@@ -127,6 +132,11 @@ public class MogoStatusManager implements IMogoStatusManager {
|
||||
return val == null ? false : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVrMode(String tag, boolean vrMode) {
|
||||
doSetStatus(tag, StatusDescriptor.VR_MODE, vrMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoiceUIShow( String tag, boolean show ) {
|
||||
doSetStatus( tag, StatusDescriptor.VOICE_UI, show );
|
||||
|
||||
Reference in New Issue
Block a user