Class PumpIntent
- All Implemented Interfaces:
com.tccc.kos.commons.util.Abortable
,com.tccc.kos.commons.util.Cancelable
,com.tccc.kos.commons.util.Terminable
,Pour
,Cloneable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Add an operation to the intent.void
clone()
Get the activePumpOp
of the intent.Return the id of the error handler.long
Return the estimated time to perform the specified intent.double
Return the estimated volume poured by the specified intent.getName()
Return the name of the intent.getOps()
Return the list of operations in the intent.Return the pipeline the intent is bound to.getProperty
(String name) Return the value of a property.Return the source of the intent.getType()
Get the type of the intent.boolean
Return true if the intent should be delegated to child pumps of aCompositePump
.boolean
isRunDry()
If true, indicates that the intent can be used on a pump that doesn't have an ingredient assigned.void
setDelegated
(boolean delegated) Set the delegated flag which when true, indicates thatCompositePump
should delegate the intent to each of the child pumps.void
setErrorHandlerId
(String errorHandlerId) Set the name of the error handler.void
setProperty
(String name, Object value) Set the value of a property.void
setRunDry
(boolean runDry) Set the runDry flag.void
Set the source of the intent to help with debugging.void
validate()
Perform validation of the intent relative to the bound pump.
-
Constructor Details
-
PumpIntent
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 byPumpItentFactory
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
Get the type of the intent. This is the type passed toPumpIntentFactory
to return the actual intent. This is set after the intent is returned by the factory and cloned internally for use. -
getName
Return the name of the intent. This is the name of this particular collection of operations, not the type of an intent. -
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
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
Return the id of the error handler. Passed toIngredientPipelineErrorHandlerFactory
to return an instance of the actual error handler to use while pouring. -
setErrorHandlerId
Set the name of the error handler. Passed toIngredientPipelineErrorHandlerFactory
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 thatCompositePump
should delegate the intent to each of the child pumps. This allows some intents to operate directly on the parentCompositePump
and others to operate on the individualCompositePumpChild
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 aCompositePump
. -
add
Add an operation to the intent. This will callvalidate()
on the operation to ensure it's valid. If the operation isn't valid, this will throwInvalidPumpOpException
.- Parameters:
op
- the operation to add
-
getOps
Return the list of operations in the intent. -
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 aReasonException
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 therunDry
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
Get the activePumpOp
of the intent. -
cancel
- Specified by:
cancel
in interfacecom.tccc.kos.commons.util.Cancelable
-
abort
- Specified by:
abort
in interfacecom.tccc.kos.commons.util.Abortable
-
clone
- Throws:
CloneNotSupportedException
-
setProperty
Description copied from interface:Pour
Set the value of a property. This is a way to attach arbitrary data to thePour
object.- Specified by:
setProperty
in interfacePour
-
getProperty
Description copied from interface:Pour
Return the value of a property.- Specified by:
getProperty
in interfacePour
-