Skip to content

Commit c1908d1

Browse files
authored
Merge pull request #108 from dan-moraru/dan-fix
Add params lock when loading a config file in setup screen
2 parents 44254bc + 5b0444a commit c1908d1

2 files changed

Lines changed: 59 additions & 13 deletions

File tree

open-robotics/configs/observalble_deadlock.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"chargePerTick" : 5.0,
1111
"energyPerMove" : 1.0,
1212
"loadingTicks" : 1,
13-
"unloadingTicks" : 1
13+
"unloadingTicks" : 1,
14+
"maxTasks" : 10,
15+
"manualTaskAssignment" : false
1416
},
1517
"map" : {
1618
"mapId" : "e8b76c63-4505-499e-8070-4eb32d17b96e",
@@ -93,7 +95,8 @@
9395
},
9496
"type" : null,
9597
"boxCount" : 1,
96-
"validDropoffIds" : null
98+
"validDropoffIds" : null,
99+
"manualDropoffAssignment" : false
97100
}, {
98101
"id" : "2222aaaa-2222-4222-a222-222222222222",
99102
"name" : "Rack-02",
@@ -103,7 +106,8 @@
103106
},
104107
"type" : null,
105108
"boxCount" : 1,
106-
"validDropoffIds" : null
109+
"validDropoffIds" : null,
110+
"manualDropoffAssignment" : false
107111
}, {
108112
"id" : "3333aaaa-3333-4333-a333-333333333333",
109113
"name" : "Rack-03",
@@ -113,7 +117,8 @@
113117
},
114118
"type" : null,
115119
"boxCount" : 1,
116-
"validDropoffIds" : null
120+
"validDropoffIds" : null,
121+
"manualDropoffAssignment" : false
117122
} ],
118123
"obstacles" : [ {
119124
"id" : "f0000000-0000-4000-a000-000000000001",

open-robotics/src/main/java/com/openrobotics/controllers/SetupController.java

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ private void initialize() {
124124
AppState.clear();
125125
configListView.getSelectionModel().clearSelection();
126126
}
127-
canvasWidthSpinner.setDisable(false);
128-
canvasHeightSpinner.setDisable(false);
127+
setConfigParamsDisabled(false);
129128
autoSetCanvasForMap(n);
130129
}
131130
refreshPreview();
@@ -197,8 +196,7 @@ private void initialize() {
197196
if (success) {
198197
// Config-backed maps own their dimensions, so clear the template selection.
199198
mapCombo.getSelectionModel().clearSelection();
200-
canvasWidthSpinner.setDisable(true);
201-
canvasHeightSpinner.setDisable(true);
199+
setConfigParamsDisabled(true);
202200
refreshPreview();
203201
checkCanvasConstraint();
204202
}
@@ -222,6 +220,9 @@ private void initialize() {
222220

223221
// Reset Actions
224222
@FXML private void onResetMap() {
223+
AppState.clear();
224+
configListView.getSelectionModel().clearSelection();
225+
setConfigParamsDisabled(false);
225226
mapCombo.getSelectionModel().selectFirst();
226227
refreshPreview();
227228
checkCanvasConstraint();
@@ -269,8 +270,7 @@ private void refreshPreview() {
269270
if (isConfigFile && previewMap != null) {
270271
cw = previewMap.getWidth();
271272
ch = previewMap.getHeight();
272-
canvasWidthSpinner.setDisable(true);
273-
canvasHeightSpinner.setDisable(true);
273+
setConfigParamsDisabled(true);
274274
}
275275

276276
double padding = 16;
@@ -674,6 +674,8 @@ private boolean goToSimulationScreen() {
674674
@FXML
675675
private void onLoadConfig() {
676676
if (promptAndLoadConfig()) {
677+
mapCombo.getSelectionModel().clearSelection();
678+
setConfigParamsDisabled(true);
677679
refreshPreview();
678680
checkCanvasConstraint();
679681
}
@@ -1092,9 +1094,48 @@ private void makeSpinnerIntegerOnly(Spinner<Integer> spinner) {
10921094
}));
10931095
}
10941096

1097+
/**
1098+
* Disables or re-enables all user-editable parameters on the setup screen.
1099+
* Called with {@code true} whenever a config file is loaded and with {@code false} when switching back to a template map.
1100+
* The reservationK spinner has its own separate policy-driven disable logic
1101+
*/
1102+
private void setConfigParamsDisabled(boolean disabled) {
1103+
1104+
// Coordination policy
1105+
policyCombo.setDisable(disabled);
1106+
if (!disabled) {
1107+
// Re-evaluate the policy-driven disable for reservationK
1108+
reservationKSpinner.setDisable(!"RESERVATION_K".equals(policyCombo.getValue()));
1109+
} else {
1110+
reservationKSpinner.setDisable(true);
1111+
}
1112+
1113+
// Task settings
1114+
if (autoTaskRadio != null) autoTaskRadio.setDisable(disabled);
1115+
if (manualTaskRadio != null) manualTaskRadio.setDisable(disabled);
1116+
maxTasksField.setDisable(disabled);
1117+
workloadSeedField.setDisable(disabled);
1118+
1119+
// Robot physics
1120+
setDisableIfPresent(batteryCapacityField, disabled);
1121+
setDisableIfPresent(lowBatteryField, disabled);
1122+
setDisableIfPresent(chargePerTickField, disabled);
1123+
setDisableIfPresent(energyPerMoveField, disabled);
1124+
1125+
// Run settings
1126+
maxTicksField.setDisable(disabled);
1127+
runNameField.setDisable(disabled);
1128+
1129+
// Canvas size
1130+
canvasWidthSpinner.setDisable(disabled);
1131+
canvasHeightSpinner.setDisable(disabled);
1132+
}
1133+
1134+
private void setDisableIfPresent(TextField field, boolean disabled) {
1135+
if (field != null) field.setDisable(disabled);
1136+
}
1137+
10951138
// Navigation
1096-
@FXML
1097-
private void onTabEditor() { /* already on setup/editor screen */ }
10981139

10991140
@FXML
11001141
private void onMenuWelcome() { ScreenNavigator.goToWelcome(); }
@@ -1114,4 +1155,4 @@ private void onExit() {
11141155
javafx.application.Platform.exit();
11151156
}
11161157
}
1117-
}
1158+
}

0 commit comments

Comments
 (0)