jmri.jmrix.loconet
Class LnClockControl

java.lang.Object
  extended by jmri.implementation.DefaultClockControl
      extended by jmri.jmrix.loconet.LnClockControl
All Implemented Interfaces:
EventListener, ClockControl, SlotListener

public class LnClockControl
extends DefaultClockControl
implements SlotListener

LnClockControl.java Implementation of the Hardware Fast Clock for Loconet

This module is based on a GUI module developed by Bob Jacobsen and Alex Shepherd to correct the Loconet fast clock rate and synchronize it with the internal JMRI fast clock Timebase. The methods that actually send, correct, or receive information from the Loconet hardware are repackaged versions of their code.

The Loconet Fast Clock is controlled by the user via the Fast Clock Setup GUI that is accessed from the JMRI Tools menu.

For this implementation, "synchronize" implies "correct", since the two clocks run at a different rate.

Some of the message formats used in this class are Copyright Digitrax, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Digitrax Inc for separate permission.


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.

Author:
Dave Duchamp Copyright (C) 2007, Bob Jacobsen, Alex Shepherd

Constructor Summary
LnClockControl(SlotManager sm, LnTrafficController tc)
          Create a ClockControl object for a Loconet clock
 
Method Summary
 boolean canCorrectHardwareClock()
          Returns true if hardware clock accuracy can be corrected using the computer clock.
 void dispose()
           
 String getHardwareClockName()
          Accessor routines
 double getRate()
           
 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.
 void initiateRead()
          Requests read of the Loconet fast clock
 void newMinute()
          Corrects the Loconet Fast Clock
 void notifyChangedSlot(LocoNetSlot s)
          Handle changed slot contents, due to clock changes.
 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 jmri.implementation.DefaultClockControl
canSet12Or24HourClock, getStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LnClockControl

public LnClockControl(SlotManager sm,
                      LnTrafficController tc)
Create a ClockControl object for a Loconet clock

Method Detail

getHardwareClockName

public String getHardwareClockName()
Accessor routines

Specified by:
getHardwareClockName in interface ClockControl
Overrides:
getHardwareClockName in class DefaultClockControl

canCorrectHardwareClock

public boolean canCorrectHardwareClock()
Description copied from class: DefaultClockControl
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
Overrides:
canCorrectHardwareClock in class DefaultClockControl

setRate

public void setRate(double newRate)
Description copied from class: DefaultClockControl
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
Overrides:
setRate in class DefaultClockControl

requiresIntegerRate

public boolean requiresIntegerRate()
Description copied from class: DefaultClockControl
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
Overrides:
requiresIntegerRate in class DefaultClockControl

getRate

public double getRate()
Specified by:
getRate in interface ClockControl
Overrides:
getRate in class DefaultClockControl

setTime

public void setTime(Date now)
Description copied from class: DefaultClockControl
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
Overrides:
setTime in class DefaultClockControl

getTime

public Date getTime()
Specified by:
getTime in interface ClockControl
Overrides:
getTime in class DefaultClockControl

startHardwareClock

public void startHardwareClock(Date now)
Description copied from class: DefaultClockControl
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
Overrides:
startHardwareClock in class DefaultClockControl

stopHardwareClock

public void stopHardwareClock()
Specified by:
stopHardwareClock in interface ClockControl
Overrides:
stopHardwareClock in class DefaultClockControl

initializeHardwareClock

public void initializeHardwareClock(double rate,
                                    Date now,
                                    boolean getTime)
Description copied from class: DefaultClockControl
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
Overrides:
initializeHardwareClock in class DefaultClockControl

initiateRead

public void initiateRead()
Requests read of the Loconet fast clock


newMinute

public void newMinute()
Corrects the Loconet Fast Clock


notifyChangedSlot

public void notifyChangedSlot(LocoNetSlot s)
Handle changed slot contents, due to clock changes. Can get here three ways: 1) clock slot as a result of action by a throttle and 2) clock slot responding to a read from this module 3) a slot not involving the clock changing

Specified by:
notifyChangedSlot in interface SlotListener
Parameters:
s -

dispose

public void dispose()


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