Class Input
- java.lang.Object
-
- org.wildstang.framework.io.inputs.Input
-
- Direct Known Subclasses:
AnalogInput
,DigitalInput
,DiscreteInput
,I2CInput
,ImageInput
public abstract class Input extends java.lang.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(java.lang.String p_name)
Constructor sets the name of the Input.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addInputListener(InputListener p_listener)
Attaches an InputListener to the Input.void
disable()
Disables the Input, does nothing at the Input level.void
enable()
Enables the Input, does nothing at the Input level.java.util.List<InputListener>
getInputListeners()
Returns a copy of the Array of all attached InputListeners.java.lang.String
getName()
Returns the name of the Input.protected boolean
hasValueChanged()
Returns true if the value of the Input has changed.boolean
isEnabled()
Returns true if the Input is enabled, does nothing at this level.protected void
notifyListeners()
Determines if the value has changed, then notifys all attached listeners that a state change has occured.protected abstract void
readDataFromInput()
Abstract function to read the hardware Input and store its value.void
removeAllListeners()
Detaches all InputListeners associated with the Input.void
removeInputListener(InputListener p_listener)
Detaches a given InputListener from the Input.protected void
setValueChanged(boolean p_changed)
Mark that the value of the Input has changed.void
update()
Reads the data from the hardware Input and notifys listeners appropriately.
-
-
-
Method Detail
-
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 java.util.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 java.lang.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.
-
-