java.lang.Object
com.tccc.kos.ext.dispense.pipeline.ingredient.PumpIntent
All Implemented Interfaces:
com.tccc.kos.commons.util.Abortable, com.tccc.kos.commons.util.Cancelable, com.tccc.kos.commons.util.Terminable, Pour, Cloneable

public class PumpIntent extends Object implements Cloneable, Pour
A collection of pump operations that define a particular task that a pump needs to perform, such as a prime. Intents are used to decouple the intent of a pour from the actual definition using external data that can easily be changed without requiring code changes.

The approach of defining various ingredient pours in terms of intents allows ui code to be completely independent of the implementation details of a particular intent which may differ by pump even though the purpose of the intent doesn't change. For example, most admin ui's offer a hold-to-pour or tap-to-pour button. When tapping to start a pour there is a question of how long to run before ending the pour so an ingredient isn't entirely drained. Similarly, for pumps with controllable flow rates, what flow rate should be used for a given pump? These details can be encoded into an intent specific to a given pump and the ui simply uses the type of the intent to initiate the pour.

For applications where there is a need to add additional information at the intent level (vs. individual PumpOps), this class may be extended to include the additional information as all intents are returned from a developer provided factory.

Intents are named but the name is not the type of the intent. The default data file format for intents defines named intents in one section and then defines rules in other sections to map named intents to typed intents specific to pumps. This allows data files to include other files and override intents by name before they are applied to pumps by the rules.

Since:
1.0
Version:
2023-01-22
  • Constructor Details

    • PumpIntent

      public PumpIntent(String name)
      Create an intent with the specified name. This is the name of the sequence of operations, not the intent type (such as prime). The name will be used by PumpItentFactory and rules in the data files to map an intent type to a named PourIntent.
      Parameters:
      name - the name of this intent
  • Method Details

    • getType

      public String getType()
      Get the type of the intent. This is the type passed to PumpIntentFactory to return the actual intent. This is set after the intent is returned by the factory and cloned internally for use.
    • getName

      public String getName()
      Return the name of the intent. This is the name of this particular collection of operations, not the type of an intent.
    • getSource

      public String getSource()
      Return the source of the intent. This is typically set to the name of the file where the intent was defined. Used primarily for debugging rules.
    • setSource

      public void setSource(String source)
      Set the source of the intent to help with debugging. This is typically set to the name of the file where the intent was defined but can be anything that helps with debugging cascaded rules.
    • isRunDry

      public boolean isRunDry()
      If true, indicates that the intent can be used on a pump that doesn't have an ingredient assigned. This is useful for processes in which the technician is responsible for ensuring there is ingredient but doesn't need/want to assign all ingredients just to perform a bulk task. This comes up during manufacturing and other processes such as sanitization.
    • setRunDry

      public void setRunDry(boolean runDry)
      Set the runDry flag. If true, the intent can be performed even if no ingredient is assigned to the pump.
    • getErrorHandlerId

      public String getErrorHandlerId()
      Return the id of the error handler. Passed to IngredientPipelineErrorHandlerFactory to return an instance of the actual error handler to use while pouring.
    • setErrorHandlerId

      public void setErrorHandlerId(String errorHandlerId)
      Set the name of the error handler. Passed to IngredientPipelineErrorHandlerFactory to return an instance of the actual error handler to use while pouring.
    • setDelegated

      public void setDelegated(boolean delegated)
      Set the delegated flag which when true, indicates that CompositePump should delegate the intent to each of the child pumps. This allows some intents to operate directly on the parent CompositePump and others to operate on the individual CompositePumpChild pumps without having to target the child pumps directly.
    • isDelegated

      public boolean isDelegated()
      Return true if the intent should be delegated to child pumps of a CompositePump .
    • add

      public void add(PumpOp op)
      Add an operation to the intent. This will call validate() on the operation to ensure it's valid. If the operation isn't valid, this will throw InvalidPumpOpException .
      Parameters:
      op - the operation to add
    • getOps

      public List<PumpOp> getOps()
      Return the list of operations in the intent.
    • getPipeline

      public IngredientNozzlePipeline getPipeline()
      Return the pipeline the intent is bound to.
    • validate

      public void validate()
      Perform validation of the intent relative to the bound pump. If validation fails, this should throw a ReasonException and the reason will be used to fail the operation. This can be used for things like verifying that the pump has an ingredient if the runDry property of the intent is false (already implemented in this class). Be sure to call super when overriding this method to ensure all validation is run.
    • getEstimatedTime

      public long getEstimatedTime()
      Return the estimated time to perform the specified intent.
    • getEstimatedVolume

      public double getEstimatedVolume()
      Return the estimated volume poured by the specified intent.
    • getActiveOp

      public PumpOp getActiveOp()
      Get the active PumpOp of the intent.
    • cancel

      public void cancel(String reason)
      Specified by:
      cancel in interface com.tccc.kos.commons.util.Cancelable
    • abort

      public void abort(String reason)
      Specified by:
      abort in interface com.tccc.kos.commons.util.Abortable
    • clone

      public Object clone() throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • setProperty

      public void setProperty(String name, Object value)
      Description copied from interface: Pour
      Set the value of a property. This is a way to attach arbitrary data to the Pour object.
      Specified by:
      setProperty in interface Pour
    • getProperty

      public Object getProperty(String name)
      Description copied from interface: Pour
      Return the value of a property.
      Specified by:
      getProperty in interface Pour