远程控制adas
This commit is contained in:
@@ -39,6 +39,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.service.autopilot.AutoPilotRemoteController;
|
||||
import com.mogo.module.service.intent.IntentHandlerFactory;
|
||||
import com.mogo.module.service.launchercard.LauncherCardRefresher;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
@@ -54,6 +55,7 @@ import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.module.service.strategy.CarIconDisplayStrategy;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -422,6 +424,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( DebugConfig.isLaunchLocationService() ) {
|
||||
initLocationServiceProcess( context );
|
||||
}
|
||||
|
||||
AutoPilotRemoteController.getInstance().start();
|
||||
}
|
||||
|
||||
private void initLocationServiceProcess( Context context ) {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.module.service.autopilot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/16
|
||||
*
|
||||
* 自动驾驶参数
|
||||
*/
|
||||
class AutoPilotParameters {
|
||||
|
||||
public AutoPilotLonLat startLatLon;
|
||||
public List< AutoPilotLonLat > wayLatLons;
|
||||
public AutoPilotLonLat endLatLon;
|
||||
public float speedLimit;
|
||||
|
||||
public static class AutoPilotLonLat {
|
||||
public double lat;
|
||||
public double lon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.mogo.module.service.autopilot;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/16
|
||||
*
|
||||
* 远端控制自动驾驶
|
||||
*/
|
||||
class AutoPilotRemoteController {
|
||||
|
||||
private static final String TAG = "AutoPilotRemoteController";
|
||||
|
||||
private static volatile AutoPilotRemoteController sInstance;
|
||||
|
||||
private IMogoSocketManager mMogoSocketManager;
|
||||
|
||||
private IMogoOnMessageListener< AutoPilotParameters > mParametersListener = new IMogoOnMessageListener< AutoPilotParameters >() {
|
||||
@Override
|
||||
public Class< AutoPilotParameters > target() {
|
||||
return AutoPilotParameters.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived( AutoPilotParameters obj ) {
|
||||
if ( obj == null ) {
|
||||
Logger.e( TAG, "远端控制参数为null", new NullPointerException() );
|
||||
return;
|
||||
}
|
||||
String json = GsonUtil.jsonFromObject( obj );
|
||||
Logger.d( TAG, json );
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().notifyAdas( json );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 远端控制自动驾驶的消息类型
|
||||
*/
|
||||
public static final int MSG_TYPE_REMOTE_CONTROL_AUTOPILOT = 401014;
|
||||
|
||||
private AutoPilotRemoteController() {
|
||||
mMogoSocketManager = MogoApisHandler.getInstance().getApis().getSocketManagerApi( AbsMogoApplication.getApp() );
|
||||
}
|
||||
|
||||
public static AutoPilotRemoteController getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AutoPilotRemoteController.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AutoPilotRemoteController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mMogoSocketManager.registerOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
if ( mMogoSocketManager != null ) {
|
||||
mMogoSocketManager.unregisterOnMessageListener( MSG_TYPE_REMOTE_CONTROL_AUTOPILOT, mParametersListener );
|
||||
}
|
||||
mMogoSocketManager = null;
|
||||
mParametersListener = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user