Class DefaultClockControl
- java.lang.Object
-
- jmri.implementation.DefaultClockControl
-
- All Implemented Interfaces:
ClockControl
- Direct Known Subclasses:
CbusClockControl
,DCCppClockControl
,LnClockControl
,MrcClockControl
,NceClockControl
,OlcbClockControl
,SRCPClockControl
public class DefaultClockControl extends java.lang.Object implements ClockControl
Class providing default logic of the ClockControl interface. Hardware systems that have fast clocks should "extend DefaultClockControl" and override the appropriate methods. This class provides default implementations of ClockControl methods that are not needed in the hardware implementation if one exists, or for those systems with no hardware fast clock.
-
-
Constructor Summary
Constructors Constructor Description DefaultClockControl()
-
Method Summary
All Methods Instance Methods Concrete 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.double
getRate()
Default implementation returns the rate of the internal clock.int
getStatus()
Get Status of the Fast Clock.java.util.Date
getTime()
Default implementation returns InstanceM default jmri.Timebase getTime().void
initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Default implementation is to ignore this request.boolean
requiresIntegerRate()
Default implementation returns false.void
setRate(double newRate)
For the default implementation, setRate is ignored.void
setTime(java.util.Date now)
For the default implementation, set time is ignored.void
startHardwareClock(java.util.Date now)
Default implementation is to call SetTime to now.void
stopHardwareClock()
Default implementation is to ignore.
-
-
-
Constructor Detail
-
DefaultClockControl
public DefaultClockControl()
-
-
Method Detail
-
getStatus
public int getStatus()
Get Status of the Fast Clock. Potentially unused? Get status of the fast clock. Potentially unused?- Specified by:
getStatus
in interfaceClockControl
- Returns:
- the status
-
getHardwareClockName
@CheckForNull public java.lang.String getHardwareClockName()
Get name of hardware clock.If there is no hardware clock, this method returns null. Get name of hardware clock Note: If there is no hardware clock, DefaultClockControl returns null, so all hardware clocks must override this method.
- Specified by:
getHardwareClockName
in interfaceClockControl
- Returns:
- the name
-
canCorrectHardwareClock
public boolean canCorrectHardwareClock()
Returns true if hardware clock accuracy can be corrected using the computer clock.Hardware implementations should override this and return true if they can correct their hardware clock. Returns true if hardware clock accuracy can be corrected using the computer clock.
- Specified by:
canCorrectHardwareClock
in interfaceClockControl
- Returns:
- true if correctable; false otherwise
-
canSet12Or24HourClock
public boolean canSet12Or24HourClock()
Returns true if hardware clock can be set to 12 or 24 hour display from JMRI software.Default implementation is to return false. Returns 'true' if hardware clock can be set to 12 or 24 hour display from JMRI software.
- Specified by:
canSet12Or24HourClock
in interfaceClockControl
- Returns:
- true if settable; false otherwise
-
requiresIntegerRate
public boolean requiresIntegerRate()
Default implementation returns false.If an integer rate is required by the hardware, this method should be overridden. Returns true if hardware clock requires an integer rate.
- Specified by:
requiresIntegerRate
in interfaceClockControl
- Returns:
- true if integer rates only; false otherwise
-
setRate
public void setRate(double newRate)
For the default implementation, setRate is ignored. 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.
- Specified by:
setRate
in interfaceClockControl
- Parameters:
newRate
- the new rate
-
getRate
public double getRate()
Default implementation returns the rate of the internal clock. 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.
- Specified by:
getRate
in interfaceClockControl
- Returns:
- Fast Clock rate.
-
setTime
public void setTime(java.util.Date now)
For the default implementation, set time is ignored. Set the fast clock time.- Specified by:
setTime
in interfaceClockControl
- Parameters:
now
- the new time
-
getTime
public java.util.Date getTime()
Default implementation returns InstanceM default jmri.Timebase getTime(). ie. the time of the internal clock. Get the fast clock time.- Specified by:
getTime
in interfaceClockControl
- Returns:
- current time.
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
Default implementation is to call SetTime to 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.- Specified by:
startHardwareClock
in interfaceClockControl
- Parameters:
now
- the starting time
-
stopHardwareClock
public void stopHardwareClock()
Default implementation is to ignore. Stop hardware fast clock. This is provided for the case where the hardware clock can be stopped and started.- Specified by:
stopHardwareClock
in interfaceClockControl
-
initializeHardwareClock
public void initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Default implementation is to ignore this request. 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.- Specified by:
initializeHardwareClock
in interfaceClockControl
- Parameters:
rate
- the ratenow
- the timegetTime
- true if hardware clock should be used; false otherwise
-
-