Class NceClockControl
- java.lang.Object
-
- jmri.implementation.DefaultClockControl
-
- jmri.jmrix.nce.NceClockControl
-
- All Implemented Interfaces:
java.util.EventListener
,ClockControl
,AbstractMRListener
,NceListener
public class NceClockControl extends DefaultClockControl implements NceListener
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.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) javax.swing.Timer
alarmSyncUpdate
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_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
(package private) java.text.DecimalFormat
fiveDigits
(package private) java.text.DecimalFormat
fourDigits
(package private) Timebase
internalClock
static int
MAX_ERROR_ARRAY
(package private) java.beans.PropertyChangeListener
minuteChangeListener
static int
SYNCMODE_INTERNAL_MASTER
static int
SYNCMODE_NCE_MASTER
static int
SYNCMODE_OFF
static double
TARGET_SYNC_DELAY
(package private) java.text.DecimalFormat
threeDigits
(package private) java.text.DecimalFormat
twoDigits
static int
WAIT_CMD_EXECUTION
-
Constructor Summary
Constructors Constructor Description NceClockControl(NceTrafficController tc, java.lang.String prefix)
Create a ClockControl object for a NCE clock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCorrectHardwareClock()
Nce clock runs stable enoughboolean
canSet12Or24HourClock()
Nce clock supports 12/24 operationvoid
dispose()
Stop any sync, removes listeners.java.lang.String
getHardwareClockName()
name of Nce clockdouble
getRate()
Get last known ratio from Nce clock.java.util.Date
getTime()
Get 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 timevoid
message(NceMessage m)
void
newInternalMinute()
Handles minute notifications for NCE Clock Monitor/Synchronizervoid
reply(NceReply r)
boolean
requiresIntegerRate()
NCE only supports integer rates.void
setRate(double newRate)
Set Nce clock speed, must be 1 to 15.void
setTime(java.util.Date now)
Set the time, the date part is ignored.void
startHardwareClock(java.util.Date now)
Set Nce clock and start clock.void
stopHardwareClock()
Stop the Nce Clock.-
Methods inherited from class jmri.implementation.DefaultClockControl
getStatus, initializeHardwareClock
-
-
-
-
Field Detail
-
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
-
fiveDigits
java.text.DecimalFormat fiveDigits
-
fourDigits
java.text.DecimalFormat fourDigits
-
threeDigits
java.text.DecimalFormat threeDigits
-
twoDigits
java.text.DecimalFormat twoDigits
-
internalClock
Timebase internalClock
-
alarmSyncUpdate
javax.swing.Timer alarmSyncUpdate
-
minuteChangeListener
java.beans.PropertyChangeListener minuteChangeListener
-
-
Constructor Detail
-
NceClockControl
public NceClockControl(NceTrafficController tc, java.lang.String prefix)
Create a ClockControl object for a NCE clock.- Parameters:
tc
- traffic controller for connectionprefix
- system connection prefix
-
-
Method Detail
-
message
public void message(NceMessage m)
- Specified by:
message
in interfaceNceListener
-
reply
public void reply(NceReply r)
- Specified by:
reply
in interfaceNceListener
-
getHardwareClockName
public java.lang.String getHardwareClockName()
name of Nce clock- Specified by:
getHardwareClockName
in interfaceClockControl
- Overrides:
getHardwareClockName
in classDefaultClockControl
- Returns:
- the name
-
canCorrectHardwareClock
public boolean canCorrectHardwareClock()
Nce clock runs stable enough- Specified by:
canCorrectHardwareClock
in interfaceClockControl
- Overrides:
canCorrectHardwareClock
in classDefaultClockControl
- Returns:
- true if correctable; false otherwise
-
canSet12Or24HourClock
public boolean canSet12Or24HourClock()
Nce clock supports 12/24 operation- Specified by:
canSet12Or24HourClock
in interfaceClockControl
- Overrides:
canSet12Or24HourClock
in classDefaultClockControl
- Returns:
- true if settable; false otherwise
-
setRate
public void setRate(double newRate)
Set Nce clock speed, must be 1 to 15.- Specified by:
setRate
in interfaceClockControl
- Overrides:
setRate
in classDefaultClockControl
- Parameters:
newRate
- the new rate
-
requiresIntegerRate
public boolean requiresIntegerRate()
NCE only supports integer rates.- Specified by:
requiresIntegerRate
in interfaceClockControl
- Overrides:
requiresIntegerRate
in classDefaultClockControl
- Returns:
- true if integer rates only; false otherwise
-
getRate
public double getRate()
Get last known ratio from Nce clock.- Specified by:
getRate
in interfaceClockControl
- Overrides:
getRate
in classDefaultClockControl
- Returns:
- Fast Clock rate.
-
setTime
public void setTime(java.util.Date now)
Set the time, the date part is ignored.- Specified by:
setTime
in interfaceClockControl
- Overrides:
setTime
in classDefaultClockControl
- Parameters:
now
- the new time
-
getTime
public java.util.Date getTime()
Get the current Nce time, does not have a date component.- Specified by:
getTime
in interfaceClockControl
- Overrides:
getTime
in classDefaultClockControl
- Returns:
- current time.
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
Set Nce clock and start clock.- Specified by:
startHardwareClock
in interfaceClockControl
- Overrides:
startHardwareClock
in classDefaultClockControl
- Parameters:
now
- the starting time
-
stopHardwareClock
public void stopHardwareClock()
Stop the Nce Clock.- Specified by:
stopHardwareClock
in interfaceClockControl
- Overrides:
stopHardwareClock
in classDefaultClockControl
-
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()
Stop any sync, removes listeners.
-
newInternalMinute
public void newInternalMinute()
Handles minute notifications for NCE Clock Monitor/Synchronizer
-
-