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.TimeralarmSyncUpdatestatic intCMD_CLOCK_SET_PARAM_SIZEstatic intCMD_CLOCK_SET_REPLY_SIZEstatic intCMD_CLOCK_SET_RUN_SIZEstatic intCMD_CLOCK_SET_TIME_SIZEstatic intCMD_MEM_SET_REPLY_SIZEstatic intCS_CLOCK_1224static intCS_CLOCK_AMPMstatic intCS_CLOCK_HOURSstatic intCS_CLOCK_MINUTESstatic intCS_CLOCK_SCALEstatic intCS_CLOCK_STATUS(package private) java.text.DecimalFormatfiveDigits(package private) java.text.DecimalFormatfourDigits(package private) TimebaseinternalClockstatic intMAX_ERROR_ARRAY(package private) java.beans.PropertyChangeListenerminuteChangeListenerstatic intSYNCMODE_INTERNAL_MASTERstatic intSYNCMODE_MRC_MASTERstatic intSYNCMODE_OFFstatic doubleTARGET_SYNC_DELAY(package private) java.text.DecimalFormatthreeDigits(package private) java.text.DecimalFormattwoDigitsstatic intWAIT_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 booleancanCorrectHardwareClock()Mrc clock runs stable enoughbooleancanSet12Or24HourClock()Mrc clock supports 12/24 operationvoiddispose()stops any sync, removes listenersjava.lang.StringgetHardwareClockName()name of Mrc clockdoublegetRate()last known ratio from Mrc clockjava.util.DategetTime()returns the current Mrc time, does not have a date componentvoidinitializeHardwareClock(double rate, java.util.Date now, boolean getTime)Default implementation is to ignore this request.voidmessage(MrcMessage r)voidnewInternalMinute()Handles minute notifications for MRC Clock Monitor/SynchronizervoidnotifyFailedXmit(java.util.Date timestamp, MrcMessage m)voidnotifyRcv(java.util.Date timestamp, MrcMessage m)voidnotifyXmit(java.util.Date timestamp, MrcMessage m)booleanrequiresIntegerRate()Mrc only supports integer ratesvoidsetRate(double newRate)sets Mrc clock speed, must be 1 to 60voidsetTime(java.util.Date now)set the time, the date part is ignoredvoidstartHardwareClock(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:
notifyXmitin interfaceMrcTrafficListener
-
notifyFailedXmit
public void notifyFailedXmit(java.util.Date timestamp, MrcMessage m)
- Specified by:
notifyFailedXmitin interfaceMrcTrafficListener
-
notifyRcv
public void notifyRcv(java.util.Date timestamp, MrcMessage m)
- Specified by:
notifyRcvin interfaceMrcTrafficListener
-
getHardwareClockName
public java.lang.String getHardwareClockName()
name of Mrc clock- Specified by:
getHardwareClockNamein interfaceClockControl- Overrides:
getHardwareClockNamein classDefaultClockControl- Returns:
- the name
-
canCorrectHardwareClock
public boolean canCorrectHardwareClock()
Mrc clock runs stable enough- Specified by:
canCorrectHardwareClockin interfaceClockControl- Overrides:
canCorrectHardwareClockin classDefaultClockControl- Returns:
- true if correctable; false otherwise
-
canSet12Or24HourClock
public boolean canSet12Or24HourClock()
Mrc clock supports 12/24 operation- Specified by:
canSet12Or24HourClockin interfaceClockControl- Overrides:
canSet12Or24HourClockin classDefaultClockControl- Returns:
- true if settable; false otherwise
-
setRate
public void setRate(double newRate)
sets Mrc clock speed, must be 1 to 60- Specified by:
setRatein interfaceClockControl- Overrides:
setRatein classDefaultClockControl- Parameters:
newRate- the new rate
-
requiresIntegerRate
public boolean requiresIntegerRate()
Mrc only supports integer rates- Specified by:
requiresIntegerRatein interfaceClockControl- Overrides:
requiresIntegerRatein classDefaultClockControl- Returns:
- true if integer rates only; false otherwise
-
getRate
public double getRate()
last known ratio from Mrc clock- Specified by:
getRatein interfaceClockControl- Overrides:
getRatein classDefaultClockControl- Returns:
- Fast Clock rate.
-
setTime
public void setTime(java.util.Date now)
set the time, the date part is ignored- Specified by:
setTimein interfaceClockControl- Overrides:
setTimein 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:
getTimein interfaceClockControl- Overrides:
getTimein classDefaultClockControl- Returns:
- current time.
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
set Mrc clock and start clock- Specified by:
startHardwareClockin interfaceClockControl- Overrides:
startHardwareClockin classDefaultClockControl- Parameters:
now- the starting time
-
initializeHardwareClock
public void initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Description copied from class:DefaultClockControlDefault 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:
initializeHardwareClockin interfaceClockControl- Overrides:
initializeHardwareClockin 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
-
-