Class Input
java.lang.Object
org.wildstang.framework.io.inputs.Input
- Direct Known Subclasses:
AnalogInput,DigitalInput,DiscreteInput,I2CInput,ImageInput
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInputListener(InputListener p_listener) Attaches an InputListener to the Input.voiddisable()Disables the Input, does nothing at the Input level.voidenable()Enables the Input, does nothing at the Input level.Returns a copy of the Array of all attached InputListeners.getName()Returns the name of the Input.protected booleanReturns true if the value of the Input has changed.booleanReturns true if the Input is enabled, does nothing at this level.protected voidDetermines if the value has changed, then notifys all attached listeners that a state change has occured.protected abstract voidAbstract function to read the hardware Input and store its value.voidDetaches all InputListeners associated with the Input.voidremoveInputListener(InputListener p_listener) Detaches a given InputListener from the Input.protected voidsetValueChanged(boolean p_changed) Mark that the value of the Input has changed.voidupdate()Reads the data from the hardware Input and notifys listeners appropriately.
-
Constructor Details
-
Input
Constructor sets the name of the Input.- Parameters:
p_name- New name of the Input.
-
-
Method Details
-
addInputListener
Attaches an InputListener to the Input.- Parameters:
p_listener- New InputListener to attach.
-
removeInputListener
Detaches a given InputListener from the Input.- Parameters:
p_listener- InputListner to detach.
-
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
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.
-