Package jmri

Interface Timebase

  • All Superinterfaces:
    java.lang.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.

    • Method Detail

      • setTime

        void setTime​(@Nonnull
                     java.util.Date d)
        Set the current time.
        Parameters:
        d - the new time
      • setTime

        void setTime​(@Nonnull
                     java.time.Instant i)
        Set the current time.
        Parameters:
        i - the new time
      • userSetTime

        void userSetTime​(@Nonnull
                         java.util.Date d)
        Set the current time and force a synchronization with the DCC system.
        Parameters:
        d - the new time
      • getTime

        @Nonnull
        java.util.Date 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.
      • 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
      • 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

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

        void setMasterName​(@Nonnull
                           java.lang.String name)
        Set the Master Clock Name.
        Parameters:
        name - master clock name.
      • getMasterName

        java.lang.String 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

        boolean 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
      • 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

        boolean 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,
                             java.util.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

        boolean 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

        @Nonnull
        java.util.Date 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

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

        void initializeClock()
        Initialise the clock. Should only be invoked at start up.
      • initializeHardwareClock

        void 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
      • dispose

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