[清扫车] 清扫车联调完成

This commit is contained in:
wangmingjun
2022-09-09 19:16:53 +08:00
parent 9ac3f3b3ee
commit f599093627
4 changed files with 96 additions and 79 deletions

View File

@@ -163,11 +163,11 @@ public abstract class BaseSweeperTabFragment<V extends IView, P extends Presente
@Override
public void onClickImpl(View v) {
if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
// if (CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE){
restartAutopilot();
}else {
ToastUtils.showShort(getResources().getString(R.string.sweeper_auto_disable_tip));
}
// }else {
// ToastUtils.showShort(getResources().getString(R.string.sweeper_auto_disable_tip));
// }
}
});

View File

@@ -472,36 +472,37 @@ public class SweeperOrderModel {
triggerStartServiceEvent(isRestart, false);
isArrivedStation = false;
SweeperStationBean currentStation = stationList.get( backgroundCurrentStationIndex);
SweeperStationBean nextStation = stationList.get( backgroundCurrentStationIndex + 1);
// SweeperStationBean currentStation = stationList.get( backgroundCurrentStationIndex);
// SweeperStationBean nextStation = stationList.get( backgroundCurrentStationIndex + 1);
// if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
// == CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState()) {
// ToastUtils.showShort("自动驾驶状态为不可用!");
// }
AutopilotControlParameters parameters = new AutopilotControlParameters();
parameters.isSpeakVoice = !isRestart;
parameters.routeID = sweeperRoutesResult.getLineId();
parameters.routeName = sweeperRoutesResult.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) {
parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
sweeperRoutesResult.getLineId(),
sweeperRoutesResult.csvFileUrl, sweeperRoutesResult.csvFileMd5,
sweeperRoutesResult.txtFileUrl, sweeperRoutesResult.txtFileMd5,
sweeperRoutesResult.contrailSaveTime, sweeperRoutesResult.carModel,
sweeperRoutesResult.csvFileUrlDPQP, sweeperRoutesResult.csvFileMd5DPQP,
sweeperRoutesResult.txtFileUrlDPQP, sweeperRoutesResult.txtFileMd5DPQP,
sweeperRoutesResult.contrailSaveTimeDPQP);
}
CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+" startLatLon="+currentStation.getName()+"endLatLon="+nextStation.getName());
// parameters.isSpeakVoice = !isRestart;
// parameters.routeID = sweeperRoutesResult.getLineId();
// parameters.routeName = sweeperRoutesResult.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) {
// parameters.autoPilotLine = new AutopilotControlParameters.AutoPilotLine(
// sweeperRoutesResult.getLineId(),
// sweeperRoutesResult.csvFileUrl, sweeperRoutesResult.csvFileMd5,
// sweeperRoutesResult.txtFileUrl, sweeperRoutesResult.txtFileMd5,
// sweeperRoutesResult.contrailSaveTime, sweeperRoutesResult.carModel,
// sweeperRoutesResult.csvFileUrlDPQP, sweeperRoutesResult.csvFileMd5DPQP,
// sweeperRoutesResult.txtFileUrlDPQP, sweeperRoutesResult.txtFileMd5DPQP,
// sweeperRoutesResult.contrailSaveTimeDPQP);
// }
// CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
// +" startLatLon="+currentStation.getName()+"endLatLon="+nextStation.getName());
CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + GsonUtil.jsonFromObject(parameters));
CallerAutoPilotManager.INSTANCE.startAutoPilot(parameters);
if (mControllerStatusCallback != null) {
@@ -651,12 +652,13 @@ public class SweeperOrderModel {
* 开启自动驾驶到下一站
*/
public void autoDriveToNextStation( boolean isRestart ) {
if ( backgroundCurrentStationIndex >= stationList.size() - 1 ) {
// 当前站是最后一站,结束当前行程
travelOver();
return;
}
leaveStation(false,isRestart);
// if ( backgroundCurrentStationIndex >= stationList.size() - 1 ) {
// // 当前站是最后一站,结束当前行程
// travelOver();
// return;
// }
// leaveStation(false,isRestart);
startAutopilot(isRestart);
}
/**
@@ -753,8 +755,10 @@ public class SweeperOrderModel {
* 在踩刹车、控制方向盘等操作后,会停止自动驾驶,重启自动驾驶的话相当于重新设置自动驾驶目的地
*/
public void restartAutopilot() {
CallerLogger.INSTANCE.d( M_BUS + TAG, "重启自动驾驶===" + isGoingToNextStation );
autoDriveToNextStation( true );
// CallerLogger.INSTANCE.d( M_BUS + TAG, "重启自动驾驶===" + isGoingToNextStation );
// autoDriveToNextStation( true );
//直接开启自动驾驶
startAutopilot(true);
}
/**
@@ -836,10 +840,10 @@ public class SweeperOrderModel {
* @param data
*/
public void onArriveAt( MessagePad.ArrivalNotification data){
if ( backgroundCurrentStationIndex +1 > stationList.size() - 1 ) {
CallerLogger.INSTANCE.e( M_BUS + TAG, "到站异常,取消后续操作结束" );
return;
}
// if ( backgroundCurrentStationIndex +1 > stationList.size() - 1 ) {
// CallerLogger.INSTANCE.e( M_BUS + TAG, "到站异常,取消后续操作结束" );
// return;
// }
if (isArrivedStation) return;
isArrivedStation = true;
@@ -852,7 +856,7 @@ public class SweeperOrderModel {
CallerLogger.INSTANCE.d( M_BUS + TAG, "到站====currentStationIndex=" + backgroundCurrentStationIndex);
isGoingToNextStation = false;
arriveSiteStation(false);//到站上报
// arriveSiteStation(false);//到站上报
}
public boolean isGoingToNextStation() {

View File

@@ -101,11 +101,11 @@ public class SweeperPresenter extends Presenter<SweeperFragment>
}
public void restartAutopilot() {
if (SweeperOrderModel.getInstance().isGoingToNextStation()){
// if (SweeperOrderModel.getInstance().isGoingToNextStation()){
currentAutopilotStatus = -1;
SweeperOrderModel.getInstance().restartAutopilot();
isRestartAutopilot = true;
}
// }
}
public void onChangeOperationStatus() {

View File

@@ -49,7 +49,7 @@ import chassis.VehicleStateOuterClass;
public class SweeperOperatePanelView extends LinearLayout {
private static final String TAG = "SweeperOperatePanelView";
private static final int CMD_EXECUTE_TIMEOUT_SECONDS = 5;
private static final int CMD_EXECUTE_TIMEOUT_SECONDS = 30;
private static final int CMD_EXECUTE_MOCK_SUCCESS_SECONDS = 3;
CheckedTextView mBtnCleanWorkOpenClose;//开关
@@ -190,7 +190,7 @@ public class SweeperOperatePanelView extends LinearLayout {
success = cleanSystemState.getSecuMotWorkSts();
}
//TODO
return true;
return success;
}
@Override
@@ -301,7 +301,7 @@ public class SweeperOperatePanelView extends LinearLayout {
&& !clean_mode_pure_draw
&& !clean_mode_pure_sweep;
if (clean_mode_close) {// 关闭放第一判断
if (isClickCurrentChoosedModeBtn && clean_mode_close) {// 关闭放第一判断
success = clean_mode_close;
} else if (isPureSweepClick) {
//success = clean_mode_pure_sweep;
@@ -315,7 +315,7 @@ public class SweeperOperatePanelView extends LinearLayout {
success = clean_mode_pure_draw;
}
//TODO
return true;
return success;
}
@Override
@@ -412,7 +412,7 @@ public class SweeperOperatePanelView extends LinearLayout {
boolean clean_direction_close = !clean_direction_left_side && !clean_direction_right_side
&& !clean_direction_both_side;
if (clean_direction_close) {//关闭放第一判断
if (isClickCurrentChoosedDirectionBtn && clean_direction_close) {//关闭放第一判断
success = clean_direction_close;
} else if (isLeftSide) {
success = clean_direction_left_side;
@@ -422,7 +422,7 @@ public class SweeperOperatePanelView extends LinearLayout {
success = clean_direction_both_side;
}
//TODO
return true;
return success;
}
@Override
@@ -495,7 +495,7 @@ public class SweeperOperatePanelView extends LinearLayout {
success = clean_intensity_strong;
}
//TODO
return true;
return success;
}
@Override
@@ -534,11 +534,13 @@ public class SweeperOperatePanelView extends LinearLayout {
* @param enable
*/
private void toggleCleanModeBtnsStatus(boolean enable) {
for (Integer viewId : cleanModeBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
runOnUIThread(() -> {
for (Integer viewId : cleanModeBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
});
}
/**
@@ -548,13 +550,15 @@ public class SweeperOperatePanelView extends LinearLayout {
* @param enable
*/
private void toggleCleanModeBtnsByChoosedViewId(int choosedBtnId, boolean enable) {
for (Integer viewId : cleanModeBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
if (view.getId() != choosedBtnId) {
view.setEnabled(enable);
view.setChecked(false);
runOnUIThread(() -> {
for (Integer viewId : cleanModeBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
if (view.getId() != choosedBtnId) {
view.setEnabled(enable);
view.setChecked(false);
}
}
}
});
}
/**
@@ -563,11 +567,13 @@ public class SweeperOperatePanelView extends LinearLayout {
* @param enable
*/
private void toggleCleanDirectionBtnsStatus(boolean enable) {
for (Integer viewId : cleanDirectionBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
runOnUIThread(() -> {
for (Integer viewId : cleanDirectionBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
});
}
/**
@@ -577,13 +583,15 @@ public class SweeperOperatePanelView extends LinearLayout {
* @param enable
*/
private void toggleCleanDirectionBtnsByChoosedViewId(int choosedBtnId, boolean enable) {
for (Integer viewId : cleanDirectionBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
if (view.getId() != choosedBtnId) {
view.setEnabled(enable);
view.setChecked(false);
runOnUIThread(() -> {
for (Integer viewId : cleanDirectionBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
if (view.getId() != choosedBtnId) {
view.setEnabled(enable);
view.setChecked(false);
}
}
}
});
}
/**
@@ -592,11 +600,13 @@ public class SweeperOperatePanelView extends LinearLayout {
* @param enable
*/
private void toggleCleanIntensityBtnsStatus(boolean enable) {
for (Integer viewId : cleanIntensityBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
runOnUIThread(() -> {
for (Integer viewId : cleanIntensityBtnViewIds) {
CheckedTextView view = (CheckedTextView) findViewById(viewId);
view.setEnabled(enable);
view.setChecked(false);
}
});
}
/**
@@ -652,6 +662,7 @@ public class SweeperOperatePanelView extends LinearLayout {
*/
private void hideLoadingMask() {
runOnUIThread(() -> {
mSweeperOperateCmdHandler.removeMessages(MSG_CMD_EXECUTE_COUNT_DOWN);
mLoadingContainer.setVisibility(View.GONE);
});
}
@@ -793,6 +804,7 @@ public class SweeperOperatePanelView extends LinearLayout {
}
// 有命令正在执行
if (mCurrentCmdRequestCallback != null) {
Log.d(TAG, "getSecuWorkLeftSts = " + cleanSystemState.getSecuWorkLeftSts());
if (mCurrentCmdRequestCallback.onCheckIfCmdSuccess(cleanSystemState)) {
mCurrentCmdRequestCallback.onCmdSuccess();
mCurrentCmdRequestCallback = null;
@@ -806,7 +818,7 @@ public class SweeperOperatePanelView extends LinearLayout {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
// TODO 最终调试时需要打开
//syncVehicleStateAndRecoverOperatePanelStates();
syncVehicleStateAndRecoverOperatePanelStates();
// Mock VehicleState 数据回调
// UiThreadHandler.postDelayed(() -> {
// onSyncVehicleStateCallBack(SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData());
@@ -968,7 +980,7 @@ public class SweeperOperatePanelView extends LinearLayout {
msg.obj = timeout;
mSweeperOperateCmdHandler.sendMessage(msg);
// Mock Cmd Success
mockSendCmdSuccess();
// mockSendCmdSuccess();
}
private void mockSendCmdSuccess() {
@@ -1045,4 +1057,5 @@ public class SweeperOperatePanelView extends LinearLayout {
void onCmdTimeout();
}
}