Package jmri.jmrix.dccpp
Class DCCppClockControl
- java.lang.Object
-
- jmri.implementation.DefaultClockControl
-
- jmri.jmrix.dccpp.DCCppClockControl
-
- All Implemented Interfaces:
java.util.EventListener,ClockControl,AbstractMRListener,DCCppListener
public class DCCppClockControl extends DefaultClockControl implements DCCppListener
Class providing Clock Control to the DCC-EX client. Does nothing unless "Synchronize Internal Fast Clock and DCC-EX Fast Clock" is enabled. If "Time Source" is "Internal Computer Clock", send any changes to Fast Clock Rate or Time to the command station. If "Time Source" is "DCC-EX Fast Clock", listen for incoming Time messages and set the Fast Clock from these. Ignores incoming Rate messages.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Calendar_cal(package private) DCCppSystemConnectionMemo_memo(package private) DCCppTrafficController_tc(package private) booleanisRunning(package private) java.beans.PropertyChangeListenerminuteChangeListener(package private) static longMSECPERHOUR(package private) static longMSECPERMINUTE(package private) Timebasetimebase
-
Constructor Summary
Constructors Constructor Description DCCppClockControl(DCCppSystemConnectionMemo memo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetHardwareClockName()Get name of hardware clock, shown in UIdoublegetRate()Default implementation returns the rate of the internal clock.java.util.DategetTime()Default implementation returns InstanceM default jmri.Timebase getTime().voidinitializeHardwareClock(double rate, java.util.Date now, boolean getTime)Default implementation is to ignore this request.voidmessage(DCCppMessage msg)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout.voidmessage(DCCppReply msg)Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.voidnotifyTimeout(DCCppMessage msg)Member function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.booleanrequiresIntegerRate()Prevent user entry of a fractional rate, since DCC-EX only supports integer ratesvoidsetRate()voidsetRate(double newRate)Send the new fastclock rate to CS if internal is master AND synchronize enabled send rate of zero if clock is not running Note: fastclock rate and time are in a single messagevoidsetTime()voidsetTime(java.util.Date newTimestamp)Send the new fast clock time to CS if internal is master AND synchronize enabled Note: fastclock rate and time are in a single messagevoidstartHardwareClock(java.util.Date now)Pause, unpause and initialize fast clockvoidstopHardwareClock()Default implementation is to ignore.-
Methods inherited from class jmri.implementation.DefaultClockControl
canCorrectHardwareClock, canSet12Or24HourClock, getStatus
-
-
-
-
Field Detail
-
_cal
java.util.Calendar _cal
-
minuteChangeListener
java.beans.PropertyChangeListener minuteChangeListener
-
isRunning
boolean isRunning
-
MSECPERHOUR
static final long MSECPERHOUR
- See Also:
- Constant Field Values
-
MSECPERMINUTE
static final long MSECPERMINUTE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DCCppClockControl
public DCCppClockControl(DCCppSystemConnectionMemo memo)
-
-
Method Detail
-
getHardwareClockName
public java.lang.String getHardwareClockName()
Get name of hardware clock, shown in UI- Specified by:
getHardwareClockNamein interfaceClockControl- Overrides:
getHardwareClockNamein classDefaultClockControl- Returns:
- the name
-
setRate
public void setRate(double newRate)
Send the new fastclock rate to CS if internal is master AND synchronize enabled send rate of zero if clock is not running Note: fastclock rate and time are in a single message- Specified by:
setRatein interfaceClockControl- Overrides:
setRatein classDefaultClockControl- Parameters:
newRate- the new rate
-
setRate
public void setRate()
-
getRate
public double getRate()
Description copied from class:DefaultClockControlDefault implementation returns the rate of the internal clock. Get the rate of the Fast Clock.The rate is a number that multiplies the wall clock. For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock.
- Specified by:
getRatein interfaceClockControl- Overrides:
getRatein classDefaultClockControl- Returns:
- Fast Clock rate.
-
setTime
public void setTime(java.util.Date newTimestamp)
Send the new fast clock time to CS if internal is master AND synchronize enabled Note: fastclock rate and time are in a single message- Specified by:
setTimein interfaceClockControl- Overrides:
setTimein classDefaultClockControl- Parameters:
newTimestamp- the new time
-
setTime
public void setTime()
-
getTime
public java.util.Date getTime()
Description copied from class:DefaultClockControlDefault implementation returns InstanceM default jmri.Timebase getTime(). ie. the time of the internal clock. Get the fast clock time.- Specified by:
getTimein interfaceClockControl- Overrides:
getTimein classDefaultClockControl- Returns:
- current time.
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
Pause, unpause and initialize fast clock- Specified by:
startHardwareClockin interfaceClockControl- Overrides:
startHardwareClockin classDefaultClockControl- Parameters:
now- the starting time
-
stopHardwareClock
public void stopHardwareClock()
Description copied from class:DefaultClockControlDefault implementation is to ignore. Stop hardware fast clock. This is provided for the case where the hardware clock can be stopped and started.- Specified by:
stopHardwareClockin interfaceClockControl- Overrides:
stopHardwareClockin classDefaultClockControl
-
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
-
requiresIntegerRate
public boolean requiresIntegerRate()
Prevent user entry of a fractional rate, since DCC-EX only supports integer rates- Specified by:
requiresIntegerRatein interfaceClockControl- Overrides:
requiresIntegerRatein classDefaultClockControl- Returns:
- true if integer rates only; false otherwise
-
message
public void message(DCCppReply msg)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.- Specified by:
messagein interfaceDCCppListener- Parameters:
msg- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
public void message(DCCppMessage msg)
Description copied from interface:DCCppListenerMember function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout. Normally, this function will do nothing.- Specified by:
messagein interfaceDCCppListener- Parameters:
msg- The received DCC++ message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
public void notifyTimeout(DCCppMessage msg)
Description copied from interface:DCCppListenerMember function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeoutin interfaceDCCppListener- Parameters:
msg- the message that timed out.
-
-