Skip to content

Commit 5f16857

Browse files
martingrswltr
authored andcommitted
Fix creation of transport orders with wrapping sequences
Allow any type of transport order to be added to order sequences that contain the _any type_ (i.e. "*") in their set of allowed order types. Merged-by: Stefan Walter <stefan.walter@iml.fraunhofer.de>
1 parent bfcaa50 commit 5f16857

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ The openTCS developers
1616
This change log lists the most relevant changes for past releases in reverse chronological order.
1717
(Note that the openTCS project adheres to https://semver.org/[Semantic Versioning].)
1818

19+
== Version 7.2.1 (2026-02-03)
20+
21+
* Bugs fixed:
22+
** Allow any type of transport order to be added to order sequences that contain the _any type_ (i.e. "*") in their set of allowed order types.
23+
1924
== Version 7.2 (2026-02-02)
2025

2126
* New features and enhancements:

opentcs-kernel/src/main/java/org/opentcs/kernel/workingset/TransportOrderPoolManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.opentcs.data.model.Vehicle;
3333
import org.opentcs.data.order.DriveOrder;
3434
import org.opentcs.data.order.DriveOrder.Destination;
35+
import org.opentcs.data.order.OrderConstants;
3536
import org.opentcs.data.order.OrderSequence;
3637
import org.opentcs.data.order.TransportOrder;
3738
import org.opentcs.util.event.EventHandler;
@@ -703,7 +704,7 @@ private TCSObjectReference<OrderSequence> getWrappingSequence(TransportOrderCrea
703704
);
704705
checkArgument(!sequence.isComplete(), "Order sequence %s is already complete", sequence);
705706
checkArgument(
706-
sequence.getOrderTypes().contains(to.getType()),
707+
typeAllowedBySequence(sequence, to.getType()),
707708
"Order sequence %s does not allow type of order %s: %s not in %s",
708709
sequence.getName(),
709710
to.getName(),
@@ -803,6 +804,11 @@ private String getIntendedVehicleName(OrderSequence sequence) {
803804
return sequence.getIntendedVehicle() == null ? null : sequence.getIntendedVehicle().getName();
804805
}
805806

807+
private boolean typeAllowedBySequence(OrderSequence sequence, String type) {
808+
return sequence.getOrderTypes().contains(OrderConstants.TYPE_ANY)
809+
|| sequence.getOrderTypes().contains(type);
810+
}
811+
806812
@Nonnull
807813
private String nameFor(
808814
@Nonnull

opentcs-kernel/src/test/java/org/opentcs/kernel/workingset/TransportOrderPoolManagerTest.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.opentcs.access.to.order.OrderSequenceCreationTO;
3030
import org.opentcs.access.to.order.TransportOrderCreationTO;
3131
import org.opentcs.data.model.Vehicle;
32+
import org.opentcs.data.order.OrderConstants;
3233
import org.opentcs.data.order.OrderSequence;
3334
import org.opentcs.data.order.TransportOrder;
3435
import org.opentcs.util.event.SimpleEventBus;
@@ -258,6 +259,76 @@ void assignProcessingVehicleToOrderSequenceIfDifferentToPreviousOne() {
258259
assertThat(seqAfterThirdAssignment, is(sameInstance(seqAfterSecondAssignment)));
259260
}
260261

262+
@Test
263+
void allowAssigningTransportOrderToOrderSequenceWithAnyType() {
264+
OrderSequence sequence = orderPoolManager.createOrderSequence(
265+
new OrderSequenceCreationTO("some-sequence")
266+
.withOrderTypes(Set.of(OrderConstants.TYPE_ANY))
267+
);
268+
269+
orderPoolManager.createTransportOrder(
270+
new TransportOrderCreationTO(
271+
"some-order",
272+
List.of(new DestinationCreationTO("some-location", "NOP"))
273+
)
274+
.withType("some-type")
275+
.withWrappingSequence(sequence.getName())
276+
);
277+
278+
assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty())));
279+
assertThat(objectRepo.getObjects(TransportOrder.class), is(not(empty())));
280+
}
281+
282+
@Test
283+
void allowAssigningTransportOrdersToOrderSequenceWithMatchingType() {
284+
OrderSequence sequence = orderPoolManager.createOrderSequence(
285+
new OrderSequenceCreationTO("some-sequence")
286+
.withOrderTypes(Set.of("some-type", "some-other-type"))
287+
);
288+
289+
orderPoolManager.createTransportOrder(
290+
new TransportOrderCreationTO(
291+
"some-order",
292+
List.of(new DestinationCreationTO("some-location", "NOP"))
293+
)
294+
.withType("some-type")
295+
.withWrappingSequence(sequence.getName())
296+
);
297+
orderPoolManager.createTransportOrder(
298+
new TransportOrderCreationTO(
299+
"some-other-order",
300+
List.of(new DestinationCreationTO("some-location", "NOP"))
301+
)
302+
.withType("some-other-type")
303+
.withWrappingSequence(sequence.getName())
304+
);
305+
306+
assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty())));
307+
assertThat(objectRepo.getObjects(TransportOrder.class), hasSize(2));
308+
}
309+
310+
311+
@Test
312+
void disallowAssigningTransportOrderToOrderSequenceWithNonMatchingType() {
313+
OrderSequence sequence = orderPoolManager.createOrderSequence(
314+
new OrderSequenceCreationTO("some-sequence")
315+
.withOrderTypes(Set.of("some-type"))
316+
);
317+
318+
TransportOrderCreationTO creationTO = new TransportOrderCreationTO(
319+
"some-order",
320+
List.of(new DestinationCreationTO("some-location", "NOP"))
321+
)
322+
.withType("some-other-type")
323+
.withWrappingSequence(sequence.getName());
324+
325+
assertThat(objectRepo.getObjects(OrderSequence.class), is(not(empty())));
326+
Assertions.assertThrows(
327+
IllegalArgumentException.class,
328+
() -> orderPoolManager.createTransportOrder(creationTO)
329+
);
330+
}
331+
261332
@Test
262333
void removeSingleOrderSequence() {
263334
OrderSequence sequence = orderPoolManager.createOrderSequence(

0 commit comments

Comments
 (0)