Package jmri.jmrix.can.cbus
Class CbusClockControl
- java.lang.Object
-
- jmri.implementation.DefaultClockControl
-
- jmri.jmrix.can.cbus.CbusClockControl
-
- All Implemented Interfaces:
java.util.EventListener
,ClockControl
,Disposable
,AbstractMRListener
,CanListener
public class CbusClockControl extends DefaultClockControl implements CanListener, Disposable
Provide access to CBUS Clock Network Functions.- Since:
- 4.19.6
-
-
Constructor Summary
Constructors Constructor Description CbusClockControl(CanSystemConnectionMemo memo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
dateFromCanFrame(AbstractMessage r)
String representation of time / date from a CanMessage or CanReply.void
dispose()
Stops listening for updates from network and main time base.java.lang.String
getHardwareClockName()
System Connection + Clock Name, e.g.int
getTemp()
Get current Temperature.void
initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
Default implementation is to ignore this request.void
message(CanMessage m)
Outgoing CAN Frames ignored.void
reply(CanReply r)
Listen for CAN Frames sent by external CBUS FC source.void
setRate(double newRate)
For the default implementation, setRate is ignored.void
setTemp(int newTemp)
Set current Temperature.void
setTime(java.util.Date now)
For the default implementation, set time is ignored.void
startHardwareClock(java.util.Date now)
Default implementation is to call SetTime to now.void
stopHardwareClock()
Default implementation is to ignore.-
Methods inherited from class jmri.implementation.DefaultClockControl
canCorrectHardwareClock, canSet12Or24HourClock, getRate, getStatus, getTime, requiresIntegerRate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.can.CanListener
addTc, addTc, removeTc, removeTc
-
-
-
-
Constructor Detail
-
CbusClockControl
public CbusClockControl(@Nonnull CanSystemConnectionMemo memo)
-
-
Method Detail
-
getTemp
public int getTemp()
Get current Temperature. Int format, not twos complement.- Returns:
- -128 to 127
-
setTemp
public void setTemp(int newTemp)
Set current Temperature. Calling this method does not send to layout, is just for setting the value. Int format, not twos complement.- Parameters:
newTemp
- -128 to 127
-
getHardwareClockName
public java.lang.String getHardwareClockName()
System Connection + Clock Name, e.g. MERG CBUS Fast Clock. Get name of hardware clock.If there is no hardware clock, this method returns null. Get name of hardware clock Note: If there is no hardware clock, DefaultClockControl returns null, so all hardware clocks must override this method.
- Specified by:
getHardwareClockName
in interfaceClockControl
- Overrides:
getHardwareClockName
in classDefaultClockControl
- Returns:
- the name
-
setTime
public void setTime(java.util.Date now)
For the default implementation, set time is ignored. Set the fast clock time.- Specified by:
setTime
in interfaceClockControl
- Overrides:
setTime
in classDefaultClockControl
- Parameters:
now
- the new time
-
setRate
public void setRate(double newRate)
For the default implementation, setRate is ignored. Set the rate of the Fast Clock.The rate is a number that multiplies the wall clock time For example, a rate of 4 specifies that the fast clock runs 4 times faster than the wall clock.
- Specified by:
setRate
in interfaceClockControl
- Overrides:
setRate
in classDefaultClockControl
- Parameters:
newRate
- the new rate
-
initializeHardwareClock
public void initializeHardwareClock(double rate, java.util.Date now, boolean getTime)
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
-
stopHardwareClock
public void stopHardwareClock()
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
-
startHardwareClock
public void startHardwareClock(java.util.Date now)
Default implementation is to call SetTime to now. Start hardware fast clock Some hardware fast clocks continue to run indefinitely. This is provided for the case where the hardware clock can be stopped and started.- Specified by:
startHardwareClock
in interfaceClockControl
- Overrides:
startHardwareClock
in classDefaultClockControl
- Parameters:
now
- the starting time
-
reply
public void reply(CanReply r)
Listen for CAN Frames sent by external CBUS FC source. Typically sent every fast minute. Called when an incoming CanFrame is received from the CAN Network.- Specified by:
reply
in interfaceCanListener
- Parameters:
r
- the CanReply being received.
-
message
public void message(CanMessage m)
Outgoing CAN Frames ignored. Called when an outgoing message is sent to the CAN Network.- Specified by:
message
in interfaceCanListener
- Parameters:
m
- the CanMessage being sent.
-
dateFromCanFrame
public static java.lang.String dateFromCanFrame(AbstractMessage r)
String representation of time / date from a CanMessage or CanReply. Does not check for FastClock OPC.- Parameters:
r
- FastClock Message to translate.- Returns:
- String format of Message, e.g.
-
dispose
public void dispose()
Stops listening for updates from network and main time base.- Specified by:
dispose
in interfaceDisposable
-
-