Package api
Class ExternalValue
- java.lang.Object
-
- api.ExternalValue
-
- All Implemented Interfaces:
IComponent,IStatefulComponent
public class ExternalValue extends java.lang.Object implements IStatefulComponent
An ExternalValue is a component representing a value that might be set by setting switches or reading external data. It is a "stateful" component whose outputs are always valid.
-
-
Constructor Summary
Constructors Constructor Description ExternalValue(int size)Constructs an ExternalValue of the given number of bits.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the internal state, if any (sets to all zeros).Pin[]inputs()Returns the array of Pins representing this component's inputs.booleaninputsValid()Returns whether all inputs are valid.voidinvalidateInputs()Changes the state of all inputs to invalid.voidinvalidateOutputs()Changes the state of all outputs to invalid.Pin[]outputs()Returns the array of Pins representing this component's outputs.booleanoutputsValid()Returns whether all outputs are valid.voidpropagate()Propagates inputs to outputs.voidsetEnabled(boolean enabled)Enables or disables updates to the internal state, if any, when processing the tick() operation.voidsetValues(int value)Sets the state of this component from the given integer, interpreted as a binary string.voidsetValues(int[] values)Sets the state of this component from the given array of integers.voidsetValues(java.lang.String values)Sets the state of this component from the given string of '0' and '1' characters, where index 0 in this object's state corresponds to the rightmost character of the string.voidtick()Updates the internal state, if any, provided that the component is enabled.
-
-
-
Method Detail
-
setValues
public void setValues(java.lang.String values)
Sets the state of this component from the given string of '0' and '1' characters, where index 0 in this object's state corresponds to the rightmost character of the string. If the string contains a character other than '0' or '1' in some position, the corresponding bit in this object's state will not be modified.- Parameters:
values- string of 0's and 1's
-
setValues
public void setValues(int value)
Sets the state of this component from the given integer, interpreted as a binary string.- Parameters:
value-
-
setValues
public void setValues(int[] values)
Sets the state of this component from the given array of integers. If the array contains any number other than 0 or 1 in some position, the corresponding bit in this object's state will not be modified.- Parameters:
values- int array of 0's and
-
inputs
public Pin[] inputs()
Description copied from interface:IComponentReturns the array of Pins representing this component's inputs.- Specified by:
inputsin interfaceIComponent- Returns:
- array of input Pins
-
outputs
public Pin[] outputs()
Description copied from interface:IComponentReturns the array of Pins representing this component's outputs.- Specified by:
outputsin interfaceIComponent- Returns:
- array of output Pins
-
inputsValid
public boolean inputsValid()
Description copied from interface:IComponentReturns whether all inputs are valid.- Specified by:
inputsValidin interfaceIComponent- Returns:
- true if all inputs are valid, false otherwise
-
outputsValid
public boolean outputsValid()
Description copied from interface:IComponentReturns whether all outputs are valid.- Specified by:
outputsValidin interfaceIComponent- Returns:
- true if all outputs are valid, false otherwise
-
invalidateInputs
public void invalidateInputs()
Description copied from interface:IComponentChanges the state of all inputs to invalid.- Specified by:
invalidateInputsin interfaceIComponent
-
invalidateOutputs
public void invalidateOutputs()
Description copied from interface:IComponentChanges the state of all outputs to invalid.- Specified by:
invalidateOutputsin interfaceIComponent
-
propagate
public void propagate()
Description copied from interface:IComponentPropagates inputs to outputs. Does nothing if not all inputs are valid.- Specified by:
propagatein interfaceIComponent
-
tick
public void tick()
Description copied from interface:IStatefulComponentUpdates the internal state, if any, provided that the component is enabled.- Specified by:
tickin interfaceIStatefulComponent
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:IStatefulComponentEnables or disables updates to the internal state, if any, when processing the tick() operation.- Specified by:
setEnabledin interfaceIStatefulComponent- Parameters:
enabled- whether or not this component should be enabled
-
clear
public void clear()
Description copied from interface:IStatefulComponentClears the internal state, if any (sets to all zeros).- Specified by:
clearin interfaceIStatefulComponent
-
-