Package jmri

Interface Timebase

All Superinterfaces:
Comparable<NamedBean>, NamedBean, PropertyChangeProvider
All Known Implementing Classes:
SimpleTimebase

public interface Timebase extends NamedBean
Provide access to clock capabilities in hardware or software.

The rate property determines how much faster than real time this runs. For example, a value of 2.0 means that the value returned by getTime will advance an hour for every half-hour of wall-clock time elapsed.

The rate and run properties are bound, so you can listen for changes to them. The time property is bound, but listeners only receive change notifications if the change is a minute or more, because it changes continuously; query to time property when needed to get the current value.

  • Field Details

  • Method Details

    • setTime

      Set the current time.
      Parameters:
      d - the new time
    • setTime

      Set the current time.
      Parameters:
      i - the new time
    • userSetTime

      Set the current time and force a synchronization with the DCC system.
      Parameters:
      d - the new time
    • getTime

      Get the current time.
      Returns:
      current time.
    • setRun

      void setRun(boolean y)
      Set if Timebase is running.
      Parameters:
      y - true if running else false.
    • getRun

      boolean getRun()
      Get if Timebase is running.
      Returns:
      true if running, else false.
    • setRate

      void setRate(double factor) throws TimebaseRateException
      Set fast clock rate.
      Parameters:
      factor - the fast clock rate
      Throws:
      TimebaseRateException - if the implementation can not use the requested rate
    • userSetRate

      void userSetRate(double factor) throws TimebaseRateException
      Set fast clock rate and force a synchronization with the DCC hardware.
      Parameters:
      factor - the fast clock rate
      Throws:
      TimebaseRateException - if the implementation can not use the requested rate
    • getRate

      double getRate()
      Caution: This method may return a fiddled clock rate if certain hardware clocks are the Time Source. Use userGetRate() if you want the real clock rate instead.
      Returns:
      the rate
    • userGetRate

      double userGetRate()
      Get the true fast clock rate even if the master timebase rate has been modified by a hardware clock. External changes in fast clock rate occur because of the peculiar way some hardware clocks attempt to synchronize with the JMRI fast clock.
      Returns:
      the rate, e.g. 1.0 runs at the same rate as real clocks, 2.0 at twice the speed.
    • setInternalMaster

      void setInternalMaster(boolean master, boolean update)
      Set internalMaster and update fields.
      Parameters:
      master - true if fast clock time is derived from internal computer clock, false if derived from hardware clock.
      update - true to send update, else false.
    • getInternalMaster

      Get internalMaster field.
      Returns:
      true if fast clock time is derived from internal computer clock, false if derived from hardware clock
    • setMasterName

      Set the Master Clock Name.
      Parameters:
      name - master clock name.
    • getMasterName

      Get the Master Clock Name.
      Returns:
      master clock name.
    • setSynchronize

      void setSynchronize(boolean synchronize, boolean update)
      Set if clock should synchronise.
      Parameters:
      synchronize - set true to synchronise hardware clocks with Time base.
      update - set true to update clock when function called.
    • getSynchronize

      boolean getSynchronize()
      Get if clock should synchronise with Time base.
      Returns:
      true if should synchronise hardware clocks.
    • setCorrectHardware

      void setCorrectHardware(boolean correct, boolean update)
      Set if should correct or update hardware.
      Parameters:
      correct - set true to correct hardware clocks.
      update - set true to update clock when function called.
    • getCorrectHardware

      Get if should correct Hardware clocks.
      Returns:
      true to correct, else false.
    • set12HourDisplay

      void set12HourDisplay(boolean display, boolean update)
      Set 12 or 24 hour display option.
      Parameters:
      display - true for a 12-hour display; false for a 24-hour display
      update - true to update clock when function called.
    • use12HourDisplay

      boolean use12HourDisplay()
      Get 12 or 24 hour display option.
      Returns:
      true for a 12-hour display; false for a 24-hour display
    • setClockInitialRunState

      Set the Clock Initial Run State ENUM.
      Parameters:
      initialState - Initial state.
    • getClockInitialRunState

      Get the Clock Initial Run State ENUM.
      Returns:
      Initial state.
    • setShowStopButton

      void setShowStopButton(boolean displayed)
      Set if to show a Stop / Resume button next to the clock.
      Parameters:
      displayed - true if to display, else false.
    • getShowStopButton

      Get if to show a Stop / Resume button next to the clock.
      Returns:
      true if to display, else false.
    • setStartSetTime

      void setStartSetTime(boolean set, Date time)
      Set time at start up option, and start up time.
      Parameters:
      set - true for set time at startup, else false.
      time - startup time.
    • getStartSetTime

      boolean getStartSetTime()
      Get if to use a set start time.
      Returns:
      true if using set start time.
    • setStartRate

      void setStartRate(double factor)
      Set the start clock speed rate.
      Parameters:
      factor - start clock speed factor.
    • getStartRate

      double getStartRate()
      Get the startup clock speed rate.
      Returns:
      startup clock speed rate factor.
    • setSetRateAtStart

      void setSetRateAtStart(boolean set)
      Set Set Rate at Start option.
      Parameters:
      set - If true, the rate at startup will be set to the value of getStartRate().
    • getSetRateAtStart

      Get if to Set Rate at Start option checked.
      Returns:
      If true, the rate at startup should be set to the value of getStartRate()
    • getStartTime

      Get the Clock Start Time.
      Returns:
      Clock Start Time.
    • setStartClockOption

      void setStartClockOption(int option)
      Set the Start Clock type Option.
      Parameters:
      option - Clock type, e.g. NIXIE_CLOCK or PRAGOTRON_CLOCK
    • getStartClockOption

      Get the Start Clock Type.
      Returns:
      Clock type, e.g. NIXIE_CLOCK or PRAGOTRON_CLOCK
    • initializeClock

      Initialise the clock. Should only be invoked at start up.
    • initializeHardwareClock

      Initialize hardware clock at start up after all options are set up.

      Note: This method is always called at start up. It should be ignored if there is no communication with a hardware clock

    • getIsInitialized

      boolean getIsInitialized()
      Returns:
      true if call to initialize Hardware Clock has occurred
    • addMinuteChangeListener

      Request a callback when the minutes place of the time changes. This is the same as calling PropertyChangeProvider.addPropertyChangeListener(String, PropertyChangeListener) with the propertyName minutes.
      Parameters:
      l - the listener to receive the callback
    • removeMinuteChangeListener

      Remove a request for callback when the minutes place of the time changes. This is the same as calling PropertyChangeProvider.removePropertyChangeListener(String, PropertyChangeListener) with the propertyName minutes.
      Parameters:
      l - the listener to receive the callback
    • getMinuteChangeListeners

      Get the list of minute change listeners. This is the same as calling PropertyChangeProvider.getPropertyChangeListeners(String) with the propertyName minutes.
      Returns:
      the list of listeners
    • dispose

      void dispose()
      Remove references to and from this object, so that it can eventually be garbage-collected.
      Specified by:
      dispose in interface NamedBean