Class NozzleMetricsService

java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.commons.core.service.AbstractConfigurableService<NozzleMetricsServiceConfig>
com.tccc.kos.ext.dispense.service.nozzle.metrics.NozzleMetricsService
All Implemented Interfaces:
com.tccc.kos.commons.core.context.CtxEventListener, com.tccc.kos.commons.core.service.config.ConfigAware<NozzleMetricsServiceConfig>, com.tccc.kos.commons.core.service.handle.ContextHandleAware, com.tccc.kos.commons.core.service.handle.HandleAware, com.tccc.kos.commons.util.ready.Ready, com.tccc.kos.commons.util.ready.ReadyListener, BeveragePipelineListener, BeveragePourListener

public class NozzleMetricsService extends com.tccc.kos.commons.core.service.AbstractConfigurableService<NozzleMetricsServiceConfig> implements BeveragePourListener
Manages all the pour metrics.
Version:
2024-01-29
  • Field Details

  • Constructor Details

    • NozzleMetricsService

      public NozzleMetricsService()
  • Method Details

    • onConfigChanged

      public void onConfigChanged(com.tccc.kos.commons.core.service.config.BeanChanges changes)
      Specified by:
      onConfigChanged in interface com.tccc.kos.commons.core.service.config.ConfigAware<NozzleMetricsServiceConfig>
    • removeNozzle

      public void removeNozzle(Nozzle nozzle)
      Remove a nozzle.
    • getTotalMetrics

      public NozzleMetrics getTotalMetrics()
      Return the metrics that track total volume poured.
      Returns:
      total pour metrics
    • getLastBeveragePourMetrics

      public NozzleMetrics getLastBeveragePourMetrics(Nozzle nozzle)
      Return the metrics that track the most recent beverage pour.
      Parameters:
      nozzle - the nozzle to return metrics for
      Returns:
      last pour metrics
    • addGlobalMetrics

      public NozzleMetrics addGlobalMetrics(String name)
      Register global metrics with the service. 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 reset() on the existing metrics.

      Global metrics will track all pour data across all nozzles.

      Internal metrics cannot be replaced and will throw InvalidMetricsException .

      Parameters:
      name - name of the metrics to add / replace
      Returns:
      the new metrics object
    • addMetrics

      public NozzleMetrics addMetrics(Nozzle nozzle, String name)
      Register metrics with the service relative to the specified 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 reset() on the existing metrics.

      This will track metrics specific to the specified nozzle.

      Internal metrics cannot be replaced and will throw InvalidMetricsException .

      Parameters:
      nozzle - the nozzle the metrics are relative to
      name - name of the metrics to add / replace
      Returns:
      the new metrics object
    • removeGlobalMetrics

      public NozzleMetrics removeGlobalMetrics(String name)
      Remove global metrics with the specified name.

      Internal metrics cannot be removed and will throw InvalidMetricsException

      Parameters:
      name - name of the metrics to remove
      Returns:
      the metrics that were removed
    • removeMetrics

      public NozzleMetrics removeMetrics(Nozzle nozzle, String name)
      Remove metrics with the specified name from the nozzle.

      Internal metrics cannot be removed and will throw InvalidMetricsException

      Parameters:
      nozzle - the nozzle to remove metrics from
      name - name of the metrics to remove
      Returns:
      the metrics that were removed
    • getGlobalMetricsNames

      public Set<String> getGlobalMetricsNames()
      Return the list of global metrics names.
      Returns:
      the list of global metrics names
    • getAllGlobalMetrics

      public Collection<NozzleMetrics> getAllGlobalMetrics()
      Return all the active metrics
    • getGlobalMetrics

      public NozzleMetrics getGlobalMetrics(String name)
      Return the global metrics with the specified name.
      Parameters:
      name - name of the metrics
      Returns:
      the named metrics
    • getMetricsNames

      public Set<String> getMetricsNames(Nozzle nozzle)
      Return the list of metrics names for the specified nozzle.
      Parameters:
      nozzle - the nozzle to return names for
      Returns:
      the list of metrics names
    • getAllMetrics

      public Collection<NozzleMetrics> getAllMetrics(Nozzle nozzle)
      Return all the active metrics for the specified nozzle.
      Parameters:
      nozzle - the nozzle to return metrics for
      Returns:
      the list of metrics
    • getMetrics

      public NozzleMetrics getMetrics(Nozzle nozzle, String name)
      Return the metrics with the specified name for the specified nozzle.
      Parameters:
      nozzle - the nozzle to query
      name - name of the metrics
      Returns:
      the named metrics
    • onBeveragePourStart

      public void onBeveragePourStart(BeverageNozzlePipeline pipeline, BeveragePour pour)
      Description copied from interface: BeveragePourListener
      Called when a beverage pour is about to start. When this is called, the pour has already been built from the sequence so no changes can be made.
      Specified by:
      onBeveragePourStart in interface BeveragePourListener
      Parameters:
      pipeline - the pipeline generating the event
      pour - the pour that just started
    • onBeveragePourStop

      public void onBeveragePourStop(BeverageNozzlePipeline pipeline, BeveragePour pour)
      Description copied from interface: BeveragePourListener
      Called when a pump intent is done. The end state of the future indicates whether the intent was successful or not.
      Specified by:
      onBeveragePourStop in interface BeveragePourListener
      Parameters:
      pipeline - the pipeline generating the event
      pour - the pour that just ended