All Implemented Interfaces:
com.tccc.kos.commons.util.Abortable, com.tccc.kos.commons.util.Cancelable, com.tccc.kos.commons.util.Terminable, Cloneable

public class TpourOp extends PumpEventPumpOp
Operation to perform a timed pour.
Since:
1.0
Version:
2023-01-21
  • Field Details

  • Constructor Details

    • TpourOp

      public TpourOp()
  • Method Details

    • getDuration

      public int getDuration()
      Returns the duration of the pour (milliseconds).
    • setDuration

      public void setDuration(int duration)
      Sets the duration of the pour (milliseconds).
    • validate

      public void validate()
      Description copied from class: PumpOp
      Called by the factory that creates the operation to validate that it is usable. Operations are typically constructed as beans using setters, so populate the settings from a factory that is driven from a data file. This introduces the risk that the underlying data file is missing a required field. This method is called to ensure that operations are properly formed after they are loaded, by throwing an exception if the operation is poorly formed.
      Overrides:
      validate in class PumpOp
    • getEstimatedTime

      public long getEstimatedTime()
      Description copied from class: PumpOp
      Returns the estimated time of the operation in ms. This is used to compute the estimated time of one or more operations grouped together into a sequence. Ideally, this reflects the estimated time returned in the future from buildFuture() , so that estimates before an operation starts reflects the operation once it begins.

      In some cases the estimate may be more accurate when an operation actually starts, in which case the associated future may have a different value.

      If buildFuture() returns a future with an estimated time of zero, it will be overridden using the value of this method. This allows implementations of ops to ignore estimated time in buildFuture() as the framework will populate it automatically.

      Specified by:
      getEstimatedTime in class PumpOp
    • getEstimatedVolume

      public double getEstimatedVolume()
      Description copied from class: PumpOp
      Returns the estimated volume of the operation in ml. This is used to compute the estimated volume of one or more operations grouped together into a sequence. This should only include the volume poured from the pump, not other pumps such as dilution. In cases where the volume is not easy to determine (runs until a sensor triggers), it is up to the developer to decide what value to return. This is generally used for informational purposes, such as showing the user an expected volume, such as for a calibration pour. This avoids the need to hard code values in the UI where they can get out of sync with the actual underlying intent.
      Specified by:
      getEstimatedVolume in class PumpOp
    • buildFuture

      public com.tccc.kos.commons.util.concurrent.future.FutureWork buildFuture(com.tccc.kos.commons.util.concurrent.future.FutureWork intentFuture)
      Description copied from class: PumpOp
      Returns a future which encapsulates the work that this operation must perform. The future is started by the caller, and it may be the case that all futures for a sequence are built before the sequence is started. This implies that a future should not be constructed differently based on external state that may change before the future is run. In this case, the future should check the external state when it is run, not when it is built.

      The returned future must be atomic under all conditions. That is, the operation must leave the system in a usable state whether it runs to completion successfully, is cancelled, or fails due to an error. An operation may generate a Trouble that results in future operations being non-runnable, but an operation may not leave internal hardware in a state that, when another valid operation is run, causes it to fail due to these internal state issues.

      The returned future can include an estimated time as this is used to compute the overall estimated time of a sequence of operations. If the actual time of an operation us unknown, use the following guidance:

      • If the operation may run longer due to an unexpected condition such as a lower flow rate than expected, simply use the expected time assuming nominal conditions.
      • If the operation may take a long time but typically ends much quicker, such as when trying to fill/empty a line, which may take minutes but probably takes seconds after already primed, use the longest expected time.
      In every case, when a future completes, the estimated time is automatically updated to reflect the actual time, and overall progress information is updated automatically to reflect this.

      If the future returned from this method does not include an estimated time (set to zero), then the framework overrides it using the result of getEstimatedTime() . This allows an operation to compute a more accurate estimated time when the future is constructed (when it knows the actual device and other details), but by default this method can simply ignore estimated time and let the framework fill it in.

      The future returned from this method is available via the getFuture() call.

      The intentFuture argument is the parent future for the entire intent. If the pump op changes state that must be cleaned up at the end of the intent, a callback on intentFuture can be used to ensure it is run when the intent is complete.

      Specified by:
      buildFuture in class PumpOp
      Parameters:
      intentFuture - the parent future for the entire intent