jmri.jmrix.nce
Class NceClockControl

java.lang.Object
  extended by jmri.implementation.DefaultClockControl
      extended by jmri.jmrix.nce.NceClockControl
All Implemented Interfaces:
EventListener, ClockControl, AbstractMRListener, NceListener

public class NceClockControl
extends DefaultClockControl
implements NceListener

NceClockControl.java Implementation of the Hardware Fast Clock for NCE

This module is based on the LocoNet version as worked over by David Duchamp based on original work by Bob Jacobsen and Alex Shepherd. It implements the sync logic to keep the Nce clock in sync with the internal clock or keeps the internal in sync to the Nce clock. The following of the Nce clock is better than the other way around due to the fine tuning available on the internal clock while the Nce clock doesn't.


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:
Ken Cameron Copyright (C) 2007, Dave Duchamp Copyright (C) 2007, Bob Jacobsen, Alex Shepherd

Field Summary
static int CMD_CLOCK_SET_PARAM_SIZE
           
static int CMD_CLOCK_SET_REPLY_SIZE
           
static int CMD_CLOCK_SET_RUN_SIZE
           
static int CMD_CLOCK_SET_TIME_SIZE
           
static int CMD_MEM_SET_REPLY_SIZE
           
static int CS_CLOCK_1224
           
static int CS_CLOCK_AMPM
           
static int CS_CLOCK_HOURS
           
static int CS_CLOCK_MEM_ADDR
           
static int CS_CLOCK_MEM_SIZE
           
static int CS_CLOCK_MINUTES
           
static int CS_CLOCK_SCALE
           
static int CS_CLOCK_SECONDS
           
static int CS_CLOCK_STATUS
           
static int CS_CLOCK_TICK
           
static int MAX_ERROR_ARRAY
           
static int SYNCMODE_INTERNAL_MASTER
           
static int SYNCMODE_NCE_MASTER
           
static int SYNCMODE_OFF
           
static double TARGET_SYNC_DELAY
           
static int WAIT_CMD_EXECUTION
           
 
Constructor Summary
NceClockControl(NceTrafficController tc, String prefix)
          Create a ClockControl object for a NCE clock
 
Method Summary
 boolean canCorrectHardwareClock()
          Nce clock runs stable enough
 boolean canSet12Or24HourClock()
          Nce clock supports 12/24 operation
 void dispose()
          stops any sync, removes listeners
 String getHardwareClockName()
          name of Nce clock
 double getRate()
          last known ratio from Nce clock
 Date getTime()
          returns the current Nce time, does not have a date component
 void initiateRead()
          not sure when or if this gets called, but will issue a read to get latest time
 void message(NceMessage m)
           
 void newInternalMinute()
          Handles minute notifications for NCE Clock Monitor/Synchronizer
 void reply(NceReply r)
           
 boolean requiresIntegerRate()
          Nce only supports integer rates
 void setRate(double newRate)
          sets Nce clock speed, must be 1 to 15
 void setTime(Date now)
          set the time, the date part is ignored
 void startHardwareClock(Date now)
          set Nce clock and start clock
 void stopHardwareClock()
          stops the Nce Clock
 
Methods inherited from class jmri.implementation.DefaultClockControl
getStatus, initializeHardwareClock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CS_CLOCK_MEM_ADDR

public static final int CS_CLOCK_MEM_ADDR
See Also:
Constant Field Values

CS_CLOCK_MEM_SIZE

public static final int CS_CLOCK_MEM_SIZE
See Also:
Constant Field Values

CS_CLOCK_SCALE

public static final int CS_CLOCK_SCALE
See Also:
Constant Field Values

CS_CLOCK_TICK

public static final int CS_CLOCK_TICK
See Also:
Constant Field Values

CS_CLOCK_SECONDS

public static final int CS_CLOCK_SECONDS
See Also:
Constant Field Values

CS_CLOCK_MINUTES

public static final int CS_CLOCK_MINUTES
See Also:
Constant Field Values

CS_CLOCK_HOURS

public static final int CS_CLOCK_HOURS
See Also:
Constant Field Values

CS_CLOCK_AMPM

public static final int CS_CLOCK_AMPM
See Also:
Constant Field Values

CS_CLOCK_1224

public static final int CS_CLOCK_1224
See Also:
Constant Field Values

CS_CLOCK_STATUS

public static final int CS_CLOCK_STATUS
See Also:
Constant Field Values

CMD_CLOCK_SET_TIME_SIZE

public static final int CMD_CLOCK_SET_TIME_SIZE
See Also:
Constant Field Values

CMD_CLOCK_SET_PARAM_SIZE

public static final int CMD_CLOCK_SET_PARAM_SIZE
See Also:
Constant Field Values

CMD_CLOCK_SET_RUN_SIZE

public static final int CMD_CLOCK_SET_RUN_SIZE
See Also:
Constant Field Values

CMD_CLOCK_SET_REPLY_SIZE

public static final int CMD_CLOCK_SET_REPLY_SIZE
See Also:
Constant Field Values

CMD_MEM_SET_REPLY_SIZE

public static final int CMD_MEM_SET_REPLY_SIZE
See Also:
Constant Field Values

MAX_ERROR_ARRAY

public static final int MAX_ERROR_ARRAY
See Also:
Constant Field Values

TARGET_SYNC_DELAY

public static final double TARGET_SYNC_DELAY
See Also:
Constant Field Values

SYNCMODE_OFF

public static final int SYNCMODE_OFF
See Also:
Constant Field Values

SYNCMODE_NCE_MASTER

public static final int SYNCMODE_NCE_MASTER
See Also:
Constant Field Values

SYNCMODE_INTERNAL_MASTER

public static final int SYNCMODE_INTERNAL_MASTER
See Also:
Constant Field Values

WAIT_CMD_EXECUTION

public static final int WAIT_CMD_EXECUTION
See Also:
Constant Field Values
Constructor Detail

NceClockControl

public NceClockControl(NceTrafficController tc,
                       String prefix)
Create a ClockControl object for a NCE clock

Method Detail

message

public void message(NceMessage m)
Specified by:
message in interface NceListener

reply

public void reply(NceReply r)
Specified by:
reply in interface NceListener

getHardwareClockName

public String getHardwareClockName()
name of Nce clock

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

canCorrectHardwareClock

public boolean canCorrectHardwareClock()
Nce clock runs stable enough

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

canSet12Or24HourClock

public boolean canSet12Or24HourClock()
Nce clock supports 12/24 operation

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

setRate

public void setRate(double newRate)
sets Nce clock speed, must be 1 to 15

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

requiresIntegerRate

public boolean requiresIntegerRate()
Nce only supports integer rates

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

getRate

public double getRate()
last known ratio from Nce clock

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

setTime

public void setTime(Date now)
set the time, the date part is ignored

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

getTime

public Date getTime()
returns the current Nce time, does not have a date component

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

startHardwareClock

public void startHardwareClock(Date now)
set Nce clock and start clock

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

stopHardwareClock

public void stopHardwareClock()
stops the Nce Clock

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

initiateRead

public void initiateRead()
not sure when or if this gets called, but will issue a read to get latest time


dispose

public void dispose()
stops any sync, removes listeners


newInternalMinute

public void newInternalMinute()
Handles minute notifications for NCE Clock Monitor/Synchronizer



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