[清扫车] feat: 新增判断各作业命令发送是否成功;

This commit is contained in:
aibingbing
2022-08-29 11:53:49 +08:00
parent 9b24d441fb
commit 6122e3ec3d

View File

@@ -31,7 +31,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.eagle.core.utilcode.util.ToastUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.och.sweeper.R;
import com.mogo.och.sweeper.util.SweeperFutianCmdUtil;
@@ -181,6 +180,15 @@ public class SweeperOperatePanelView extends LinearLayout {
@Override
public boolean onCheckIfCmdSuccess(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
boolean success = false;
if (cleanSystemState == null) {
return success;
}
if (isCloseAction) {
success = !cleanSystemState.getSecuMotWorkSts();
} else {
success = cleanSystemState.getSecuMotWorkSts();
}
//TODO
return true;
}
@@ -253,8 +261,14 @@ public class SweeperOperatePanelView extends LinearLayout {
}
boolean isClickCurrentChoosedModeBtn = currentChoosedModeBtnView != null
&& currentChoosedModeBtnView.getId() == currentClickView.getId();
//是否纯吸
//是否纯吸View
boolean isPureAbsorption = currentClickView.getId() == R.id.btn_clean_mode_pure_absorption;
//是否纯洗View
boolean isPureWash = currentClickView.getId() == R.id.btn_clean_mode_pure_wash;
//是否纯扫View
boolean isPureSweep = currentClickView.getId() == R.id.btn_clean_mode_pure_sweep;
//是否洗扫View
boolean isWashSweep = currentClickView.getId() == R.id.btn_clean_mode_sweep_wash;
CmdRequestCallback cmdRequestCallback = new CmdRequestCallback() {
@Override
@@ -269,6 +283,28 @@ public class SweeperOperatePanelView extends LinearLayout {
@Override
public boolean onCheckIfCmdSuccess(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
boolean success = false;
if (cleanSystemState == null) {
return success;
}
// 洗扫
boolean clean_mode_wash_sweep = cleanSystemState.getSecuModWashSweepSts();
// 纯洗
boolean clean_mode_pure_wash = cleanSystemState.getSecuModWashSts();
// 纯吸
boolean clean_mode_pure_draw = cleanSystemState.getSecuWorkTonSts();
// 纯扫 模式判断不是另外其他3个模式同时有清扫方向说明开启了纯扫模式
boolean clean_mode_pure_sweep = checkIfCleanModePureSweep(cleanSystemState);
if (isPureSweep) {
success = clean_mode_pure_sweep;
} else if (isPureWash) {
success = clean_mode_pure_wash;
} else if (isWashSweep) {
success = clean_mode_wash_sweep;
} else if (isPureAbsorption) {
success = clean_mode_pure_draw;
}
//TODO
return true;
}
@@ -335,6 +371,11 @@ public class SweeperOperatePanelView extends LinearLayout {
boolean isClickCurrentChoosedDirectionBtn = currentChoosedDirectionBtnView != null
&& currentChoosedDirectionBtnView.getId() == currentClickView.getId();
boolean isLeftSide = currentClickView.getId() == R.id.btn_clean_direction_left_side;
boolean isRightSide = currentClickView.getId() == R.id.btn_clean_direction_right_side;
boolean isBothSide = currentClickView.getId() == R.id.btn_clean_direction_both_side;
CmdRequestCallback cmdRequestCallback = new CmdRequestCallback() {
@Override
public void onSendCmd() {
@@ -348,6 +389,24 @@ public class SweeperOperatePanelView extends LinearLayout {
@Override
public boolean onCheckIfCmdSuccess(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
boolean success = false;
if (cleanSystemState == null) {
return success;
}
// 左侧
boolean clean_direction_left_side = cleanSystemState.getSecuWorkLeftSts();
// 右侧
boolean clean_direction_right_side = cleanSystemState.getSecuWorkRightSts();
// 两侧
boolean clean_direction_both_side = cleanSystemState.getSecuWorkOnBothsidesSts();
if (isLeftSide) {
success = clean_direction_left_side;
} else if (isRightSide) {
success = clean_direction_right_side;
} else if (isBothSide) {
success = clean_direction_both_side;
}
//TODO
return true;
}
@@ -396,6 +455,7 @@ public class SweeperOperatePanelView extends LinearLayout {
private void onCleanIntensityBtnClick(final View currentClickView) {
boolean isStandardBtnClick = currentClickView.getId() == R.id.btn_clean_intensity_standard;
boolean isStrongBtnClick = currentClickView.getId() == R.id.btn_clean_intensity_strong;
CmdRequestCallback cmdRequestCallback = new CmdRequestCallback() {
@Override
public void onSendCmd() {
@@ -409,6 +469,17 @@ public class SweeperOperatePanelView extends LinearLayout {
@Override
public boolean onCheckIfCmdSuccess(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
boolean success = false;
if (cleanSystemState == null) {
return success;
}
boolean clean_intensity_standard = cleanSystemState.getSecuWorkStandSts();
boolean clean_intensity_strong = cleanSystemState.getSecuWorkStrongSts();
if (isStandardBtnClick) {
success = clean_intensity_standard;
} else if (isStrongBtnClick) {
success = clean_intensity_strong;
}
//TODO
return true;
}
@@ -708,12 +779,12 @@ public class SweeperOperatePanelView extends LinearLayout {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
syncVehicleStateAndRecoverOperatePanelStates();
// syncVehicleStateAndRecoverOperatePanelStates();
// TODO
// Mock VehicleState 数据回调
UiThreadHandler.postDelayed(() -> {
onSyncVehicleStateCallBack(SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData());
}, 3000L);
// UiThreadHandler.postDelayed(() -> {
// onSyncVehicleStateCallBack(SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData());
// }, 3000L);
}
@Override
@@ -753,8 +824,7 @@ public class SweeperOperatePanelView extends LinearLayout {
boolean clean_direction_both_side = cleanSystemState.getSecuWorkOnBothsidesSts();
// 纯扫 模式判断不是另外其他3个模式同时有清扫方向说明开启了纯扫模式
boolean clean_mode_pure_sweep = (clean_direction_left_side || clean_direction_right_side || clean_direction_both_side)
&& (!clean_mode_wash_sweep && !clean_mode_pure_wash && !clean_mode_pure_draw);
boolean clean_mode_pure_sweep = checkIfCleanModePureSweep(cleanSystemState);
// 作业强度状态
boolean clean_intensity_standard = cleanSystemState.getSecuWorkStandSts();
@@ -818,6 +888,35 @@ public class SweeperOperatePanelView extends LinearLayout {
});
}
/**
* 通过底盘数据判断是纯扫模式
*
* @param cleanSystemState
* @return
*/
private boolean checkIfCleanModePureSweep(VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
// 作业模式状态
// 洗扫
boolean clean_mode_wash_sweep = cleanSystemState.getSecuModWashSweepSts();
// 纯洗
boolean clean_mode_pure_wash = cleanSystemState.getSecuModWashSts();
// 纯吸
boolean clean_mode_pure_draw = cleanSystemState.getSecuWorkTonSts();
// 清扫方向状态
// 左侧
boolean clean_direction_left_side = cleanSystemState.getSecuWorkLeftSts();
// 右侧
boolean clean_direction_right_side = cleanSystemState.getSecuWorkRightSts();
// 两侧
boolean clean_direction_both_side = cleanSystemState.getSecuWorkOnBothsidesSts();
// 纯扫 模式判断不是另外其他3个模式同时有清扫方向说明开启了纯扫模式
boolean clean_mode_pure_sweep = (clean_direction_left_side || clean_direction_right_side || clean_direction_both_side)
&& (!clean_mode_wash_sweep && !clean_mode_pure_wash && !clean_mode_pure_draw);
return clean_mode_pure_sweep;
}
/**
* 发送清扫车相关作业命令
*