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
rateproperty 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
rateandrunproperties are bound, so you can listen for changes to them. Thetimeproperty is bound, but listeners only receive change notifications if the change is a minute or more, because it changes continuously; query totimeproperty when needed to get the current value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTimebase.ClockInitialRunStateDefines 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 intANALOG_CLOCKClock start option.static intLCD_CLOCKClock start option.static intNIXIE_CLOCKClock start option.static intNONEClock start option.static intPRAGOTRON_CLOCKClock start option.static java.lang.StringPROPERTY_CHANGE_MINUTESProperty Change sent when the minute value changes.static java.lang.StringPROPERTY_CHANGE_RATEProperty Change sent when the rate value changes.static java.lang.StringPROPERTY_CHANGE_RUNProperty Change sent when the run status changes.static java.lang.StringPROPERTY_CHANGE_TIMEProperty 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddMinuteChangeListener(java.beans.PropertyChangeListener l)Request 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.Timebase.ClockInitialRunStategetClockInitialRunState()Get the Clock Initial Run State ENUM.booleangetCorrectHardware()Get if should correct Hardware clocks.booleangetInternalMaster()Get internalMaster field.booleangetIsInitialized()java.lang.StringgetMasterName()Get the Master Clock Name.java.beans.PropertyChangeListener[]getMinuteChangeListeners()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.booleangetSetRateAtStart()Get if to Set Rate at Start option checked.booleangetShowStopButton()Get if to show a Stop / Resume button next to the clock.intgetStartClockOption()Get the Start Clock Type.doublegetStartRate()Get the startup clock speed rate.booleangetStartSetTime()Get if to use a set start time.java.util.DategetStartTime()Get the Clock Start Time.booleangetSynchronize()Get if clock should synchronise with Time base.java.util.DategetTime()Get the current time.voidinitializeClock()Initialise the clock.voidinitializeHardwareClock()Initialize hardware clock at start up after all options are set up.voidremoveMinuteChangeListener(java.beans.PropertyChangeListener l)Remove 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(java.lang.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, java.util.Date time)Set time at start up option, and start up time.voidsetSynchronize(boolean synchronize, boolean update)Set if clock should synchronise.voidsetTime(java.time.Instant i)Set the current time.voidsetTime(java.util.Date d)Set the current time.booleanuse12HourDisplay()Get 12 or 24 hour display option.doubleuserGetRate()Get 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(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, getRecommendedToolTip, 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
-
PROPERTY_CHANGE_MINUTES
static final java.lang.String PROPERTY_CHANGE_MINUTES
Property Change sent when the minute value changes.- See Also:
- Constant Field Values
-
PROPERTY_CHANGE_RATE
static final java.lang.String PROPERTY_CHANGE_RATE
Property Change sent when the rate value changes.- See Also:
- Constant Field Values
-
PROPERTY_CHANGE_RUN
static final java.lang.String PROPERTY_CHANGE_RUN
Property Change sent when the run status changes.- See Also:
- Constant Field Values
-
PROPERTY_CHANGE_TIME
static final java.lang.String PROPERTY_CHANGE_TIME
Property Change sent when the minute value changes.- See Also:
- Constant Field Values
-
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, e.g. 1.0 runs at the same rate as real clocks, 2.0 at twice the speed.
-
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
-
-