jmri.implementation
Class DefaultClockControl

java.lang.Object
  extended by jmri.implementation.DefaultClockControl
All Implemented Interfaces:
ClockControl
Direct Known Subclasses:
LnClockControl, NceClockControl

public class DefaultClockControl
extends 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.

Author:
Dave Duchamp Copyright (C) 2007

Constructor Summary
DefaultClockControl()
           
 
Method Summary
 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.
 String getHardwareClockName()
          Get name of hardware clock Note: If there is no hardware clock, this method returns null.
 double getRate()
           
 int getStatus()
          Get Status of the Fast Clock
 Date getTime()
           
 void initializeHardwareClock(double rate, 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 Note: Default implementation returns false.
 void setRate(double newRate)
          Get and set the rate of the fast clock Note: The rate is an integer that multiplies the wall clock For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock.
 void setTime(Date now)
          Set and get the fast clock time For the default implementation,set time is ignored and getTime returns the time of the internal clock;
 void startHardwareClock(Date now)
          Start and stop hardware fast clock Many hardware fast clocks continue to run indefinitely.
 void stopHardwareClock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultClockControl

public DefaultClockControl()
Method Detail

getStatus

public int getStatus()
Get Status of the Fast Clock

Specified by:
getStatus in interface ClockControl

getHardwareClockName

public String getHardwareClockName()
Get name of hardware clock Note: If there is no hardware clock, this method returns null.

Specified by:
getHardwareClockName in interface ClockControl

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.

Specified by:
canCorrectHardwareClock in interface ClockControl

canSet12Or24HourClock

public boolean canSet12Or24HourClock()
Returns true if hardware clock can be set to 12 or 24 hour display from JMRI software. Note: Default implementation is to return false.

Specified by:
canSet12Or24HourClock in interface ClockControl

requiresIntegerRate

public boolean requiresIntegerRate()
Returns true if hardware clock requires an integer rate Note: Default implementation returns false. If an integer rate is required by the hardware, this method should be overridden.

Specified by:
requiresIntegerRate in interface ClockControl

setRate

public void setRate(double newRate)
Get and set the rate of the fast clock Note: The rate is an integer that multiplies the wall clock For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock. For the default implementation, setRate is ignored, and getRate returns the rate of the internal clock;

Specified by:
setRate in interface ClockControl

getRate

public double getRate()
Specified by:
getRate in interface ClockControl

setTime

public void setTime(Date now)
Set and get the fast clock time For the default implementation,set time is ignored and getTime returns the time of the internal clock;

Specified by:
setTime in interface ClockControl

getTime

public Date getTime()
Specified by:
getTime in interface ClockControl

startHardwareClock

public void startHardwareClock(Date now)
Start and stop hardware fast clock Many 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 interface ClockControl

stopHardwareClock

public void stopHardwareClock()
Specified by:
stopHardwareClock in interface ClockControl

initializeHardwareClock

public void initializeHardwareClock(double rate,
                                    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. Default implementation is to ignore this request.

Specified by:
initializeHardwareClock in interface ClockControl


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads