rebase
This commit is contained in:
@@ -2,12 +2,9 @@ package com.mogo.module.service;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
@@ -15,12 +12,9 @@ import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cloud.socket.IMogoSocketManager;
|
||||
import com.mogo.service.datamanager.IMogoDataManager;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.intent.IMogoIntentManager;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoActionManager;
|
||||
@@ -38,42 +32,30 @@ public class MarkerServiceHandler {
|
||||
private static final String TAG = "MarkerServiceHandler";
|
||||
|
||||
private static IMogoServiceApis sApis;
|
||||
|
||||
private static IMogoMapService sMapService;
|
||||
private static IMogoMarkerManager sMarkerManager;
|
||||
private static IMogoMapUIController sMapUIController;
|
||||
private static IMogoLocationClient sLocationClient;
|
||||
private static IMogoStatusManager sMogoStatusManager;
|
||||
private static IMogoImageloader sImageloader;
|
||||
private static IMogoSocketManager sMogoSocketManager;
|
||||
private static IMogoAnalytics sMogoAnalytics;
|
||||
private static IMogoRegisterCenter sRegisterCenter;
|
||||
private static IMogoActionManager sActionManager;
|
||||
private static IMogoDataManager sDataManager;
|
||||
private static IMogoIntentManager sIntentManager;
|
||||
private static IMogoADASController sADASController;
|
||||
private static IMogoFragmentManager sFragmentManager;
|
||||
private static IMogoOverlayManager sIMogoOverlayManager;
|
||||
|
||||
public static synchronized void init( final Context context ) {
|
||||
|
||||
public static synchronized void init(final Context context) {
|
||||
sApis = MogoApisHandler.getInstance().getApis();
|
||||
sMapService = sApis.getMapServiceApi();
|
||||
sImageloader = sApis.getImageLoaderApi();
|
||||
sMogoStatusManager = sApis.getStatusManagerApi();
|
||||
sMogoSocketManager = sApis.getSocketManagerApi( context );
|
||||
sMogoAnalytics = sApis.getAnalyticsApi();
|
||||
sMarkerManager = sMapService.getMarkerManager( context );
|
||||
sIMogoOverlayManager = sMapService.getOverlayManager(context);
|
||||
sMarkerManager = sMapService.getMarkerManager(context);
|
||||
sMapUIController = sMapService.getMapUIController();
|
||||
sLocationClient = sMapService.getSingletonLocationClient( context );
|
||||
sRegisterCenter = sApis.getRegisterCenterApi();
|
||||
sActionManager = sApis.getActionManagerApi();
|
||||
sDataManager = sApis.getDataManagerApi();
|
||||
sIntentManager = sApis.getIntentManagerApi();
|
||||
sADASController = sApis.getAdasControllerApi();
|
||||
sFragmentManager = sApis.getFragmentManagerApi();
|
||||
MapMarkerManager.getInstance().init( context );
|
||||
MapMarkerManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
public static IMogoServiceApis getApis() {
|
||||
@@ -92,14 +74,6 @@ public class MarkerServiceHandler {
|
||||
return sMapUIController;
|
||||
}
|
||||
|
||||
public static IMogoImageloader getImageloader() {
|
||||
return sImageloader;
|
||||
}
|
||||
|
||||
public static IMogoSocketManager getMogoSocketManager() {
|
||||
return sMogoSocketManager;
|
||||
}
|
||||
|
||||
public static IMogoStatusManager getMogoStatusManager() {
|
||||
return sMogoStatusManager;
|
||||
}
|
||||
@@ -108,10 +82,6 @@ public class MarkerServiceHandler {
|
||||
return sMogoAnalytics;
|
||||
}
|
||||
|
||||
public static IMogoLocationClient getMogoLocationClient() {
|
||||
return sLocationClient;
|
||||
}
|
||||
|
||||
public static MapMarkerManager getMapMarkerManager() {
|
||||
return MapMarkerManager.getInstance();
|
||||
}
|
||||
@@ -128,10 +98,6 @@ public class MarkerServiceHandler {
|
||||
return sIntentManager;
|
||||
}
|
||||
|
||||
public static IMogoADASController getADASController() {
|
||||
return sADASController;
|
||||
}
|
||||
|
||||
public static IMogoFragmentManager getFragmentManager() {
|
||||
return sFragmentManager;
|
||||
}
|
||||
@@ -140,15 +106,6 @@ public class MarkerServiceHandler {
|
||||
return sDataManager;
|
||||
}
|
||||
|
||||
|
||||
public static IMogoOverlayManager getsIMogoOverlayManager() {
|
||||
return sIMogoOverlayManager;
|
||||
}
|
||||
|
||||
public static void setsIMogoOverlayManager(IMogoOverlayManager sIMogoOverlayManager) {
|
||||
MarkerServiceHandler.sIMogoOverlayManager = sIMogoOverlayManager;
|
||||
}
|
||||
|
||||
//TODO -------------以下方法是临时过度使用的,后面统一使用,getMapMarkerManager进行调用
|
||||
|
||||
/**
|
||||
@@ -158,8 +115,8 @@ public class MarkerServiceHandler {
|
||||
* @see MapMarkerManager#drawMapMarker(MarkerResponse)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void drawMapMarker( MarkerResponse response ) {
|
||||
getMapMarkerManager().drawMapMarker( response );
|
||||
public static void drawMapMarker(MarkerResponse response) {
|
||||
getMapMarkerManager().drawMapMarker(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,8 +126,8 @@ public class MarkerServiceHandler {
|
||||
* @see MapMarkerManager#drawMapMarker(MarkerShowEntity, int)
|
||||
*/
|
||||
@Deprecated
|
||||
public static IMogoMarker drawMapMarker( MarkerShowEntity markerShowEntity ) {
|
||||
return getMapMarkerManager().drawMapMarker( markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH );
|
||||
public static IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
|
||||
return getMapMarkerManager().drawMapMarker(markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +135,7 @@ public class MarkerServiceHandler {
|
||||
* 建议使用
|
||||
*/
|
||||
@Deprecated
|
||||
public static void highlightedMarker( String typeTag ) {
|
||||
Logger.w( TAG, "do not invoke this method any more." );
|
||||
public static void highlightedMarker(String typeTag) {
|
||||
Logger.w(TAG, "do not invoke this method any more.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.module.service.dispatch.DispatchAutoPilotManager;
|
||||
import com.mogo.module.service.routeoverlay.MogoRouteOverlayManager;
|
||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
@@ -98,12 +97,8 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init" );
|
||||
MarkerServiceHandler.init( context );
|
||||
// if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
// }
|
||||
// MogoRTKLocation.getInstance().init(); //todo RTK LOCATION Close
|
||||
MogoServices.getInstance().preInit( context );
|
||||
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
|
||||
DispatchAutoPilotManager.getInstance().initSocket(context);
|
||||
MogoRouteOverlayManager.getInstance(context).init();
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
}, 5_000L );
|
||||
|
||||
@@ -41,9 +41,7 @@ import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.service.refresh.AutoRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.CustomRefreshStrategy;
|
||||
import com.mogo.module.service.refresh.RefreshObject;
|
||||
import com.mogo.module.service.timedelay.TimeDelayUploadManager;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.fragmentmanager.FragmentStackTransactionListener;
|
||||
import com.mogo.service.fragmentmanager.IMogoFragmentManager;
|
||||
import com.mogo.service.intent.IMogoIntentListener;
|
||||
@@ -130,7 +128,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
private IMogoStatusManager mStatusManager;
|
||||
private IMogoIntentManager mIntentManager;
|
||||
private IMogoActionManager mActionManager;
|
||||
private IMogoADASController mADASController;
|
||||
private IMogoFragmentManager mFragmentManager;
|
||||
private IMogoRegisterCenter mRegisterCenter;
|
||||
|
||||
@@ -310,13 +307,11 @@ public class MogoServices implements IMogoMapListener,
|
||||
mActionManager = MarkerServiceHandler.getActionManager();
|
||||
|
||||
mIntentManager = MarkerServiceHandler.getIntentManager();
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTIION_ADAS, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_UI, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_NEXT, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_PREVIOUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_MY_LOCATION, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_READY, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOCK, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_BACK, this );
|
||||
@@ -325,7 +320,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this );
|
||||
mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
|
||||
|
||||
mADASController = MarkerServiceHandler.getADASController();
|
||||
mFragmentManager = MarkerServiceHandler.getFragmentManager();
|
||||
|
||||
mFragmentManager.addMainFragmentStackTransactionListener( this );
|
||||
@@ -337,7 +331,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
MoGoAiCloudRealTime.startRealTime( mContext, DebugConfig.getSocketAppId() );
|
||||
}
|
||||
TimeDelayUploadManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
@@ -389,17 +382,14 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
}
|
||||
filter.addAction( MogoReceiver.VOICE_ACTION );
|
||||
filter.addAction( MogoReceiver.ACTIION_ADAS );
|
||||
// 小智语音
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_UI );
|
||||
filter.addAction( MogoReceiver.ACTION_ADAS_STATUS );
|
||||
filter.addAction( MogoReceiver.ACTION_VOICE_READY );
|
||||
filter.addAction( MogoReceiver.ACTION_MOCK );
|
||||
filter.addAction( Intent.ACTION_CLOSE_SYSTEM_DIALOGS );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER );
|
||||
filter.addAction( MogoReceiver.ACTION_AUTO_NAVI_SEND );
|
||||
filter.addAction( MogoReceiver.ACTION_MOGO );
|
||||
filter.addAction( MogoReceiver.ACTION_TXZ_BLOCK_SEARCH );
|
||||
filter.addAction( ConnectivityManager.CONNECTIVITY_ACTION );
|
||||
try {
|
||||
context.getApplicationContext().registerReceiver( mAIAssistReceiver, filter );
|
||||
|
||||
@@ -100,19 +100,12 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String COMMAND_PREVIOUS = "com.zhidao.desk.previous";
|
||||
public static final String CMD_UN_WAKE_PREV = "CMD_UN_WAKE_PREV";
|
||||
public static final String[] CMD_UN_WAKE_PREV_UN_WAKE_WORDS = new String[]{
|
||||
"上一条"
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换卡片内容下一个
|
||||
*/
|
||||
public static final String COMMAND_NEXT = "com.zhidao.desk.next";
|
||||
public static final String CMD_UN_WAKE_NEXT = "CMD_UN_WAKE_NEXT";
|
||||
public static final String[] CMD_UN_WAKE_NEXT_UN_WAKE_WORDS = new String[]{
|
||||
"下一条",
|
||||
"换一个"
|
||||
};
|
||||
|
||||
/**
|
||||
* 查看多媒体卡片、探路卡片、在线车辆、首页、新鲜事
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean;
|
||||
|
||||
|
||||
public class DispatchAirportDialog extends DispatchBaseDialog {
|
||||
|
||||
private static final String TAG = "DispatchAirportDialog";
|
||||
private IDispatchRemindClickListener mListener;
|
||||
|
||||
private final TextView tvStartLoc;
|
||||
private final TextView tvEndLoc;
|
||||
private final TextView tvTaskTime;
|
||||
private final TextView tvFlightInfo;
|
||||
private final TextView tvTaskContent;
|
||||
|
||||
public DispatchAirportDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
setContentView(R.layout.module_dialog_adas_dispatch_airport);
|
||||
setCanceledOnTouchOutside(false);
|
||||
tvStartLoc = findViewById(R.id.module_services_dispatch_dialog_start_content);
|
||||
tvEndLoc = findViewById(R.id.module_services_dispatch_dialog_end_content);
|
||||
tvTaskTime = findViewById(R.id.module_services_dispatch_dialog_task_time);
|
||||
tvFlightInfo = findViewById(R.id.module_services_dispatch_dialog_flight_time);
|
||||
tvTaskContent = findViewById(R.id.module_services_dispatch_dialog_task_content);
|
||||
Button btnAffirm = findViewById(R.id.module_services_dispatch_dialog_confirm);
|
||||
btnAffirm.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.affirm();
|
||||
dismissDialog();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDialog(DispatchAdasAutoPilotLocReceiverBean dispatchContent) {
|
||||
show();
|
||||
if (!TextUtils.isEmpty(dispatchContent.getStartLocAddress())) {
|
||||
tvStartLoc.setText(dispatchContent.getStartLocAddress());
|
||||
}
|
||||
if (!TextUtils.isEmpty(dispatchContent.getEndLocAddress())) {
|
||||
tvEndLoc.setText(dispatchContent.getEndLocAddress());
|
||||
}
|
||||
if (!TextUtils.isEmpty(dispatchContent.getTaskTime())) {
|
||||
tvTaskTime.setText(dispatchContent.getTaskTime());
|
||||
}
|
||||
if (!TextUtils.isEmpty(dispatchContent.getFlightInfo())) {
|
||||
tvFlightInfo.setText(dispatchContent.getFlightInfo());
|
||||
}
|
||||
if (!TextUtils.isEmpty(dispatchContent.getTaskInfo())) {
|
||||
tvTaskContent.setText(dispatchContent.getTaskInfo());
|
||||
}
|
||||
}
|
||||
|
||||
private void dismissDialog() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIDispatchRemindListener(IDispatchRemindClickListener listener) {
|
||||
if (listener == null) {
|
||||
Logger.d(TAG, "addIDispatchRemindListener listener is null");
|
||||
return;
|
||||
}
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,329 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.data.autopilot.ADASTrajectoryInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotGuardianStatusInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.eagle.core.function.api.hmi.autopilot.IMoGoCheckAutoPilotBtnListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean;
|
||||
import com.mogo.module.service.dispatch.model.DispatchServiceModel;
|
||||
import com.mogo.module.service.dispatch.model.IDispatch;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mogo.module.service.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_AFFIRM;
|
||||
import static com.mogo.module.service.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_MANUAL_CANCEL;
|
||||
import static com.mogo.module.service.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_TIMER_CANCEL;
|
||||
|
||||
//负责监听自动驾驶状态并进行状态上报,自动驾驶路线上报,接收调度指令展示指令弹窗
|
||||
public class DispatchAutoPilotManager implements IMogoOnMessageListener<DispatchAdasAutoPilotLocReceiverBean>
|
||||
, IDispatchRemindClickListener, IMogoCarLocationChangedListener2,
|
||||
IMoGoCheckAutoPilotBtnListener, IMoGoAutopilotPlanningListener, IMoGoAutopilotStatusListener {
|
||||
|
||||
private static final String TAG = "DispatchAutoPilotManager";
|
||||
private static volatile DispatchAutoPilotManager instance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private Context mContext;
|
||||
private static final int MSG_SOCKET_TYPE = 501000;
|
||||
private static final int MSG_TYPE_SHOW_DIALOG = 0;
|
||||
private static final int MSG_TYPE_UPLOAD_AUTOPILOT_STATUS = 1;
|
||||
|
||||
private DispatchDialogManager dispatchDialogManager;
|
||||
private MogoLocation mogoLocation;
|
||||
private DispatchAdasAutoPilotLocReceiverBean receiverBean;
|
||||
private int autoPilotStatus = 0;
|
||||
private String reason = null;
|
||||
private boolean isDispatch = false;
|
||||
private boolean isArriveEnd = false;
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
|
||||
private DispatchAutoPilotManager() {
|
||||
|
||||
}
|
||||
|
||||
public static DispatchAutoPilotManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (obj) {
|
||||
if (instance == null) {
|
||||
instance = new DispatchAutoPilotManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_TYPE_SHOW_DIALOG) {
|
||||
if (dispatchDialogManager.isShowing()) {
|
||||
Logger.d(TAG, "此时已经有调度,又收到调度信息");
|
||||
return;
|
||||
}
|
||||
isDispatch = true;
|
||||
isArriveEnd = false;
|
||||
DispatchAdasAutoPilotLocReceiverBean msgData = (DispatchAdasAutoPilotLocReceiverBean) msg.obj;
|
||||
dispatchDialogManager.showDialog(msgData);
|
||||
} else if (msg.what == MSG_TYPE_UPLOAD_AUTOPILOT_STATUS) {
|
||||
DispatchServiceModel.getInstance().uploadAutopilotStatus(autoPilotStatus, reason);
|
||||
handler.sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void initSocket(Context context) {
|
||||
mContext = context;
|
||||
mApis = MogoApisHandler.getInstance().getApis();
|
||||
|
||||
mApis.getSocketManagerApi(context).registerOnMessageListener(MSG_SOCKET_TYPE, this);
|
||||
mApis.getRegisterCenterApi()
|
||||
.registerCarLocationChangedListener(TAG, this);
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.INSTANCE.addCheckAutoPilotBtnListener(TAG, this);
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
|
||||
dispatchDialogManager = DispatchDialogManager.getInstance(context);
|
||||
dispatchDialogManager.addIDispatchRemindListener(this);
|
||||
handler.sendEmptyMessageDelayed(MSG_TYPE_UPLOAD_AUTOPILOT_STATUS, 1000L);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
// 添加自动驾驶按钮选中监听
|
||||
CallerHmiListenerManager.INSTANCE.removeCheckAutoPilotBtnListener(TAG);
|
||||
// 添加 规划路径相关回调 监听
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG);
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DispatchAdasAutoPilotLocReceiverBean> target() {
|
||||
return DispatchAdasAutoPilotLocReceiverBean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(DispatchAdasAutoPilotLocReceiverBean adasAutoPilotLocReceiverBean) {
|
||||
if (adasAutoPilotLocReceiverBean != null
|
||||
&& adasAutoPilotLocReceiverBean.getStartLat() != 0.0
|
||||
&& adasAutoPilotLocReceiverBean.getStartLon() != 0.0) {
|
||||
this.receiverBean = adasAutoPilotLocReceiverBean;
|
||||
Message message = new Message();
|
||||
message.what = MSG_TYPE_SHOW_DIALOG;
|
||||
message.obj = adasAutoPilotLocReceiverBean;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void affirm() {
|
||||
dispatchDialogManager.releaseDialog();
|
||||
DispatchServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
startAutoPilot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void startAutoPilot() {
|
||||
AutopilotControlParameters currentAutopilot = new AutopilotControlParameters();
|
||||
currentAutopilot.isSpeakVoice = false;
|
||||
List<AutopilotControlParameters.AutoPilotLonLat> wayLatLon = new ArrayList<>();
|
||||
if (receiverBean != null && receiverBean.getStopsList() != null) {
|
||||
for (MogoLatLng mogoLatLng : receiverBean.getStopsList()) {
|
||||
wayLatLon.add(new AutopilotControlParameters.AutoPilotLonLat(mogoLatLng.lat, mogoLatLng.lon));
|
||||
}
|
||||
}
|
||||
currentAutopilot.wayLatLons = wayLatLon;
|
||||
currentAutopilot.startLatLon = new AutopilotControlParameters.AutoPilotLonLat(receiverBean.getStartLat(), receiverBean.getStartLon());
|
||||
currentAutopilot.endLatLon = new AutopilotControlParameters.AutoPilotLonLat(receiverBean.getEndLat(), receiverBean.getEndLon());
|
||||
currentAutopilot.vehicleType = 10;
|
||||
Logger.d(TAG, "开启自动驾驶====" + currentAutopilot);
|
||||
CallerAutoPilotManager.INSTANCE.startAutoPilot(currentAutopilot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(boolean manualTrigger) {
|
||||
dispatchDialogManager.releaseDialog();
|
||||
DispatchServiceModel.getInstance().dispatchResultUpload(manualTrigger ? DISPATCH_RESULT_MANUAL_CANCEL
|
||||
: DISPATCH_RESULT_TIMER_CANCEL, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location location) {
|
||||
//坐标转换
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
mogoLocation = loc;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCheck(boolean isChecked) {
|
||||
if (isChecked) {
|
||||
// 确保到达终点后,再次点击,不会有回馈,并且在下次调开始时,才会重置
|
||||
if (isArriveEnd) {
|
||||
return;
|
||||
}
|
||||
//todo 确认是否要根据停靠时自动驾驶状态,再次开启自动驾驶
|
||||
// 确保处于调度中并且返回的自动驾驶状态为1才开启自动驾驶
|
||||
// 上述等待鄂州项目复盘后,产品输出完成方案后再进操作!!!
|
||||
if (isDispatch) {
|
||||
startAutoPilot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testAutopilotStatus() {
|
||||
autoPilotStatus = 2;
|
||||
}
|
||||
|
||||
public void testEZhouStart() {
|
||||
Logger.d(TAG, "test to trigger mock testEZhouStart");
|
||||
DispatchAdasAutoPilotLocReceiverBean adasAutoPilotLocReceiverBean = new DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU, DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START, "1",
|
||||
26.825571122, 112.5762410415, "起点---5号跑道",
|
||||
26.825571122, 112.5762410415, "终点---鄂州机场",
|
||||
"5分钟", "AR453航班", "你车需执行编号ca1098次航班的引导任务,从A区A1到B区B1", System.currentTimeMillis(), new ArrayList<>());
|
||||
this.receiverBean = adasAutoPilotLocReceiverBean;
|
||||
DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean);
|
||||
}
|
||||
|
||||
public void testEZhouStop() {
|
||||
Logger.d(TAG, "test to trigger mock testEZhouStop");
|
||||
DispatchAdasAutoPilotLocReceiverBean adasAutoPilotLocReceiverBean = new DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU, DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_STOP, "1",
|
||||
0.0, 0.0, "",
|
||||
0.0, 0.0, "",
|
||||
"", "", "", System.currentTimeMillis(), new ArrayList<>());
|
||||
this.receiverBean = adasAutoPilotLocReceiverBean;
|
||||
DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean);
|
||||
}
|
||||
|
||||
public void testHengYangStart() {
|
||||
Logger.d(TAG, "test to trigger mock testHengYangStart");
|
||||
DispatchAdasAutoPilotLocReceiverBean adasAutoPilotLocReceiverBean = new DispatchAdasAutoPilotLocReceiverBean(
|
||||
DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_HENGYANG, DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START, "2",
|
||||
26.825571122, 112.5762410415, "衡阳科学城",
|
||||
26.825571122, 112.5762410415, "衡阳首钢集团",
|
||||
"", "", "", System.currentTimeMillis(), new ArrayList<>());
|
||||
this.receiverBean = adasAutoPilotLocReceiverBean;
|
||||
DispatchDialogManager.getInstance(mContext).showDialog(adasAutoPilotLocReceiverBean);
|
||||
}
|
||||
|
||||
public void testDispatchResultUpload() {
|
||||
DispatchServiceModel.getInstance().dispatchResultUpload(DISPATCH_RESULT_AFFIRM, new IDispatch() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(ArrayList<ADASTrajectoryInfo> trajectoryInfos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(AutopilotRouteInfo autopilotRoute) {
|
||||
if (autopilotRoute == null || autopilotRoute.getModels() == null || autopilotRoute.getModels().size() == 0) {
|
||||
return;
|
||||
}
|
||||
DispatchServiceModel.getInstance().uploadAutopilotRoute(autopilotRoute.getModels());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) {
|
||||
autoPilotStatus = autoPilotStatusInfo.getState();
|
||||
this.reason = autoPilotStatusInfo.getReason();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotArriveAtStation(@Nullable AutopilotStationInfo autopilotWayArrive) {
|
||||
if (!isDispatch) {
|
||||
return;
|
||||
}
|
||||
if (autopilotWayArrive == null) {
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG, "onArriveAt data : " + autopilotWayArrive.toString());
|
||||
double endLat = autopilotWayArrive.getLat();
|
||||
double endLon = autopilotWayArrive.getLon();
|
||||
// 计算是不是到了终点
|
||||
float distanceFromSelf = CoordinateUtils.calculateLineDistance(receiverBean.getEndLon(), receiverBean.getEndLat()
|
||||
, endLon, endLat);
|
||||
Logger.d(TAG, "onArriveAt cal distance : " + distanceFromSelf);
|
||||
if (distanceFromSelf < 10) {
|
||||
Logger.d(TAG, "onArriveAt end location");
|
||||
isDispatch = false;
|
||||
isArriveEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotGuardian(@Nullable AutopilotGuardianStatusInfo guardianInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.module.common.dialog.BaseFloatDialog;
|
||||
import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean;
|
||||
|
||||
public abstract class DispatchBaseDialog extends BaseFloatDialog {
|
||||
|
||||
public DispatchBaseDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public abstract void addIDispatchRemindListener(IDispatchRemindClickListener listener);
|
||||
|
||||
public abstract void showDialog(DispatchAdasAutoPilotLocReceiverBean dispatchContent);
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean;
|
||||
|
||||
public class DispatchCarsDialog extends DispatchBaseDialog{
|
||||
|
||||
private static final String TAG = "DispatchCarsDialog";
|
||||
private static final int MSG_TYPE_TIMER = 0;
|
||||
private static int TIMER = 10;
|
||||
private IDispatchRemindClickListener mListener;
|
||||
|
||||
private final TextView tvTimer;
|
||||
private final TextView tvLoc;
|
||||
|
||||
private final Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_TYPE_TIMER) {
|
||||
if (TIMER > 0) {
|
||||
TIMER--;
|
||||
Logger.d(TAG,"timer : " + TIMER);
|
||||
tvTimer.setText(String.valueOf(TIMER));
|
||||
handler.sendEmptyMessageDelayed(MSG_TYPE_TIMER,1000L);
|
||||
} else {
|
||||
hideDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public DispatchCarsDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
setContentView(R.layout.module_dialog_adas_dispatch_cars);
|
||||
setCanceledOnTouchOutside(false);
|
||||
tvTimer = findViewById(R.id.module_adas_dispatch_remind_timer);
|
||||
tvLoc = findViewById(R.id.module_adas_dispatch_remind_loc);
|
||||
Button btnAffirm = (Button) findViewById(R.id.module_adas_dispatch_remind_affirm);
|
||||
Button btnCancel = (Button) findViewById(R.id.module_adas_dispatch_remind_cancel);
|
||||
tvTimer.setText(String.valueOf(TIMER));
|
||||
btnAffirm.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.affirm();
|
||||
dismissDialog();
|
||||
}
|
||||
});
|
||||
btnCancel.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.cancel(true);
|
||||
dismissDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void hideDialog() {
|
||||
if (mListener != null) {
|
||||
mListener.cancel(false);
|
||||
}
|
||||
dismissDialog();
|
||||
}
|
||||
|
||||
private void dismissDialog(){
|
||||
handler.removeMessages(MSG_TYPE_TIMER);
|
||||
TIMER = 10;
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIDispatchRemindListener(IDispatchRemindClickListener listener) {
|
||||
if (listener == null) {
|
||||
Logger.d(TAG, "addIDispatchRemindListener listener is null");
|
||||
return;
|
||||
}
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDialog(DispatchAdasAutoPilotLocReceiverBean dispatchContent) {
|
||||
if(TextUtils.isEmpty(dispatchContent.getEndLocAddress())){
|
||||
return;
|
||||
}
|
||||
show();
|
||||
handler.sendEmptyMessage(MSG_TYPE_TIMER);
|
||||
tvLoc.setText(dispatchContent.getEndLocAddress());
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import static com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_EZHOU;
|
||||
import static com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_SOURCE_HENGYANG;
|
||||
import static com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_START;
|
||||
import static com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean.DISPATCH_TYPE_STOP;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.service.dispatch.bean.DispatchAdasAutoPilotLocReceiverBean;
|
||||
|
||||
public class DispatchDialogManager {
|
||||
|
||||
private static final String TAG = "DispatchDialogManager";
|
||||
private static volatile DispatchDialogManager manager;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private Context mContext;
|
||||
private IDispatchRemindClickListener mListener;
|
||||
private DispatchBaseDialog dialog;
|
||||
|
||||
private DispatchDialogManager(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static DispatchDialogManager getInstance(Context context) {
|
||||
if (manager == null) {
|
||||
synchronized (obj) {
|
||||
if (manager == null) {
|
||||
manager = new DispatchDialogManager(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
public void addIDispatchRemindListener(IDispatchRemindClickListener listener) {
|
||||
if (listener == null) {
|
||||
Logger.d(TAG, "addIDispatchRemindListener listener is null");
|
||||
return;
|
||||
}
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public boolean isShowing() {
|
||||
return dialog != null && dialog.isShowing();
|
||||
}
|
||||
|
||||
public void showDialog(DispatchAdasAutoPilotLocReceiverBean msgData) {
|
||||
if (msgData == null) {
|
||||
return;
|
||||
}
|
||||
switch (msgData.getSource()) {
|
||||
case DISPATCH_SOURCE_HENGYANG:
|
||||
dispatchHengYang(msgData);
|
||||
break;
|
||||
case DISPATCH_SOURCE_EZHOU:
|
||||
dispatchEZhou(msgData);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dispatchHengYang(DispatchAdasAutoPilotLocReceiverBean msgData) {
|
||||
if (msgData.getType() == DISPATCH_TYPE_START) { //衡阳只有开始调度
|
||||
if (dialog != null && dialog.isShowing()) { //避免下发两次
|
||||
return;
|
||||
}
|
||||
if (dialog == null) {
|
||||
dialog = new DispatchCarsDialog(mContext);
|
||||
}
|
||||
dialog.addIDispatchRemindListener(mListener);
|
||||
dialog.showDialog(msgData);
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchEZhou(DispatchAdasAutoPilotLocReceiverBean msgData) {
|
||||
switch (msgData.getType()) {
|
||||
case DISPATCH_TYPE_START:
|
||||
if (dialog != null && dialog.isShowing()) { //避免下发两次
|
||||
return;
|
||||
}
|
||||
if (dialog == null) {
|
||||
dialog = new DispatchAirportDialog(mContext);
|
||||
}
|
||||
dialog.addIDispatchRemindListener(mListener);
|
||||
dialog.showDialog(msgData);
|
||||
break;
|
||||
case DISPATCH_TYPE_STOP:
|
||||
//语音播报
|
||||
voice();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void voice() {
|
||||
AIAssist.getInstance(mContext).speakTTSVoice("请立即停车!请立即停车!");
|
||||
}
|
||||
|
||||
public void releaseDialog() {
|
||||
if (dialog != null) {
|
||||
if (dialog.isShowing()) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
|
||||
|
||||
public class DispatchTestPanelBroadCastReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "DispatchTestPanelBroadCastReceiver";
|
||||
|
||||
/**
|
||||
* Adas测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
int sceneType = intent.getIntExtra(BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
Logger.d(TAG, "textPanelOpenType:" + sceneType);
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发处理场景
|
||||
*
|
||||
* @param sceneType 场景类型
|
||||
*/
|
||||
private void dispatchSceneTest(int sceneType) {
|
||||
Logger.d(TAG, "sceneType=" + sceneType);
|
||||
if (sceneType == 0) {
|
||||
DispatchAutoPilotManager.getInstance().testEZhouStart();
|
||||
} else if (sceneType == 1) {
|
||||
DispatchAutoPilotManager.getInstance().testEZhouStop();
|
||||
} else if (sceneType == 2) {
|
||||
DispatchAutoPilotManager.getInstance().testHengYangStart();
|
||||
} else if (sceneType == 3) { //验证自动驾驶调度上报接口
|
||||
DispatchAutoPilotManager.getInstance().testDispatchResultUpload();
|
||||
} else if (sceneType == 4) { //更改自动驾驶状态上报
|
||||
DispatchAutoPilotManager.getInstance().testAutopilotStatus();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.mogo.module.service.dispatch;
|
||||
|
||||
public interface IDispatchRemindClickListener {
|
||||
|
||||
void affirm();
|
||||
|
||||
void cancel(boolean manualTrigger);
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DispatchAdasAutoPilotLocReceiverBean {
|
||||
|
||||
public static final int DISPATCH_SOURCE_HENGYANG = 1;
|
||||
public static final int DISPATCH_SOURCE_EZHOU = 2;
|
||||
public static final int DISPATCH_TYPE_START = 1;
|
||||
public static final int DISPATCH_TYPE_STOP = 2;
|
||||
|
||||
private int source; // 1:衡阳 2:鄂州
|
||||
private int type; // 1:启动 2:停止
|
||||
private String poiId;
|
||||
|
||||
private double startLat;
|
||||
private double startLon;
|
||||
private String startLocAddress;
|
||||
|
||||
private double endLat;
|
||||
private double endLon;
|
||||
private String endLocAddress;
|
||||
|
||||
private String taskTime;
|
||||
private String flightInfo;
|
||||
private String taskInfo;
|
||||
private long systemTime;
|
||||
private List<MogoLatLng> stopsList;
|
||||
|
||||
public DispatchAdasAutoPilotLocReceiverBean(int source, int type, String poiId, double startLat, double startLon, String startLocAddress, double endLat, double endLon, String endLocAddress, String taskTime, String flightInfo, String taskInfo, long systemTime, List<MogoLatLng> stopsList) {
|
||||
this.source = source;
|
||||
this.type = type;
|
||||
this.poiId = poiId;
|
||||
this.startLat = startLat;
|
||||
this.startLon = startLon;
|
||||
this.startLocAddress = startLocAddress;
|
||||
this.endLat = endLat;
|
||||
this.endLon = endLon;
|
||||
this.endLocAddress = endLocAddress;
|
||||
this.taskTime = taskTime;
|
||||
this.flightInfo = flightInfo;
|
||||
this.taskInfo = taskInfo;
|
||||
this.systemTime = systemTime;
|
||||
this.stopsList = stopsList;
|
||||
}
|
||||
|
||||
public int getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(int source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPoiId() {
|
||||
return poiId;
|
||||
}
|
||||
|
||||
public void setPoiId(String poiId) {
|
||||
this.poiId = poiId;
|
||||
}
|
||||
|
||||
public double getStartLat() {
|
||||
return startLat;
|
||||
}
|
||||
|
||||
public void setStartLat(double startLat) {
|
||||
this.startLat = startLat;
|
||||
}
|
||||
|
||||
public double getStartLon() {
|
||||
return startLon;
|
||||
}
|
||||
|
||||
public void setStartLon(double startLon) {
|
||||
this.startLon = startLon;
|
||||
}
|
||||
|
||||
public String getStartLocAddress() {
|
||||
return startLocAddress;
|
||||
}
|
||||
|
||||
public void setStartLocAddress(String startLocAddress) {
|
||||
this.startLocAddress = startLocAddress;
|
||||
}
|
||||
|
||||
public double getEndLat() {
|
||||
return endLat;
|
||||
}
|
||||
|
||||
public void setEndLat(double endLat) {
|
||||
this.endLat = endLat;
|
||||
}
|
||||
|
||||
public double getEndLon() {
|
||||
return endLon;
|
||||
}
|
||||
|
||||
public void setEndLon(double endLon) {
|
||||
this.endLon = endLon;
|
||||
}
|
||||
|
||||
public String getEndLocAddress() {
|
||||
return endLocAddress;
|
||||
}
|
||||
|
||||
public void setEndLocAddress(String endLocAddress) {
|
||||
this.endLocAddress = endLocAddress;
|
||||
}
|
||||
|
||||
public String getTaskTime() {
|
||||
return taskTime;
|
||||
}
|
||||
|
||||
public void setTaskTime(String taskTime) {
|
||||
this.taskTime = taskTime;
|
||||
}
|
||||
|
||||
public String getFlightInfo() {
|
||||
return flightInfo;
|
||||
}
|
||||
|
||||
public void setFlightInfo(String flightInfo) {
|
||||
this.flightInfo = flightInfo;
|
||||
}
|
||||
|
||||
public String getTaskInfo() {
|
||||
return taskInfo;
|
||||
}
|
||||
|
||||
public void setTaskInfo(String taskInfo) {
|
||||
this.taskInfo = taskInfo;
|
||||
}
|
||||
|
||||
public long getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public void setSystemTime(long systemTime) {
|
||||
this.systemTime = systemTime;
|
||||
}
|
||||
|
||||
public List<MogoLatLng> getStopsList() {
|
||||
return stopsList;
|
||||
}
|
||||
|
||||
public void setStopsList(List<MogoLatLng> stopsList) {
|
||||
this.stopsList = stopsList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DispatchAdasAutoPilotLocReceiverBean{" +
|
||||
"source=" + source +
|
||||
", type=" + type +
|
||||
", poiId='" + poiId + '\'' +
|
||||
", startLat=" + startLat +
|
||||
", startLon=" + startLon +
|
||||
", startLocAddress='" + startLocAddress + '\'' +
|
||||
", endLat=" + endLat +
|
||||
", endLon=" + endLon +
|
||||
", endLocAddress='" + endLocAddress + '\'' +
|
||||
", taskTime='" + taskTime + '\'' +
|
||||
", flightInfo='" + flightInfo + '\'' +
|
||||
", taskInfo='" + taskInfo + '\'' +
|
||||
", systemTime=" + systemTime +
|
||||
", stopsList=" + stopsList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.bean;
|
||||
|
||||
public class EndLatLon {
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
public EndLatLon(double lat, double lon) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EndLatLon{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.bean;
|
||||
|
||||
public class ReportDispatchResult {
|
||||
|
||||
private String sn;
|
||||
private int dispatchResult;
|
||||
|
||||
public ReportDispatchResult(String sn, int dispatchResult) {
|
||||
this.sn = sn;
|
||||
this.dispatchResult = dispatchResult;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public int getDispatchResult() {
|
||||
return dispatchResult;
|
||||
}
|
||||
|
||||
public void setDispatchResult(int dispatchResult) {
|
||||
this.dispatchResult = dispatchResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReportDispatchResult{" +
|
||||
"sn='" + sn + '\'' +
|
||||
", dispatchResult=" + dispatchResult +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.bean;
|
||||
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatus;
|
||||
|
||||
/**
|
||||
* 上报自动驾驶规划的路径
|
||||
*/
|
||||
public class ReportedRoute {
|
||||
private String sn;
|
||||
private AutopilotStatus.ValuesBean bean;
|
||||
private String siteList;
|
||||
|
||||
public ReportedRoute(String sn, AutopilotStatus.ValuesBean bean) {
|
||||
this.sn = sn;
|
||||
this.bean = bean;
|
||||
}
|
||||
|
||||
public ReportedRoute(String sn, String siteList) {
|
||||
this.sn = sn;
|
||||
this.siteList = siteList;
|
||||
}
|
||||
|
||||
public String getSiteList() {
|
||||
return siteList;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return "{\"sn\":\"" + sn + "\",\"state\":" + bean.getState() + ",\"speed\":" + bean.getSpeed() + ",\"reason\":\"" + bean.getReason() + "\",\"camera\":" + bean.getCamera() + ",\"radar\":" + bean.getRadar() + ",\"rtk\":" + bean.getRtk() + "}";
|
||||
}
|
||||
|
||||
public String getRoute() {
|
||||
return "{\"sn\":\"" + sn + "\",\"siteList\":" + siteList + "}";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.model;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotRouteInfo;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatus;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.service.dispatch.bean.ReportDispatchResult;
|
||||
import com.mogo.module.service.dispatch.bean.ReportedRoute;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.commons.context.ContextHolderUtil.getContext;
|
||||
import static com.mogo.module.common.constants.HostConst.DATA_SERVICE_HOST;
|
||||
|
||||
|
||||
|
||||
public class DispatchServiceModel {
|
||||
|
||||
private static final String TAG = "DispatchServiceModel";
|
||||
private static volatile DispatchServiceModel instance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
|
||||
public static final int DISPATCH_RESULT_AFFIRM = 0;
|
||||
public static final int DISPATCH_RESULT_MANUAL_CANCEL = 1;
|
||||
public static final int DISPATCH_RESULT_TIMER_CANCEL = 2;
|
||||
|
||||
private final IDispatchAdasApiService mAdasApiService;
|
||||
|
||||
private DispatchServiceModel() {
|
||||
this.mAdasApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(IDispatchAdasApiService.class, DATA_SERVICE_HOST);
|
||||
}
|
||||
|
||||
public static DispatchServiceModel getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (obj) {
|
||||
if (instance == null) {
|
||||
instance = new DispatchServiceModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态
|
||||
*/
|
||||
public void uploadAutopilotStatus(int state, String reason) {
|
||||
AutopilotStatus autopilotStatus = new AutopilotStatus();
|
||||
autopilotStatus.setAction("autopilotstate");
|
||||
AutopilotStatus.ValuesBean valuesBean = new AutopilotStatus.ValuesBean();
|
||||
valuesBean.setState(state);
|
||||
valuesBean.setReason(reason);
|
||||
autopilotStatus.setValues(valuesBean);
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
|
||||
ReportedRoute reportedRoute = new ReportedRoute(sn, autopilotStatus.getValues());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", GsonUtil.jsonFromObject(reportedRoute));
|
||||
mAdasApiService.uploadAutopilotState(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onNext(BaseData o) {
|
||||
super.onNext(o);
|
||||
//Logger.d(TAG, "uploadAutopilotStatus success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG, "uploadAutopilotStatus error : " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报自动驾驶路线
|
||||
*
|
||||
* @param list 路线集合
|
||||
*/
|
||||
public void uploadAutopilotRoute(List<AutopilotRouteInfo.RouteModels> list) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportedRoute reportedRoute = new ReportedRoute(sn, GsonUtil.jsonFromObject(list));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", GsonUtil.jsonFromObject(reportedRoute));
|
||||
mAdasApiService.uploadAutopilotRoute(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onNext(BaseData o) {
|
||||
super.onNext(o);
|
||||
Logger.d(TAG, "uploadAutopilotRoute success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG, "uploadAutopilotRoute error : " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报调度处理结果
|
||||
*
|
||||
* @param dispatchResultType int
|
||||
*/
|
||||
public void dispatchResultUpload(int dispatchResultType, IDispatch dispatch) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
ReportDispatchResult reportDispatchResult = new ReportDispatchResult(sn, dispatchResultType);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("data", GsonUtil.jsonFromObject(reportDispatchResult));
|
||||
mAdasApiService.uploadDispatchResult(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getContext())) {
|
||||
@Override
|
||||
public void onNext(BaseData o) {
|
||||
super.onNext(o);
|
||||
Logger.d(TAG, "dispatchResultUpload success");
|
||||
dispatch.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
Logger.d(TAG, "dispatchResultUpload error : " + e.getMessage());
|
||||
dispatch.onError(e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(BaseData o) {
|
||||
super.onSuccess(o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.model;
|
||||
|
||||
public interface IDispatch {
|
||||
|
||||
void onSuccess();
|
||||
|
||||
void onError(String msg);
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.mogo.module.service.dispatch.model;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface IDispatchAdasApiService {
|
||||
|
||||
/**
|
||||
* 上报自动驾驶路径 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiveCarPreSetPath")
|
||||
Observable<BaseData> uploadAutopilotRoute(@FieldMap Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* 上报自动驾驶调度处理结果 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiverDestSiteResult")
|
||||
Observable<BaseData> uploadDispatchResult(@FieldMap Map<String, Object> parameters);
|
||||
|
||||
/**
|
||||
* 上报自动驾驶状态 服务于业务调度
|
||||
*
|
||||
* @param parameters map
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/dataService/autoDriver/receiveAutopilotState")
|
||||
Observable<BaseData> uploadAutopilotState(@FieldMap Map<String, Object> parameters);
|
||||
}
|
||||
@@ -42,7 +42,6 @@ import com.mogo.module.common.drawer.IdentifyDataDrawer;
|
||||
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.timedelay.TimeDelayUploadManager;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -490,13 +489,8 @@ public class MockIntentHandler implements IntentHandler {
|
||||
case 54:
|
||||
// mTimeTickCarHandler.sendEmptyMessageDelayed(1, 0L);
|
||||
break;
|
||||
case 55:
|
||||
//开启模拟数据Mock,用于验证算法准确性
|
||||
TimeDelayUploadManager.getInstance().init(context);
|
||||
break;
|
||||
case 56:
|
||||
// 开启数据采集 自车定位和视觉识别
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,24 +24,12 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
public static final String VOICE_ACTION = "com.zhidao.speech.awake.notify";
|
||||
public static final String PARAM_COMMAND = "command";
|
||||
|
||||
/**
|
||||
* ADAS
|
||||
*/
|
||||
public static final String ACTIION_ADAS = "com.zhidao.autopilot.adas";
|
||||
// ADAS 状态 0 - 关闭 1 - 打开
|
||||
public static final String PARAM_ADAS_STATUS = "adas_drawer_status";
|
||||
|
||||
// 小智语音唤醒UI
|
||||
public static final String ACTION_VOICE_UI = "com.zhidao.xiaozhi.wake.status";
|
||||
public static final String PARRAM_WAKE_STATUS = "WAKE_STATUS";
|
||||
public static final String VALUE_DISMISS = "dismiss";
|
||||
public static final String VALUE_SHOW = "show";
|
||||
|
||||
/**
|
||||
* 从 adas 同步过来的信息
|
||||
*/
|
||||
public static final String ACTION_ADAS_STATUS = "com.zhidao.autopilot.adas.msg";
|
||||
|
||||
/**
|
||||
* 小智语音准备就绪
|
||||
*/
|
||||
@@ -56,13 +44,10 @@ public class MogoReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String ACTION_MOGO = "com.mogo.ACTION";
|
||||
|
||||
// 同行者 查询xxx堵不堵发送的广播
|
||||
public static final String ACTION_TXZ_BLOCK_SEARCH = "com.zhidao.roadcondition.roadinfo";
|
||||
|
||||
//车辆监控
|
||||
public static final String ACTION_CHECK_VEHICLE_MONITORING = "ACTION_CHECK_VEHICLE_MONITORING";
|
||||
|
||||
private IMogoIntentManager mMogoIntentManager;
|
||||
private final IMogoIntentManager mMogoIntentManager;
|
||||
|
||||
public MogoReceiver(Context context) {
|
||||
mMogoIntentManager = MarkerServiceHandler.getIntentManager();
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.mogo.module.service.timedelay;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
|
||||
public class MockDataDelayUploadHttpConstant {
|
||||
|
||||
public static final String HOST_DEV = "http://dzt-test.zhidaozhixing.com";
|
||||
public static final String HOST_TEST = "http://dzt-test.zhidaozhixing.com";
|
||||
public static final String HOST_DEMO = "http://dzt-show.zhidaozhixing.com";
|
||||
public static final String HOST_PRODUCT = "http://dzt.zhidaozhixing.com";
|
||||
|
||||
public static String getBaseUrl() {
|
||||
switch (DebugConfig.getNetMode()) {
|
||||
case DebugConfig.NET_MODE_DEV:
|
||||
return HOST_DEV;
|
||||
case DebugConfig.NET_MODE_QA:
|
||||
return HOST_TEST;
|
||||
case DebugConfig.NET_MODE_DEMO:
|
||||
return HOST_DEMO;
|
||||
default:
|
||||
return HOST_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package com.mogo.module.service.timedelay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.socket.entity.SocketDownData;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.network.RequestOptions;
|
||||
import com.mogo.eagle.core.network.SubscribeImpl;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.network.TimeDelayApiService;
|
||||
import com.mogo.module.service.network.bean.MockSocketReceiverData;
|
||||
import com.mogo.module.service.network.bean.MockSocketSendData;
|
||||
import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
import static com.mogo.commons.AbsMogoApplication.getApp;
|
||||
import static com.mogo.module.service.network.bean.MockSocketReceiverData.MOCK_RECEIVER_STATUS_START;
|
||||
|
||||
/**
|
||||
* 接收服务端模拟定位数据,对下发数据做实时Post上报,统计时延
|
||||
*/
|
||||
public class TimeDelayUploadManager implements IMogoOnMessageListener<MockSocketReceiverData>, IMogoCloudOnMsgListener {
|
||||
|
||||
private static final String TAG = "TimeDelayUploadManager";
|
||||
|
||||
private volatile static TimeDelayUploadManager timeDelayUploadManager;
|
||||
private static final int MSG_SOCKET_TYPE = 403000;
|
||||
private static final int MOCK_MSG = 1;
|
||||
private boolean isMockData = false;
|
||||
private MockSocketReceiverData mMockData;
|
||||
private long mRecordSatelliteTime; //todo 后续多点模拟用
|
||||
|
||||
private TimeDelayApiService timeDelayApiService;
|
||||
private IMogoADASController adasControllerApi;
|
||||
|
||||
private TimeDelayUploadManager() {
|
||||
|
||||
}
|
||||
|
||||
public static TimeDelayUploadManager getInstance() {
|
||||
if (timeDelayUploadManager == null) {
|
||||
synchronized (TimeDelayUploadManager.class) {
|
||||
if (timeDelayUploadManager == null) {
|
||||
timeDelayUploadManager = new TimeDelayUploadManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return timeDelayUploadManager;
|
||||
}
|
||||
|
||||
public boolean isMock() {
|
||||
return isMockData;
|
||||
}
|
||||
|
||||
public void init(Context mContext) {
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getSocketManagerApi(mContext).registerOnMessageListener(MSG_SOCKET_TYPE, this);
|
||||
MoGoAiCloudRealTime.registerOnMsgListener(this);
|
||||
adasControllerApi = MogoApisHandler.getInstance().getApis().getAdasControllerApi();
|
||||
}
|
||||
|
||||
private final Handler mockHandler = new Handler(WorkThreadHandler.newInstance("mock-algorithm-work-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MOCK_MSG) {
|
||||
//改变地图定位数据,触发自车移动
|
||||
JSONObject jo = new JSONObject();
|
||||
try {
|
||||
jo.put("lon", mMockData.getLon());
|
||||
jo.put("lat", mMockData.getLat());
|
||||
jo.put("heading", mMockData.getHeading());
|
||||
jo.put("systemTime", System.currentTimeMillis());
|
||||
jo.put("satelliteTime", System.currentTimeMillis());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo);
|
||||
SnapshotLocationDataCenter.getInstance().syncAdasLocationInfo(jo);
|
||||
mockHandler.sendEmptyMessageDelayed(MOCK_MSG, 50);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Class<MockSocketReceiverData> target() {
|
||||
return MockSocketReceiverData.class;
|
||||
}
|
||||
|
||||
//接收socket数据
|
||||
@Override
|
||||
public void onMsgReceived(MockSocketReceiverData mockData) {
|
||||
Logger.d(TAG, "onMsgReceived obj : " + mockData.toString());
|
||||
if (mockData.getStatus() == MOCK_RECEIVER_STATUS_START) { //todo 暂时以单条数据发送,后续多点实时发送Message
|
||||
isMockData = true;
|
||||
//开启定位模拟
|
||||
mMockData = mockData;
|
||||
mRecordSatelliteTime = mockData.getSatelliteTime();
|
||||
mockHandler.sendEmptyMessage(MOCK_MSG);
|
||||
if (timeDelayApiService == null) {
|
||||
timeDelayApiService = MogoApisHandler.getInstance().getApis().getNetworkApi().create(TimeDelayApiService.class, MockDataDelayUploadHttpConstant.getBaseUrl());
|
||||
}
|
||||
} else {
|
||||
isMockData = false;
|
||||
//停止定位模拟
|
||||
if (mockHandler.hasMessages(MOCK_MSG)) {
|
||||
mockHandler.removeMessages(MOCK_MSG);
|
||||
mMockData = null;
|
||||
mRecordSatelliteTime = 0;
|
||||
timeDelayApiService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgSend(long id) {
|
||||
|
||||
}
|
||||
|
||||
//接收实时数据监听回调,用于给服务端上报时延
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@Override
|
||||
public void onMsgReceived(SocketDownData.LauncherSnapshotProto mogoSnapshotSetData) {
|
||||
if (isMockData) {
|
||||
Logger.d(TAG,"收到下发数据 mogoSnapshotSetData : " + mogoSnapshotSetData.toString());
|
||||
//接口数据上报
|
||||
SocketDownData.CloudRoadDataProto result = mogoSnapshotSetData.getAllListList()
|
||||
.stream()
|
||||
.filter(cloudRoadData -> cloudRoadData.getUuid().contains("serialNumber_"))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
if (result == null) {
|
||||
Logger.d(TAG, "未找到与之匹配数据");
|
||||
return;
|
||||
}
|
||||
Logger.d(TAG,"找到匹配数据 result : " + result.toString());
|
||||
long satelliteTime;
|
||||
if (TextUtils.isEmpty(adasControllerApi.getSatelliteTime())) {
|
||||
satelliteTime = System.currentTimeMillis();
|
||||
} else {
|
||||
satelliteTime = Long.parseLong(adasControllerApi.getSatelliteTime());
|
||||
}
|
||||
MockSocketSendData mockSocketSendData = new MockSocketSendData(satelliteTime, result.getUuid(), result.getSatelliteTime());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
map.put("data", GsonUtil.jsonFromObject(mockSocketSendData));
|
||||
Logger.d(TAG, "mockSocketSendData : " + GsonUtil.jsonFromObject(mockSocketSendData));
|
||||
Logger.d(TAG, "data uuid : " + result.getUuid() + " duration : " + (satelliteTime - result.getSatelliteTime()));
|
||||
timeDelayApiService.uploadDelayData(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<BaseData>(RequestOptions.create(getApp())) {
|
||||
@Override
|
||||
public void onNext(BaseData o) {
|
||||
super.onNext(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user