Class Input

java.lang.Object
org.wildstang.framework.io.inputs.Input
Direct Known Subclasses:
AnalogInput, DigitalInput, DiscreteInput, I2CInput, ImageInput

public abstract class Input extends Object
Core input functions, primarily handling InputListeners. Note: Input's update() handles InputListener triggering, latency could be increase if abstracted versions call readDataFromInput() then notifyListners().
  • Constructor Summary

    Constructors
    Constructor
    Description
    Input(String p_name)
    Constructor sets the name of the Input.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Attaches an InputListener to the Input.
    void
    Disables the Input, does nothing at the Input level.
    void
    Enables the Input, does nothing at the Input level.
    Returns a copy of the Array of all attached InputListeners.
    Returns the name of the Input.
    protected boolean
    Returns true if the value of the Input has changed.
    boolean
    Returns true if the Input is enabled, does nothing at this level.
    protected void
    Determines if the value has changed, then notifys all attached listeners that a state change has occured.
    protected abstract void
    Abstract function to read the hardware Input and store its value.
    void
    Detaches all InputListeners associated with the Input.
    void
    Detaches a given InputListener from the Input.
    protected void
    setValueChanged(boolean p_changed)
    Mark that the value of the Input has changed.
    void
    Reads the data from the hardware Input and notifys listeners appropriately.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Input

      public Input(String p_name)
      Constructor sets the name of the Input.
      Parameters:
      p_name - New name of the Input.
  • Method Details

    • addInputListener

      public void addInputListener(InputListener p_listener)
      Attaches an InputListener to the Input.
      Parameters:
      p_listener - New InputListener to attach.
    • removeInputListener

      public void removeInputListener(InputListener p_listener)
      Detaches a given InputListener from the Input.
      Parameters:
      p_listener - InputListner to detach.
    • getInputListeners

      public List<InputListener> getInputListeners()
      Returns a copy of the Array of all attached InputListeners.
      Returns:
      Copy of the Array of InputListeners.
    • notifyListeners

      protected void notifyListeners()
      Determines if the value has changed, then notifys all attached listeners that a state change has occured.
    • update

      public void update()
      Reads the data from the hardware Input and notifys listeners appropriately.
    • getName

      public String getName()
      Returns the name of the Input.
      Returns:
      Name of the Input.
    • setValueChanged

      protected void setValueChanged(boolean p_changed)
      Mark that the value of the Input has changed.
      Parameters:
      p_changed - New state of the valueChanged.
    • hasValueChanged

      protected boolean hasValueChanged()
      Returns true if the value of the Input has changed.
      Returns:
      True if the value of the Input has changed.
    • readDataFromInput

      protected abstract void readDataFromInput()
      Abstract function to read the hardware Input and store its value.
    • removeAllListeners

      public void removeAllListeners()
      Detaches all InputListeners associated with the Input.
    • enable

      public void enable()
      Enables the Input, does nothing at the Input level.
    • disable

      public void disable()
      Disables the Input, does nothing at the Input level.
    • isEnabled

      public boolean isEnabled()
      Returns true if the Input is enabled, does nothing at this level.
      Returns:
      True if the Input is enabled.