public class BrickletRealTimeClock extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletRealTimeClock.Alarm |
static interface |
BrickletRealTimeClock.AlarmListener
This listener is triggered every time the current date and time matches the
configured alarm (see
setAlarm(byte, byte, byte, byte, byte, byte, int) ). |
class |
BrickletRealTimeClock.DateTime |
static interface |
BrickletRealTimeClock.DateTimeListener
This listener is triggered periodically with the period that is set by
setDateTimeCallbackPeriod(long) . |
Device.Identity
Modifier and Type | Field and Description |
---|---|
static int |
ALARM_INTERVAL_DISABLED |
static byte |
ALARM_MATCH_DISABLED |
static String |
DEVICE_DISPLAY_NAME |
static int |
DEVICE_IDENTIFIER |
static byte |
FUNCTION_GET_ALARM |
static byte |
FUNCTION_GET_DATE_TIME |
static byte |
FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD |
static byte |
FUNCTION_GET_IDENTITY |
static byte |
FUNCTION_GET_OFFSET |
static byte |
FUNCTION_GET_TIMESTAMP |
static byte |
FUNCTION_SET_ALARM |
static byte |
FUNCTION_SET_DATE_TIME |
static byte |
FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD |
static byte |
FUNCTION_SET_OFFSET |
static short |
WEEKDAY_FRIDAY |
static short |
WEEKDAY_MONDAY |
static short |
WEEKDAY_SATURDAY |
static short |
WEEKDAY_SUNDAY |
static short |
WEEKDAY_THURSDAY |
static short |
WEEKDAY_TUESDAY |
static short |
WEEKDAY_WEDNESDAY |
Constructor and Description |
---|
BrickletRealTimeClock(String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addAlarmListener(BrickletRealTimeClock.AlarmListener listener)
Adds a Alarm listener.
|
void |
addDateTimeListener(BrickletRealTimeClock.DateTimeListener listener)
Adds a DateTime listener.
|
BrickletRealTimeClock.Alarm |
getAlarm()
Returns the alarm configuration as set by
setAlarm(byte, byte, byte, byte, byte, byte, int) . |
BrickletRealTimeClock.DateTime |
getDateTime()
Returns the current date (including weekday) and the current time of the
real-time clock.
|
long |
getDateTimeCallbackPeriod()
Returns the period as set by
setDateTimeCallbackPeriod(long) . |
Device.Identity |
getIdentity()
Returns the UID, the UID where the Bricklet is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
byte |
getOffset()
Returns the offset as set by
setOffset(byte) . |
long |
getTimestamp()
Returns the current date and the time of the real-time clock.
|
void |
removeAlarmListener(BrickletRealTimeClock.AlarmListener listener)
Removes a Alarm listener.
|
void |
removeDateTimeListener(BrickletRealTimeClock.DateTimeListener listener)
Removes a DateTime listener.
|
void |
setAlarm(byte month,
byte day,
byte hour,
byte minute,
byte second,
byte weekday,
int interval)
Configures a repeatable alarm.
|
void |
setDateTime(int year,
short month,
short day,
short hour,
short minute,
short second,
short centisecond,
short weekday)
Sets the current date (including weekday) and the current time.
|
void |
setDateTimeCallbackPeriod(long period)
Sets the period with which the
BrickletRealTimeClock.DateTimeListener listener is triggered
periodically. |
void |
setOffset(byte offset)
Sets the offset the real-time clock should compensate for in 2.17 ppm steps
between -277.76 ppm (-128) and +275.59 ppm (127).
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_SET_DATE_TIME
public static final byte FUNCTION_GET_DATE_TIME
public static final byte FUNCTION_GET_TIMESTAMP
public static final byte FUNCTION_SET_OFFSET
public static final byte FUNCTION_GET_OFFSET
public static final byte FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD
public static final byte FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD
public static final byte FUNCTION_SET_ALARM
public static final byte FUNCTION_GET_ALARM
public static final byte FUNCTION_GET_IDENTITY
public static final short WEEKDAY_MONDAY
public static final short WEEKDAY_TUESDAY
public static final short WEEKDAY_WEDNESDAY
public static final short WEEKDAY_THURSDAY
public static final short WEEKDAY_FRIDAY
public static final short WEEKDAY_SATURDAY
public static final short WEEKDAY_SUNDAY
public static final byte ALARM_MATCH_DISABLED
public static final int ALARM_INTERVAL_DISABLED
public BrickletRealTimeClock(String uid, IPConnection ipcon)
public void setDateTime(int year, short month, short day, short hour, short minute, short second, short centisecond, short weekday) throws TinkerforgeException
TinkerforgeException
public BrickletRealTimeClock.DateTime getDateTime() throws TinkerforgeException
TinkerforgeException
public long getTimestamp() throws TinkerforgeException
TinkerforgeException
public void setOffset(byte offset) throws TinkerforgeException
TinkerforgeException
public byte getOffset() throws TinkerforgeException
setOffset(byte)
.TinkerforgeException
public void setDateTimeCallbackPeriod(long period) throws TinkerforgeException
BrickletRealTimeClock.DateTimeListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletRealTimeClock.DateTimeListener
Listener is only triggered if the date or time changed
since the last triggering.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public long getDateTimeCallbackPeriod() throws TinkerforgeException
setDateTimeCallbackPeriod(long)
.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public void setAlarm(byte month, byte day, byte hour, byte minute, byte second, byte weekday, int interval) throws TinkerforgeException
BrickletRealTimeClock.AlarmListener
listener is triggered if the
current date and time matches the configured alarm.
Setting a parameter to -1 means that it should be disabled and doesn't take part
in the match. Setting all parameters to -1 disables the alarm completely.
For example, to make the alarm trigger every day at 7:30 AM it can be
configured as (-1, -1, 7, 30, -1, -1, -1). The hour is set to match 7 and the
minute is set to match 30. The alarm is triggered if all enabled parameters
match.
The interval has a special role. It allows to make the alarm reconfigure itself.
This is useful if you need a repeated alarm that cannot be expressed by matching
the current date and time. For example, to make the alarm trigger every 23
seconds it can be configured as (-1, -1, -1, -1, -1, -1, 23). Internally the
Bricklet will take the current date and time, add 23 seconds to it and set the
result as its alarm. The first alarm will be triggered 23 seconds after the
call. Because the interval is not -1, the Bricklet will do the same again
internally, take the current date and time, add 23 seconds to it and set that
as its alarm. This results in a repeated alarm that triggers every 23 seconds.
The interval can also be used in combination with the other parameters. For
example, configuring the alarm as (-1, -1, 7, 30, -1, -1, 300) results in an
alarm that triggers every day at 7:30 AM and is then repeated every 5 minutes.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public BrickletRealTimeClock.Alarm getAlarm() throws TinkerforgeException
setAlarm(byte, byte, byte, byte, byte, byte, int)
.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addDateTimeListener(BrickletRealTimeClock.DateTimeListener listener)
public void removeDateTimeListener(BrickletRealTimeClock.DateTimeListener listener)
public void addAlarmListener(BrickletRealTimeClock.AlarmListener listener)
public void removeAlarmListener(BrickletRealTimeClock.AlarmListener listener)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.