java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.ext.dispense.service.nozzle.Nozzle
All Implemented Interfaces:
com.tccc.kos.commons.core.context.CtxEventListener, com.tccc.kos.commons.core.service.config.ConfigAware<NozzleConfig>, com.tccc.kos.commons.core.service.handle.ContextHandleAware, com.tccc.kos.commons.core.service.handle.HandleAware, com.tccc.kos.commons.core.service.trouble.TroubleAware, com.tccc.kos.commons.core.service.trouble.TroubleListener, com.tccc.kos.commons.util.ready.Ready, com.tccc.kos.commons.util.ready.ReadyListener, com.tccc.kos.core.service.assembly.AssemblyAware, PourAvailability

public class Nozzle extends com.tccc.kos.commons.util.ready.ReadyBean implements com.tccc.kos.core.service.assembly.AssemblyAware, com.tccc.kos.commons.core.service.handle.ContextHandleAware, com.tccc.kos.commons.core.service.config.ConfigAware<NozzleConfig>, com.tccc.kos.commons.core.service.trouble.TroubleListener, PourAvailability, com.tccc.kos.commons.core.context.CtxEventListener
Logical representation of a physical nozzle in a dispenser.

A nozzle has an associated list of pumps (and therefore, ingredients) which are connected to it. A nozzle can have one more pipelines, which are used for pouring from the nozzle.

Pipelines are constructed within the BeanContext of the nozzle, which keeps the pipelines of one nozzle isolated from the pipelines of other nozzles. This allows multiple pipelines to contain instances of the same service, which operate independently but can be autowired within the pipeline.

The handles to objects are also context-relative, so if the same service appears on multiple pipelines in multiple nozzles, then each instance will have a distinct path and therefore distinct configuration settings.

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

    • Nozzle

      public Nozzle(com.tccc.kos.core.service.assembly.Assembly assembly, String name)
      Creates a new nozzle with the specified name and parent context (typically the system context).
  • Method Details

    • lock

      public boolean lock(Object ref)
      Locks the nozzle to the specified object. If there is no lock, this becomes the lock object. Additional lock calls using this object increments the lock count. Corresponding calls to unlock with the same object decrements the lock count. When the count reaches zero, the nozzle lock is available to be claimed by a different object.

      The object used for the lock is typically a pipeline object or a key service within a pipeline.

      Parameters:
      ref - the object the lock request is relative to
    • unlock

      public void unlock(Object ref)
      Decrements the nozzle lock count for the specified object. This is only meaningful if the specified object currently holds the nozzle lock. In this case the use count is decremented. Once the use count reaches zero, then the lock is released and the nozzle is available to be locked by some other pipeline.
      Parameters:
      ref - the object used to acquire the lock
    • triggerPumpValidation

      public void triggerPumpValidation()
      Triggers pump validation.
    • getBlockedPumpCount

      public int getBlockedPumpCount()
      Returns the number of pumps that are currently blocked from pouring for some reason.
    • getPumps

      public Collection<Pump<?>> getPumps()
      Returns the list of pumps attached to this nozzle.
    • add

      public void add(Pump<?> pump)
      Adds a pump to the pending list. This pump becomes active in the nozzle when the associated assembly is installed, and is removed when the assembly is uninstalled.
    • add

      public void add(Collection<? extends Pump<?>> pumps)
      Adds a list of pumps to the pending list. These pumps become active in the nozzle when the associated assembly is installed, and is removed when the assembly is uninstalled.
    • add

      public void add(NozzlePipeline pipeline)
      Adds a pipeline to the nozzle. A pipeline can only be installed to a single nozzle.
      Parameters:
      pipeline - the pipeline to add
    • remove

      public void remove(NozzlePipeline pipeline)
      Removes a pipeline from the nozzle.
      Parameters:
      pipeline - the pipeline to remove
    • getPipelines

      public Set<NozzlePipeline> getPipelines()
      Return the pipelines associated with this nozzle.
    • getPipeline

      public <T extends NozzlePipeline> T getPipeline(Class<T> type)
      Get the pipeline with the specified type.
      Parameters:
      type - the class to match
    • getAssignablePipeline

      public <T extends NozzlePipeline> T getAssignablePipeline(Class<T> type)
      Get the pipeline that is an instance of the specified type. This will match pipelines that are subclasses of the specified type.
      Parameters:
      type - the class to match
    • getIngredientPipelineService

      public IngredientPipelineService getIngredientPipelineService()
      Return IngredientPipelineService from the associated IngredientNozzlePipeline if installed. This provides easy access to ingredient based pouring using intents.
    • getLastBeveragePourMetrics

      public NozzleMetrics getLastBeveragePourMetrics()
      Return the metrics for the last beverage pour on this nozzle.
    • addMetrics

      public NozzleMetrics addMetrics(String name)
      Register metrics associated with this nozzle. These will be updated with pour data regardless of how the ingredient is poured (both beverage and ingredient pours). Adding a name that already exists will simply call resetMetrics() on the existing metrics.

      Internal metrics cannot be replaced and will throw InvalidMetricsException .

      Parameters:
      name - name of the metrics
      Returns:
      the associated metrics
    • getMetrics

      public NozzleMetrics getMetrics(String name)
      Return the metrics with the specified name for this nozzle.
      Parameters:
      name - name of the metrics
      Returns:
      the named metrics
    • onCtxAutowiringCompleted

      public void onCtxAutowiringCompleted()
      Specified by:
      onCtxAutowiringCompleted in interface com.tccc.kos.commons.core.context.CtxEventListener
    • onTroubleAdded

      public void onTroubleAdded(com.tccc.kos.commons.core.service.trouble.Trouble trouble)
      Specified by:
      onTroubleAdded in interface com.tccc.kos.commons.core.service.trouble.TroubleAware
    • onTroubleResolved

      public void onTroubleResolved(com.tccc.kos.commons.core.service.trouble.Trouble trouble, boolean success)
      Specified by:
      onTroubleResolved in interface com.tccc.kos.commons.core.service.trouble.TroubleAware
    • onTroubleRemoved

      public void onTroubleRemoved(com.tccc.kos.commons.core.service.trouble.Trouble trouble)
      Specified by:
      onTroubleRemoved in interface com.tccc.kos.commons.core.service.trouble.TroubleAware
    • getMetricsService

      public NozzleMetricsService getMetricsService()
    • getHandle

      public com.tccc.kos.commons.core.service.handle.Handle getHandle()
      Specified by:
      getHandle in interface com.tccc.kos.commons.core.service.handle.HandleAware
    • getAssembly

      public com.tccc.kos.core.service.assembly.Assembly getAssembly()
      Specified by:
      getAssembly in interface com.tccc.kos.core.service.assembly.AssemblyAware
    • getName

      public String getName()
      Specified by:
      getName in interface com.tccc.kos.commons.core.service.handle.HandleAware
    • getCtx

      public com.tccc.kos.commons.core.context.BeanContext getCtx()
    • getConfig

      public NozzleConfig getConfig()
      Specified by:
      getConfig in interface com.tccc.kos.commons.core.service.config.ConfigAware<NozzleConfig>
    • setConfig

      public void setConfig(NozzleConfig config)
      Specified by:
      setConfig in interface com.tccc.kos.commons.core.service.config.ConfigAware<NozzleConfig>
    • getMatcher

      public com.tccc.kos.commons.core.service.trouble.TroubleMatcher getMatcher()
      Specified by:
      getMatcher in interface com.tccc.kos.commons.core.service.trouble.TroubleListener
    • getBeverageAvailabilityLock

      public AvailabilityLock getBeverageAvailabilityLock()
      Description copied from interface: PourAvailability
      Return the object add to a trouble impact list to block beverage pouring.
      Specified by:
      getBeverageAvailabilityLock in interface PourAvailability
    • getIngredientAvailabilityLock

      public AvailabilityLock getIngredientAvailabilityLock()
      Description copied from interface: PourAvailability
      Return the object add to a trouble impact list to block all pouring.
      Specified by:
      getIngredientAvailabilityLock in interface PourAvailability