Package jmri.jmrix.mrc
Class MrcClockControl
- java.lang.Object
-
- jmri.implementation.DefaultClockControl
-
- jmri.jmrix.mrc.MrcClockControl
-
- All Implemented Interfaces:
ClockControl
,MrcTrafficListener
public class MrcClockControl extends DefaultClockControl implements MrcTrafficListener
Implementation of the Hardware Fast Clock for MrcThis module is based on the NCE version.
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_MINUTES
static int
CS_CLOCK_SCALE
static int
CS_CLOCK_STATUS
(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_MRC_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 MrcClockControl(MrcTrafficController tc, java.lang.String prefix)
Create a ClockControl object for a Mrc clock
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCorrectHardwareClock()
Mrc clock runs stable enoughboolean
canSet12Or24HourClock()
Mrc clock supports 12/24 operationvoid
dispose()
stops any sync, removes listenersjava.lang.String
getHardwareClockName()
name of Mrc clockdouble
getRate()
last known ratio from Mrc clockjava.util.Date
getTime()
returns the current Mrc time, does not have a date componentvoid
initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Default implementation is to ignore this request.void
message(MrcMessage r)
void
newInternalMinute()
Handles minute notifications for MRC Clock Monitor/Synchronizervoid
notifyFailedXmit(java.util.Date timestamp, MrcMessage m)
void
notifyRcv(java.util.Date timestamp, MrcMessage m)
void
notifyXmit(java.util.Date timestamp, MrcMessage m)
boolean
requiresIntegerRate()
Mrc only supports integer ratesvoid
setRate(double newRate)
sets Mrc clock speed, must be 1 to 60void
setTime(java.util.Date now)
set the time, the date part is ignoredvoid
startHardwareClock(java.util.Date now)
set Mrc clock and start clock-
Methods inherited from class jmri.implementation.DefaultClockControl
getStatus, stopHardwareClock
-
-
-
-
Field Detail
-
CS_CLOCK_SCALE
public static final int CS_CLOCK_SCALE
- 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_MRC_MASTER
public static final int SYNCMODE_MRC_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
-
MrcClockControl
public MrcClockControl(MrcTrafficController tc, java.lang.String prefix)
Create a ClockControl object for a Mrc clock- Parameters:
tc
- traffic control for connectionprefix
- system prefix for connection
-
-
Method Detail
-
message
public void message(MrcMessage r)
-
notifyXmit
public void notifyXmit(java.util.Date timestamp, MrcMessage m)
- Specified by:
notifyXmit
in interfaceMrcTrafficListener
-
notifyFailedXmit
public void notifyFailedXmit(java.util.Date timestamp, MrcMessage m)
- Specified by:
notifyFailedXmit
in interfaceMrcTrafficListener
-
notifyRcv
public void notifyRcv(java.util.Date timestamp, MrcMessage m)
- Specified by:
notifyRcv
in interfaceMrcTrafficListener
-
getHardwareClockName
public java.lang.String getHardwareClockName()
name of Mrc clock- Specified by:
getHardwareClockName
in interfaceClockControl
- Overrides:
getHardwareClockName
in classDefaultClockControl
- Returns:
- the name
-
canCorrectHardwareClock
public boolean canCorrectHardwareClock()
Mrc clock runs stable enough- Specified by:
canCorrectHardwareClock
in interfaceClockControl
- Overrides:
canCorrectHardwareClock
in classDefaultClockControl
- Returns:
- true if correctable; false otherwise
-
canSet12Or24HourClock
public boolean canSet12Or24HourClock()
Mrc 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)
sets Mrc clock speed, must be 1 to 60- Specified by:
setRate
in interfaceClockControl
- Overrides:
setRate
in classDefaultClockControl
- Parameters:
newRate
- the new rate
-
requiresIntegerRate
public boolean requiresIntegerRate()
Mrc 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()
last known ratio from Mrc 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()
returns the current Mrc 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 Mrc clock and start clock- Specified by:
startHardwareClock
in interfaceClockControl
- Overrides:
startHardwareClock
in classDefaultClockControl
- Parameters:
now
- the starting time
-
initializeHardwareClock
public void initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Description copied from class:DefaultClockControl
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
- Overrides:
initializeHardwareClock
in classDefaultClockControl
- Parameters:
rate
- the ratenow
- the timegetTime
- true if hardware clock should be used; false otherwise
-
dispose
public void dispose()
stops any sync, removes listeners
-
newInternalMinute
public void newInternalMinute()
Handles minute notifications for MRC Clock Monitor/Synchronizer
-
-