Class OrderSequence

java.lang.Object
org.opentcs.data.TCSObject<OrderSequence>
org.opentcs.data.order.OrderSequence
All Implemented Interfaces:
java.io.Serializable

public class OrderSequence
extends TCSObject<OrderSequence>
implements java.io.Serializable
Describes a process spanning multiple TransportOrders which are to be executed subsequently by the same Vehicle.

The most important rules for order sequence processing are:

  • Only transport orders that have not yet been activated may be added to an order sequence. Allowing them to be added at a later point of time would imply that, due to concurrency in the kernel, a transport order might happen to be dispatched at the same time or shortly after it is added to a sequence, regardless of if its predecessors in the sequence have already been finished or not.
  • The intendedVehicle of a transport order being added to an order sequence must be the same as that of the sequence itself. If it is null in the sequence, a vehicle that will process all orders in the sequence will be chosen automatically once the first order in the sequence is dispatched.
  • If an order sequence is marked as complete and all transport orders belonging to it have arrived in state FINISHED or FAILED, it will be marked as finished implicitly.
  • If a transport order belonging to an order sequence fails and the sequence's failureFatal flag is set, all subsequent orders in the sequence will automatically be considered (and marked as) failed, too, and the order sequence will implicitly be marked as complete (and finished).
See Also:
Serialized Form
  • Constructor Details

    • OrderSequence

      public OrderSequence​(java.lang.String name)
      Creates a new OrderSequence.
      Parameters:
      name - This sequence's name.
  • Method Details

    • withProperty

      public OrderSequence withProperty​(java.lang.String key, java.lang.String value)
      Description copied from class: TCSObject
      Creates a copy of this object, with the given property integrated.
      Specified by:
      withProperty in class TCSObject<OrderSequence>
      Parameters:
      key - The key of the property to be changed.
      value - The new value of the property, or null, if the property is to be removed.
      Returns:
      A copy of this object, with the given property integrated.
    • withProperties

      public OrderSequence withProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
      Description copied from class: TCSObject
      Creates a copy of this object, with the given properties.
      Specified by:
      withProperties in class TCSObject<OrderSequence>
      Parameters:
      properties - The properties.
      Returns:
      A copy of this object, with the given properties.
    • withHistoryEntry

      public TCSObject<OrderSequence> withHistoryEntry​(ObjectHistory.Entry entry)
      Description copied from class: TCSObject
      Creates a copy of this object, with the given history entry integrated.
      Specified by:
      withHistoryEntry in class TCSObject<OrderSequence>
      Parameters:
      entry - The history entry to be integrated.
      Returns:
      A copy of this object, with the given history entry integrated.
    • withHistory

      public TCSObject<OrderSequence> withHistory​(ObjectHistory history)
      Description copied from class: TCSObject
      Creates a copy of this object, with the given history.
      Specified by:
      withHistory in class TCSObject<OrderSequence>
      Parameters:
      history - The history.
      Returns:
      A copy of this object, with the given history.
    • getType

      @Nonnull public java.lang.String getType()
      Returns this order sequence's type.
      Returns:
      This order sequence's type.
    • withType

      public OrderSequence withType​(java.lang.String type)
      Creates a copy of this object, with the given type.
      Parameters:
      type - The type to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • getOrders

      public java.util.List<TCSObjectReference<TransportOrder>> getOrders()
      Returns the list of orders making up this sequence.
      Returns:
      The list of orders making up this sequence.
    • withOrder

      public OrderSequence withOrder​(TCSObjectReference<TransportOrder> order)
      Creates a copy of this object, with the given order.
      Parameters:
      order - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • getNextUnfinishedOrder

      public TCSObjectReference<TransportOrder> getNextUnfinishedOrder()
      Returns the next order in the sequence that hasn't been finished, yet.
      Returns:
      null if this sequence has been finished already or currently doesn't have any unfinished orders, else the order after the one that was last finished.
    • getFinishedIndex

      public int getFinishedIndex()
      Returns the index of the order that was last finished in the sequence, or -1, if none was finished, yet.
      Returns:
      the index of the order that was last finished in the sequence.
    • withFinishedIndex

      public OrderSequence withFinishedIndex​(int finishedIndex)
      Creates a copy of this object, with the given finished index.
      Parameters:
      finishedIndex - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • isComplete

      public boolean isComplete()
      Indicates whether this order sequence is complete and will not be extended by more orders.
      Returns:
      true if, and only if, this order sequence is complete and will not be extended by more orders.
    • withComplete

      public OrderSequence withComplete​(boolean complete)
      Creates a copy of this object, with the given complete flag.
      Parameters:
      complete - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • isFinished

      public boolean isFinished()
      Indicates whether this order sequence has been processed completely. (Note that processed completely does not necessarily mean finished successfully; it is possible that one or more transport orders belonging to this sequence have failed.)
      Returns:
      true if, and only if, this order sequence has been processed completely.
    • withFinished

      public OrderSequence withFinished​(boolean finished)
      Creates a copy of this object, with the given finished flag.
      Parameters:
      finished - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • isFailureFatal

      public boolean isFailureFatal()
      Indicates whether the failure of a single order in this sequence implies that all subsequent orders in this sequence are to be considered failed, too.
      Returns:
      true if, and only if, the failure of an order in this sequence implies the failure of all subsequent orders.
    • withFailureFatal

      public OrderSequence withFailureFatal​(boolean failureFatal)
      Creates a copy of this object, with the given failure-fatal flag.
      Parameters:
      failureFatal - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • getIntendedVehicle

      public TCSObjectReference<Vehicle> getIntendedVehicle()
      Returns a reference to the vehicle that is intended to process this order sequence.
      Returns:
      A reference to the vehicle that is intended to process this order sequence. If this sequence is free to be processed by any vehicle, null is returned.
    • withIntendedVehicle

      public OrderSequence withIntendedVehicle​(TCSObjectReference<Vehicle> intendedVehicle)
      Creates a copy of this object, with the given intended vehicle.
      Parameters:
      intendedVehicle - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.
    • getProcessingVehicle

      public TCSObjectReference<Vehicle> getProcessingVehicle()
      Returns a reference to the vehicle currently processing this sequence.
      Returns:
      A reference to the vehicle currently processing this sequence. If this sequence has not been processed, yet, null is returned.
    • withProcessingVehicle

      public OrderSequence withProcessingVehicle​(TCSObjectReference<Vehicle> processingVehicle)
      Creates a copy of this object, with the given processing vehicle.
      Parameters:
      processingVehicle - The value to be set in the copy.
      Returns:
      A copy of this object, differing in the given value.