[清扫车]由于启动自驾和开始任务使用同一个按钮,与实际业务冲突,把启动自驾和开始任务拆分

This commit is contained in:
bxb
2023-03-01 09:27:07 +08:00
parent 5cb698a9ca
commit 612a875a03
17 changed files with 218 additions and 151 deletions

View File

@@ -6,5 +6,6 @@ import com.mogo.och.sweeper.database.bean.WeltDataBean
data class WeltDataEvent(
var type:Int, //1.添加起点和终点 2.实时添加贴边数据 3.清除数据
var weltDataBeanList: MutableList<WeltDataBean>?,
var markers:MutableList<LatLng>?
var markers:MutableList<LatLng>?,
var distance:Double//贴边数据
)

View File

@@ -425,15 +425,15 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
*
* @param weltDataBeans
*/
public void setWeltDataToMap(ArrayList<WeltDataBean> weltDataBeans,Boolean isWeltData) {
public void setWeltDataToMap(ArrayList<WeltDataBean> weltDataBeans,Boolean isWeltData,double distance) {
if (mMapWeltView != null) {
runOnUIThread(() -> {
mMapWeltView.setWeltData(weltDataBeans,isWeltData);
UiThreadHandler.post(()->{
mMapWeltView.setWeltData(weltDataBeans,isWeltData,distance);
mMapWeltView.drawablePolyline();
});
}
this.weltDataBeanList = weltDataBeans;
EventBus.getDefault().postSticky(new WeltDataEvent(2, weltDataBeans, null));
EventBus.getDefault().postSticky(new WeltDataEvent(2, weltDataBeans, null,distance));
}
/**
@@ -447,7 +447,7 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
latLngs.add(0, startPoint);
latLngs.add(1, endPoint);
this.latLngList = latLngs;
EventBus.getDefault().postSticky(new WeltDataEvent(1, null, latLngs));
EventBus.getDefault().postSticky(new WeltDataEvent(1, null, latLngs,0));
}
/**
@@ -457,20 +457,8 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
if (mMapWeltView != null) {
mMapWeltView.clearAllMarkerAndPolyline();
}
EventBus.getDefault().postSticky(new WeltDataEvent(3, null, null));
EventBus.getDefault().postSticky(new WeltDataEvent(3, null, null,0));
}
private void runOnUIThread(Runnable executor) {
if (executor == null) {
return;
}
if (Looper.myLooper() != Looper.getMainLooper()) {
UiThreadHandler.post(executor);
} else {
executor.run();
}
}
/**
* 导航去目的地
*/

View File

@@ -2,7 +2,6 @@ package com.mogo.och.sweeper.fragment
import android.os.Bundle
import android.view.View
import androidx.annotation.UiThread
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import chassis.ChassisStatesOuterClass
@@ -24,9 +23,11 @@ import com.mogo.och.sweeper.ui.adapter.TaskListAdapter
import com.mogo.och.sweeper.ui.dialog.SweeperManualDrivingDialog
import com.mogo.och.sweeper.ui.dialog.SweeperNoTitleCommonDialog
import com.mogo.och.sweeper.ui.popwindow.MenuPopWindow
import com.mogo.och.sweeper.util.SweeperFutianCmdUtil
import kotlinx.android.synthetic.main.fragment_och_sweeper.*
import kotlinx.android.synthetic.main.sweeper_no_data_common_view.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
/**
@@ -119,8 +120,14 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
/**
* 根据自动驾驶状态更新按钮
*/
fun readyTaskBtn(isClick: Boolean, isPause: Boolean) {
sweeper_current_task_view.setEnableClickBtn(isClick, isPause)
fun startAutoBtn(autopilotState:Int) {
sweeper_current_task_view.setStartAutoBtn(autopilotState)
}
/**
* 任务按钮状态
*/
fun setTaskBtn(isWorking: Boolean) {
sweeper_current_task_view.setEnableClickBtn(isWorking)
}
/**
@@ -168,11 +175,9 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
}
}
}
@UiThread
fun onSweeperFutianCleanSystemState(cleanSystemState: ChassisStatesOuterClass.SweeperFuTianTaskSystemStates) {
this.mCleanSystemState = cleanSystemState
lifecycleScope.launch(Dispatchers.Main){
mCleanSystemState = cleanSystemState
sweeper_cl_work_mode.setSweeperFutianCleanSystemState(mSubTaskType, cleanSystemState)
}
}
@@ -267,15 +272,12 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
}
}
TaskStatusEnum.START_SUBTASK.code -> { //子任务开始
if (mSubTaskType.code == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) {//自动驾驶子任务
readyTaskBtn(true, true)
} else {
readyTaskBtn(false, false)
}
setTaskBtn(true)
setShowTaskListPanelView(false)
sweeper_cl_work_mode.visibility = View.VISIBLE
setShowCurrentTaskPanelView(true)
sweeper_current_task_view.setCurrentData(mCurrentSubPosition)
sweeper_current_task_view.setTaskStatus(2)
}
}
@@ -444,14 +446,20 @@ class SweeperFragment : BaseSweeperTabFragment<SweeperFragment?, SweeperPresente
endWeltData.weltDistance=-9999.0
dataList.add(endWeltData)
}
setWeltDataToMap(dataList,false)
setWeltDataToMap(dataList,false,0.0)
}
}
//模拟结束子任务
override fun debugEndSubTask() {
mSubInfo?.let {
mPresenter?.onArriveTaskEnd(null)
// mSubInfo?.let {
// mPresenter?.onArriveTaskEnd(null)
// }
lifecycleScope.launch(Dispatchers.IO) {
while (true){
onSweeperFutianCleanSystemState( SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData())
delay(500)
}
}
}
}

View File

@@ -53,7 +53,7 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
}
}
weltDataList?.let {
setWeltData(it,false)
setWeltData(it,false,0.0)
drawablePolyline()
}
}
@@ -105,8 +105,8 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
}
}
} else if (weltDataEvent.type == 2) {
setWeltData(weltDataEvent.weltDataBeanList,true)
lifecycleScope.launch(Dispatchers.Main) {
setWeltData(weltDataEvent.weltDataBeanList,true,weltDataEvent.distance)
drawablePolyline()
}
} else if (weltDataEvent.type == 3) {
@@ -119,8 +119,8 @@ class WeltMapOverViewFragment(var mIWeltMapSwitchToSmallCallBack: IWeltMapSwitch
/**
* 设置任务路线数据
*/
private fun setWeltData(weltDatas: MutableList<WeltDataBean>?,isWeltData:Boolean) {
weltMapOverView.setWeltData(weltDatas,isWeltData)
private fun setWeltData(weltDatas: MutableList<WeltDataBean>?,isWeltData:Boolean,distance:Double) {
weltMapOverView.setWeltData(weltDatas,isWeltData,distance)
}
/**

View File

@@ -289,7 +289,6 @@ public class SweeperTaskModel {
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "行程日志-重启自动驾驶===" + mIsSubTaskWorking);
//只去启动自动驾驶
startAutopilot(firstStartAutopilot >= 1);
mIsSubTaskWorking=true;
}
/**
@@ -377,7 +376,9 @@ public class SweeperTaskModel {
SweeperAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send,
mCurrentSubTaskDetail.getStartSiteName(), mCurrentSubTaskDetail.getEndSiteName(), mCurrentSubTaskDetail.getLineId());
}
public boolean isRestartAutopilot() {
return firstStartAutopilot > 1;
}
public void triggerUnableStartAPReasonEvent() {
if (mCurrentSubTaskDetail == null) {
return;

View File

@@ -1,6 +1,5 @@
package com.mogo.och.sweeper.presenter;
import android.os.Looper;
import com.amap.api.maps.model.LatLng;
import com.mogo.commons.AbsMogoApplication;
@@ -14,7 +13,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerSweeperFutianCleanSystemListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
import com.mogo.och.sweeper.bean.SweeperMainTaskBean;
@@ -69,6 +68,8 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
private static final long WELT_DATA_INTERVAL_MILLIS = 2000L;
// 贴边数据当前时间戳
private long mWeltDataCurrentTimeMillis;
//当前自动驾驶状态
private int mCurrentAutopilotStatus;
public SweeperPresenter(SweeperFragment view) {
super(view);
@@ -114,11 +115,11 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
@Override
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autopilotStatusInfo) {
if (autopilotStatusInfo == null) return;
CallerLogger.INSTANCE.d(M_SWEEPER + TAG,"onAutopilotStatusResponse state:"+autopilotStatusInfo.getState());
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onAutopilotStatusResponse state:" + autopilotStatusInfo.getState());
SweeperTaskModel.getInstance().setAutopilotState(autopilotStatusInfo.getState());
ThreadUtils.runOnUiThread(() -> mView.startAutoBtn(autopilotStatusInfo.getState()));
switch (autopilotStatusInfo.getState()) {
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE://不可自动驾驶
runOnUIThread(() -> mView.readyTaskBtn(false, false));
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE://人工驾驶
if (SweeperTaskModel.getInstance().getSubWorking()) {
@@ -131,17 +132,16 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
SweeperTaskModel.getInstance().closeBeautificationMode();
}
}
runOnUIThread(() -> mView.readyTaskBtn(true, false));
break;
case IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING://自动驾驶中
SweeperTaskModel.getInstance().triggerStartServiceEvent(
SweeperTaskModel.getInstance().isRestartAutopilot(), true);
if (SweeperTaskModel.getInstance().getSubWorking()) {
if (FunctionBuildConfig.isDemoMode) {//美化模式开启时
SweeperTaskModel.getInstance().startBeautificationMode();
}
runOnUIThread(() -> mView.readyTaskBtn( true, true));
} else {
runOnUIThread(() -> mView.readyTaskBtn(true, false));
}
break;
case IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING://平行驾驶
if (SweeperTaskModel.getInstance().getSubWorking()) {
if (FunctionBuildConfig.isDemoMode) {//美化模式开启时
@@ -154,7 +154,6 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
SweeperTaskModel.getInstance().closeBeautificationMode();
}
}
runOnUIThread(() -> mView.readyTaskBtn(true, false));
break;
default:
break;
@@ -163,14 +162,14 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
@Override
public void onVRModeChanged(boolean isVRMode) {
runOnUIThread(() -> mView.onVRModeChanged(isVRMode));
ThreadUtils.runOnUiThread(() -> mView.onVRModeChanged(isVRMode));
}
@Override
public void onCarLocationChanged(MogoLocation location) {
if (null != location) {
runOnUIThread(() -> mView.updateSpeedView((float) location.getGnssSpeed()));
runOnUIThread(() -> mView.setCurrentLocation(location));
ThreadUtils.runOnUiThread(() -> mView.updateSpeedView((float) location.getGnssSpeed()));
ThreadUtils.runOnUiThread(() -> mView.setCurrentLocation(location));
}
}
@@ -178,25 +177,16 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
public void startOpenAutopilot() {
}
public void startAutopilot(){
SweeperTaskModel.getInstance().startAutopilot();
}
/**
* 设置当前子任务信息
*/
public void setSubtask(boolean isFirstSubtask,boolean isLastSubtask,int subTaskId) {
public void setSubtask(boolean isFirstSubtask, boolean isLastSubtask, int subTaskId) {
this.mSubTaskId = subTaskId;
SweeperTaskModel.getInstance().setSubtask(isFirstSubtask,isLastSubtask,subTaskId);
SweeperTaskModel.getInstance().setSubtask(isFirstSubtask, isLastSubtask, subTaskId);
}
private void runOnUIThread(Runnable executor) {
if (executor == null) {
return;
}
if (Looper.myLooper() != Looper.getMainLooper()) {
UiThreadHandler.post(executor);
} else {
executor.run();
}
}
/**
* 测试使用
*
@@ -236,12 +226,14 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
public void onStartAdasFailure() {
}
public void onArriveTaskEnd(@Nullable MessagePad.ArrivalNotification arrivalNotification){
public void onArriveTaskEnd(@Nullable MessagePad.ArrivalNotification arrivalNotification) {
SweeperTaskModel.getInstance().onArriveTaskEnd(arrivalNotification);
}
@Override
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
if (cleanSystemState==null){
if (cleanSystemState == null) {
return;
}
long current = System.currentTimeMillis();
@@ -294,8 +286,8 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
.append("强力:")
.append(clean_intensity_strong);
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianCleanSystemState"+stringBuilder);
mView.onSweeperFutianCleanSystemState(cleanSystemState);
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianCleanSystemState" + stringBuilder);
mView.onSweeperFutianCleanSystemState(cleanSystemState);
}
@Override
@@ -305,7 +297,7 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
return;
}
mWeltDataCurrentTimeMillis = current;
if (roboSweeperTaskIndex==null){
if (roboSweeperTaskIndex == null) {
return;
}
StringBuilder stringBuilder = new StringBuilder();
@@ -321,11 +313,12 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
.append(roboSweeperTaskIndex.getLocLon())
.append("纬度:")
.append(roboSweeperTaskIndex.getLocLat());
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianTaskIndexData"+stringBuilder);
CallerLogger.INSTANCE.d(M_SWEEPER + TAG, "onSweeperFutianTaskIndexData" + stringBuilder);
//保存贴边数据到数据库中
WeltDataBean weltDataBean=new WeltDataBean();
WeltDataBean weltDataBean = new WeltDataBean();
//把wgs坐标系坐标转换成gcj坐标
LatLng latLng=CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(),roboSweeperTaskIndex.getLocLon(),roboSweeperTaskIndex.getLocLat());
LatLng latLng = CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(AbsMogoApplication.getApp(), roboSweeperTaskIndex.getLocLon(),
roboSweeperTaskIndex.getLocLat());
weltDataBean.setLocLon(latLng.longitude);
weltDataBean.setLocLat(latLng.latitude);
weltDataBean.setWeltDistance(roboSweeperTaskIndex.getDistToRefEdgePoint());
@@ -334,7 +327,7 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
weltDataBean.setCleanIntensity(roboSweeperTaskIndex.getCleanIntensity());
weltDataBean.setSubTaskId(mSubTaskId);
MyDataBase.getInstance().getWeltDataDao().insert(weltDataBean);
mView.setWeltDataToMap((ArrayList<WeltDataBean>) MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo(),true);
mView.setWeltDataToMap((ArrayList<WeltDataBean>) MyDataBase.getInstance().getWeltDataDao().loadAllWeltDataInfo(), true,roboSweeperTaskIndex.getDistToRefEdgePoint());
}
/**
@@ -343,12 +336,14 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
public void getCurrentTask() {
SweeperTaskModel.getInstance().getCurrentTask();
}
/**
* 获取主任务列表
*/
public void getMainTaskList() {
SweeperTaskModel.getInstance().getMainTaskList();
}
/**
* 获取子任务列表
*/
@@ -359,8 +354,8 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
/**
* 获取子任务详情包括轨迹文件信息
*/
public void getSubTaskDetail(boolean isFirst,boolean isEnd,int subTaskId, SubTaskTypeEnum subTaskType,boolean isStartSubtask) {
SweeperTaskModel.getInstance().getSubTaskDetail(isFirst,isEnd,subTaskId, subTaskType,isStartSubtask);
public void getSubTaskDetail(boolean isFirst, boolean isEnd, int subTaskId, SubTaskTypeEnum subTaskType, boolean isStartSubtask) {
SweeperTaskModel.getInstance().getSubTaskDetail(isFirst, isEnd, subTaskId, subTaskType, isStartSubtask);
}
/**
* 子任务开始上报
@@ -368,20 +363,10 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
/**
* 开始任务
*/
public void startTask(boolean isFirst,boolean isEnd,int subTaskId, SubTaskTypeEnum subTaskType,int subTaskStatus) {
if (SweeperTaskModel.getInstance().getSubWorking()) {//如果任务正在执行中,被人工接管后掉出自驾,则只重启自动驾驶
if (subTaskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE) {
SweeperTaskModel.getInstance().startAutopilot();
}
} else {
if (subTaskStatus==1){//子任务未执行,则开始执行
SweeperTaskModel.getInstance().subTaskStart(isFirst,isEnd,subTaskId, subTaskType);
}else{
if (subTaskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE) {
SweeperTaskModel.getInstance().startAutopilot();
}
}
}
public void startTask(boolean isFirst, boolean isEnd, int subTaskId, SubTaskTypeEnum subTaskType, int subTaskStatus) {
if (subTaskStatus==1){
SweeperTaskModel.getInstance().subTaskStart(isFirst, isEnd, subTaskId, subTaskType);
}
// AutopilotControlParameters parameters = new AutopilotControlParameters();
// parameters.isSpeakVoice = true;
// parameters.routeID = 164;
@@ -417,15 +402,15 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
/**
* 子任务结束上报
*/
public void subTaskEnd(boolean isFirst,boolean isEnd,int subTaskId) {
SweeperTaskModel.getInstance().subTaskEnd(isFirst,isEnd,subTaskId);
public void subTaskEnd(boolean isFirst, boolean isEnd, int subTaskId) {
SweeperTaskModel.getInstance().subTaskEnd(isFirst, isEnd, subTaskId);
}
/**
* 子任务跳过上报
*/
public void subTaskSkip(boolean isFirst,boolean isEnd,int subTaskId) {
SweeperTaskModel.getInstance().subTaskSkip(isFirst,isEnd,subTaskId);
public void subTaskSkip(boolean isFirst, boolean isEnd, int subTaskId) {
SweeperTaskModel.getInstance().subTaskSkip(isFirst, isEnd, subTaskId);
}
/**

View File

@@ -5,8 +5,8 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.utils.DateTimeUtil
import com.mogo.och.sweeper.R
import com.mogo.och.sweeper.bean.SubInfo
@@ -20,14 +20,15 @@ import kotlinx.android.synthetic.main.sweeper_current_task_info.view.*
* 清扫车当前任务信息展示
*/
class SweeperCurrentTaskInfoView : ConstraintLayout {
private val TAG:String="SweeperCurrentTaskInfoView"
private val TAG: String = "SweeperCurrentTaskInfoView"
//当前任务操作菜单
private var mTaskMenuPopWindow: MenuPopWindow? = null
private var presenter: SweeperPresenter? = null
private var mCurrentPosition = 0
private var listTask: List<SubInfo>? = null
private var isStartTask: Boolean = false
private var mSubTaskType: SubTaskTypeEnum = SubTaskTypeEnum.AUTOPILOT_SUBTYPE
private var mSubTaskStatus: Int = 1
constructor(context: Context) : super(context) {}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
@@ -39,6 +40,22 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
private fun initView(context: Context) {
LayoutInflater.from(context).inflate(R.layout.sweeper_current_task_info, this)
setEnableClickBtn(false)
readyTaskBtn.setOnClickListener {
//开始执行任务
startSubTask()
}
tvStartAuto.setOnClickListener {
if (mSubTaskStatus==1){
ToastUtils.showLong("任务未开始无轨迹,无法启动自驾")
return@setOnClickListener
}
if (mSubTaskType==SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE){
ToastUtils.showLong("人工子任务无轨迹,无法启动自驾")
return@setOnClickListener
}
presenter?.startAutopilot()
}
}
/**
@@ -60,6 +77,10 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
val calendar = DateTimeUtil.formatLongToCalendar(taskStartTime)
tvTaskTime.text = DateTimeUtil.formatCalendarToString(calendar, DateTimeUtil.TAXI_HH_mm)
}
listTask?.let {
mSubTaskStatus=it[currentPosition].taskStatus
setEnableClickBtn(mSubTaskStatus==2)
}
setCurrentData(currentPosition)
//任务操作菜单打开关闭处理
ivMore.setOnClickListener {
@@ -73,44 +94,44 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
mTaskMenuPopWindow?.dismiss()
}
}
readyTaskBtn.setOnClickListener {
if (!isStartTask) {
//开始执行任务
startSubTask()
} else {
isStartTask = false
}
}
}
/**
* 设置准备就绪按钮时都可以点击
*/
fun setEnableClickBtn(isClick: Boolean, isPause: Boolean) {
CallerLogger.d(SceneConstant.M_SWEEPER + TAG, "setEnableClickBtn isClick${isClick} isPause:${isPause}")
if (mSubTaskType.code == SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE.code) {//人工驾驶子任务
fun setEnableClickBtn(isWorking: Boolean) {
readyTaskBtn.isSelected = !isWorking
readyTaskBtn.isClickable=!isWorking
if (isWorking) {
tvTaskState.text = "正在作业"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working)
} else {
tvTaskState.text = "暂未准备"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
readyTaskBtn.text = "准备出发"
readyTaskBtn.isClickable = false
readyTaskBtn.isSelected = false
isStartTask = false
} else {
if (isPause) {
readyTaskBtn.text = "暂停任务"
} else {
readyTaskBtn.text = "准备出发"
}
}
/**
* 设置准备就绪按钮时都可以点击
*/
fun setStartAutoBtn(autopilotState: Int) {
when (autopilotState) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
tvStartAuto.isSelected = false
tvStartAuto.isClickable = false
}
readyTaskBtn.isClickable = isClick
readyTaskBtn.isSelected = isClick
isStartTask = isPause
if (isPause) {
tvTaskState.text = "正在作业"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_working)
} else {
tvTaskState.text = "暂未准备"
tvTaskState.setBackgroundResource(R.drawable.bg_shape_task_state_not_ready)
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {
tvStartAuto.isSelected = true
tvStartAuto.isClickable = true
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
tvStartAuto.isSelected = true
tvStartAuto.isClickable = true
}
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> {
tvStartAuto.isSelected = false
tvStartAuto.isClickable = false
}
}
}
@@ -125,22 +146,32 @@ class SweeperCurrentTaskInfoView : ConstraintLayout {
isLastSubTask(),
it[mCurrentPosition].taskId,
if (it[mCurrentPosition].taskType == SubTaskTypeEnum.AUTOPILOT_SUBTYPE.code) SubTaskTypeEnum.AUTOPILOT_SUBTYPE else SubTaskTypeEnum.MANUAL_DRIVING_SUBTYPE,
it[mCurrentPosition].taskStatus
mSubTaskStatus
)
}
}
/**
* 是否第一个子任务
*/
private fun isFirstSubTask():Boolean{
return mCurrentPosition==0
private fun isFirstSubTask(): Boolean {
return mCurrentPosition == 0
}
/**
* 是否第一个子任务
*/
private fun isLastSubTask():Boolean{
private fun isLastSubTask(): Boolean {
return mCurrentPosition == (listTask?.size?.minus(1))
}
/**
* 设置任务状态
*/
fun setTaskStatus(status: Int) {
this.mSubTaskStatus = status
}
/**
* 填充数据
*/

View File

@@ -11,6 +11,7 @@ import chassis.Chassis.GearPosition
import chassis.Chassis.LightSwitch
import chassis.ChassisStatesOuterClass.BMSSystemStates
import chassis.ChassisStatesOuterClass.SweeperFuTianTaskSystemStates
import com.elegant.utils.UiThreadHandler
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
@@ -21,7 +22,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.och.sweeper.R
import com.mogo.och.sweeper.presenter.SweeperPresenter
import planning.RoboSweeperTaskIndexOuterClass
/**
@@ -105,13 +105,16 @@ class SweeperTrafficDataView : ConstraintLayout,
}
mCurrentTimeWaterMillis = current
d(SceneConstant.M_SWEEPER + TAG, "水位:${cleanSystemState.hasSecuCleanWaterTankLow()}")
if (cleanSystemState.hasSecuCleanWaterTankLow()) { //清水箱水位低不能清洗作业报警信号
ivBgWaterWarning?.visibility = VISIBLE
ivWater?.isSelected = true
} else {
ivBgWaterWarning?.visibility = GONE
ivWater?.isSelected = false
UiThreadHandler.post {
if (cleanSystemState.hasSecuCleanWaterTankLow()) { //清水箱水位低不能清洗作业报警信号
ivBgWaterWarning?.visibility = VISIBLE
ivWater?.isSelected = true
} else {
ivBgWaterWarning?.visibility = GONE
ivWater?.isSelected = false
}
}
}
@SuppressLint("SetTextI18n")
@@ -122,7 +125,9 @@ class SweeperTrafficDataView : ConstraintLayout,
}
mCurrentTimeBatteryMillis = current
d(SceneConstant.M_SWEEPER + TAG, "电量:${states.bmsSoc}")
tvBattery?.text = "${states.bmsSoc*100}%"
UiThreadHandler.post{
tvBattery?.text = "${states.bmsSoc}%"
}
}
/**
* 车辆转向灯

View File

@@ -173,14 +173,15 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
/**
* 设置贴边数据
*/
fun setWeltData(weltData: MutableList<WeltDataBean>?,isWeltData: Boolean) {
fun setWeltData(weltData: MutableList<WeltDataBean>?, isWeltData: Boolean, distance: Double) {
if (weltData != null) {
this.mWeltData.addAll(weltData)
for (i in mWeltData.indices) {
mCoordinatesLatLng.add(LatLng(mWeltData[i].locLat, mWeltData[i].locLon))
}
}
if (!mFirst&&isWeltData) {
setDistance(distance)
if (!mFirst && isWeltData) {
mFirst = true
showOrHiddenLegendData(true)
}
@@ -199,6 +200,10 @@ class WeltMapOverView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
sweeperLegend6.setData(R.drawable.sweeper_legend6, "未经过")
}
private fun setDistance(distance: Double) {
taskWeltDistanceTv.text = "贴边:${distance}cm"
}
fun onCreateView(savedInstanceState: Bundle?) {
sweeperTextureMapView.onCreate(savedInstanceState)
}

View File

@@ -209,11 +209,12 @@ class WeltSmallMapView : ConstraintLayout, IMoGoChassisLocationGCJ02Listener {
/**
* 设置贴边数据
*/
fun setWeltData(weltData: MutableList<WeltDataBean>,isWeltData: Boolean) {
fun setWeltData(weltData: MutableList<WeltDataBean>,isWeltData: Boolean,distance:Double) {
this.mWeltData = weltData
for (i in mWeltData.indices) {
mCoordinatesLatLng.add(CoordinateCalculateRouteUtil.coordinateConverterWgsToGcj(context, mWeltData[i].locLon, mWeltData[i].locLat))
}
taskWeltDistanceTv.text="贴边:${distance}cm"
if (!mFirst&&isWeltData) {
showOrHiddenWelt(true)
mFirst = true

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false" android:drawable="@drawable/sweeper_start_auto_not_selected"/>
<item android:state_selected="true" android:drawable="@drawable/sweeper_start_auto_selected"/>
</selector>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#254e7d" />
<corners
android:bottomLeftRadius="30dp" />
</shape>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:bottomLeftRadius="30dp"/>
<gradient android:angle="180" android:endColor="#004DFF" android:startColor="#20AAFF" />
</shape>
</item>
</selector>

View File

@@ -2,6 +2,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#254e7d" />
<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp" />
</shape>

View File

@@ -3,8 +3,7 @@
<item>
<shape android:shape="rectangle">
<corners android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"/>
<corners android:bottomRightRadius="30dp"/>
<gradient android:angle="180" android:endColor="#004DFF" android:startColor="#20AAFF" />
</shape>
</item>

View File

@@ -33,12 +33,12 @@
android:id="@+id/sweeper_current_task_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@drawable/bg_shape_work_mode">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/sweeperListCl"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:visibility="gone">
<View
android:id="@+id/sweeperListLine"
android:layout_width="@dimen/dp_10"

View File

@@ -106,18 +106,41 @@
android:layout_marginTop="@dimen/dp_16"
/>
<TextView
android:id="@+id/readyTaskBtn"
android:layout_width="match_parent"
android:id="@+id/tvStartAuto"
android:layout_width="0dp"
android:layout_height="@dimen/sweeper_switch_line_btn_height_1"
android:background="@drawable/sweeper_task_btn"
android:background="@drawable/sweeper_start_auto_btn"
android:gravity="center"
android:text="@string/sweeper_switch_line_btn"
android:text="启动自驾"
android:textColor="@android:color/white"
android:textSize="@dimen/module_mogo_och_sweeper_station_notice_text_size"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="@dimen/dp_20"
app:layout_constraintWidth_percent="0.5"
/>
<View
android:id="@+id/line1"
android:layout_width="2dp"
android:layout_height="@dimen/sweeper_switch_line_btn_height_1"
app:layout_constraintStart_toEndOf="@+id/tvStartAuto"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:id="@+id/readyTaskBtn"
android:layout_width="0dp"
android:layout_height="@dimen/sweeper_switch_line_btn_height_1"
android:background="@drawable/sweeper_task_btn"
android:gravity="center"
android:text="开始任务"
android:textColor="@android:color/white"
android:textSize="@dimen/module_mogo_och_sweeper_station_notice_text_size"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/line1"
android:layout_marginTop="@dimen/dp_20"
android:clickable="false"
app:layout_constraintWidth_percent="0.5"
/>
</androidx.constraintlayout.widget.ConstraintLayout>