Skip to content

Commit

Permalink
Ensure assignment of recharge orders
Browse files Browse the repository at this point in the history
It is now allowed for vehicles with critical energy level to execute
transport orders where the first operation is a recharge operation,
making it possible to explicitly create recharging orders for vehicles.

Merged-by: Martin Grzenia <[email protected]>
  • Loading branch information
swltr authored and martingr committed Nov 6, 2024
1 parent 5cdd59f commit 1860398
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This change log lists the most relevant changes for past releases in reverse chr

* New features and enhancements:
** Add support for pluggable transformation of data sent to / received from vehicles, e.g. for conversion between the coordinate system in the plant model and a vehicle-specific one.
** Allow assignment of externally-created recharging orders to vehicles with critical energy level.
** Update web API specification and implementation to version 1.9.0:
*** Add missing _required_ markers for request and response bodies.
*** Include a vehicle's 'sufficiently recharged' and 'fully recharged' energy levels when requesting vehicle data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ To make this decision, the default dispatcher takes the following steps:
*** It may not be assigned to a transport order, or the assigned transport order must be _dispensable_.
That is the case with parking orders, for instance, or with recharging orders if the vehicle's energy level is not critical.
*** Its energy level must not be critical.
(Vehicles with critical energy level are taken into account only for transport orders with which the first destination operation is a recharge operation.)
** Criteria for a transport order to be taken into account are:
*** It must be generally dispatchable.
*** It must not be part of an order sequence that is already being processed by a vehicle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void run() {
private boolean couldProcessTransportOrder(Vehicle vehicle) {
return vehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_UTILIZED
&& vehicle.getCurrentPosition() != null
&& !vehicle.isEnergyLevelCritical()
&& (processesNoOrder(vehicle)
|| processesDispensableOrder(vehicle));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private void tryAssignOrder(
= availableOrders.stream()
.filter(
order -> (!assignmentState.wasAssignedToVehicle(order)
&& vehicleCanTakeOrder(vehicle, order)
&& orderAssignableToVehicle(order, vehicle))
)
.map(order -> computeCandidate(vehicle, vehiclePosition, order))
Expand Down Expand Up @@ -206,6 +207,7 @@ private void tryAssignVehicle(
= availableVehicles.stream()
.filter(
vehicle -> (!assignmentState.wasAssignedToOrder(vehicle)
&& vehicleCanTakeOrder(vehicle, order)
&& orderAssignableToVehicle(order, vehicle))
)
.map(
Expand Down Expand Up @@ -286,6 +288,14 @@ private Optional<AssignmentCandidate> computeCandidate(
.map(driveOrders -> new AssignmentCandidate(vehicle, order, driveOrders));
}

private boolean vehicleCanTakeOrder(Vehicle vehicle, TransportOrder order) {
return !vehicle.isEnergyLevelCritical()
|| Objects.equals(
order.getAllDriveOrders().getFirst().getDestination().getOperation(),
vehicle.getRechargeOperation()
);
}

private boolean orderAssignableToVehicle(TransportOrder order, Vehicle vehicle) {
return (order.getIntendedVehicle() == null
|| Objects.equals(order.getIntendedVehicle(), vehicle.getReference()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public boolean test(Vehicle vehicle) {
return vehicle.getIntegrationLevel() == Vehicle.IntegrationLevel.TO_BE_UTILIZED
&& vehicle.getCurrentPosition() != null
&& vehicle.getOrderSequence() == null
&& !vehicle.isEnergyLevelCritical()
&& !needsMoreCharging(vehicle)
&& (processesNoOrder(vehicle)
|| processesDispensableOrder(vehicle))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ void checkVehicleHasOrderSequence() {
assertFalse(isAvailableForAnyOrder.test(vehicle));
}

@Test
void checkVehicleHasCriticalEnergyLevel() {
Vehicle vehicle = vehicleAvailableForAnyOrder.withEnergyLevel(0);

assertFalse(isAvailableForAnyOrder.test(vehicle));
}

@Test
void checkVehicleNeedsMoreCharging() {
Vehicle vehicle = vehicleAvailableForAnyOrder
Expand Down

0 comments on commit 1860398

Please sign in to comment.