com.dalsemi.onewire.container
Class OneWireContainer27

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer27
All Implemented Interfaces:
ClockContainer, OneWireSensor

public class OneWireContainer27
extends OneWireContainer
implements ClockContainer

1-Wire container for Real-Time Clock with Interrupt, DS2417. This container encapsulates the functionality of the iButton family type 27 (hex)

Features

Usage

See the usage example in ClockContainer for clock specific operations.

DataSheet

http://pdfserv.maxim-ic.com/arpdf/DS2417.pdf

Version:
1.00, 6 September 2001
See Also:
ClockContainer

Field Summary
static byte INTERRUPT_INTERVAL_1
           
static byte INTERRUPT_INTERVAL_131072
           
static byte INTERRUPT_INTERVAL_2048
           
static byte INTERRUPT_INTERVAL_32
           
static byte INTERRUPT_INTERVAL_4
           
static byte INTERRUPT_INTERVAL_4096
           
static byte INTERRUPT_INTERVAL_64
           
static byte INTERRUPT_INTERVAL_65536
           
 
Constructor Summary
OneWireContainer27()
          Create an empty container that is not complete until after a call to setupContainer.
OneWireContainer27(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.
OneWireContainer27(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.
OneWireContainer27(DSPortAdapter sourceAdapter, String newAddress)
          Create a container with the provided adapter instance and the address of the iButton or 1-Wire device.
 
Method Summary
 boolean canDisableClock()
          Query to see if the clock can be disabled.
 String getAlternateNames()
          Get the alternate Dallas Semiconductor 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 getClockResolution()
          Query to get the clock resolution in milliseconds
 String getDescription()
          Get a short description of the function of this iButton or 1-Wire Device type.
 long getInterruptInterval(byte[] state)
          Returns the interval, in seconds, that the device will interrupt on.
 String getName()
          Get the Dallas Semiconductor part number of the iButton or 1-Wire Device as a string.
 boolean hasClockAlarm()
          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.
 boolean isInterruptEnabled(byte[] state)
          Checks to see if interrupt mode is turned on.
 byte[] readDevice()
          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 setInterruptEnable(boolean iEnable, byte[] state)
          Enables or disables hardware interrupting.
 void setInterruptInterval(byte intervalValue, byte[] state)
          Sets the interval at which interrupting will occur.
 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, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERRUPT_INTERVAL_1

public static final byte INTERRUPT_INTERVAL_1

INTERRUPT_INTERVAL_4

public static final byte INTERRUPT_INTERVAL_4

INTERRUPT_INTERVAL_32

public static final byte INTERRUPT_INTERVAL_32

INTERRUPT_INTERVAL_64

public static final byte INTERRUPT_INTERVAL_64

INTERRUPT_INTERVAL_2048

public static final byte INTERRUPT_INTERVAL_2048

INTERRUPT_INTERVAL_4096

public static final byte INTERRUPT_INTERVAL_4096

INTERRUPT_INTERVAL_65536

public static final byte INTERRUPT_INTERVAL_65536

INTERRUPT_INTERVAL_131072

public static final byte INTERRUPT_INTERVAL_131072
Constructor Detail

OneWireContainer27

public OneWireContainer27()
Create an empty container that is not complete until after a call to setupContainer.

This is one of the methods to construct a container. The others are through creating a OneWireContainer with parameters.

See Also:
super.setupContainer()

OneWireContainer27

public OneWireContainer27(DSPortAdapter sourceAdapter,
                          byte[] newAddress)
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 iButton
newAddress - Address of this 1-Wire device
See Also:
OneWireContainer27, utils.Address

OneWireContainer27

public OneWireContainer27(DSPortAdapter sourceAdapter,
                          long newAddress)
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 device
newAddress - Address of this 1-Wire device
See Also:
OneWireContainer27, utils.Address

OneWireContainer27

public OneWireContainer27(DSPortAdapter sourceAdapter,
                          String newAddress)
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 device
newAddress - Address of this 1-Wire device
See Also:
OneWireContainer27, utils.Address
Method Detail

getName

public String getName()
Get the Dallas Semiconductor part number of the iButton or 1-Wire Device as a string. For example 'DS1992'.
Overrides:
getName in class OneWireContainer
Returns:
iButton or 1-Wire device name

getAlternateNames

public String getAlternateNames()
Get the alternate Dallas Semiconductor 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 class OneWireContainer
Returns:
1-Wire device alternate names

getDescription

public String getDescription()
Get a short description of the function of this iButton or 1-Wire Device type.
Overrides:
getDescription in class OneWireContainer
Returns:
device description

hasClockAlarm

public boolean hasClockAlarm()
Query to see if the clock has an alarm feature.
Specified by:
hasClockAlarm in interface ClockContainer
Returns:
true if the Real-Time clock has an alarm
See Also:
getClockAlarm(byte[]), isClockAlarmEnabled(byte[]), isClockAlarming(byte[]), setClockAlarm(long,byte[]), setClockAlarmEnable(boolean,byte[])

canDisableClock

public boolean canDisableClock()
Query to see if the clock can be disabled.
Specified by:
canDisableClock in interface ClockContainer
Returns:
true if the clock can be enabled and disabled
See Also:
isClockRunning(byte[]), setClockRunEnable(boolean,byte[])

getClockResolution

public long getClockResolution()
Query to get the clock resolution in milliseconds
Specified by:
getClockResolution in interface ClockContainer
Returns:
the clock resolution in milliseconds

readDevice

public byte[] readDevice()
                  throws OneWireIOException,
                         OneWireException
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 interface OneWireSensor
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

public void writeDevice(byte[] state)
                 throws OneWireIOException,
                        OneWireException
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 interface OneWireSensor
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 interface ClockContainer
Parameters:
state - current state of the device returned from readDevice()
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:
OneWireSensor.readDevice(), setClock(long,byte[])

getClockAlarm

public long getClockAlarm(byte[] state)
                   throws OneWireException
Extracts the clock alarm value for the Real-Time clock.
Specified by:
getClockAlarm in interface ClockContainer
Parameters:
state - current state of the device returned from readDevice()
Returns:
milliseconds since 1970 that the clock alarm is set to
Throws:
OneWireException - if this device does not have clock alarms
See Also:
OneWireSensor.readDevice(), hasClockAlarm(), isClockAlarmEnabled(byte[]), isClockAlarming(byte[]), setClockAlarm(long,byte[]), setClockAlarmEnable(boolean,byte[])

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 interface ClockContainer
Parameters:
state - current state of the device returned from readDevice()
Returns:
true if the Real-Time clock is alarming
See Also:
OneWireSensor.readDevice(), hasClockAlarm(), isClockAlarmEnabled(byte[]), getClockAlarm(byte[]), setClockAlarm(long,byte[]), setClockAlarmEnable(boolean,byte[])

isClockAlarmEnabled

public boolean isClockAlarmEnabled(byte[] state)
Checks if the clock alarm is enabled.
Specified by:
isClockAlarmEnabled in interface ClockContainer
Parameters:
state - current state of the device returned from readDevice()
Returns:
true if clock alarm is enabled
See Also:
OneWireSensor.readDevice(), hasClockAlarm(), isClockAlarming(byte[]), getClockAlarm(byte[]), setClockAlarm(long,byte[]), setClockAlarmEnable(boolean,byte[])

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 interface ClockContainer
Parameters:
state - current state of the device returned from readDevice()
Returns:
true if the clock is running
See Also:
OneWireSensor.readDevice(), canDisableClock(), setClockRunEnable(boolean,byte[])

getInterruptInterval

public long getInterruptInterval(byte[] state)
Returns the interval, in seconds, that the device will interrupt on.
Parameters:
state - current state of the device returned from readDevice()
Returns:
number of seconds in between interrupts.
See Also:
OneWireSensor.writeDevice(byte[]), getClock(byte[])

isInterruptEnabled

public boolean isInterruptEnabled(byte[] state)
Checks to see if interrupt mode is turned on. If so, pulses will be generated at an interval selected by setInterruptInterval.
Parameters:
state - current state of the device returned from readDevice()
Returns:
true if interrupts are enabled
See Also:
OneWireSensor.readDevice(), canDisableClock(), setClockRunEnable(boolean,byte[])

setClock

public void setClock(long time,
                     byte[] state)
Sets the Real-Time clock. The method writeDevice(byte[]) must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[]).
Specified by:
setClock in interface ClockContainer
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 from readDevice()
See Also:
OneWireSensor.writeDevice(byte[]), getClock(byte[])

setClockAlarm

public void setClockAlarm(long time,
                          byte[] state)
                   throws OneWireException
Sets the clock alarm. The method writeDevice(byte[]) must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[]). Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the hasClockAlarm() method.
Specified by:
setClockAlarm in interface ClockContainer
Parameters:
time - - new value for the Real-Time clock alarm, in milliseconds since January 1, 1970
state - current state of the device returned from readDevice()
Throws:
OneWireException - if this device does not have clock alarms
See Also:
OneWireSensor.writeDevice(byte[]), hasClockAlarm(), isClockAlarmEnabled(byte[]), getClockAlarm(byte[]), isClockAlarming(byte[]), setClockAlarmEnable(boolean,byte[])

setClockAlarmEnable

public void setClockAlarmEnable(boolean alarmEnable,
                                byte[] state)
                         throws OneWireException
Enables or disables the clock alarm. The method writeDevice(byte[]) must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[]). Also note that not all clock devices have alarms. Check to see if this device has alarms first by calling the hasClockAlarm() method.
Specified by:
setClockAlarmEnable in interface ClockContainer
Parameters:
alarmEnable - true to enable the clock alarm
state - current state of the device returned from readDevice()
Throws:
OneWireException - if this device does not have clock alarms
See Also:
OneWireSensor.writeDevice(byte[]), hasClockAlarm(), isClockAlarmEnabled(byte[]), getClockAlarm(byte[]), setClockAlarm(long,byte[]), isClockAlarming(byte[])

setInterruptInterval

public void setInterruptInterval(byte intervalValue,
                                 byte[] state)
Sets the interval at which interrupting will occur. Note that this feature must be enabled first using setInterruptEnable(true,state). The method writeDevice(byte[]) must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(byte[]).
Parameters:
intervalValue - One of the following variables should be passed, representing different time intervals to interrupt at: INTERRUPT_INTERVAL_1 1 second INTERRUPT_INTERVAL_4 4 seconds INTERRUPT_INTERVAL_32 32 seconds INTERRUPT_INTERVAL_32 64 seconds INTERRUPT_INTERVAL_64 2048 seconds INTERRUPT_INTERVAL_2048 4096 seconds INTERRUPT_INTERVAL_4096 65536 seconds INTERRUPT_INTERVAL_131072 131072 seconds
state - current state of the device returned from readDevice()
See Also:
OneWireSensor.writeDevice(byte[]), getClock(byte[])

setClockRunEnable

public void setClockRunEnable(boolean runEnable,
                              byte[] state)
Enables or disables the oscillator, turning the clock 'on' and 'off'. The method writeDevice(byte[]) must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice(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 the canDisableClock() method.
Specified by:
setClockRunEnable in interface ClockContainer
Parameters:
runEnable - true to enable the clock oscillator
state - current state of the device returned from readDevice()
See Also:
OneWireSensor.writeDevice(byte[]), canDisableClock(), isClockRunning(byte[])

setInterruptEnable

public void setInterruptEnable(boolean iEnable,
                               byte[] state)
Enables or disables hardware interrupting. If enabled, the device sends an interrupt at intervals defined by using the setInterruptInterval function.
Parameters:
runEnable - true to enable interval interrupts.
state - current state of the device returned from readDevice()
See Also:
OneWireSensor.writeDevice(byte[]), canDisableClock(), isClockRunning(byte[])