Package api

Class 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
      void clear()
      Clears the internal state, if any (sets to all zeros).
      Pin[] inputs()
      Returns the array of Pins representing this component's inputs.
      boolean inputsValid()
      Returns whether all inputs are valid.
      void invalidateInputs()
      Changes the state of all inputs to invalid.
      void invalidateOutputs()
      Changes the state of all outputs to invalid.
      Pin[] outputs()
      Returns the array of Pins representing this component's outputs.
      boolean outputsValid()
      Returns whether all outputs are valid.
      void propagate()
      Propagates inputs to outputs.
      void setEnabled​(boolean enabled)
      Enables or disables updates to the internal state, if any, when processing the tick() operation.
      void setValues​(int value)
      Sets the state of this component from the given integer, interpreted as a binary string.
      void setValues​(int[] values)
      Sets the state of this component from the given array of integers.
      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.
      void tick()
      Updates the internal state, if any, provided that the component is enabled.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ExternalValue

        public ExternalValue​(int size)
        Constructs an ExternalValue of the given number of bits.
        Parameters:
        size - number of bits for the value represented by this component
    • 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: IComponent
        Returns the array of Pins representing this component's inputs.
        Specified by:
        inputs in interface IComponent
        Returns:
        array of input Pins
      • outputs

        public Pin[] outputs()
        Description copied from interface: IComponent
        Returns the array of Pins representing this component's outputs.
        Specified by:
        outputs in interface IComponent
        Returns:
        array of output Pins
      • inputsValid

        public boolean inputsValid()
        Description copied from interface: IComponent
        Returns whether all inputs are valid.
        Specified by:
        inputsValid in interface IComponent
        Returns:
        true if all inputs are valid, false otherwise
      • outputsValid

        public boolean outputsValid()
        Description copied from interface: IComponent
        Returns whether all outputs are valid.
        Specified by:
        outputsValid in interface IComponent
        Returns:
        true if all outputs are valid, false otherwise
      • invalidateInputs

        public void invalidateInputs()
        Description copied from interface: IComponent
        Changes the state of all inputs to invalid.
        Specified by:
        invalidateInputs in interface IComponent
      • invalidateOutputs

        public void invalidateOutputs()
        Description copied from interface: IComponent
        Changes the state of all outputs to invalid.
        Specified by:
        invalidateOutputs in interface IComponent
      • propagate

        public void propagate()
        Description copied from interface: IComponent
        Propagates inputs to outputs. Does nothing if not all inputs are valid.
        Specified by:
        propagate in interface IComponent
      • tick

        public void tick()
        Description copied from interface: IStatefulComponent
        Updates the internal state, if any, provided that the component is enabled.
        Specified by:
        tick in interface IStatefulComponent
      • setEnabled

        public void setEnabled​(boolean enabled)
        Description copied from interface: IStatefulComponent
        Enables or disables updates to the internal state, if any, when processing the tick() operation.
        Specified by:
        setEnabled in interface IStatefulComponent
        Parameters:
        enabled - whether or not this component should be enabled