diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java index fa60cf4551..e957b8b535 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/fragment/BaseSweeperTabFragment.java @@ -71,10 +71,6 @@ public abstract class BaseSweeperTabFragment(), MenuPopWindow.OnMenuItemOnClickListener{ private var mAdapter: TaskListAdapter? = null - private var mPosition: Int = -1 - private val mutableList: MutableList by lazy { mutableListOf() } - private var subTaskType:Int=1;//1:自动驾驶子任务 2:人工驾驶子任务 - private var cleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates?=null + private var mCurrentSubPosition: Int =0 //子任务下标 + private var mMainMutableList: MutableList?=null + private var mSubMutableList: MutableList?=null + private var mSubTaskBean: SweeperSubTaskBean?=null + private var mSubTaskType:SubTaskTypeEnum=SubTaskTypeEnum.AUTOPILOT_SUBTYPE //1:自动驾驶子任务 2:人工驾驶子任务 + private var mCleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates?=null + private var mIsLastSubTask=false //是否最后一个子任务 + private var mSubTaskId=-1//子任务id + private var mMainTask:SweeperMainTaskBean?=null //当前经纬度 override fun getTagName(): String { @@ -31,17 +41,30 @@ class SweeperFragment : BaseSweeperTabFragment + mSubTaskBean= SweeperSubTaskBean(task.mainTaskId,task.mainTaskName,task.mainTaskStartTime,mSubMutableList) + //获取当前子任务列表 + presenter?.getSubTaskList(task.mainTaskId,mSubTaskBean) + } + //mock 数据 setShowTaskListPanelView(false) workModePanelView.visibility = View.VISIBLE setShowCurrentTaskPanelView(true) - currentTaskPanelView.setData(workModePanelView,mutableList, mPosition,this) - workModePanelView.setSweeperFutianCleanSystemState(subTaskType,if(cleanSystemState==null) SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData() else cleanSystemState,trafficDataView) - } - currentTaskPanelView.getReadyTaskBtn().setOnClickListener { - mPresenter?.startAutopilot() + currentTaskPanelView.setData(workModePanelView,mSubTaskBean, mCurrentSubPosition,this,presenter) + workModePanelView.setSweeperFutianCleanSystemState(mSubTaskType,if(mCleanSystemState==null) SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData() else mCleanSystemState,trafficDataView) } } private val onTaskItemClickListener = object : TaskListAdapter.TaskItemClickListener { - override fun onItemClick(position: Int) { + override fun onItemClick(position: Int,mainTask:SweeperMainTaskBean) { mAdapter?.selectPosition(position) - mPosition = position tvTaskConfirm.isSelected = true + this@SweeperFragment.mMainTask=mainTask } } - override fun onMenuItemClick(itemType: TaskMenuTypeEnum) { - when (itemType.code) { - TaskMenuTypeEnum.JUMP_OVER_TASK.code -> { - setShowTaskListPanelView(true) - setShowCurrentTaskPanelView(false) - workModePanelView.visibility = View.GONE + override fun onMenuItemClick(itemType: TaskStatusEnum) { + when (itemType) { + TaskStatusEnum.JUMP_OVER_SUBTASK -> {//跳过任务 + presenter?.subTaskSkip(mSubTaskId,mIsLastSubTask) + //mock + mCurrentSubPosition++ + currentTaskPanelView.setData(workModePanelView,mSubTaskBean, mCurrentSubPosition,this,presenter) + } - TaskMenuTypeEnum.END_TASK.code -> { + TaskStatusEnum.END_TASK -> { + mMainTask?.let { + presenter?.mainTaskReset(it.mainTaskId) + } + //mock setShowTaskListPanelView(true) setShowCurrentTaskPanelView(false) workModePanelView.visibility = View.GONE @@ -130,8 +159,8 @@ class SweeperFragment : BaseSweeperTabFragment?){ + setShowCurrentTaskPanelView(false) + setShowTaskListPanelView(true) + workModePanelView.visibility = View.GONE + if(mainTaskBeanList!=null&& mainTaskBeanList.isNotEmpty()){ + noTaskDataView.visibility=View.GONE + sweeperListCl.visibility=View.VISIBLE + mAdapter?.setTaskListData(mainTaskBeanList) + }else{ + noTaskDataView.visibility=View.VISIBLE + sweeperListCl.visibility=View.GONE + } + } + /** + * 设置当前子任务列表数据 + */ + fun setSubTaskBean(subTaskBean: SweeperSubTaskBean?){ + this.mSubTaskBean= subTaskBean + setShowCurrentTaskPanelView(true) + setShowTaskListPanelView(false) + workModePanelView.visibility = View.VISIBLE + currentTaskPanelView.setData(workModePanelView,mSubTaskBean, mCurrentSubPosition,this,presenter) + setSubTaskData() + } + /** + * 更新子任务状态 + */ + fun updateSubTaskStatus(typeEnum: TaskStatusEnum, isLastSubTask: Boolean){ + if (isLastSubTask){ + setShowCurrentTaskPanelView(false) + setShowTaskListPanelView(true) + return + } + when(typeEnum){ + TaskStatusEnum.END_SUBTASK->{//子任务结束 + mCurrentSubPosition++ + setSubTaskData() + presenter?.startTask(mSubTaskId,mSubTaskType) + } + TaskStatusEnum.JUMP_OVER_SUBTASK->{ //子任务跳过 + presenter?.subTaskEnd(mSubTaskId,mIsLastSubTask) + } + TaskStatusEnum.START_SUBTASK->{ //子任务开始 + if (mSubTaskType==SubTaskTypeEnum.AUTOPILOT_SUBTYPE){//自动驾驶子任务 + readyTaskBtn("暂停任务",true,true) + }else{//手动驾驶的子任务会弹窗 + + } + currentTaskPanelView.setCurrentData(mCurrentSubPosition) + } + } + + } + /** + * 主任务重置 + */ + fun setMainTaskReset(isSuccess: Boolean){ + if (isSuccess){ + setShowCurrentTaskPanelView(false) + setShowTaskListPanelView(true) + workModePanelView.visibility = View.GONE + } + } + + /** + * 设置子任务数据 + */ + private fun setSubTaskData(){ + mSubMutableList?.let { + mSubTaskId=it[mCurrentSubPosition].taskId + mSubTaskType=if (it[mCurrentSubPosition].taskType==SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) + SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE + } + } } \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/ISweeperTask.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/ISweeperTask.java deleted file mode 100644 index 57282def28..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/ISweeperTask.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mogo.och.sweeper.model; - -import java.util.List; - -public interface ISweeperTask { - - /** - * 获取任务列表 - * @return - */ - List getTaskList(); - - /** - * 设置任务列表 - * @param taskList - */ - void setTaskList(List taskList); - - /** - * 获取当前任务 - * @return - */ - T getCurrentTask(); - - /** - * 设置当前任务 - * @param currentTask - */ - void setCurrentTask(T currentTask); - - /** - * 开始任务 - */ - void startTask(); - - /** - * 暂停任务 - */ - void pauseTask(); - - /** - * 跳过任务 - */ - void jumpOverTask(); - - /** - * 结束任务 - */ - void endTask(); - -} diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt deleted file mode 100644 index 085afd2c72..0000000000 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/OperationalTask.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.mogo.och.sweeper.model - -import com.mogo.och.sweeper.bean.TaskInfoBean - -/** - * 运营任务 - */ -class OperationalTask : ISweeperTask { - override fun getTaskList(): MutableList { - return mutableListOf() - } - - override fun startTask() { - - } - - override fun pauseTask() { - - } - - override fun jumpOverTask() { - - } - - override fun endTask() { - - } - - override fun setTaskList(taskList: MutableList?) { - - } - - override fun getCurrentTask(): TaskInfoBean { - return TaskInfoBean(1, "", 1) - } - - override fun setCurrentTask(currentTask: TaskInfoBean?) { - - } -} \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java index 11691dfa51..857c140d36 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/model/SweeperTaskModel.java @@ -1,6 +1,7 @@ package com.mogo.och.sweeper.model; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_SWEEPER; import android.content.Context; @@ -17,7 +18,6 @@ import com.mogo.commons.module.status.StatusDescriptor; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLocation; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener; import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; @@ -25,20 +25,30 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager; import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.eagle.core.utilcode.util.ToastUtils; +import com.mogo.och.common.module.biz.network.OchCommonServiceCallback; import com.mogo.och.common.module.callback.OchAdasStartFailureCallback; import com.mogo.och.common.module.manager.OCHAdasAbilityManager; import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil; import com.mogo.och.common.module.utils.NumberFormatUtil; import com.mogo.och.common.module.utils.PinYinUtil; +import com.mogo.och.sweeper.R; +import com.mogo.och.sweeper.bean.BaseResponse; +import com.mogo.och.sweeper.bean.SubInfo; +import com.mogo.och.sweeper.bean.SweeperMainTaskBean; import com.mogo.och.sweeper.bean.SweeperRoutePlanningUpdateReqBean; -import com.mogo.och.sweeper.bean.SweeperRoutesResult; -import com.mogo.och.sweeper.bean.SweeperTaskBean; -import com.mogo.och.sweeper.callback.IRefreshSweeperTaskCallback; +import com.mogo.och.sweeper.bean.SweeperSubTaskBean; +import com.mogo.och.sweeper.bean.SweeperSubTaskDetailBean; +import com.mogo.och.sweeper.callback.ISweeperTaskCallback; import com.mogo.och.sweeper.callback.ISweeperADASStatusCallback; import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; +import com.mogo.och.sweeper.constant.SubTaskTypeEnum; import com.mogo.och.sweeper.constant.SweeperConst; +import com.mogo.och.sweeper.constant.TaskStatusEnum; +import com.mogo.och.sweeper.net.SweeperServiceManager; import com.mogo.och.sweeper.util.SweeperAnalyticsManager; +import com.mogo.och.sweeper.util.SweeperTrajectoryManager; import org.jetbrains.annotations.NotNull; @@ -50,6 +60,7 @@ import io.reactivex.exceptions.UndeliverableException; import io.reactivex.functions.Consumer; import io.reactivex.plugins.RxJavaPlugins; import mogo.telematics.pad.MessagePad; + /** * @author congtaowang * @since 2021/3/23 @@ -58,29 +69,27 @@ import mogo.telematics.pad.MessagePad; */ public class SweeperTaskModel { private final String TAG = SweeperTaskModel.class.getSimpleName(); - private int currentLineId = -1; - private int backgroundCurrentTaskIndex = 0;//A->B 此处值是A任务索引 private static volatile SweeperTaskModel sInstance; public double mLongitude = 0; public double mLatitude = 0; private Context mContext; - private final List stationList = new ArrayList<>(); - private SweeperRoutesResult busRoutesResult = null; - /** - * 用来表示是否正在开往下一站 - */ - private boolean isGoingToNextStation = false; // 运营类型 private static final int VEHICLE_TYPE = 10; private ISweeperControllerStatusCallback mControllerStatusCallback; //Model->Presenter:VR mode等 private ISweeperADASStatusCallback mADASStatusCallback; - private IRefreshSweeperTaskCallback mRefreshSweeperTaskCallback; - + private ISweeperTaskCallback mSweeperTaskCallback; List points = new ArrayList<>();//全路径信息 - - private volatile boolean isArrivedStation = false; - - //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次到站/路线结束清空置为0 + //当前子任务详情信息包括轨迹文件信息 + private SweeperSubTaskDetailBean currentSubTaskDetail; + //子任务是否正在进行中 + private boolean isSubTaskWorking = false; + //自动驾驶是否到达子任务终点 + private boolean isArriveSubTaskEndSite = false; + //当前子任务id + private int mSubTaskId=0; + // //当前是否最后一个子任务 + private boolean mIsLastSubtask=false; + //0: 代表没有启动过 1代表是启动第一次,当>=1 代表是重试 每次子任务结束/主任务结束清空置为0 private volatile int firstStartAutopilot = 0; public static SweeperTaskModel getInstance() { @@ -97,7 +106,6 @@ public class SweeperTaskModel { private SweeperTaskModel() { } - public void init() { mContext = AbsMogoApplication.getApp(); // 定位监听 @@ -120,41 +128,47 @@ public class SweeperTaskModel { public void accept(Throwable e) { if (e instanceof UndeliverableException) { e = e.getCause(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "UndeliverableException"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "UndeliverableException"); } if ((e instanceof IOException)) {// // fine, irrelevant network problem or API that throws on cancellation - CallerLogger.INSTANCE.d(M_BUS + TAG, "IOException"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "IOException"); return; } if (e instanceof InterruptedException) { // fine, some blocking code was interrupted by a dispose call - CallerLogger.INSTANCE.d(M_BUS + TAG, "InterruptedException"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "InterruptedException"); return; } if ((e instanceof NullPointerException) || (e instanceof IllegalArgumentException)) { // that's likely a bug in the application - CallerLogger.INSTANCE.d(M_BUS + TAG, "NullPointerException or IllegalArgumentException"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "NullPointerException or IllegalArgumentException"); Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); return; } if (e instanceof IllegalStateException) { // that's a bug in RxJava or in a custom operator - CallerLogger.INSTANCE.d(M_BUS + TAG, "IllegalStateException"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "IllegalStateException"); Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e); return; } - CallerLogger.INSTANCE.d(M_BUS + TAG, "Undeliverable exception"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "Undeliverable exception"); } }); } - public void setAdasStatusCallback(ISweeperADASStatusCallback callback){ + + public void setAdasStatusCallback(ISweeperADASStatusCallback callback) { this.mADASStatusCallback = callback; } + public void setControllerStatusCallback(ISweeperControllerStatusCallback callback) { this.mControllerStatusCallback = callback; } + public void setSweeperTaskCallback(ISweeperTaskCallback callback) { + this.mSweeperTaskCallback = callback; + } + private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() { @Override @@ -166,8 +180,15 @@ public class SweeperTaskModel { } }; + public void setSubTaskId(int mSubTaskId) { + this.mSubTaskId = mSubTaskId; + } - public static List coordinateConverterWgsToGcjList(Context mContext, List mogoLatLngList) { + public void setIsLastSubtask(boolean mIsLastSubtask) { + this.mIsLastSubtask = mIsLastSubtask; + } + public static List coordinateConverterWgsToGcjList(Context mContext, + List mogoLatLngList) { List points = new ArrayList<>(); for (MessagePad.Location m : mogoLatLngList) { LatLng mogoLatLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(mContext, m); @@ -178,6 +199,7 @@ public class SweeperTaskModel { } return points; } + public void release() { MogoStatusManager.getInstance().unregisterStatusChangedListener(TAG, StatusDescriptor.VR_MODE, mMogoStatusChangedListener); // 注销定位监听 @@ -208,8 +230,8 @@ public class SweeperTaskModel { @Override public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { SweeperAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); - if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ - CallerLogger.INSTANCE.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); + if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode) { + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "mAdasStartFailureListener = " + startFailedMessage); mADASStatusCallback.onStartAdasFailure(); } } @@ -225,72 +247,56 @@ public class SweeperTaskModel { if (mControllerStatusCallback != null) { mControllerStatusCallback.onCarLocationChanged(gnssInfo); } - //是否到站的围栏判断 离站状态并且自动驾驶还未触发到站 - if (isGoingToNextStation && !isArrivedStation) { + //子任务完成的围栏判断 子任务正在执行中,还未到达子任务终点 + if (isSubTaskWorking&&!isArriveSubTaskEndSite) { judgeArrivedStation(gnssInfo); } } }; - //根据围栏判断,是否到达站点 + //根据围栏判断,是否到达子任务终点 private void judgeArrivedStation(MogoLocation location) { - - if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "到站数组越界"); - return; - } - SweeperTaskBean upcomingStation = stationList.get(backgroundCurrentTaskIndex + 1); - - double startLon = upcomingStation.getGcjLon(); - double startLat = upcomingStation.getGcjLat(); + double endSiteLon = currentSubTaskDetail.getEndSiteLon(); + double endSiteLat = currentSubTaskDetail.getEndSiteLat(); double distance = CoordinateUtils.calculateLineDistance( - startLon, startLat, + endSiteLon, endSiteLat, location.getLongitude(), location.getLatitude()); - if (distance <= SweeperConst.ARRIVE_AT_END_STATION_DISTANCE) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-judgeArrivedStation() distance = " + distance - + " to " + upcomingStation.getName()); - onArriveAt(null); //无自动驾驶到站信息传null + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-judgeArrivedStation() distance = " + distance + + " to " + currentSubTaskDetail.getEndSiteName()); + onArriveTaskEnd(null); //无自动驾驶到终点信息传null return; } } - private void onStartAutopilot(int leaveIndex) { - //开启自动驾驶 2.10.0: 如果自动驾驶状态下开启, 非自动驾驶状态下不开启,需手动点击自动驾驶按钮开启 - isGoingToNextStation = true; - if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() - == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - startAutopilot(false, leaveIndex); - } else { - firstStartAutopilot = 0; - } + /** + * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 + */ + public void startAutopilot() { + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-重启自动驾驶===" + isSubTaskWorking); + //只去启动自动驾驶 + startAutopilot(firstStartAutopilot >= 1); } /** * 开启自动驾驶 * * @param isRestart */ - private void startAutopilot(boolean isRestart, int leaveIndex) { - + private void startAutopilot(boolean isRestart) { if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) { ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试"); triggerUnableStartAPReasonEvent(); return; } - firstStartAutopilot++; - triggerStartServiceEvent(isRestart, false); - - AutopilotControlParameters parameters = initAutopilotControlParameters(leaveIndex); + AutopilotControlParameters parameters = initAutopilotControlParameters(); if (null == parameters) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty."); + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "行程日志-AutopilotControlParameters is empty."); return; } - CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters); - - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) + " startLatLon=" + parameters.startName + ",endLatLon=" + parameters.endName + "isRestart = " + isRestart); @@ -298,185 +304,398 @@ public class SweeperTaskModel { mControllerStatusCallback.startOpenAutopilot(); } } + + /** + * 获取任务子任务执行状态 + */ + public boolean getSubWorking(){ + return isSubTaskWorking; + } /** * 关闭美化模式 */ public void closeBeautificationMode() { if (FunctionBuildConfig.isDemoMode) { FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false; //是否强制绘制引导线 - CallerAutoPilotControlManager.INSTANCE.setIgnoreConditionDraw(false);// 同步给乘客屏 CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(false);//是否自动启动自驾 - CallerLogger.INSTANCE.d(M_BUS + TAG, "美化模式-ignore:置为false"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "美化模式-ignore:置为false"); } } - private void clearStartAutopilotTag() { - firstStartAutopilot = 0; - } /** * 开启美化模式 */ - private void startBeautificationMode() { - FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; - CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(true); + public void startBeautificationMode() { + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;//是否强制绘制引导线 + CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(true);//是否自动启动自驾 } - public void clearBusStationData() { - if (mRefreshSweeperTaskCallback != null) { - mRefreshSweeperTaskCallback.clearSweeperTasksMarkers(); - } - } /** - * 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地 - */ - public void restartAutopilot() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-重启自动驾驶===" + isGoingToNextStation); - //只去启动自动驾驶,不再去上报离站 - startAutopilot(firstStartAutopilot >= 1, -1); - } - public boolean isRestartAutopilot() { - return firstStartAutopilot > 1; - } - /** - * task正常结束 - */ - private void endTask() { - if (backgroundCurrentTaskIndex >= stationList.size()) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "travel over index out of station list"); - return; - } - CallerLogger.INSTANCE.d(M_BUS + TAG, "单程结束===="); - CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot(); - CallerLogger.INSTANCE.d(M_BUS + TAG, "任务正常走完endTask()"); - - } - /** - * 到站 - * * @param data */ - public void onArriveAt(MessagePad.ArrivalNotification data) { - if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站异常,取消后续操作结束"); - return; - } - + public void onArriveTaskEnd(MessagePad.ArrivalNotification data) { //MAP 280 每隔100ms左右返回一次到站, 导致在到达中间站后再次滑动出发后会有时间差,收到一次到站,出现问题 - //此处比对 自驾告诉的到站站点坐标和本地应到站站点坐标, 一致时才能到站 + //此处比对 自驾告诉的子任务终点坐标和本地应到子任务终点坐标, 一致时才表示子任务完成 if (data != null && data.getEndLocation() != null) { - String latitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLatitude(), 5); //wgs String longitude = NumberFormatUtil.cutOutNumber(data.getEndLocation().getLongitude(), 5); - - int arrivedStationIndex = backgroundCurrentTaskIndex + 1; - SweeperTaskBean arriveStation = stationList.get(arrivedStationIndex); - String arriveLat = NumberFormatUtil.cutOutNumber(arriveStation.getLat(), 5); - String arriveLon = NumberFormatUtil.cutOutNumber(arriveStation.getLon(), 5); - + String arriveLat = NumberFormatUtil.cutOutNumber(currentSubTaskDetail.getEndSiteWgs64Lat(), 5); + String arriveLon = NumberFormatUtil.cutOutNumber(currentSubTaskDetail.getEndSiteWgs64Lon(), 5); if (!latitude.equals(arriveLat) || !longitude.equals(arriveLon)) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-到站拦截,到站坐标不一致"); + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "行程日志-子任务终点拦截,自动子任务终点与本地子任务终点不一致"); return; } } - - if (isArrivedStation) return; - - CallerLogger.INSTANCE.d(M_BUS + TAG, "行程日志-当前==backgroundCurrentTaskIndex=" - + backgroundCurrentTaskIndex); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-当前==subTaskId=" + + currentSubTaskDetail.getId()); + //到达子任务终点 结束子任务 + subTaskEnd(mSubTaskId,mIsLastSubtask); } - public boolean isGoingToNextStation() { - return isGoingToNextStation; - } public void triggerStartServiceEvent(boolean isRestart, boolean send) { - if (stationList == null || backgroundCurrentTaskIndex >= stationList.size() - 1) { + if (currentSubTaskDetail == null) { return; } - SweeperTaskBean currentStation = stationList.get(backgroundCurrentTaskIndex); - SweeperTaskBean nextStation = stationList.get(backgroundCurrentTaskIndex + 1); SweeperAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, - currentStation.getName(), nextStation.getName(), currentLineId); + currentSubTaskDetail.getStartSiteName(), currentSubTaskDetail.getEndSiteName(), currentSubTaskDetail.getLineId()); } public void triggerUnableStartAPReasonEvent() { - if (stationList == null || backgroundCurrentTaskIndex >= stationList.size() - 1) { + if (currentSubTaskDetail == null) { return; } - SweeperTaskBean currentStation = stationList.get(backgroundCurrentTaskIndex); - SweeperTaskBean nextStation = stationList.get(backgroundCurrentTaskIndex + 1); SweeperAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( - currentStation.getName(), nextStation.getName(), currentLineId, + currentSubTaskDetail.getStartSiteName(), currentSubTaskDetail.getEndSiteName(), currentSubTaskDetail.getLineId(), OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); } - public SweeperRoutesResult getBusRoutesResult() { - return busRoutesResult; - } - - public int getCurrentStationIndex() { - return backgroundCurrentTaskIndex; - } - /** * 将业务订单信息保存,鹰眼可取用 */ private void updateAutopilotControlParameters() { - AutopilotControlParameters parameters = initAutopilotControlParameters(-1); + AutopilotControlParameters parameters = initAutopilotControlParameters(); if (null == parameters) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "AutopilotControlParameters is empty."); + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "AutopilotControlParameters is empty."); return; } - CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is update."); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "AutopilotControlParameters is update."); CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(parameters); } private void clearAutopilotControlParameters() { - CallerLogger.INSTANCE.d(M_BUS + TAG, "AutopilotControlParameters is clear."); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "AutopilotControlParameters is clear."); CallerAutoPilotStatusListenerManager.INSTANCE.updateAutopilotControlParameters(null); } - private AutopilotControlParameters initAutopilotControlParameters(int leaveIndex) { - SweeperTaskBean currentStation = null; - SweeperTaskBean nextStation = null; - - if (leaveIndex < 0) { - if (backgroundCurrentTaskIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition1."); - return null; - } - currentStation = stationList.get(backgroundCurrentTaskIndex); - nextStation = stationList.get(backgroundCurrentTaskIndex + 1); - } else { - if (leaveIndex + 1 > stationList.size() - 1 || !isGoingToNextStation) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "行程日志-mismatch condition2."); - return null; - } - currentStation = stationList.get(leaveIndex); - nextStation = stationList.get(leaveIndex + 1); - } - + private AutopilotControlParameters initAutopilotControlParameters() { AutopilotControlParameters parameters = new AutopilotControlParameters(); - parameters.routeID = busRoutesResult.getLineId(); - parameters.routeName = busRoutesResult.getName(); - parameters.startName = PinYinUtil.getPinYinHeadChar(currentStation.getName()); - parameters.endName = PinYinUtil.getPinYinHeadChar(nextStation.getName()); - parameters.startLatLon = new AutopilotControlParameters - .AutoPilotLonLat(currentStation.getLat(), currentStation.getLon()); - parameters.endLatLon = new AutopilotControlParameters - .AutoPilotLonLat(nextStation.getLat(), nextStation.getLon()); - parameters.vehicleType = VEHICLE_TYPE; - if (parameters.autoPilotLine == null) { + if (currentSubTaskDetail != null) { + parameters.routeID = currentSubTaskDetail.getLineId(); + parameters.routeName = currentSubTaskDetail.getLineName(); + parameters.startName = PinYinUtil.getPinYinHeadChar(currentSubTaskDetail.getStartSiteName()); + parameters.endName = PinYinUtil.getPinYinHeadChar(currentSubTaskDetail.getEndSiteName()); + parameters.startLatLon = new AutopilotControlParameters + .AutoPilotLonLat(currentSubTaskDetail.getStartSiteWgs64Lat(), currentSubTaskDetail.getStartSiteWgs64Lon()); + parameters.endLatLon = new AutopilotControlParameters + .AutoPilotLonLat(currentSubTaskDetail.getEndSiteWgs64Lat(), currentSubTaskDetail.getEndSiteWgs64Lon()); + parameters.vehicleType = VEHICLE_TYPE; parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( - busRoutesResult.getLineId(), - busRoutesResult.csvFileUrl, busRoutesResult.csvFileMd5, - busRoutesResult.txtFileUrl, busRoutesResult.txtFileMd5, - busRoutesResult.contrailSaveTime, busRoutesResult.carModel, - busRoutesResult.csvFileUrlDPQP, busRoutesResult.csvFileMd5DPQP, - busRoutesResult.txtFileUrlDPQP, busRoutesResult.txtFileMd5DPQP, - busRoutesResult.contrailSaveTimeDPQP); + currentSubTaskDetail.getLineId(), + currentSubTaskDetail.getCsvFileUrl(),currentSubTaskDetail.getCsvFileMd5(), + currentSubTaskDetail.getTxtFileUrl(),currentSubTaskDetail.getTxtFileMd5(), + currentSubTaskDetail.getContrailSaveTime(), currentSubTaskDetail.getCarModel(), + currentSubTaskDetail.getCsvFileUrlDPQP(),currentSubTaskDetail.getCsvFileMd5DPQP(), + currentSubTaskDetail.getTxtFileUrlDPQP(),currentSubTaskDetail.getTxtFileMd5DPQP(), + currentSubTaskDetail.getContrailSaveTimeDPQP()); } - return parameters; } + + /** + * 获取当前正在执行的任务 + */ + public void getCurrentTask() { + SweeperServiceManager.getCurrentTask(mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (mSweeperTaskCallback != null && data != null) { + SweeperSubTaskBean sweeperSubTaskBean = data.getData(); + if (sweeperSubTaskBean != null && sweeperSubTaskBean.getSubList()!=null&&sweeperSubTaskBean.getSubList().size() > 0) { + mSweeperTaskCallback.setSubTaskBean(sweeperSubTaskBean); + } else { + getMainTaskList(); + } + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + }); + } + + /** + * 获取主任务列表 + */ + public void getMainTaskList() { + SweeperServiceManager.getMainTaskList(mContext, new OchCommonServiceCallback>>() { + @Override + public void onSuccess(BaseResponse> data) { + if (mSweeperTaskCallback != null && data != null && data.getCode() == 0) { + List list = data.getData(); + mSweeperTaskCallback.setMainTaskList(list); + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 获取子任务列表 + */ + public void getSubTaskList(int taskId,SweeperSubTaskBean sweeperSubTaskBean) { + SweeperServiceManager.getSubTaskList(taskId, mContext, new OchCommonServiceCallback>>() { + @Override + public void onSuccess(BaseResponse> data) { + if (mSweeperTaskCallback != null && data != null && data.getCode() == 0) { + List list = data.getData(); + if (list != null && list.size() > 0) { + sweeperSubTaskBean.setSubList(list); + mSweeperTaskCallback.setSubTaskBean(sweeperSubTaskBean); + } else { + getMainTaskList(); + } + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 获取子任务详情包括轨迹文件信息 + */ + public void getSubTaskDetail(int subTaskId) { + SweeperServiceManager.getSubTaskDetail(subTaskId, mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (data != null) { + currentSubTaskDetail = data.getData(); + if (currentSubTaskDetail!=null){ + //向自动驾驶发送要下载文件轨迹路径 + SweeperTrajectoryManager.getInstance().syncTrajectoryInfo(currentSubTaskDetail); + updateAutopilotControlParameters(); + } + + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 子任务开始上报 + */ + public void subTaskStart(int subTaskId, SubTaskTypeEnum subTaskType) { + SweeperServiceManager.subTaskStart(subTaskId, mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (mSweeperTaskCallback != null && data != null) { + if (data.getData()) { + mSweeperTaskCallback.updateSubTaskStatus(TaskStatusEnum.START_SUBTASK,false); + startBeautificationMode(); + if (subTaskType==SubTaskTypeEnum.AUTOPILOT_SUBTYPE){//如果是自动驾驶子任务子开启自驾 + startAutopilot(false); + } + } + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 子任务结束上报 + */ + public void subTaskEnd(int subTaskId,boolean isLastSubTask) { + SweeperServiceManager.subTaskEnd(subTaskId, mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (mSweeperTaskCallback != null && data != null) { + if (data.getData()) { + mSweeperTaskCallback.updateSubTaskStatus(TaskStatusEnum.END_SUBTASK,isLastSubTask); + } + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 子任务跳过上报 + */ + public void subTaskSkip(int subTaskId,boolean isLastSubTask) { + SweeperServiceManager.subTaskSkip(subTaskId, mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (mSweeperTaskCallback != null && data != null) { + if (data.getData()) { + mSweeperTaskCallback.updateSubTaskStatus(TaskStatusEnum.JUMP_OVER_SUBTASK,isLastSubTask); + if (isLastSubTask){//如果是最后一个子任务,则跳过完成后,调用结束子任务接口 + subTaskEnd(subTaskId, true); + } + } + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } + + /** + * 主任务重置 + */ + public void mainTaskReset(int taskId) { + SweeperServiceManager.mainTaskReset(taskId, mContext, new OchCommonServiceCallback>() { + @Override + public void onSuccess(BaseResponse data) { + if (mSweeperTaskCallback != null && data != null) { + mSweeperTaskCallback.setMainTaskReset(data.getData()); + } + } + + @Override + public void onFail(int code, String msg) { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort("网络异常,请稍后重试"); + } else { + ToastUtils.showShort(msg); + } + } + + @Override + public void onError() { + if (!NetworkUtils.isConnected(mContext)) { + ToastUtils.showShort(mContext.getString(R.string.network_error_tip)); + } else { + ToastUtils.showShort(mContext.getString(R.string.request_error_tip)); + } + } + }); + } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java index a546ae00c4..4800bc3c75 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/presenter/SweeperPresenter.java @@ -8,6 +8,7 @@ import com.mogo.commons.mvp.Presenter; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.autopilot.IMoGoSweeperFutianCleanSystemListener; @@ -18,14 +19,21 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.UiThreadHandler; import com.mogo.och.common.module.manager.OCHAdasAbilityManager; import com.mogo.och.common.module.utils.PinYinUtil; +import com.mogo.och.sweeper.bean.SweeperMainTaskBean; +import com.mogo.och.sweeper.bean.SweeperSubTaskBean; import com.mogo.och.sweeper.callback.ISweeperADASStatusCallback; import com.mogo.och.sweeper.callback.ISweeperControllerStatusCallback; +import com.mogo.och.sweeper.callback.ISweeperTaskCallback; +import com.mogo.och.sweeper.constant.SubTaskTypeEnum; +import com.mogo.och.sweeper.constant.TaskStatusEnum; import com.mogo.och.sweeper.fragment.SweeperFragment; import com.mogo.och.sweeper.model.SweeperTaskModel; import com.mogo.och.sweeper.util.SweeperTrajectoryManager; import org.jetbrains.annotations.NotNull; +import java.util.List; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.LifecycleOwner; @@ -35,20 +43,19 @@ import mogo_msg.MogoReportMsg; import planning.RoboSweeperTaskIndexOuterClass; import system_master.SystemStatusInfo; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; - /** * 网约车小巴 * * @author tongchenfei */ public class SweeperPresenter extends Presenter - implements IMoGoAutopilotStatusListener, ISweeperControllerStatusCallback, ISweeperADASStatusCallback, IMoGoSweeperFutianCleanSystemListener { + implements IMoGoAutopilotStatusListener, ISweeperControllerStatusCallback, ISweeperADASStatusCallback, IMoGoSweeperFutianCleanSystemListener, ISweeperTaskCallback { private static final String TAG = "BusPresenter"; - - private int currentAutopilotStatus = -1; - private boolean isRestartAutopilot = false; + //当前子任务id + private int mSubTaskId=0; + //当前是否最后一个子任务 + private boolean mIsLastSubtask=false; public SweeperPresenter(SweeperFragment view) { super(view); @@ -76,50 +83,59 @@ public class SweeperPresenter extends Presenter public void initModelListener() { SweeperTaskModel.getInstance().setControllerStatusCallback(this); SweeperTaskModel.getInstance().setAdasStatusCallback(this); + SweeperTaskModel.getInstance().setSweeperTaskCallback(this); } public void releaseListener() { SweeperTaskModel.getInstance().setControllerStatusCallback(null); SweeperTaskModel.getInstance().setAdasStatusCallback(null); + SweeperTaskModel.getInstance().setSweeperTaskCallback(null); CallerSweeperFutianCleanSystemListenerManager.INSTANCE.removeListener(TAG); } - - public void restartAutopilot() { - currentAutopilotStatus = -1; - SweeperTaskModel.getInstance().restartAutopilot(); - isRestartAutopilot = true; - } @Override public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) { if (autopilotStatusInfo == null) return; - int state = autopilotStatusInfo.getState(); - switch (state) { - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE: - if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) { - currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE; - } - // 设置自动驾驶状态是否可用 - runOnUIThread(() -> mView.onAutopilotEnableChange(true)); + switch (autopilotStatusInfo.getState()){ + case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶 + runOnUIThread(() -> mView.readyTaskBtn("准备出发",false,false)); break; - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING: - if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; - SweeperTaskModel.getInstance().triggerStartServiceEvent( - SweeperTaskModel.getInstance().isRestartAutopilot(), true); + case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶 + if (SweeperTaskModel.getInstance().getSubWorking()){ + if(FunctionBuildConfig.isDemoMode){//美化模式开启时 + SweeperTaskModel.getInstance().startBeautificationMode(); + } + }else{ + if (FunctionBuildConfig.isDemoMode){//美化模式开启时 + //关闭美化模式 + SweeperTaskModel.getInstance().closeBeautificationMode(); + } } - // 设置自动驾驶状态是否可用 - runOnUIThread(() -> mView.onAutopilotEnableChange(true)); + runOnUIThread(() -> mView.readyTaskBtn("准备出发",true,false)); break; - case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE: - if (currentAutopilotStatus != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE) { - currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE; + case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中 + if (SweeperTaskModel.getInstance().getSubWorking()){ + if (FunctionBuildConfig.isDemoMode){//美化模式开启时 + SweeperTaskModel.getInstance().startBeautificationMode(); + } + runOnUIThread(() -> mView.readyTaskBtn("暂停任务",true,true)); + }else{ + runOnUIThread(() -> mView.readyTaskBtn("准备出发",true,false)); } - // 设置自动驾驶状态是否可用 - runOnUIThread(() -> mView.onAutopilotEnableChange(false)); + case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶 + if (SweeperTaskModel.getInstance().getSubWorking()){ + if(FunctionBuildConfig.isDemoMode){//美化模式开启时 + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true;//是否强制绘制引导线 + CallerAutoPilotControlManager.INSTANCE.setIPCDemoMode(false);//是否自动启动自驾 + } + }else{ + if (FunctionBuildConfig.isDemoMode){//美化模式开启时 + //关闭美化模式 + SweeperTaskModel.getInstance().closeBeautificationMode(); + } + } + runOnUIThread(() -> mView.readyTaskBtn("准备出发",true,false)); break; default: - // 设置自动驾驶状态是否可用 - runOnUIThread(() -> mView.onAutopilotEnableChange(false)); break; } } @@ -135,12 +151,22 @@ public class SweeperPresenter extends Presenter runOnUIThread(() -> mView.updateSpeedView((float) location.getGnssSpeed())); } } - + public void cancelAutoPilot(){ + //结束自动驾驶 + CallerAutoPilotControlManager.INSTANCE.cancelAutoPilot(); + } @Override public void startOpenAutopilot() { } - + public void setSubTaskId(int mSubTaskId) { + this.mSubTaskId = mSubTaskId; + SweeperTaskModel.getInstance().setSubTaskId(mSubTaskId); + } + public void setIsLastSubtask(boolean mIsLastSubtask) { + this.mIsLastSubtask = mIsLastSubtask; + SweeperTaskModel.getInstance().setIsLastSubtask(mIsLastSubtask); + } private void runOnUIThread(Runnable executor) { if (executor == null) { return; @@ -151,38 +177,6 @@ public class SweeperPresenter extends Presenter executor.run(); } } - public void startAutopilot(){ - AutopilotControlParameters parameters = new AutopilotControlParameters(); - parameters.isSpeakVoice = true; - parameters.routeID = 164; - parameters.routeName = "bus5KM(小董)"; - parameters.startName = PinYinUtil.getPinYinHeadChar("鹰眼270-13号路口起"); - parameters.endName = PinYinUtil.getPinYinHeadChar("老干部演绎中心11223"); - parameters.startLatLon = new AutopilotControlParameters - .AutoPilotLonLat( 40.199247410363796,116.73367125257714 ); - parameters.endLatLon = new AutopilotControlParameters - .AutoPilotLonLat(40.20237, 116.74481 ); - parameters.vehicleType = 10; - if (parameters.autoPilotLine == null) { - parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( - 164, - "/home/mogo/data/vehicle_monitor/MapEngine_data/track_record_data/JL/traj_164.csv", - "", - "/home/mogo/data/vehicle_monitor/MapEngine_data/track_record_data/JL/stop_164.txt", - "", - 1662021611000L, - "金旅牌XML6606JEVY0", - "", - "", - "", - "", - 0L); - } -// CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) -// +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); - CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)); - CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters); - } /** * 测试使用 * @@ -210,7 +204,7 @@ public class SweeperPresenter extends Presenter @Override public void onAutopilotArriveAtStation(@Nullable MessagePad.ArrivalNotification arrivalNotification) { - + SweeperTaskModel.getInstance().onArriveTaskEnd(arrivalNotification); } @Override @@ -230,5 +224,115 @@ public class SweeperPresenter extends Presenter @Override public void onSweeperFutianTaskIndexData(@NonNull RoboSweeperTaskIndexOuterClass.RoboSweeperTaskIndex roboSweeperTaskIndex) { + } + /** + * 获取当前正在执行的任务 + */ + public void getCurrentTask(){ + SweeperTaskModel.getInstance().getCurrentTask(); + } + /** + * 获取子任务列表 + */ + public void getSubTaskList(int taskId,SweeperSubTaskBean sweeperSubTaskBean){ + SweeperTaskModel.getInstance().getSubTaskList(taskId,sweeperSubTaskBean); + } + /** + * 获取子任务详情包括轨迹文件信息 + */ + public void getSubTaskDetail(int subTaskId){ + SweeperTaskModel.getInstance().getSubTaskDetail(subTaskId); + } + /** + * 子任务开始上报 + */ + /** + * 开始任务 + */ + public void startTask(int subTaskId,SubTaskTypeEnum subTaskType){ + if (SweeperTaskModel.getInstance().getSubWorking()&&subTaskType==SubTaskTypeEnum.AUTOPILOT_SUBTYPE){//如果任务正在执行中,被人工接管后掉出自驾,则只重启自动驾驶 + SweeperTaskModel.getInstance().startAutopilot(); + }else{ + SweeperTaskModel.getInstance().subTaskStart(subTaskId,subTaskType); + } +// AutopilotControlParameters parameters = new AutopilotControlParameters(); +// parameters.isSpeakVoice = true; +// parameters.routeID = 164; +// parameters.routeName = "bus5KM(小董)"; +// parameters.startName = PinYinUtil.getPinYinHeadChar("鹰眼270-13号路口起"); +// parameters.endName = PinYinUtil.getPinYinHeadChar("老干部演绎中心11223"); +// parameters.startLatLon = new AutopilotControlParameters +// .AutoPilotLonLat( 40.199247410363796,116.73367125257714 ); +// parameters.endLatLon = new AutopilotControlParameters +// .AutoPilotLonLat(40.20237, 116.74481 ); +// parameters.vehicleType = 10; +// if (parameters.autoPilotLine == null) { +// parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine( +// 164, +// "/home/mogo/data/vehicle_monitor/MapEngine_data/track_record_data/JL/traj_164.csv", +// "", +// "/home/mogo/data/vehicle_monitor/MapEngine_data/track_record_data/JL/stop_164.txt", +// "", +// 1662021611000L, +// "金旅牌XML6606JEVY0", +// "", +// "", +// "", +// "", +// 0L); +// } +//// CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters) +//// +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); +// CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)); +// CallerAutoPilotControlManager.INSTANCE.startAutoPilot(parameters); + } + /** + * 子任务结束上报 + */ + public void subTaskEnd(int subTaskId,boolean isLastSubTask){ + SweeperTaskModel.getInstance().subTaskEnd(subTaskId,isLastSubTask); + } + /** + * 子任务跳过上报 + */ + public void subTaskSkip(int subTaskId,boolean isLastSubTask){ + SweeperTaskModel.getInstance().subTaskSkip(subTaskId,isLastSubTask); + } + /** + * 主任务重置 + */ + public void mainTaskReset(int taskId){ + SweeperTaskModel.getInstance().mainTaskReset(taskId); + } + + @Override + public void setMainTaskList(List mainTaskBeanList) { + mView.setMainTaskList(mainTaskBeanList); + } + + @Override + public void setSubTaskBean(SweeperSubTaskBean subTaskBean) { + mView.setSubTaskBean(subTaskBean); + } + + @Override + public void updateSubTaskStatus(TaskStatusEnum typeEnum,boolean isLastSubTask) { + if (isLastSubTask){ + if(FunctionBuildConfig.isDemoMode){//美化模式开启时 + SweeperTaskModel.getInstance().closeBeautificationMode(); + } + cancelAutoPilot(); + } + mView.updateSubTaskStatus(typeEnum,isLastSubTask); + } + + @Override + public void setMainTaskReset(boolean isSuccess) { + mView.setMainTaskReset(isSuccess); + } + + @Override + public void emptyDataUI(int type) { + } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java index 7094014b49..cad2cc733e 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/SweeperOperatePanelView.java @@ -52,6 +52,7 @@ public class SweeperOperatePanelView extends LinearLayout { private static final int CMD_EXECUTE_TIMEOUT_SECONDS = 30; private static final int CMD_EXECUTE_MOCK_SUCCESS_SECONDS = 3; + CheckedTextView mBtnCleanWorkOpenClose;//开关 CheckedTextView mBtnCleanModePureSweep;//纯扫 CheckedTextView mBtnCleanModePureWash;//纯洗 CheckedTextView mBtnCleanModeSweepWash;//洗扫 @@ -64,7 +65,6 @@ public class SweeperOperatePanelView extends LinearLayout { LinearLayout mLoadingContainer;//loading container TextView mLoadingHintTop;//loading 提示-上面 TextView mLoadingHintBottom;//loading 提示-下面 - private TextView mBtnReset;//复位 // 作业模式相关操作按钮的id List cleanModeBtnViewIds = Arrays.asList( @@ -114,10 +114,7 @@ public class SweeperOperatePanelView extends LinearLayout { private CleaningModeStateCallback cleaningModeStateCallback; - private int count = 0; - private static ChassisStatesOuterClass.SweeperFuTianTaskSystemStates mCurrentCleanSystemState;//当前作业模式 - private ChassisStatesOuterClass.SweeperFuTianTaskSystemStates mCleanSystemState;//原有的作业模式 public SweeperOperatePanelView(Context context) { super(context); @@ -140,6 +137,7 @@ public class SweeperOperatePanelView extends LinearLayout { private void initView(Context context) { LayoutInflater.from(context).inflate(R.layout.sweeper_operate_panel_view, this, true); + mBtnCleanWorkOpenClose = (CheckedTextView) findViewById(R.id.btn_clean_work_open_close); mBtnCleanModePureSweep = (CheckedTextView) findViewById(R.id.btn_clean_mode_pure_sweep); mBtnCleanModePureWash = (CheckedTextView) findViewById(R.id.btn_clean_mode_pure_wash); mBtnCleanModeSweepWash = (CheckedTextView) findViewById(R.id.btn_clean_mode_sweep_wash); @@ -152,11 +150,11 @@ public class SweeperOperatePanelView extends LinearLayout { mLoadingContainer = findViewById(R.id.loading_hint_container); mLoadingHintTop = findViewById(R.id.loading_hint_top); mLoadingHintBottom = findViewById(R.id.loading_hint_bottom); - mBtnReset = findViewById(R.id.btn_operate_panel_reset); initViewListener(); } private void initViewListener() { + setClickListener(mBtnCleanWorkOpenClose, (v) -> onCleanWorkBtnClick()); setClickListener(mBtnCleanModePureSweep, (v) -> onCleanModeBtnClick(v)); setClickListener(mBtnCleanModePureWash, (v) -> onCleanModeBtnClick(v)); setClickListener(mBtnCleanModeSweepWash, (v) -> onCleanModeBtnClick(v)); @@ -166,7 +164,90 @@ public class SweeperOperatePanelView extends LinearLayout { setClickListener(mBtnCleanDirectionBothSide, (v) -> onCleanDirectionBtnClick(v)); setClickListener(mBtnCleanIntensityStandard, (v) -> onCleanIntensityBtnClick(v)); setClickListener(mBtnCleanIntensityStrong, (v) -> onCleanIntensityBtnClick(v)); - setClickListener(mBtnReset, (v) -> onOperateReset()); + } + /** + * 清扫任务开关按钮点击事件 + */ + private void onCleanWorkBtnClick() { + // 是否是 关闭 操作 + boolean isCloseAction = mBtnCleanWorkOpenClose.isChecked(); + CmdRequestCallback cmdRequestCallback = new CmdRequestCallback() { + @Override + public void onSendCmd() { + showLoadingMask(CMD_EXECUTE_TIMEOUT_SECONDS); + } + + @Override + public void onCountDownTick(int seconds) { + updateLoadingCountDown(seconds); + } + + @Override + public boolean onCheckIfCmdSuccess(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) { + boolean success = false; + if (cleanSystemState == null) { + return success; + } + if (isCloseAction) { + success = !cleanSystemState.getSecuMotWorkSts(); + } else { + success = cleanSystemState.getSecuMotWorkSts(); + } + return success; + } + + @Override + public void onCmdSuccess() { + runOnUIThread(() -> { + if (isCloseAction) { + mBtnCleanWorkOpenClose.setText("打开"); + mBtnCleanWorkOpenClose.setChecked(false); + toggleCleanModeBtnsStatus(false); + toggleCleanDirectionBtnsStatus(false); + toggleCleanIntensityBtnsStatus(false); + } else { + mBtnCleanWorkOpenClose.setText("关闭"); + mBtnCleanWorkOpenClose.setChecked(true); + toggleCleanModeBtnsStatus(true); + } + hideLoadingMask(); + showCmdExecuteSuccessToast(); + }); + } + + @Override + public void onCmdFailed() { + } + + @Override + public void onCmdTimeout() { + //按钮样式恢复原样 + runOnUIThread(() -> { + if (isCloseAction) { + mBtnCleanWorkOpenClose.setText("打开"); + mBtnCleanWorkOpenClose.setChecked(true); + } else { + mBtnCleanWorkOpenClose.setText("关闭"); + mBtnCleanWorkOpenClose.setChecked(false); + } + hideLoadingMask(); + showCmdExecuteTimeoutToast(); + }); + } + }; + if (isCloseAction) { + //关闭操作,点击时需要弹框提示确认后,关闭 + sendSweeperCmd( + SweeperFutianCmdUtil.buildCleanWorkStopCmd(), + cmdRequestCallback + , CMD_EXECUTE_TIMEOUT_SECONDS); + } else { + //打开操作,点击时打开 + sendSweeperCmd( + SweeperFutianCmdUtil.buildCleanWorkStartCmd(), + cmdRequestCallback, + CMD_EXECUTE_TIMEOUT_SECONDS); + } } /** @@ -662,12 +743,6 @@ public class SweeperOperatePanelView extends LinearLayout { public void setSweeperFutianCleanSystemState(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState, CleaningModeStateCallback cleaningModeStateCallback) { this.cleaningModeStateCallback = cleaningModeStateCallback; - this.mCleanSystemState = cleanSystemState; - //hideLoadingMask(); -// if (isResetWorkMode){ -// isResetWorkMode=false; -// resetSuccess(cleanSystemState); -// } onSyncVehicleStateCallBack(cleanSystemState); // 有命令正在执行 if (mCurrentCmdRequestCallback != null) { @@ -724,6 +799,15 @@ public class SweeperOperatePanelView extends LinearLayout { // 作业强度状态 boolean clean_intensity_standard = cleanSystemState.getSecuWorkStandSts(); boolean clean_intensity_strong = cleanSystemState.getSecuWorkStrongSts(); + if (clean_open_requirement) { + // 打开状态 + mBtnCleanWorkOpenClose.setText("关闭"); + mBtnCleanWorkOpenClose.setChecked(true); + } else { + // 关闭状态 + mBtnCleanWorkOpenClose.setText("打开"); + mBtnCleanWorkOpenClose.setChecked(false); + } if (clean_mode_pure_sweep) { //纯扫 mBtnCleanModePureSweep.setChecked(true); @@ -817,153 +901,6 @@ public class SweeperOperatePanelView extends LinearLayout { + "[clean_intensity_requirement = " + clean_intensity_requirement + "]" ); } - - /** - * 复位 - */ - private void onOperateReset() { - if (mCleanSystemState != null) { - // 洗扫 - if (mCurrentCleanSystemState.getSecuModWashSweepSts() || mCurrentCleanSystemState.getSecuModWashSts() || mCurrentCleanSystemState.getSecuWorkTonSts() || SweeperFutianCmdUtil.checkIfCleanModePureSweep(mCurrentCleanSystemState)) { - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanModeCloseCmd()); - } - // 左侧 - if (mCurrentCleanSystemState.getSecuWorkLeftSts() || mCurrentCleanSystemState.getSecuWorkRightSts() || mCurrentCleanSystemState.getSecuWorkOnBothsidesSts()) { - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanDirectionCloseCmd()); - } - - // 洗扫 - if (mCurrentCleanSystemState.getSecuModWashSweepSts()) { - count++; - // 发送命令 - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanModeCmd(CLEAN_MODE_WASH_SWEEP)); - } - // 纯洗 - if (mCleanSystemState.getSecuModWashSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanModeCmd(CLEAN_MODE_PURE_WASH)); - } - // 纯吸 - if (mCleanSystemState.getSecuWorkTonSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanModeCmd(CLEAN_MODE_PURE_DRAW)); - } - //纯扫 - if (SweeperFutianCmdUtil.checkIfCleanModePureSweep(mCleanSystemState)) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanModeCmd(CLEAN_MODE_PURE_SWEEP)); - } - // 左侧 - if (mCleanSystemState.getSecuWorkLeftSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanDirectionCmd(CLEAN_DIRECTION_LEFT_SIDE)); - } - // 右侧 - if (mCleanSystemState.getSecuWorkRightSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanDirectionCmd(CLEAN_DIRECTION_RIGHT_SIDE)); - } - // 两侧 - if (mCleanSystemState.getSecuWorkOnBothsidesSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanDirectionCmd(CLEAN_DIRECTION_BOTH_SIDE)); - } - //标准 - if (mCleanSystemState.getSecuWorkStandSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanIntensityCmd(CLEAN_INTENSITY_STRAND)); - } - //强力 - if (mCleanSystemState.getSecuWorkStrongSts()) { - count++; - sendFuTianTaskCmd(SweeperFutianCmdUtil.buildCleanIntensityCmd(CLEAN_INTENSITY_STRONG)); - } - mCurrentCmdRequestCallback = new CmdRequestCallback() { - @Override - public void onSendCmd() { - showLoadingMask(count * CMD_EXECUTE_TIMEOUT_SECONDS); - } - - @Override - public void onCountDownTick(int senonds) { - updateLoadingCountDown(senonds); - } - - @Override - public boolean onCheckIfCmdSuccess(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) { - // 洗扫 - if (cleanSystemState.getSecuModWashSweepSts()) { - count--; - } - // 纯洗 - if (cleanSystemState.getSecuModWashSts()) { - count--; - } - // 纯吸 - if (cleanSystemState.getSecuWorkTonSts()) { - count--; - } - //纯扫 - if (SweeperFutianCmdUtil.checkIfCleanModePureSweep(cleanSystemState)) { - count--; - } - // 左侧 - if (cleanSystemState.getSecuWorkLeftSts()) { - count--; - } - // 右侧 - if (cleanSystemState.getSecuWorkRightSts()) { - count--; - } - // 两侧 - if (cleanSystemState.getSecuWorkOnBothsidesSts()) { - count--; - } - //标准 - if (cleanSystemState.getSecuWorkStandSts()) { - count--; - } - //强力 - if (cleanSystemState.getSecuWorkStrongSts()) { - count--; - } - return count == 0; - } - - @Override - public void onCmdSuccess() { - resetSuccess(mCleanSystemState); - mCurrentCleanSystemState=mCleanSystemState; - hideLoadingMask(); - showCmdExecuteSuccessToast(); - - } - - @Override - public void onCmdFailed() { - - } - - @Override - public void onCmdTimeout() { - runOnUIThread(() -> { - hideLoadingMask(); - showCmdExecuteTimeoutToast(); - }); - } - }; - // onSendCmd - mCurrentCmdRequestCallback.onSendCmd(); - // 开启倒计时 - Message msg = Message.obtain(); - msg.what = MSG_CMD_EXECUTE_COUNT_DOWN; - msg.obj = count * CMD_EXECUTE_TIMEOUT_SECONDS; - mSweeperOperateCmdHandler.sendMessage(msg); - // Mock Cmd Success - //mockSendCmdSuccess(); - } - } - /** * 发送指令 */ diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/adapter/TaskListAdapter.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/adapter/TaskListAdapter.kt index 412a851fc7..1c6a1f5798 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/adapter/TaskListAdapter.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/adapter/TaskListAdapter.kt @@ -8,12 +8,14 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView +import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.bean.TaskInfoBean +import com.mogo.och.sweeper.bean.SweeperMainTaskBean +import com.mogo.och.sweeper.constant.SubTaskTypeEnum class TaskListAdapter( private val context: Context, - private val data: List?, + private var data: List?, ) : RecyclerView.Adapter() { private var mItemClickListener: TaskItemClickListener? = null private var mSelectPosition: Int = -1 @@ -25,11 +27,13 @@ class TaskListAdapter( val selectIv: ImageView val taskName: TextView//任务名称 val taskDesc: TextView//任务描述 + val tvTaskTime: TextView//任务时间 init { selectIv = itemView.findViewById(R.id.ivTaskSelect) taskName = itemView.findViewById(R.id.tvTaskName) taskDesc = itemView.findViewById(R.id.tvTaskDesc) + tvTaskTime = itemView.findViewById(R.id.tvTaskTime) } } @@ -37,9 +41,12 @@ class TaskListAdapter( this.mSelectPosition = position notifyDataSetChanged() } - + fun setTaskListData(data: List?){ + this.data=data + notifyDataSetChanged() + } interface TaskItemClickListener { - fun onItemClick(position: Int) + fun onItemClick(position: Int,mainTask:SweeperMainTaskBean) } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TaskViewHolder { @@ -50,6 +57,19 @@ class TaskListAdapter( } override fun onBindViewHolder(holder: TaskViewHolder, position: Int) { + data?.let { mainTask-> + holder.taskName.text= mainTask[position].mainTaskName + holder.taskDesc.text= "全程包含${mainTask[position].subTaskTotal}个子任务" + val calendar = DateTimeUtil.formatLongToCalendar(mainTask[position].mainTaskStartTime) + if (DateTimeUtil.compareDateIsCurrentDay(calendar)){ + holder.tvTaskTime.text="今天${DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm)}" + }else{ + holder.tvTaskTime.text=DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_MM_dd_HH_mm) + } + holder.itemView.setOnClickListener { + mItemClickListener?.onItemClick(position,mainTask[position]) + } + } if (position == mSelectPosition) { holder.selectIv.visibility = View.VISIBLE holder.itemView.setBackgroundColor(Color.parseColor("#FF152644")) @@ -57,9 +77,6 @@ class TaskListAdapter( holder.selectIv.visibility = View.GONE holder.itemView.setBackgroundColor(Color.parseColor("#00000000")) } - holder.itemView.setOnClickListener { - mItemClickListener?.onItemClick(position) - } } override fun getItemCount(): Int = data?.size ?: 0 diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/MenuPopWindow.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/MenuPopWindow.kt index 94992a6f57..1f2c5ad8f0 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/MenuPopWindow.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/MenuPopWindow.kt @@ -8,11 +8,8 @@ import android.view.View import android.view.ViewGroup.LayoutParams import android.widget.PopupWindow import android.widget.TextView -import chassis.ChassisStatesOuterClass import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.callback.CleaningModeStateCallback -import com.mogo.och.sweeper.constant.OperateStateEnum -import com.mogo.och.sweeper.constant.TaskMenuTypeEnum +import com.mogo.och.sweeper.constant.TaskStatusEnum /** * 当前任务操作菜单栏 @@ -71,21 +68,21 @@ class MenuPopWindow : PopupWindow, View.OnClickListener{ } interface OnMenuItemOnClickListener { - fun onMenuItemClick(itemType: TaskMenuTypeEnum) + fun onMenuItemClick(itemType: TaskStatusEnum) } override fun onClick(v: View) { when(v.id){ R.id.tvJumpOverTask->{ - mMenuItemClickListener?.onMenuItemClick(TaskMenuTypeEnum.JUMP_OVER_TASK) + mMenuItemClickListener?.onMenuItemClick(TaskStatusEnum.JUMP_OVER_SUBTASK) dismiss() } R.id.tvEndTask->{ - mMenuItemClickListener?.onMenuItemClick(TaskMenuTypeEnum.END_TASK) + mMenuItemClickListener?.onMenuItemClick(TaskStatusEnum.END_TASK) dismiss() } R.id.tvCancelTask->{ - mMenuItemClickListener?.onMenuItemClick(TaskMenuTypeEnum.CANCEL_TASK) + mMenuItemClickListener?.onMenuItemClick(TaskStatusEnum.CANCEL_TASK) dismiss() } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt index ca164caf11..b32ce8b15c 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/ui/popwindow/SweeperOperatePanelPopWindow.kt @@ -18,7 +18,6 @@ import com.mogo.och.sweeper.ui.SweeperOperatePanelView class SweeperOperatePanelPopWindow : PopupWindow { private var mOperatePanelView: SweeperOperatePanelView? = null - private var mBtnCancel: TextView? = null //取消 constructor(context: Context) : super(context) { init(context) @@ -27,16 +26,12 @@ class SweeperOperatePanelPopWindow : PopupWindow { private fun init(context: Context) { setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) mOperatePanelView = LayoutInflater.from(context).inflate(R.layout.sweeper_popwindow_operate_panel, null) as SweeperOperatePanelView? - mBtnCancel = mOperatePanelView?.findViewById(R.id.btn_operate_panel_cancel) width = ViewGroup.LayoutParams.WRAP_CONTENT height = ViewGroup.LayoutParams.WRAP_CONTENT contentView = mOperatePanelView - isFocusable = false - isOutsideTouchable = false + isFocusable = true + isOutsideTouchable = true isTouchable=true - mBtnCancel?.setOnClickListener { - dismiss() - } } /** diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java index cc61639c5f..6c58b2d6e5 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/util/SweeperTrajectoryManager.java @@ -1,24 +1,22 @@ package com.mogo.och.sweeper.util; -import androidx.annotation.Nullable; - import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.GsonUtils; -import com.mogo.och.sweeper.bean.SweeperRoutesResult; +import com.mogo.och.sweeper.bean.SweeperSubTaskDetailBean; import com.mogo.och.sweeper.constant.SweeperConst; -import com.mogo.och.sweeper.model.SweeperTaskModel; import java.util.concurrent.TimeUnit; +import androidx.annotation.Nullable; import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; import mogo_msg.MogoReportMsg; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_SWEEPER; /** * Bus轨迹管理:给MEC下发用于轨迹下载的信息 @@ -47,82 +45,63 @@ public class SweeperTrajectoryManager { /** * 同步Bus路线信息 */ - public void syncTrajectoryInfo() { - SweeperRoutesResult routesResult = SweeperTaskModel.getInstance().getBusRoutesResult(); - if (routesResult != null - && SweeperTaskModel.getInstance().getCurrentStationIndex() == 0 - && !SweeperTaskModel.getInstance().isGoingToNextStation()) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "syncTrajectoryInfo() start."); - startTrajReqLoop(); + public void syncTrajectoryInfo(SweeperSubTaskDetailBean sweeperSubTaskDetailBean) { + if (sweeperSubTaskDetailBean != null) { + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "syncTrajectoryInfo() start."); + startTrajReqLoop(sweeperSubTaskDetailBean); } else { // 无路线信息or当前未在始发站 - CallerLogger.INSTANCE.d(M_BUS + TAG, "syncTrajectoryInfo() stop."); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "syncTrajectoryInfo() stop."); stopTrajReqLoop(); } } /** * 接口MEC反馈的常规信息(MAP v2.5.0新增轨迹相关信息) + * * @param guardianInfo */ public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) { if (guardianInfo == null || !guardianInfo.hasCode()) return; if ("ISYS_INIT_TRAJECTORY_START".equals(guardianInfo.getCode())) { // 1. 轨迹管理_轨迹开始下载(本地已有对应轨迹也触发) - CallerLogger.INSTANCE.d(M_BUS + TAG, "onAutopilotGuardian() 轨迹开始下载"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotGuardian() 轨迹开始下载"); // ToastUtils.showShort("轨迹开始下载"); stopTrajReqLoop(); } else if ("ISYS_INIT_TRAJECTORY_SUCCESS".equals(guardianInfo.getCode())) { // 2. 轨迹管理_轨迹下载成功(本地已有对应轨迹也触发) - CallerLogger.INSTANCE.d(M_BUS + TAG, "onAutopilotGuardian() 轨迹下载成功"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotGuardian() 轨迹下载成功"); // ToastUtils.showShort("轨迹下载成功"); stopTrajReqLoop(); } else if ("ISYS_INIT_TRAJECTORY_FAILURE".equals(guardianInfo.getCode())) { // 3. 轨迹管理_轨迹下载失败,本地无对应轨迹 - CallerLogger.INSTANCE.d(M_BUS + TAG, "onAutopilotGuardian() " + + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotGuardian() " + "轨迹下载失败,本地无对应轨迹"); // ToastUtils.showShort("轨迹下载失败,本地无对应轨迹"); } else if ("ISYS_INIT_TRAJECTORY_WARNING".equals(guardianInfo.getCode())) { // 4. 轨迹管理_轨迹下载失败,本地有对应轨迹,认为成功 - CallerLogger.INSTANCE.d(M_BUS + TAG, "onAutopilotGuardian() " + + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotGuardian() " + "轨迹下载失败,本地有对应轨迹,认为成功"); // ToastUtils.showShort("轨迹下载失败,本地有对应轨迹,认为成功"); } else if ("ISYS_INIT_TRAJECTORY_TIMEOUT".equals(guardianInfo.getCode())) { // 5. 轨迹管理_轨迹下载超时 - CallerLogger.INSTANCE.d(M_BUS + TAG, "onAutopilotGuardian() 轨迹下载超时"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotGuardian() 轨迹下载超时"); // ToastUtils.showShort("轨迹下载超时"); } } - private void setupAutoPilotLine() { - SweeperRoutesResult routesResult = SweeperTaskModel.getInstance().getBusRoutesResult(); - if (routesResult == null) { - CallerLogger.INSTANCE.e(M_BUS + TAG, - "setupAutoPilotLine(): routesResult is null."); + private void setupAutoPilotLine(SweeperSubTaskDetailBean subTaskDetail) { + if (subTaskDetail == null) { + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "setupAutoPilotLine(): routesResult is null."); return; } else { - if (mAutoPilotLine == null) { - mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(routesResult.getLineId(), - routesResult.csvFileUrl, routesResult.csvFileMd5, - routesResult.txtFileUrl, routesResult.txtFileMd5, - routesResult.contrailSaveTime, routesResult.carModel, - routesResult.csvFileUrlDPQP, routesResult.csvFileMd5DPQP, - routesResult.txtFileUrlDPQP, routesResult.txtFileMd5DPQP, - routesResult.contrailSaveTimeDPQP); - } else { - mAutoPilotLine.setLineId(routesResult.getLineId()); - mAutoPilotLine.setTrajUrl(routesResult.csvFileUrl); - mAutoPilotLine.setTrajMd5(routesResult.csvFileMd5); - mAutoPilotLine.setStopUrl(routesResult.txtFileUrl); - mAutoPilotLine.setStopMd5(routesResult.txtFileMd5); - mAutoPilotLine.setTimestamp(routesResult.contrailSaveTime); - mAutoPilotLine.setVehicleModel(routesResult.carModel); - mAutoPilotLine.setTrajUrl_dpqp(routesResult.csvFileUrlDPQP); - mAutoPilotLine.setTrajMd5_dpqp(routesResult.csvFileMd5DPQP); - mAutoPilotLine.setStopUrl_dpqp(routesResult.txtFileUrlDPQP); - mAutoPilotLine.setStopMd5_dpqp(routesResult.txtFileMd5DPQP); - mAutoPilotLine.setTimestamp_dpqp(routesResult.contrailSaveTimeDPQP); - } + mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(subTaskDetail.getLineId(), + subTaskDetail.getCsvFileUrl(), subTaskDetail.getCsvFileMd5(), + subTaskDetail.getTxtFileUrl(), subTaskDetail.getTxtFileMd5(), + subTaskDetail.getContrailSaveTime(), subTaskDetail.getCarModel(), + subTaskDetail.getCsvFileUrlDPQP(), subTaskDetail.getCsvFileMd5DPQP(), + subTaskDetail.getTxtFileUrlDPQP(), subTaskDetail.getTxtFileMd5DPQP(), + subTaskDetail.getContrailSaveTimeDPQP()); } } @@ -142,14 +121,14 @@ public class SweeperTrajectoryManager { mAutoPilotLine.setTimestamp_dpqp(0); } - private void startTrajReqLoop() { + private void startTrajReqLoop(SweeperSubTaskDetailBean sweeperSubTaskDetailBean) { if (mSendReqDisposable != null && !mSendReqDisposable.isDisposed()) { return; } - CallerLogger.INSTANCE.d(M_BUS + TAG, "startTrajReqLoop()"); - setupAutoPilotLine(); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "startTrajReqLoop()"); + setupAutoPilotLine(sweeperSubTaskDetailBean); mSendReqDisposable = Observable.interval(SweeperConst.LOOP_DELAY, - SweeperConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS) + SweeperConst.LOOP_PERIOD_10S, TimeUnit.MILLISECONDS) .map((aLong -> aLong + 1)) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -158,14 +137,14 @@ public class SweeperTrajectoryManager { stopTrajReqLoop(); return; } - CallerLogger.INSTANCE.d(M_BUS + TAG, "loop sendTrajectoryReq: " + aLong); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "loop sendTrajectoryReq: " + aLong); sendTrajectoryReq(); }); } public void stopTrajReqLoop() { if (mSendReqDisposable != null) { - CallerLogger.INSTANCE.d(M_BUS + TAG, "stopTrajReqLoop()"); + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "stopTrajReqLoop()"); mSendReqDisposable.dispose(); mSendReqDisposable = null; clearAutoPilotLine(); @@ -174,7 +153,7 @@ public class SweeperTrajectoryManager { private void sendTrajectoryReq() { if (mAutoPilotLine == null) { - CallerLogger.INSTANCE.e(M_BUS + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!"); + CallerLogger.INSTANCE.e(M_SWEEPER + TAG, "sendTrajectoryReq(): mAutoPilotLine is null!!!"); return; } @@ -198,7 +177,7 @@ public class SweeperTrajectoryManager { // mAutoPilotLine.setVehicleModel("红旗H9"); CallerAutoPilotControlManager.INSTANCE.sendTrajectoryDownloadReq(mAutoPilotLine); - CallerLogger.INSTANCE.d(M_BUS + TAG, "sendTrajectoryReq(): " + CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "sendTrajectoryReq(): " + GsonUtils.toJson(mAutoPilotLine)); } } diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SubTaskView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SubTaskView.kt index 188506b569..1238c6ad23 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SubTaskView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SubTaskView.kt @@ -6,8 +6,10 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.och.common.module.utils.DateTimeUtil import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.bean.TaskInfoBean +import com.mogo.och.sweeper.bean.SubInfo +import com.mogo.och.sweeper.bean.SweeperSubTaskBean import kotlinx.android.synthetic.main.sweeper_subtask_view.view.* /** @@ -29,16 +31,27 @@ class SubTaskView : ConstraintLayout { /** * 设置子任务信息 */ - fun setData(taskInfo:TaskInfoBean,isSelect:Boolean=false,isLastTask:Boolean=false){ + fun setData(taskInfo: SubInfo, isSelect: Boolean = false, isLastTask: Boolean = false) { tvSubTaskName.text = taskInfo.taskName - tvSubTaskName.setTextColor(if (isSelect) Color.parseColor("#3BD2FF")else Color.parseColor("#FFFFFF")) - if (isSelect){ - ivSubTaskSelect.visibility=View.VISIBLE - ivSubTask.visibility=View.GONE - }else{ - ivSubTaskSelect.visibility=View.GONE - ivSubTask.visibility=View.VISIBLE + var mileage: String = if (taskInfo.mileage < 1000) { + "${taskInfo.mileage}米" + } else { + "${taskInfo.mileage / 1000F}千米" } - ivRightDownArrow.visibility=if (isLastTask) View.GONE else View.VISIBLE + var timeSpent=if(DateTimeUtil.secondsToHourStr(taskInfo.timeSpent)!=""){ + "${DateTimeUtil.secondsToHourStr(taskInfo.timeSpent/1000)}小时${DateTimeUtil.secondsToMinuteStr(taskInfo.timeSpent/1000)}分钟" + }else{ + "${DateTimeUtil.secondsToMinuteStr(taskInfo.timeSpent/1000)}分钟" + } + tvSubTaskDesc.text = "全程约${mileage},预计耗时$timeSpent 分钟" + tvSubTaskName.setTextColor(if (isSelect) Color.parseColor("#3BD2FF") else Color.parseColor("#FFFFFF")) + if (isSelect) { + ivSubTaskSelect.visibility = View.VISIBLE + ivSubTask.visibility = View.GONE + } else { + ivSubTaskSelect.visibility = View.GONE + ivSubTask.visibility = View.VISIBLE + } + ivRightDownArrow.visibility = if (isLastTask) View.GONE else View.VISIBLE } } \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperCurrentTaskInfoView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperCurrentTaskInfoView.kt index 42918e2334..841d7436e3 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperCurrentTaskInfoView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperCurrentTaskInfoView.kt @@ -4,11 +4,12 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.View -import android.widget.ImageView -import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import com.mogo.och.sweeper.R -import com.mogo.och.sweeper.bean.TaskInfoBean +import com.mogo.och.sweeper.bean.SubInfo +import com.mogo.och.sweeper.bean.SweeperSubTaskBean +import com.mogo.och.sweeper.constant.SubTaskTypeEnum +import com.mogo.och.sweeper.presenter.SweeperPresenter import com.mogo.och.sweeper.ui.popwindow.MenuPopWindow import kotlinx.android.synthetic.main.sweeper_current_task_info.view.* @@ -18,6 +19,10 @@ import kotlinx.android.synthetic.main.sweeper_current_task_info.view.* class SweeperCurrentTaskInfoView : ConstraintLayout { //当前任务操作菜单 private var mTaskMenuPopWindow: MenuPopWindow? = null + private var presenter: SweeperPresenter?=null + private var mCurrentPosition=-1 + private var listTask:List?=null + constructor(context: Context) : super(context) {} constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { initView(context) @@ -29,41 +34,22 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { private fun initView(context: Context) { LayoutInflater.from(context).inflate(R.layout.sweeper_current_task_info, this) } + /** * 设置当前任务数据 */ - fun setData(workModePanelView:SweeperWorkModeView,listTask: List, currentPosition: Int,menuItemClickListener: MenuPopWindow.OnMenuItemOnClickListener) { + fun setData( + workModePanelView: SweeperWorkModeView, + subTaskBean: SweeperSubTaskBean?, + currentPosition: Int, + menuItemClickListener: MenuPopWindow.OnMenuItemOnClickListener, + presenter:SweeperPresenter? + ) { + this.presenter=presenter + this.listTask=subTaskBean?.subList + this.mCurrentPosition=currentPosition mTaskMenuPopWindow = MenuPopWindow(context, menuItemClickListener) - if (listTask.size == 1) { - preSubTask.setData(listTask[currentPosition], isSelect=true,isLastTask=true) - currentSubTask.visibility = View.INVISIBLE - lastSubTask.visibility = View.INVISIBLE - } else if (listTask.size == 2) { - if (currentPosition==0){ - preSubTask.setData(listTask[currentPosition], isSelect=true) - currentSubTask.setData(listTask[1], isSelect=true) - }else{ - preSubTask.setData(listTask[currentPosition - 1]) - currentSubTask.setData(listTask[currentPosition], isSelect=true,isLastTask=true) - } - lastSubTask.visibility = View.INVISIBLE - } else { - //当前正在执行的任务是第一个子任务 - if (currentPosition == 0) { - preSubTask.setData(listTask[currentPosition], isSelect=true) - currentSubTask.setData(listTask[1]) - lastSubTask.setData(listTask[2], isLastTask=true) - //当前正在执行的任务是最后一个子任务 - } else if (currentPosition == listTask.size - 1) { - preSubTask.setData(listTask[currentPosition - 2]) - currentSubTask.setData(listTask[currentPosition-1]) - lastSubTask.setData(listTask[currentPosition], isSelect=true,isLastTask=true) - } else { - preSubTask.setData(listTask[currentPosition - 1]) - currentSubTask.setData(listTask[currentPosition],isSelect=true) - lastSubTask.setData(listTask[currentPosition + 1],isLastTask=true) - } - } + setCurrentData(currentPosition) //任务操作菜单打开关闭处理 ivMore.setOnClickListener { if (mTaskMenuPopWindow?.isShowing != true) { @@ -76,16 +62,72 @@ class SweeperCurrentTaskInfoView : ConstraintLayout { mTaskMenuPopWindow?.dismiss() } } - } + readyTaskBtn.setOnClickListener { + //开始执行任务 + startSubTask() + } + } /** * 设置准备就绪按钮时都可以点击 */ - fun setEnableClickBtn(isEnable:Boolean){ - readyTaskBtn.isSelected= isEnable + fun setEnableClickBtn(text:String,isClick:Boolean,isTaskWorking:Boolean) { + readyTaskBtn.text=text + readyTaskBtn.isClickable=isClick + readyTaskBtn.isSelected=isClick + if (isTaskWorking){ + tvTaskState.text="正在作业" + tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working) + }else{ + tvTaskState.text="暂未准备" + tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready) + } } - fun getReadyTaskBtn():TextView{ - return readyTaskBtn + /** + * 开始子任务 + */ + private fun startSubTask(){ + listTask?.let { + presenter?.startTask(it[mCurrentPosition].taskId, + if(it[mCurrentPosition].taskType== SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE) + } + } + /** + * 填充数据 + */ + fun setCurrentData(mCurrentPosition:Int){ + listTask?.let { + if (it.size == 1) { + preSubTask.setData(it[mCurrentPosition], isSelect = true, isLastTask = true) + currentSubTask.visibility = View.INVISIBLE + lastSubTask.visibility = View.INVISIBLE + } else if (it.size == 2) { + if (mCurrentPosition == 0) { + preSubTask.setData(it[mCurrentPosition], isSelect = true) + currentSubTask.setData(it[1], isSelect = true) + } else { + preSubTask.setData(it[mCurrentPosition - 1]) + currentSubTask.setData(it[mCurrentPosition], isSelect = true, isLastTask = true) + } + lastSubTask.visibility = View.INVISIBLE + } else { + //当前正在执行的任务是第一个子任务 + if (mCurrentPosition == 0) { + preSubTask.setData(it[mCurrentPosition], isSelect = true) + currentSubTask.setData(it[1]) + lastSubTask.setData(it[2], isLastTask = true) + //当前正在执行的任务是最后一个子任务 + } else if (mCurrentPosition == it.size - 1) { + preSubTask.setData(it[mCurrentPosition - 2]) + currentSubTask.setData(it[mCurrentPosition - 1]) + lastSubTask.setData(it[mCurrentPosition], isSelect = true, isLastTask = true) + } else { + preSubTask.setData(it[mCurrentPosition - 1]) + currentSubTask.setData(it[mCurrentPosition], isSelect = true) + lastSubTask.setData(it[mCurrentPosition + 1], isLastTask = true) + } + } + } } } \ No newline at end of file diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt index ef454443c6..96533fa27d 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperWorkModeView.kt @@ -9,6 +9,7 @@ import chassis.ChassisStatesOuterClass.SweeperFuTianTaskSystemStates import com.mogo.och.sweeper.R import com.mogo.och.sweeper.callback.CleaningModeStateCallback import com.mogo.och.sweeper.constant.OperateStateEnum +import com.mogo.och.sweeper.constant.SubTaskTypeEnum import com.mogo.och.sweeper.ui.popwindow.SweeperOperatePanelPopWindow import com.mogo.och.sweeper.util.SweeperFutianCmdUtil import kotlinx.android.synthetic.main.sweeper_work_mode.view.* @@ -39,7 +40,7 @@ class SweeperWorkModeView : ConstraintLayout, CleaningModeStateCallback { /** * 设置清扫模式面板 */ - fun setSweeperFutianCleanSystemState(taskType: Int, cleanSystemState: SweeperFuTianTaskSystemStates?, trafficDataView: SweeperTrafficDataView) { + fun setSweeperFutianCleanSystemState(taskType: SubTaskTypeEnum, cleanSystemState: SweeperFuTianTaskSystemStates?, trafficDataView: SweeperTrafficDataView) { mOperatePanelPopWindow?.setCleanSystemState(cleanSystemState, this@SweeperWorkModeView) //清扫模式选择面板打开关闭处理 ivOpenOperatePanel.setOnClickListener { @@ -54,7 +55,7 @@ class SweeperWorkModeView : ConstraintLayout, CleaningModeStateCallback { } } //清扫车暂未选择清扫模式或者任务类型是人工驾驶子任务,则暂无清扫模式 - if (SweeperFutianCmdUtil.checkIfCleanMode(cleanSystemState) || taskType == 2) { + if (SweeperFutianCmdUtil.checkIfCleanMode(cleanSystemState) || taskType.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) { setShowOrHideCleanSystemState(OperateStateEnum.NO_STATUS, cleanSystemState) } else { setShowOrHideCleanSystemState(OperateStateEnum.SUCCESS_STATUS, cleanSystemState) diff --git a/OCH/mogo-och-sweeper/src/main/res/layout/fragment_och_sweeper.xml b/OCH/mogo-och-sweeper/src/main/res/layout/fragment_och_sweeper.xml index 6bfaec3e97..efd874b9ab 100644 --- a/OCH/mogo-och-sweeper/src/main/res/layout/fragment_och_sweeper.xml +++ b/OCH/mogo-och-sweeper/src/main/res/layout/fragment_och_sweeper.xml @@ -10,6 +10,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"> + android:layout_marginTop="@dimen/dp_21" + android:layout_marginEnd="@dimen/dp_10"/> diff --git a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_operate_panel_view.xml b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_operate_panel_view.xml index 0ca75e841c..fd6265904f 100644 --- a/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_operate_panel_view.xml +++ b/OCH/mogo-och-sweeper/src/main/res/layout/sweeper_operate_panel_view.xml @@ -4,6 +4,37 @@ android:layout_width="@dimen/dp_957" android:layout_height="@dimen/dp_758" android:background="@drawable/bg_sweeper_operate_panel"> + + + @@ -230,33 +261,6 @@ android:textSize="@dimen/sweeper_operate_panel_btn_text_size" app:layout_constraintLeft_toRightOf="@id/btn_clean_intensity_standard" app:layout_constraintTop_toBottomOf="@id/hint_clean_intensity" /> - - + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools">