Class HubWorkerAdapter

java.lang.Object
org.bzdev.scripting.ScriptListenerAdapter
org.bzdev.bikeshare.HubWorkerAdapter
All Implemented Interfaces:
EventListener, HubWorkerListener

public class HubWorkerAdapter extends ScriptListenerAdapter implements HubWorkerListener
Adapter for hub-worker listeners. This class provides default implementations for the methods specified by HubWorkerListener and allows the listener to be implemented in a scripting language. For use in Java code, one should override the methods of this class. For use in a scripting environment, the implementation of the methods is provided by a scripting-language object whose methods include ones that the same names as the methods of this class. If a method is missing, the call will succeed but no action will be performed.
  • Constructor Details

    • HubWorkerAdapter

      public HubWorkerAdapter()
      Constructor.
    • HubWorkerAdapter

      public HubWorkerAdapter(ExpressionParser.ESPObject scriptObject)
      Constructor with only a script object. This creates an adapter for use with the ESP scripting language.

      Note: This is equivalent to using the constructor HubWorkerAdapter(ScriptingContext,Object) with a null first argument.

      Parameters:
      scriptObject - the scripting-language object implementing the listener interface for this adapter.
    • HubWorkerAdapter

      public HubWorkerAdapter(ScriptingContext sc, Object scriptObject)
      Constructor given a scripting context and script object.
      Parameters:
      sc - the scripting context for this adapter
      scriptObject - the scripting-language object implementing the listener interface for this adapter.
  • Method Details

    • dequeued

      public void dequeued(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicate that a worker left a storage-hub queue.
      Specified by:
      dequeued in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • enteredHub

      public void enteredHub(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicate that a worker entered a hub.
      Specified by:
      enteredHub in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • fixingOverflows

      public void fixingOverflows(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicated that a worker started to remove bicycles from the overflow area.
      Specified by:
      fixingOverflows in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • fixingPreferred

      public void fixingPreferred(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicate that a worker started to handle the preferred area.
      Specified by:
      fixingPreferred in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • leftHub

      public void leftHub(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicate that a worker left a hub.
      Specified by:
      leftHub in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • queued

      public void queued(HubWorker worker, double time, long ticks, Hub hub)
      Description copied from interface: HubWorkerListener
      Indicate that a worker joined a queue.
      Specified by:
      queued in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
    • changedCount

      public void changedCount(HubWorker worker, double time, long ticks, Hub hub, int oldcount, int newcount)
      Description copied from interface: HubWorkerListener
      Indicate that a worker's bicycle count changed.
      Specified by:
      changedCount in interface HubWorkerListener
      Parameters:
      worker - the hub worker being tracked
      time - the simulation time in double-precision units
      ticks - the simulation time in ticks
      hub - the hub at which this event occurred
      oldcount - the bicycle count before the change
      newcount - the bicycle count after the change