Skip to content

Commit 01195fa

Browse files
swltrmartingr
authored andcommitted
Respect integration level for all position updates
More specifically, never set a vehicle's logical position (and allocate associated resources) if the vehicle is supposed to be ignored. Merged-by: Martin Grzenia <martin.grzenia@iml.fraunhofer.de>
1 parent bc610bc commit 01195fa

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

opentcs-documentation/src/docs/release-notes/changelog.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This change log lists the most relevant changes for past releases in reverse chr
3131
** Avoid `NullPointerException` when trying to assign a vehicle to a reserved transport orders that has been removed in the meantime.
3232
** Actually add given properties to newly-created plant models' visual layouts.
3333
** Ensure failed transport orders in order sequences are skipped correctly.
34+
** Respect integration level for all updates of a vehicle's logical position.
3435
* Changes affecting developers:
3536
** Update JUnit to 6.0.2.
3637
** Update Mockito to 5.21.0.

opentcs-kernel/src/main/java/org/opentcs/kernel/vehicles/DefaultVehicleController.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ private void handleProcessModelEvent(PropertyChangeEvent evt) {
837837
);
838838

839839
if (Objects.equals(evt.getPropertyName(), VehicleProcessModel.Attribute.POSITION.name())) {
840-
updateVehiclePosition((String) evt.getNewValue());
840+
setVehiclePosition((String) evt.getNewValue());
841841
}
842842
else if (Objects.equals(
843843
evt.getPropertyName(),
@@ -975,18 +975,19 @@ private void updateVehiclePose(
975975
vehicleService.updateVehiclePose(vehicle.getReference(), incomingPoseTransformer.apply(pose));
976976
}
977977

978-
private void updateVehiclePosition(String position) {
979-
// Get an up-to-date copy of the vehicle
978+
private void setVehiclePosition(String position) {
980979
Vehicle currVehicle = vehicleService.fetch(Vehicle.class, vehicle.getReference()).orElseThrow();
981980

982-
if (currVehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_RESPECTED
983-
|| currVehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_UTILIZED
984-
|| currVehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_NOTICED) {
985-
setVehiclePosition(position);
981+
boolean acceptPosition = switch (currVehicle.getIntegrationLevel()) {
982+
case TO_BE_RESPECTED, TO_BE_UTILIZED, TO_BE_NOTICED -> true;
983+
// Null position values reflect resetting the position and are always accepted.
984+
case TO_BE_IGNORED -> position == null;
985+
};
986+
987+
if (!acceptPosition) {
988+
return;
986989
}
987-
}
988990

989-
private void setVehiclePosition(String position) {
990991
// Place the vehicle on the given position, regardless of what the kernel
991992
// might expect. The vehicle is physically there, even if it shouldn't be.
992993
// The same is true for null values - if the vehicle says it's not on any

0 commit comments

Comments
 (0)