Class OneWireContainer24
- All Implemented Interfaces:
ClockContainer
,OneWireSensor
- Direct Known Subclasses:
OneWireContainer27
1-Wire container for Real-Time-Clock (RTC) iButton, DS1904 and 1-Wire Chip, DS2415. This container encapsulates the functionality of the iButton family type 24 (hex)
This iButton is used as a portable real-time-clock.
Features
- Real-Time Clock with fully compatible 1-Wire MicroLAN interface
- Uses the same binary time/date representation as the DS2404 but with 1 second resolution
- Clock accuracy @htmlonly ± @endhtmlonly 2 minutes per month at 25@htmlonly °C @endhtmlonly
- Operating temperature range from -40@htmlonly °C @endhtmlonly to +70@htmlonly °C @endhtmlonly (iButton), -40@htmlonly °C @endhtmlonly to +85@htmlonly °C @endhtmlonly (1-Wire chip)
- Over 10 years of data retention (iButton form factor)
- Low power, 200 nA typical with oscillator running
Alternate Names
- DS2415
Clock
The clock methods can be organized into the following categories. Note that
methods that are implemented for the
ClockContainer
interface
are marked with (*):
- Information
- Read
- Clock
- Misc
- Write
- Clock
- Misc
Usage
- See the usage examples in
ClockContainer
for basic clock operations.
DataSheets
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
protected static final byte
protected static final int
protected static final byte
Fields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty container that is not complete until after a call tosetupContainer
.OneWireContainer24
(DSPortAdapter sourceAdapter, byte[] newAddress) Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.OneWireContainer24
(DSPortAdapter sourceAdapter, long newAddress) Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.OneWireContainer24
(DSPortAdapter sourceAdapter, String newAddress) Create a container with the provided adapter instance and the address of the iButton or 1-Wire device. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Query to see if the clock can be disabled.Get the alternate Maxim Integrated Products part numbers or names.long
getClock
(byte[] state) Extracts the Real-Time clock value in milliseconds.long
getClockAlarm
(byte[] state) Extracts the clock alarm value for the Real-Time clock.long
Query to get the clock resolution in millisecondsGet a short description of the function of this iButton or 1-Wire Device type.getName()
Get the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string.boolean
Query to see if the clock has an alarm feature.boolean
isClockAlarmEnabled
(byte[] state) Checks if the clock alarm is enabled.boolean
isClockAlarming
(byte[] state) Checks if the clock alarm flag has been set.boolean
isClockRunning
(byte[] state) Checks if the device's oscillator is enabled.byte[]
Retrieves the five byte state over the 1-Wire bus.void
setClock
(long time, byte[] state) Sets the Real-Time clock.void
setClockAlarm
(long time, byte[] state) Sets the clock alarm.void
setClockAlarmEnable
(boolean alarmEnable, byte[] state) Enables or disables the clock alarm.void
setClockRunEnable
(boolean runEnable, byte[] state) Enables or disables the oscillator, turning the clock 'on' and 'off'.void
writeDevice
(byte[] state) Writes the 1-Wire device sensor state that have been changed by 'set' methods.Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
Field Details
-
RTC_OFFSET
protected static final int RTC_OFFSET- See Also:
-
CONTROL_OFFSET
protected static final int CONTROL_OFFSET- See Also:
-
READ_CLOCK_COMMAND
protected static final byte READ_CLOCK_COMMAND- See Also:
-
WRITE_CLOCK_COMMAND
protected static final byte WRITE_CLOCK_COMMAND- See Also:
-
-
Constructor Details
-
OneWireContainer24
public OneWireContainer24()Create an empty container that is not complete until after a call tosetupContainer
.This is one of the methods to construct a container. The others are through creating a OneWireContainer with parameters.
- See Also:
-
OneWireContainer24
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this iButtonnewAddress
-Address
of this 1-Wire device- See Also:
-
OneWireContainer24
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this 1-Wire devicenewAddress
-Address
of this 1-Wire device- See Also:
-
OneWireContainer24
Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.This is one of the methods to construct a container. The other is through creating a OneWireContainer with NO parameters.
- Parameters:
sourceAdapter
- adapter instance used to communicate with this 1-Wire devicenewAddress
-Address
of this 1-Wire device- See Also:
-
-
Method Details
-
getName
Get the Maxim Integrated Products part number of the iButton or 1-Wire Device as a string. For example 'DS1992'.- Overrides:
getName
in classOneWireContainer
- Returns:
- iButton or 1-Wire device name
-
getAlternateNames
Get the alternate Maxim Integrated Products part numbers or names. A 'family' of 1-Wire Network devices may have more than one part number depending on packaging. There can also be nicknames such as 'Crypto iButton'.- Overrides:
getAlternateNames
in classOneWireContainer
- Returns:
- 1-Wire device alternate names
-
getDescription
Get a short description of the function of this iButton or 1-Wire Device type.- Overrides:
getDescription
in classOneWireContainer
- Returns:
- device description
-
hasClockAlarm
public boolean hasClockAlarm()Query to see if the clock has an alarm feature.- Specified by:
hasClockAlarm
in interfaceClockContainer
- Returns:
- true if the Real-Time clock has an alarm
- See Also:
-
canDisableClock
public boolean canDisableClock()Query to see if the clock can be disabled.- Specified by:
canDisableClock
in interfaceClockContainer
- Returns:
- true if the clock can be enabled and disabled
- See Also:
-
getClockResolution
public long getClockResolution()Query to get the clock resolution in milliseconds- Specified by:
getClockResolution
in interfaceClockContainer
- Returns:
- the clock resolution in milliseconds
-
readDevice
Retrieves the five byte state over the 1-Wire bus. This state array must be passed to the Get/Set methods as well as the WriteDevice method.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
- 1-Wire device sensor state
- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
writeDevice
Writes the 1-Wire device sensor state that have been changed by 'set' methods. Only the state registers that changed are updated. This is done by referencing a field information appended to the state data.- Specified by:
writeDevice
in interfaceOneWireSensor
- Parameters:
state
- 1-Wire device sensor state- Throws:
OneWireIOException
- on a 1-Wire communication error such as reading an incorrect CRC from a 1-Wire device. This could be caused by a physical interruption in the 1-Wire Network due to shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.OneWireException
- on a communication or setup error with the 1-Wire adapter
-
getClock
public long getClock(byte[] state) Extracts the Real-Time clock value in milliseconds.- Specified by:
getClock
in interfaceClockContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- the time represented in this clock in milliseconds since some reference time, as chosen by the user (ie. 12:00am, Jan 1st 1970)
- See Also:
-
getClockAlarm
Extracts the clock alarm value for the Real-Time clock.- Specified by:
getClockAlarm
in interfaceClockContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- milliseconds since 1970 that the clock alarm is set to
- Throws:
OneWireException
- if this device does not have clock alarms- See Also:
-
isClockAlarming
public 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.- Specified by:
isClockAlarming
in interfaceClockContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- true if the Real-Time clock is alarming
- See Also:
-
isClockAlarmEnabled
public boolean isClockAlarmEnabled(byte[] state) Checks if the clock alarm is enabled.- Specified by:
isClockAlarmEnabled
in interfaceClockContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- true if clock alarm is enabled
- See Also:
-
isClockRunning
public boolean isClockRunning(byte[] state) Checks if the device's oscillator is enabled. The clock will not increment if the clock oscillator is not enabled.- Specified by:
isClockRunning
in interfaceClockContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- true if the clock is running
- See Also:
-
setClock
public void setClock(long time, byte[] state) Sets the Real-Time clock. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
.- Specified by:
setClock
in interfaceClockContainer
- Parameters:
time
- new value for the Real-Time clock, in milliseconds since some reference time (ie. 12:00am, January 1st, 1970)state
- current state of the device returned fromreadDevice()
- See Also:
-
setClockAlarm
Sets the clock alarm. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling thehasClockAlarm()
method.- Specified by:
setClockAlarm
in interfaceClockContainer
- Parameters:
time
- - new value for the Real-Time clock alarm, in milliseconds since January 1, 1970state
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- if this device does not have clock alarms- See Also:
-
setClockAlarmEnable
Enables or disables the clock alarm. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
. Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling thehasClockAlarm()
method.- Specified by:
setClockAlarmEnable
in interfaceClockContainer
- Parameters:
alarmEnable
- true to enable the clock alarmstate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- if this device does not have clock alarms- See Also:
-
setClockRunEnable
public void setClockRunEnable(boolean runEnable, byte[] state) Enables or disables the oscillator, turning the clock 'on' and 'off'. The methodwriteDevice(byte[])
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice(byte[])
. Also note that not all clock devices can disable their oscillators. Check to see if this device can disable its oscillator first by calling thecanDisableClock()
method.- Specified by:
setClockRunEnable
in interfaceClockContainer
- Parameters:
runEnable
- true to enable the clock oscillatorstate
- current state of the device returned fromreadDevice()
- See Also:
-