Class NozzlePipeline

java.lang.Object
com.tccc.kos.ext.dispense.service.nozzle.NozzlePipeline
All Implemented Interfaces:
com.tccc.kos.commons.core.service.handle.HandleAware
Direct Known Subclasses:
BeverageNozzlePipeline, IngredientNozzlePipeline

public class NozzlePipeline extends Object implements com.tccc.kos.commons.core.service.handle.HandleAware
A pipeline for a nozzle. A pipeline implements a mechanism to pour from the nozzle and can implement any strategy for pouring. Only one pipeline can pour from a nozzle at a time, effectively providing a global lock across all pipelines. This makes it easy to implement pipelines that aren't generally aware of each other even though they use the same underlying hardware as the nozzle lock will ensure only one pipeline is interacting with the hardware at a time.

Although pipeline access to the nozzle is serialized, any given pipeline is free to use the nozzle (and associated pumps) in whatever way makes sense. For example while it makes no sense to have more than one concurrent beverage pour, a pipeline that implements utility pumping (technician operations for example) is free to run multiple concurrent pours as makes sense for the application.

A pipeline creates a new BeanContext that is a child of the nozzle context. This allows objects to be placed in the pipeline context and autowire to each other without mixing with objects in other pipelines. Even if instances of the same class are placed in multiple pipelines, they will be isolated by context and also have a unique handle path related to the nozzle and pipeline. This ensures that multiple instances of service in different pipelines are uniquely identifiable and have distinct config settings, allowing each pipeline to be uniquely configured.

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

    • NozzlePipeline

      public NozzlePipeline(String name)
      Create a new nozzle pipeline with the specified name. The name will be part of the handle path and will also be used to namespace any controllers that exist within the pipeline.
  • Method Details

    • start

      public void start()
      Called when the pipeline is installed to the nozzle. The nozzle will be set and the pipeline context will be bound to the nozzle context before this is called. This allows the pipeline to prepare for use. Any controllers in the pipeline will be made active when this returns. Override as needed.
    • stop

      public void stop()
      Called when a pipeline is uninstalled from the nozzle. The nozzle will remain set until this returns. Any controllers in the pipeline will be disabled before this is called. Override as needed.
    • send

      public void send(String topic)
      Send a message with the specified topic which will be automatically prefixed with the base nozzle topic.
      Parameters:
      topic - the relative topic to send
    • send

      public void send(String topic, Object body)
      Send a message with the specified topic and body. The topic will be automatically prefixed with the base nozzle topic.
      Parameters:
      topic - the relative topic to send
      body - object to serialize as the body of the topic
    • send

      public void send(String topic, Object body, Class<?> view)
      Send a message with the specified topic and body. The topic will be automatically prefixed with the base nozzle topic. The body will be serialized using the specified view.
      Parameters:
      topic - the relative topic to send
      body - object to serialize as the body of the topic
      view - the view to use to serialize the body
    • getPumpEventService

      public PumpEventService getPumpEventService()
    • getHandle

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

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

      public Nozzle getNozzle()
    • isInstalled

      public boolean isInstalled()
    • getTopicPrefix

      public String getTopicPrefix()