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) boolean
isRunning
(package private) java.beans.PropertyChangeListener
minuteChangeListener
(package private) static long
MSECPERHOUR
(package private) static long
MSECPERMINUTE
(package private) Timebase
timebase
-
Constructor Summary
Constructors Constructor Description DCCppClockControl(DCCppSystemConnectionMemo memo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getHardwareClockName()
Get name of hardware clock, shown in UIdouble
getRate()
Default implementation returns the rate of the internal clock.java.util.Date
getTime()
Default implementation returns InstanceM default jmri.Timebase getTime().void
initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Default implementation is to ignore this request.void
message(DCCppMessage msg)
Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message sent to the layout.void
message(DCCppReply msg)
Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.void
notifyTimeout(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.boolean
requiresIntegerRate()
Prevent user entry of a fractional rate, since DCC-EX only supports integer ratesvoid
setRate()
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 messagevoid
setTime()
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 messagevoid
startHardwareClock(java.util.Date now)
Pause, unpause and initialize fast clockvoid
stopHardwareClock()
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:
getHardwareClockName
in interfaceClockControl
- Overrides:
getHardwareClockName
in 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:
setRate
in interfaceClockControl
- Overrides:
setRate
in classDefaultClockControl
- Parameters:
newRate
- the new rate
-
setRate
public void setRate()
-
getRate
public double getRate()
Description copied from class:DefaultClockControl
Default 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:
getRate
in interfaceClockControl
- Overrides:
getRate
in 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:
setTime
in interfaceClockControl
- Overrides:
setTime
in classDefaultClockControl
- Parameters:
newTimestamp
- the new time
-
setTime
public void setTime()
-
getTime
public java.util.Date getTime()
Description copied from class:DefaultClockControl
Default implementation returns InstanceM default jmri.Timebase getTime(). ie. the time of the internal clock. Get the fast clock time.- Specified by:
getTime
in interfaceClockControl
- Overrides:
getTime
in classDefaultClockControl
- Returns:
- current time.
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
Pause, unpause and initialize fast clock- Specified by:
startHardwareClock
in interfaceClockControl
- Overrides:
startHardwareClock
in classDefaultClockControl
- Parameters:
now
- the starting time
-
stopHardwareClock
public void stopHardwareClock()
Description copied from class:DefaultClockControl
Default 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:
stopHardwareClock
in interfaceClockControl
- Overrides:
stopHardwareClock
in classDefaultClockControl
-
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
-
requiresIntegerRate
public boolean requiresIntegerRate()
Prevent user entry of a fractional rate, since DCC-EX only supports integer rates- Specified by:
requiresIntegerRate
in interfaceClockControl
- Overrides:
requiresIntegerRate
in classDefaultClockControl
- Returns:
- true if integer rates only; false otherwise
-
message
public void message(DCCppReply msg)
Description copied from interface:DCCppListener
Member function that will be invoked by a DCCppInterface implementation to forward a DCC++ message from the layout.- Specified by:
message
in 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:DCCppListener
Member 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:
message
in 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:DCCppListener
Member function invoked by an DCCppInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeout
in interfaceDCCppListener
- Parameters:
msg
- the message that timed out.
-
-