Package jmri
Interface Timebase
-
- All Superinterfaces:
java.lang.Comparable<NamedBean>
,NamedBean
,PropertyChangeProvider
- All Known Implementing Classes:
SimpleTimebase
public interface Timebase extends NamedBean
Provide access to clock capabilities in hardware or software.The
rate
property determines how much faster than real time this runs. For example, a value of 2.0 means that the value returned by getTime will advance an hour for every half-hour of wall-clock time elapsed.The
rate
andrun
properties are bound, so you can listen for changes to them. Thetime
property is bound, but listeners only receive change notifications if the change is a minute or more, because it changes continuously; query totime
property when needed to get the current value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Timebase.ClockInitialRunState
Defines what to do with the fast clock when JMRI starts up.-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description static int
ANALOG_CLOCK
Clock start option.static int
LCD_CLOCK
Clock start option.static int
NIXIE_CLOCK
Clock start option.static int
NONE
Clock start option.static int
PRAGOTRON_CLOCK
Clock start option.-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMinuteChangeListener(java.beans.PropertyChangeListener l)
Request a callback when the minutes place of the time changes.void
dispose()
Remove references to and from this object, so that it can eventually be garbage-collected.Timebase.ClockInitialRunState
getClockInitialRunState()
Get the Clock Initial Run State ENUM.boolean
getCorrectHardware()
Get if should correct Hardware clocks.boolean
getInternalMaster()
Get internalMaster field.boolean
getIsInitialized()
java.lang.String
getMasterName()
Get the Master Clock Name.java.beans.PropertyChangeListener[]
getMinuteChangeListeners()
Get the list of minute change listeners.double
getRate()
Caution: This method may return a fiddled clock rate if certain hardware clocks are the Time Source.boolean
getRun()
Get if Timebase is running.boolean
getSetRateAtStart()
Get if to Set Rate at Start option checked.boolean
getShowStopButton()
Get if to show a Stop / Resume button next to the clock.int
getStartClockOption()
Get the Start Clock Type.double
getStartRate()
Get the startup clock speed rate.boolean
getStartSetTime()
Get if to use a set start time.java.util.Date
getStartTime()
Get the Clock Start Time.boolean
getSynchronize()
Get if clock should synchronise with Time base.java.util.Date
getTime()
Get the current time.void
initializeClock()
Initialise the clock.void
initializeHardwareClock()
Initialize hardware clock at start up after all options are set up.void
removeMinuteChangeListener(java.beans.PropertyChangeListener l)
Remove a request for callback when the minutes place of the time changes.void
set12HourDisplay(boolean display, boolean update)
Set 12 or 24 hour display option.void
setClockInitialRunState(Timebase.ClockInitialRunState initialState)
Set the Clock Initial Run State ENUM.void
setCorrectHardware(boolean correct, boolean update)
Set if should correct or update hardware.void
setInternalMaster(boolean master, boolean update)
Set internalMaster and update fields.void
setMasterName(java.lang.String name)
Set the Master Clock Name.void
setRate(double factor)
Set fast clock rate.void
setRun(boolean y)
Set if Timebase is running.void
setSetRateAtStart(boolean set)
Set Set Rate at Start option.void
setShowStopButton(boolean displayed)
Set if to show a Stop / Resume button next to the clock.void
setStartClockOption(int option)
Set the Start Clock type Option.void
setStartRate(double factor)
Set the start clock speed rate.void
setStartSetTime(boolean set, java.util.Date time)
Set time at start up option, and start up time.void
setSynchronize(boolean synchronize, boolean update)
Set if clock should synchronise.void
setTime(java.time.Instant i)
Set the current time.void
setTime(java.util.Date d)
Set the current time.boolean
use12HourDisplay()
Get 12 or 24 hour display option.double
userGetRate()
Get the true fast clock rate even if the master timebase rate has been modified by a hardware clock.void
userSetRate(double factor)
Set fast clock rate and force a synchronization with the DCC hardware.void
userSetTime(java.util.Date d)
Set the current time and force a synchronization with the DCC system.-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, getBeanType, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getState, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setState, setUserName, toString, updateListenerRef, vetoableChange
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
NONE
static final int NONE
Clock start option. No startup clock type.- See Also:
- Constant Field Values
-
NIXIE_CLOCK
static final int NIXIE_CLOCK
Clock start option. Startup Nixie clock type.- See Also:
- Constant Field Values
-
ANALOG_CLOCK
static final int ANALOG_CLOCK
Clock start option. Startup Analogue clock type.- See Also:
- Constant Field Values
-
LCD_CLOCK
static final int LCD_CLOCK
Clock start option. Startup LCD clock type.- See Also:
- Constant Field Values
-
PRAGOTRON_CLOCK
static final int PRAGOTRON_CLOCK
Clock start option. Startup Pragotron clock type.- See Also:
- Constant Field Values
-
-
Method Detail
-
setTime
void setTime(@Nonnull java.time.Instant i)
Set the current time.- Parameters:
i
- the new time
-
userSetTime
void userSetTime(@Nonnull java.util.Date d)
Set the current time and force a synchronization with the DCC system.- Parameters:
d
- the new time
-
setRun
void setRun(boolean y)
Set if Timebase is running.- Parameters:
y
- true if running else false.
-
getRun
boolean getRun()
Get if Timebase is running.- Returns:
- true if running, else false.
-
setRate
void setRate(double factor) throws TimebaseRateException
Set fast clock rate.- Parameters:
factor
- the fast clock rate- Throws:
TimebaseRateException
- if the implementation can not use the requested rate
-
userSetRate
void userSetRate(double factor) throws TimebaseRateException
Set fast clock rate and force a synchronization with the DCC hardware.- Parameters:
factor
- the fast clock rate- Throws:
TimebaseRateException
- if the implementation can not use the requested rate
-
getRate
double getRate()
Caution: This method may return a fiddled clock rate if certain hardware clocks are the Time Source. UseuserGetRate()
if you want the real clock rate instead.- Returns:
- the rate
-
userGetRate
double userGetRate()
Get the true fast clock rate even if the master timebase rate has been modified by a hardware clock. External changes in fast clock rate occur because of the peculiar way some hardware clocks attempt to synchronize with the JMRI fast clock.- Returns:
- the rate
-
setInternalMaster
void setInternalMaster(boolean master, boolean update)
Set internalMaster and update fields.- Parameters:
master
- true if fast clock time is derived from internal computer clock, false if derived from hardware clock.update
- true to send update, else false.
-
getInternalMaster
boolean getInternalMaster()
Get internalMaster field.- Returns:
- true if fast clock time is derived from internal computer clock, false if derived from hardware clock
-
setMasterName
void setMasterName(@Nonnull java.lang.String name)
Set the Master Clock Name.- Parameters:
name
- master clock name.
-
getMasterName
java.lang.String getMasterName()
Get the Master Clock Name.- Returns:
- master clock name.
-
setSynchronize
void setSynchronize(boolean synchronize, boolean update)
Set if clock should synchronise.- Parameters:
synchronize
- set true to synchronise hardware clocks with Time base.update
- set true to update clock when function called.
-
getSynchronize
boolean getSynchronize()
Get if clock should synchronise with Time base.- Returns:
- true if should synchronise hardware clocks.
-
setCorrectHardware
void setCorrectHardware(boolean correct, boolean update)
Set if should correct or update hardware.- Parameters:
correct
- set true to correct hardware clocks.update
- set true to update clock when function called.
-
getCorrectHardware
boolean getCorrectHardware()
Get if should correct Hardware clocks.- Returns:
- true to correct, else false.
-
set12HourDisplay
void set12HourDisplay(boolean display, boolean update)
Set 12 or 24 hour display option.- Parameters:
display
- true for a 12-hour display; false for a 24-hour displayupdate
- true to update clock when function called.
-
use12HourDisplay
boolean use12HourDisplay()
Get 12 or 24 hour display option.- Returns:
- true for a 12-hour display; false for a 24-hour display
-
setClockInitialRunState
void setClockInitialRunState(Timebase.ClockInitialRunState initialState)
Set the Clock Initial Run State ENUM.- Parameters:
initialState
- Initial state.
-
getClockInitialRunState
Timebase.ClockInitialRunState getClockInitialRunState()
Get the Clock Initial Run State ENUM.- Returns:
- Initial state.
-
setShowStopButton
void setShowStopButton(boolean displayed)
Set if to show a Stop / Resume button next to the clock.- Parameters:
displayed
- true if to display, else false.
-
getShowStopButton
boolean getShowStopButton()
Get if to show a Stop / Resume button next to the clock.- Returns:
- true if to display, else false.
-
setStartSetTime
void setStartSetTime(boolean set, java.util.Date time)
Set time at start up option, and start up time.- Parameters:
set
- true for set time at startup, else false.time
- startup time.
-
getStartSetTime
boolean getStartSetTime()
Get if to use a set start time.- Returns:
- true if using set start time.
-
setStartRate
void setStartRate(double factor)
Set the start clock speed rate.- Parameters:
factor
- start clock speed factor.
-
getStartRate
double getStartRate()
Get the startup clock speed rate.- Returns:
- startup clock speed rate factor.
-
setSetRateAtStart
void setSetRateAtStart(boolean set)
Set Set Rate at Start option.- Parameters:
set
- If true, the rate at startup will be set to the value of getStartRate().
-
getSetRateAtStart
boolean getSetRateAtStart()
Get if to Set Rate at Start option checked.- Returns:
- If true, the rate at startup should be set to the value of getStartRate()
-
getStartTime
@Nonnull java.util.Date getStartTime()
Get the Clock Start Time.- Returns:
- Clock Start Time.
-
setStartClockOption
void setStartClockOption(int option)
Set the Start Clock type Option.- Parameters:
option
- Clock type, e.g. NIXIE_CLOCK or PRAGOTRON_CLOCK
-
getStartClockOption
int getStartClockOption()
Get the Start Clock Type.- Returns:
- Clock type, e.g. NIXIE_CLOCK or PRAGOTRON_CLOCK
-
initializeClock
void initializeClock()
Initialise the clock. Should only be invoked at start up.
-
initializeHardwareClock
void initializeHardwareClock()
Initialize hardware clock at start up after all options are set up.Note: This method is always called at start up. It should be ignored if there is no communication with a hardware clock
-
getIsInitialized
boolean getIsInitialized()
- Returns:
- true if call to initialize Hardware Clock has occurred
-
addMinuteChangeListener
void addMinuteChangeListener(@Nonnull java.beans.PropertyChangeListener l)
Request a callback when the minutes place of the time changes. This is the same as callingPropertyChangeProvider.addPropertyChangeListener(String, PropertyChangeListener)
with the propertyNameminutes
.- Parameters:
l
- the listener to receive the callback
-
removeMinuteChangeListener
void removeMinuteChangeListener(@Nonnull java.beans.PropertyChangeListener l)
Remove a request for callback when the minutes place of the time changes. This is the same as callingPropertyChangeProvider.removePropertyChangeListener(String, PropertyChangeListener)
with the propertyNameminutes
.- Parameters:
l
- the listener to receive the callback
-
getMinuteChangeListeners
@Nonnull java.beans.PropertyChangeListener[] getMinuteChangeListeners()
Get the list of minute change listeners. This is the same as callingPropertyChangeProvider.getPropertyChangeListeners(String)
with the propertyNameminutes
.- Returns:
- the list of listeners
-
-