Skip to content

Commit c669b41

Browse files
gamze1806martingrswltr
committed
Add support for transport order types with priorities
For vehicle elements, transport order types (that a vehicle is allowed to process) can now be assigned a priority. Also add a new key "BY_ORDER_TYPE_PRIORITY" that can be configured for the kernel configuration entries "defaultdispatcher.orderCandidatePriorities" and "defaultdispatcher.vehicleCandidatePriorities". With this key configured, a vehicle's acceptable order types are considered when assigning transport order to it. Finally, add an endpoint "PUT /vehicles/{NAME}/acceptableOrderTypes", which allows a vehicle's set of acceptable order types to be modified during runtime. This endpoint replaces "PUT /vehicles/{NAME}/allowedOrderTypes", which is now deprecated. Co-authored-by: Martin Grzenia <[email protected]> Co-authored-by: Stefan Walter <[email protected]> Reviewed-by: Finja Averhaus <[email protected]> Merged-by: Stefan Walter <[email protected]>
1 parent 762c924 commit c669b41

File tree

54 files changed

+1937
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1937
-406
lines changed

opentcs-api-base/src/main/java/org/opentcs/access/rmi/services/RemoteVehicleService.java

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.opentcs.access.rmi.ClientID;
99
import org.opentcs.components.kernel.services.VehicleService;
1010
import org.opentcs.data.TCSObjectReference;
11+
import org.opentcs.data.model.AcceptableOrderType;
1112
import org.opentcs.data.model.Vehicle;
1213
import org.opentcs.data.model.Vehicle.EnergyLevelThresholdSet;
1314
import org.opentcs.drivers.vehicle.AdapterCommand;
@@ -95,13 +96,24 @@ default void updateVehicleEnergyLevelThresholdSet(
9596
throw new UnsupportedOperationException("Not yet implemented.");
9697
}
9798

99+
@Deprecated
100+
@ScheduledApiChange(when = "7.0", details = "Will be removed.")
98101
void updateVehicleAllowedOrderTypes(
99102
ClientID clientId,
100103
TCSObjectReference<Vehicle> ref,
101104
Set<String> allowedOrderTypes
102105
)
103106
throws RemoteException;
104107

108+
default void updateVehicleAcceptableOrderTypes(
109+
ClientID clientId,
110+
TCSObjectReference<Vehicle> ref,
111+
Set<AcceptableOrderType> acceptableOrderTypes
112+
)
113+
throws RemoteException {
114+
throw new UnsupportedOperationException("Not yet implemented.");
115+
}
116+
105117
void updateVehicleEnvelopeKey(
106118
ClientID clientId,
107119
TCSObjectReference<Vehicle> ref,

opentcs-api-base/src/main/java/org/opentcs/access/rmi/services/RemoteVehicleServiceProxy.java

+25
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import org.opentcs.components.kernel.services.VehicleService;
99
import org.opentcs.data.ObjectUnknownException;
1010
import org.opentcs.data.TCSObjectReference;
11+
import org.opentcs.data.model.AcceptableOrderType;
1112
import org.opentcs.data.model.Vehicle;
1213
import org.opentcs.data.model.Vehicle.EnergyLevelThresholdSet;
1314
import org.opentcs.drivers.vehicle.AdapterCommand;
1415
import org.opentcs.drivers.vehicle.VehicleCommAdapterDescription;
1516
import org.opentcs.drivers.vehicle.management.VehicleAttachmentInformation;
1617
import org.opentcs.drivers.vehicle.management.VehicleProcessModelTO;
18+
import org.opentcs.util.annotations.ScheduledApiChange;
1719

1820
/**
1921
* The default implementation of the vehicle service.
@@ -185,6 +187,8 @@ public void updateVehicleEnergyLevelThresholdSet(
185187
}
186188

187189
@Override
190+
@Deprecated
191+
@ScheduledApiChange(when = "7.0", details = "Will be removed.")
188192
public void updateVehicleAllowedOrderTypes(
189193
TCSObjectReference<Vehicle> ref,
190194
Set<String> allowedOrderTypes
@@ -205,6 +209,27 @@ public void updateVehicleAllowedOrderTypes(
205209
}
206210
}
207211

212+
@Override
213+
public void updateVehicleAcceptableOrderTypes(
214+
TCSObjectReference<Vehicle> ref,
215+
Set<AcceptableOrderType> acceptableOrderTypes
216+
)
217+
throws ObjectUnknownException,
218+
KernelRuntimeException {
219+
checkServiceAvailability();
220+
221+
try {
222+
getRemoteService().updateVehicleAcceptableOrderTypes(
223+
getClientId(),
224+
ref,
225+
acceptableOrderTypes
226+
);
227+
}
228+
catch (RemoteException ex) {
229+
throw findSuitableExceptionFor(ex);
230+
}
231+
}
232+
208233
@Override
209234
public void updateVehicleEnvelopeKey(TCSObjectReference<Vehicle> ref, String envelopeKey)
210235
throws ObjectUnknownException,

opentcs-api-base/src/main/java/org/opentcs/components/kernel/services/VehicleService.java

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.opentcs.access.KernelRuntimeException;
77
import org.opentcs.data.ObjectUnknownException;
88
import org.opentcs.data.TCSObjectReference;
9+
import org.opentcs.data.model.AcceptableOrderType;
910
import org.opentcs.data.model.Vehicle;
1011
import org.opentcs.data.model.Vehicle.EnergyLevelThresholdSet;
1112
import org.opentcs.drivers.vehicle.AdapterCommand;
@@ -176,14 +177,34 @@ default void updateVehicleEnergyLevelThresholdSet(
176177
* @param allowedOrderTypes A set of transport order types.
177178
* @throws ObjectUnknownException If the referenced vehicle does not exist.
178179
* @throws KernelRuntimeException In case there is an exception executing this method.
180+
* @deprecated Use {@link #updateVehicleAcceptableOrderTypes(TCSObjectReference, Set)} instead.
179181
*/
182+
@Deprecated
183+
@ScheduledApiChange(when = "7.0", details = "Will be removed.")
180184
void updateVehicleAllowedOrderTypes(
181185
TCSObjectReference<Vehicle> ref,
182186
Set<String> allowedOrderTypes
183187
)
184188
throws ObjectUnknownException,
185189
KernelRuntimeException;
186190

191+
/**
192+
* Updates the types of transport orders a vehicle is allowed to process.
193+
*
194+
* @param ref A reference to the vehicle to be modified.
195+
* @param acceptableOrderTypes A set of transport order types and their priorities.
196+
* @throws ObjectUnknownException If the referenced vehicle does not exist.
197+
* @throws KernelRuntimeException In case there is an exception executing this method.
198+
*/
199+
default void updateVehicleAcceptableOrderTypes(
200+
TCSObjectReference<Vehicle> ref,
201+
Set<AcceptableOrderType> acceptableOrderTypes
202+
)
203+
throws ObjectUnknownException,
204+
KernelRuntimeException {
205+
throw new UnsupportedOperationException("Not yet implemented.");
206+
}
207+
187208
/**
188209
* Updates the vehicle's envelope key.
189210
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// SPDX-FileCopyrightText: The openTCS Authors
2+
// SPDX-License-Identifier: MIT
3+
package org.opentcs.data.model;
4+
5+
import static java.util.Objects.requireNonNull;
6+
7+
import java.io.Serializable;
8+
import java.util.Objects;
9+
10+
/**
11+
* Acceptable order type with priority.
12+
*/
13+
public class AcceptableOrderType
14+
implements
15+
Serializable {
16+
17+
private final String name;
18+
private final int priority;
19+
20+
/**
21+
* Creates a new vehicle.
22+
*
23+
* @param name The name of the order type.
24+
* @param priority Priority of the order type, with a lower value indicating a higher priority.
25+
*/
26+
public AcceptableOrderType(String name, int priority) {
27+
this.name = requireNonNull(name, "name");
28+
this.priority = priority;
29+
}
30+
31+
/**
32+
* Returns the name of the order type.
33+
*
34+
* @return The name of the order type.
35+
*/
36+
public String getName() {
37+
return name;
38+
}
39+
40+
/**
41+
* Returns the priority of the order type, with a lower value indicating a higher priority.
42+
*
43+
* @return The priority of the order type.
44+
*/
45+
public int getPriority() {
46+
return priority;
47+
}
48+
49+
@Override
50+
public boolean equals(Object o) {
51+
if (o == this) {
52+
return true;
53+
}
54+
if (!(o instanceof AcceptableOrderType other)) {
55+
return false;
56+
}
57+
58+
return Objects.equals(name, other.getName()) && priority == other.getPriority();
59+
}
60+
61+
@Override
62+
public int hashCode() {
63+
return Objects.hash(name, priority);
64+
}
65+
66+
@Override
67+
public String toString() {
68+
return "AcceptableOrderType{"
69+
+ "name=" + name
70+
+ ", priority=" + priority
71+
+ '}';
72+
}
73+
74+
}

0 commit comments

Comments
 (0)