Class VpourOp
- All Implemented Interfaces:
com.tccc.kos.commons.util.Abortable
,com.tccc.kos.commons.util.Cancelable
,com.tccc.kos.commons.util.Terminable
,Cloneable
- Since:
- 1.0
- Version:
- 2023-01-21
-
Nested Class Summary
Nested classes/interfaces inherited from class com.tccc.kos.ext.dispense.pipeline.ingredient.ops.PumpOp
PumpOp.Grant
-
Field Summary
FieldsFields inherited from class com.tccc.kos.ext.dispense.pipeline.ingredient.ops.PumpOp
GRANT_LIMIT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.tccc.kos.commons.util.concurrent.future.FutureWork
buildFuture
(com.tccc.kos.commons.util.concurrent.future.FutureWork intentFuture) Returns a future which encapsulates the work that this operation must perform.long
Returns the estimated time of the operation in ms.double
Returns the estimated volume of the operation in ml.double
Returns the volume of the pour (milliliters).void
setVolume
(double volume) Sets the volume of the pour (milliliters).void
validate()
Called by the factory that creates the operation to validate that it is usable.Methods inherited from class com.tccc.kos.ext.dispense.pipeline.ingredient.ops.PumpEventPumpOp
start, stop
Methods inherited from class com.tccc.kos.ext.dispense.pipeline.ingredient.ops.PumpOp
abort, addGrant, cancel, clone, getEffectiveRate, getErrorHandlerId, getFuture, getGrants, getGrants, getIngredientPipelineService, getIntent, getPump, getRate, getType, isDiluted, setDiluted, setErrorHandlerId, setRate
-
Field Details
-
TYPE
- See Also:
-
-
Constructor Details
-
VpourOp
public VpourOp()
-
-
Method Details
-
getVolume
public double getVolume()Returns the volume of the pour (milliliters). -
setVolume
public void setVolume(double volume) Sets the volume of the pour (milliliters). -
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. -
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 frombuildFuture()
, 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 inbuildFuture()
as the framework will populate it automatically.- Specified by:
getEstimatedTime
in classPumpOp
-
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 classPumpOp
-
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.
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 onintentFuture
can be used to ensure it is run when the intent is complete.- Specified by:
buildFuture
in classPumpOp
- Parameters:
intentFuture
- the parent future for the entire intent
-