Class DispenseAssembly

java.lang.Object
com.kosdev.kos.core.service.assembly.Assembly
com.kosdev.kos.ext.dispense.DispenseAssembly
All Implemented Interfaces:
com.kosdev.kos.commons.core.service.handle.HandleAware, com.kosdev.kos.commons.util.json.JsonDescriptorAware, com.kosdev.kos.core.util.Loadable, PumpOpLimitAware

public abstract class DispenseAssembly extends com.kosdev.kos.core.service.assembly.Assembly implements PumpOpLimitAware
Assembly that tracks dispense related objects. This is optional to use but offers the convenience of tracking various dispense related objects automatically.

This implements PumpOpLimitAware which enforces a simple limit grant count algorithm which can be enabled by setting pumpOpGrantLimit to the max number of concurrent pumps that can be used. If not set, no limit is enforced. Override checkPumpOpLimits() to implement a different algorithm if needed.

Since:
1
Version:
1
  • Constructor Details

    • DispenseAssembly

      public DispenseAssembly(String name)
      Create a new assembly with the specified name.
      Parameters:
      name - name of the assembly
      Since:
      1
  • Method Details

    • add

      public void add(Object obj)
      Overrides:
      add in class com.kosdev.kos.core.service.assembly.Assembly
    • addNozzle

      @Deprecated public void addNozzle(Nozzle nozzle)
      Deprecated.
      Add a nozzle to the assembly. This exists for backward compatibility and simply calls add(nozzle) . There is no need to manually add nozzles as the Nozzle constructor takes an Assembly and adds the nozzle automatically via add() .
      Since:
      1
    • getNozzle

      public Nozzle getNozzle(String name)
      Return a nozzle by nozzle name.
      Parameters:
      name - the name of the nozzle to return
      Since:
      1
    • addHolder

      public void addHolder(Holder holder, String group)
      Add a holder to the assembly with the specified group name.
      Parameters:
      holder - the holder to add
      group - the group the holder is part of
      Since:
      1
    • getDefaultHolders

      public List<Holder> getDefaultHolders()
      Return holders from the default group. This will include holders that were added without a group.
      Since:
      1
    • getHoldersByGroup

      public List<Holder> getHoldersByGroup(String group)
      Return holders in the specified group.
      Parameters:
      group - the group to return
      Since:
      1
    • getHolder

      public Holder getHolder(String name)
      Return the holder with the specified name.
      Parameters:
      name - the name of the holder to return
      Since:
      1
    • getAllHolders

      public Collection<Holder> getAllHolders()
      Return all holders.
      Since:
      1
    • checkPumpOpLimits

      public boolean checkPumpOpLimits(List<String> requests)
      Description copied from interface: PumpOpLimitAware
      Check the list of requests and return true if they are all allowed to run concurrently. A request is a string which may be null or a name. By default, tpour and vpour have limit grants with no request type so they will appear as null entries in the list. This can be used for simple count logic. If there is a need to limit based on other criteria such as power or pump types, the limit grant can include that information as the grant value and those values will be the strings in the request list. This allows developers to create very complex limit policies without needing to create a new type of grant.
      Specified by:
      checkPumpOpLimits in interface PumpOpLimitAware
      Parameters:
      requests - the grant requests to check
    • getPumpOpGrantLimit

      public int getPumpOpGrantLimit()
    • setPumpOpGrantLimit

      public void setPumpOpGrantLimit(int pumpOpGrantLimit)