Inherited by MissionContainer, OneWireContainer04, OneWireContainer21, OneWireContainer24, OneWireContainer27, and OneWireContainer41.
ClockContainer
extends com.dalsemi.onewire.container.OneWireSensor
, so the general usage model applies to any ClockContainer
:
ClockContainer
Consider this interaction with a ClockContainer
that reads from the Real-Time clock, then tries to set it to the system's current clock setting before disabling the oscillator:
//clockcontainer is a com.dalsemi.onewire.container.ClockContainer
byte[] state = clockcontainer.readDevice();
long current_time = clockcontainer.getClock(state);
System.out.println("Current time is :"+(new Date(current_time)));
long system_time = System.currentTimeMillis();
clockcontainer.setClock(system_time,state);
clockcontainer.writeDevice(state);
//now try to disable to clock oscillator
if (clockcontainer.canDisableClock())
{
state = clockcontainer.readDevice();
clockcontainer.setClockRunEnable(false,state);
clockcontainer.writeDevice(state);
}
Public Member Functions | |
boolean | hasClockAlarm () |
Checks to see if the clock has an alarm feature. | |
boolean | canDisableClock () |
Checks to see if the clock can be disabled. | |
long | getClockResolution () |
Gets the clock resolution in milliseconds. | |
long | getClock (byte[] state) |
Extracts the Real-Time clock value in milliseconds. | |
long | getClockAlarm (byte[] state) throws OneWireException |
Extracts the clock alarm value for the Real-Time clock. | |
boolean | isClockAlarming (byte[] state) |
Checks if the clock alarm flag has been set. | |
boolean | isClockAlarmEnabled (byte[] state) |
Checks if the clock alarm is enabled. | |
boolean | isClockRunning (byte[] state) |
Checks if the device's oscillator is enabled. | |
void | setClock (long time, byte[] state) |
Sets the Real-Time clock. | |
void | setClockAlarm (long time, byte[] state) throws OneWireException |
Sets the clock alarm. | |
void | setClockRunEnable (boolean runEnable, byte[] state) throws OneWireException |
Enables or disables the oscillator, turning the clock 'on' and 'off'. | |
void | setClockAlarmEnable (boolean alarmEnable, byte[] state) throws OneWireException |
Enables or disables the clock alarm. |
boolean hasClockAlarm | ( | ) |
Checks to see if the clock has an alarm feature.
isClockAlarmEnabled(byte[])
isClockAlarming(byte[])
setClockAlarm(long,byte[])
setClockAlarmEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
boolean canDisableClock | ( | ) |
Checks to see if the clock can be disabled.
setClockRunEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
long getClockResolution | ( | ) |
Gets the clock resolution in milliseconds.
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
long getClock | ( | byte[] | state | ) |
Extracts the Real-Time clock value in milliseconds.
state | current state of the device returned from readDevice() |
setClock(long,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
long getClockAlarm | ( | byte[] | state | ) | throws OneWireException |
Extracts the clock alarm value for the Real-Time clock.
state | current state of the device returned from readDevice() |
OneWireException | if this device does not have clock alarms |
isClockAlarmEnabled(byte[])
isClockAlarming(byte[])
setClockAlarm(long,byte[])
setClockAlarmEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
boolean isClockAlarming | ( | byte[] | state | ) |
Checks if the clock alarm flag has been set.
This will occur when the value of the Real-Time clock equals the value of the clock alarm.
state | current state of the device returned from readDevice() |
isClockAlarmEnabled(byte[])
getClockAlarm(byte[])
setClockAlarm(long,byte[])
setClockAlarmEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
boolean isClockAlarmEnabled | ( | byte[] | state | ) |
Checks if the clock alarm is enabled.
state | current state of the device returned from readDevice() |
isClockAlarming(byte[])
getClockAlarm(byte[])
setClockAlarm(long,byte[])
setClockAlarmEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
boolean isClockRunning | ( | byte[] | state | ) |
Checks if the device's oscillator is enabled.
The clock will not increment if the clock oscillator is not enabled.
state | current state of the device returned from readDevice() |
setClockRunEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
void setClock | ( | long | time, | |
byte[] | state | |||
) |
Sets the Real-Time clock.
The method writeDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
.
time | new value for the Real-Time clock, in milliseconds since January 1, 1970 | |
state | current state of the device returned from readDevice() |
getClock(byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
void setClockAlarm | ( | long | time, | |
byte[] | state | |||
) | throws OneWireException |
Sets the clock alarm.
The method writeDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the hasClockAlarm()
method.
time | - new value for the Real-Time clock alarm, in milliseconds since January 1, 1970 | |
state | current state of the device returned from readDevice() |
OneWireException | if this device does not have clock alarms |
isClockAlarmEnabled(byte[])
getClockAlarm(byte[])
isClockAlarming(byte[])
setClockAlarmEnable(boolean,byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
void setClockRunEnable | ( | boolean | runEnable, | |
byte[] | state | |||
) | throws OneWireException |
Enables or disables the oscillator, turning the clock 'on' and 'off'.
The method writeDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
. Also note that not all clock devices can disable their oscillators. Check to see if this device can disable its oscillator first by calling the canDisableClock()
method.
runEnable | true to enable the clock oscillator | |
state | current state of the device returned from readDevice() |
OneWireException | if the clock oscillator cannot be disabled |
isClockRunning(byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.
void setClockAlarmEnable | ( | boolean | alarmEnable, | |
byte[] | state | |||
) | throws OneWireException |
Enables or disables the clock alarm.
The method writeDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice()
. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the hasClockAlarm()
method.
alarmEnable | true to enable the clock alarm | |
state | current state of the device returned from readDevice() |
OneWireException | if this device does not have clock alarms |
isClockAlarmEnabled(byte[])
getClockAlarm(byte[])
setClockAlarm(long,byte[])
isClockAlarming(byte[])
Implemented in OneWireContainer04, OneWireContainer21, OneWireContainer24, and OneWireContainer41.