Package jmri

Interface ClockControl

  • All Known Implementing Classes:
    CbusClockControl, DCCppClockControl, DefaultClockControl, LnClockControl, MrcClockControl, NceClockControl, OlcbClockControl, SRCPClockControl

    public interface ClockControl
    ClockControl defines an interface for control of hardware Fast Clocks

    Each hardware system that has a hardware Fast Clock implementation must supply a module that implements this interface. Each ClockControl module must register itself with the Instance Manager at start up.

    Parameters for fast clocks are set up generically in the Fast Clock Setup, accessed via the JMRI Tools menu. These parameters are saved in the configuration file generically, so no special configxml module is needed for storing parameters.

    Hardware ClockControl modules should extend DefaultClockControl, which supplies default implementations of methods required by this interface that specific hardware implementations may not need.

    All Clock Control modules communicate with the internal clock and the master JMRI timebase, using methods of the Timebase interface.


    This file is part of JMRI.

    JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

    JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean canCorrectHardwareClock()
      Returns true if hardware clock accuracy can be corrected using the computer clock.
      boolean canSet12Or24HourClock()
      Returns 'true' if hardware clock can be set to 12 or 24 hour display from JMRI software.
      java.lang.String getHardwareClockName()
      Get name of hardware clock Note: If there is no hardware clock, DefaultClockControl returns null, so all hardware clocks must override this method.
      double getRate()
      Get the rate of the Fast Clock.
      int getStatus()
      Get status of the fast clock.
      java.util.Date getTime()
      Get the fast clock time.
      void initializeHardwareClock​(double rate, java.util.Date now, boolean getTime)
      Initialize the hardware fast clock Note: When the hardware clock control receives this, it should initialize those clock settings that are available on the hardware clock.
      boolean requiresIntegerRate()
      Returns true if hardware clock requires an integer rate.
      void setRate​(double newRate)
      Set the rate of the Fast Clock.
      void setTime​(java.util.Date now)
      Set the fast clock time.
      void startHardwareClock​(java.util.Date now)
      Start hardware fast clock Some hardware fast clocks continue to run indefinitely.
      void stopHardwareClock()
      Stop hardware fast clock.
    • Method Detail

      • getStatus

        int getStatus()
        Get status of the fast clock. Potentially unused?
        Returns:
        the status
      • getHardwareClockName

        java.lang.String getHardwareClockName()
        Get name of hardware clock Note: If there is no hardware clock, DefaultClockControl returns null, so all hardware clocks must override this method.
        Returns:
        the name
      • canCorrectHardwareClock

        boolean canCorrectHardwareClock()
        Returns true if hardware clock accuracy can be corrected using the computer clock.
        Returns:
        true if correctable; false otherwise
      • canSet12Or24HourClock

        boolean canSet12Or24HourClock()
        Returns 'true' if hardware clock can be set to 12 or 24 hour display from JMRI software.
        Returns:
        true if settable; false otherwise
      • requiresIntegerRate

        boolean requiresIntegerRate()
        Returns true if hardware clock requires an integer rate.
        Returns:
        true if integer rates only; false otherwise
      • setRate

        void setRate​(double newRate)
        Set the rate of the Fast Clock.

        The rate is a number that multiplies the wall clock time For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock.

        Parameters:
        newRate - the new rate
      • getRate

        double getRate()
        Get the rate of the Fast Clock.

        The rate is a number that multiplies the wall clock. For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock.

        Returns:
        Fast Clock rate.
      • setTime

        void setTime​(java.util.Date now)
        Set the fast clock time.
        Parameters:
        now - the new time
      • getTime

        java.util.Date getTime()
        Get the fast clock time.
        Returns:
        current time.
      • startHardwareClock

        void startHardwareClock​(java.util.Date now)
        Start hardware fast clock Some hardware fast clocks continue to run indefinitely. This is provided for the case where the hardware clock can be stopped and started.
        Parameters:
        now - the starting time
      • stopHardwareClock

        void stopHardwareClock()
        Stop hardware fast clock. This is provided for the case where the hardware clock can be stopped and started.
      • initializeHardwareClock

        void initializeHardwareClock​(double rate,
                                     java.util.Date now,
                                     boolean getTime)
        Initialize the hardware fast clock Note: When the hardware clock control receives this, it should initialize those clock settings that are available on the hardware clock. This method is used when the fast clock is started, and when time source, synchronize, or correct options are changed. If rate is 0.0, the hardware clock should be initialized "stopped", and the current rate saved for when the clock is restarted. If getTime is "true" the time from the hardware clock should be used in place of the supplied time if possible.
        Parameters:
        rate - the rate
        now - the time
        getTime - true if hardware clock should be used; false otherwise