Class DutyCycleSim


  • public class DutyCycleSim
    extends Object
    Class to control a simulated duty cycle digital input.
    • Constructor Detail

      • DutyCycleSim

        public DutyCycleSim​(DutyCycle dutyCycle)
        Constructs from a DutyCycle object.
        Parameters:
        dutyCycle - DutyCycle to simulate
    • Method Detail

      • createForChannel

        public static DutyCycleSim createForChannel​(int channel)
        Creates a DutyCycleSim for a digital input channel.
        Parameters:
        channel - digital input channel
        Returns:
        Simulated object
        Throws:
        NoSuchElementException - if no DutyCycle is configured for that channel
      • createForIndex

        public static DutyCycleSim createForIndex​(int index)
        Creates a DutyCycleSim for a simulated index. The index is incremented for each simulated DutyCycle.
        Parameters:
        index - simulator index
        Returns:
        Simulated object
      • registerInitializedCallback

        public CallbackStore registerInitializedCallback​(NotifyCallback callback,
                                                         boolean initialNotify)
        Register a callback to be run when this duty cycle input is initialized.
        Parameters:
        callback - the callback
        initialNotify - whether to run the callback with the initial state
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • getInitialized

        public boolean getInitialized()
        Check whether this duty cycle input has been initialized.
        Returns:
        true if initialized
      • setInitialized

        public void setInitialized​(boolean initialized)
        Define whether this duty cycle input has been initialized.
        Parameters:
        initialized - whether this object is initialized
      • registerFrequencyCallback

        public CallbackStore registerFrequencyCallback​(NotifyCallback callback,
                                                       boolean initialNotify)
        Register a callback to be run whenever the frequency changes.
        Parameters:
        callback - the callback
        initialNotify - whether to call the callback with the initial state
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • getFrequency

        public int getFrequency()
        Measure the frequency.
        Returns:
        the duty cycle frequency
      • setFrequency

        public void setFrequency​(int frequency)
        Change the duty cycle frequency.
        Parameters:
        frequency - the new frequency
      • registerOutputCallback

        public CallbackStore registerOutputCallback​(NotifyCallback callback,
                                                    boolean initialNotify)
        Register a callback to be run whenever the output changes.
        Parameters:
        callback - the callback
        initialNotify - whether to call the callback with the initial state
        Returns:
        the CallbackStore object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
      • getOutput

        public double getOutput()
        Measure the output from this duty cycle port.
        Returns:
        the output value
      • setOutput

        public void setOutput​(double output)
        Change the duty cycle output.
        Parameters:
        output - the new output value
      • resetData

        public void resetData()
        Reset all simulation data for the duty cycle output.