Package jmri
Interface Timebase
- All Superinterfaces:
Comparable<NamedBean>,NamedBean,PropertyChangeProvider
- All Known Implementing Classes:
SimpleTimebase
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 and run properties are bound, so you can listen for
changes to them. The time property is bound, but listeners only
receive change notifications if the change is a minute or more, because it
changes continuously; query to time property when needed to get the
current value.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDefines 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
FieldsModifier and TypeFieldDescriptionstatic final intClock start option.static final intClock start option.static final intClock start option.static final intClock start option.static final intClock start option.static final StringProperty Change sent when the minute value changes.static final StringProperty Change sent when the rate value changes.static final StringProperty Change sent when the run status changes.static final StringProperty Change sent when the minute value changes.Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Method Summary
Modifier and TypeMethodDescriptionvoidRequest a callback when the minutes place of the time changes.voiddispose()Remove references to and from this object, so that it can eventually be garbage-collected.Get the Clock Initial Run State ENUM.booleanGet if should correct Hardware clocks.booleanGet internalMaster field.booleanGet the Master Clock Name.Get the list of minute change listeners.doublegetRate()Caution: This method may return a fiddled clock rate if certain hardware clocks are the Time Source.booleangetRun()Get if Timebase is running.booleanGet if to Set Rate at Start option checked.booleanGet if to show a Stop / Resume button next to the clock.intGet the Start Clock Type.doubleGet the startup clock speed rate.booleanGet if to use a set start time.Get the Clock Start Time.booleanGet if clock should synchronise with Time base.getTime()Get the current time.voidInitialise the clock.voidInitialize hardware clock at start up after all options are set up.voidRemove a request for callback when the minutes place of the time changes.voidset12HourDisplay(boolean display, boolean update) Set 12 or 24 hour display option.voidsetClockInitialRunState(Timebase.ClockInitialRunState initialState) Set the Clock Initial Run State ENUM.voidsetCorrectHardware(boolean correct, boolean update) Set if should correct or update hardware.voidsetInternalMaster(boolean master, boolean update) Set internalMaster and update fields.voidsetMasterName(String name) Set the Master Clock Name.voidsetRate(double factor) Set fast clock rate.voidsetRun(boolean y) Set if Timebase is running.voidsetSetRateAtStart(boolean set) Set Set Rate at Start option.voidsetShowStopButton(boolean displayed) Set if to show a Stop / Resume button next to the clock.voidsetStartClockOption(int option) Set the Start Clock type Option.voidsetStartRate(double factor) Set the start clock speed rate.voidsetStartSetTime(boolean set, Date time) Set time at start up option, and start up time.voidsetSynchronize(boolean synchronize, boolean update) Set if clock should synchronise.voidSet the current time.voidSet the current time.booleanGet 12 or 24 hour display option.doubleGet the true fast clock rate even if the master timebase rate has been modified by a hardware clock.voiduserSetRate(double factor) Set fast clock rate and force a synchronization with the DCC hardware.voiduserSetTime(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, getRecommendedToolTip, getState, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setState, setUserName, toString, updateListenerRef, vetoableChangeMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
PROPERTY_CHANGE_MINUTES
Property Change sent when the minute value changes.- See Also:
-
PROPERTY_CHANGE_RATE
Property Change sent when the rate value changes.- See Also:
-
PROPERTY_CHANGE_RUN
Property Change sent when the run status changes.- See Also:
-
PROPERTY_CHANGE_TIME
Property Change sent when the minute value changes.- See Also:
-
NONE
Clock start option. No startup clock type.- See Also:
-
NIXIE_CLOCK
Clock start option. Startup Nixie clock type.- See Also:
-
ANALOG_CLOCK
Clock start option. Startup Analogue clock type.- See Also:
-
LCD_CLOCK
Clock start option. Startup LCD clock type.- See Also:
-
PRAGOTRON_CLOCK
Clock start option. Startup Pragotron clock type.- See Also:
-
-
Method Details
-
setTime
Set the current time.- Parameters:
d- the new time
-
setTime
Set the current time.- Parameters:
i- the new time
-
userSetTime
Set the current time and force a synchronization with the DCC system.- Parameters:
d- the new time
-
getTime
Get the current time.- Returns:
- current time.
-
setRun
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
Set fast clock rate.- Parameters:
factor- the fast clock rate- Throws:
TimebaseRateException- if the implementation can not use the requested rate
-
userSetRate
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, e.g. 1.0 runs at the same rate as real clocks, 2.0 at twice the speed.
-
setInternalMaster
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
Set the Master Clock Name.- Parameters:
name- master clock name.
-
getMasterName
Get the Master Clock Name.- Returns:
- master clock name.
-
setSynchronize
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
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
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
Set the Clock Initial Run State ENUM.- Parameters:
initialState- Initial state.
-
getClockInitialRunState
Get the Clock Initial Run State ENUM.- Returns:
- Initial state.
-
setShowStopButton
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
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
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
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
Get the Clock Start Time.- Returns:
- Clock Start Time.
-
setStartClockOption
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
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
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
Get the list of minute change listeners. This is the same as callingPropertyChangeProvider.getPropertyChangeListeners(String)with the propertyNameminutes.- Returns:
- the list of listeners
-
dispose
void dispose()Remove references to and from this object, so that it can eventually be garbage-collected.
-