diff --git a/open-robotics/configs/observalble_deadlock.json b/open-robotics/configs/observalble_deadlock.json index e03f0c9..1f08674 100644 --- a/open-robotics/configs/observalble_deadlock.json +++ b/open-robotics/configs/observalble_deadlock.json @@ -10,7 +10,9 @@ "chargePerTick" : 5.0, "energyPerMove" : 1.0, "loadingTicks" : 1, - "unloadingTicks" : 1 + "unloadingTicks" : 1, + "maxTasks" : 10, + "manualTaskAssignment" : false }, "map" : { "mapId" : "e8b76c63-4505-499e-8070-4eb32d17b96e", @@ -93,7 +95,8 @@ }, "type" : null, "boxCount" : 1, - "validDropoffIds" : null + "validDropoffIds" : null, + "manualDropoffAssignment" : false }, { "id" : "2222aaaa-2222-4222-a222-222222222222", "name" : "Rack-02", @@ -103,7 +106,8 @@ }, "type" : null, "boxCount" : 1, - "validDropoffIds" : null + "validDropoffIds" : null, + "manualDropoffAssignment" : false }, { "id" : "3333aaaa-3333-4333-a333-333333333333", "name" : "Rack-03", @@ -113,7 +117,8 @@ }, "type" : null, "boxCount" : 1, - "validDropoffIds" : null + "validDropoffIds" : null, + "manualDropoffAssignment" : false } ], "obstacles" : [ { "id" : "f0000000-0000-4000-a000-000000000001", diff --git a/open-robotics/src/main/java/com/openrobotics/controllers/SetupController.java b/open-robotics/src/main/java/com/openrobotics/controllers/SetupController.java index 68e8226..07ec32f 100644 --- a/open-robotics/src/main/java/com/openrobotics/controllers/SetupController.java +++ b/open-robotics/src/main/java/com/openrobotics/controllers/SetupController.java @@ -124,8 +124,7 @@ private void initialize() { AppState.clear(); configListView.getSelectionModel().clearSelection(); } - canvasWidthSpinner.setDisable(false); - canvasHeightSpinner.setDisable(false); + setConfigParamsDisabled(false); autoSetCanvasForMap(n); } refreshPreview(); @@ -197,8 +196,7 @@ private void initialize() { if (success) { // Config-backed maps own their dimensions, so clear the template selection. mapCombo.getSelectionModel().clearSelection(); - canvasWidthSpinner.setDisable(true); - canvasHeightSpinner.setDisable(true); + setConfigParamsDisabled(true); refreshPreview(); checkCanvasConstraint(); } @@ -222,6 +220,9 @@ private void initialize() { // Reset Actions @FXML private void onResetMap() { + AppState.clear(); + configListView.getSelectionModel().clearSelection(); + setConfigParamsDisabled(false); mapCombo.getSelectionModel().selectFirst(); refreshPreview(); checkCanvasConstraint(); @@ -269,8 +270,7 @@ private void refreshPreview() { if (isConfigFile && previewMap != null) { cw = previewMap.getWidth(); ch = previewMap.getHeight(); - canvasWidthSpinner.setDisable(true); - canvasHeightSpinner.setDisable(true); + setConfigParamsDisabled(true); } double padding = 16; @@ -674,6 +674,8 @@ private boolean goToSimulationScreen() { @FXML private void onLoadConfig() { if (promptAndLoadConfig()) { + mapCombo.getSelectionModel().clearSelection(); + setConfigParamsDisabled(true); refreshPreview(); checkCanvasConstraint(); } @@ -1092,9 +1094,48 @@ private void makeSpinnerIntegerOnly(Spinner spinner) { })); } + /** + * Disables or re-enables all user-editable parameters on the setup screen. + * Called with {@code true} whenever a config file is loaded and with {@code false} when switching back to a template map. + * The reservationK spinner has its own separate policy-driven disable logic + */ + private void setConfigParamsDisabled(boolean disabled) { + + // Coordination policy + policyCombo.setDisable(disabled); + if (!disabled) { + // Re-evaluate the policy-driven disable for reservationK + reservationKSpinner.setDisable(!"RESERVATION_K".equals(policyCombo.getValue())); + } else { + reservationKSpinner.setDisable(true); + } + + // Task settings + if (autoTaskRadio != null) autoTaskRadio.setDisable(disabled); + if (manualTaskRadio != null) manualTaskRadio.setDisable(disabled); + maxTasksField.setDisable(disabled); + workloadSeedField.setDisable(disabled); + + // Robot physics + setDisableIfPresent(batteryCapacityField, disabled); + setDisableIfPresent(lowBatteryField, disabled); + setDisableIfPresent(chargePerTickField, disabled); + setDisableIfPresent(energyPerMoveField, disabled); + + // Run settings + maxTicksField.setDisable(disabled); + runNameField.setDisable(disabled); + + // Canvas size + canvasWidthSpinner.setDisable(disabled); + canvasHeightSpinner.setDisable(disabled); + } + + private void setDisableIfPresent(TextField field, boolean disabled) { + if (field != null) field.setDisable(disabled); + } + // Navigation - @FXML - private void onTabEditor() { /* already on setup/editor screen */ } @FXML private void onMenuWelcome() { ScreenNavigator.goToWelcome(); } @@ -1114,4 +1155,4 @@ private void onExit() { javafx.application.Platform.exit(); } } -} +} \ No newline at end of file