com.dalsemi.onewire.container
Class OneWireContainer

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
Direct Known Subclasses:
OneWireContainer01, OneWireContainer02, OneWireContainer04, OneWireContainer05, OneWireContainer06, OneWireContainer08, OneWireContainer09, OneWireContainer0A, OneWireContainer0B, OneWireContainer0C, OneWireContainer0F, OneWireContainer10, OneWireContainer12, OneWireContainer13, OneWireContainer14, OneWireContainer16, OneWireContainer18, OneWireContainer1A, OneWireContainer1D, OneWireContainer1F, OneWireContainer20, OneWireContainer21, OneWireContainer23, OneWireContainer26, OneWireContainer28, OneWireContainer2C, OneWireContainer30

public class OneWireContainer
extends java.lang.Object

General iButton container class with basic communication functions. This class should only be used if a device specific class is not available or known. Most OneWireContainer classes will extend this basic class.

Version:
0.00, 28 Aug 2000

Constructor Summary
OneWireContainer()
          Constructor OneWireContainer
OneWireContainer(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer(DSPortAdapter sourceAdapter, java.lang.String newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
 
Method Summary
 void doSpeed()
          Go to the specified speed for this container.
 DSPortAdapter getAdapter()
          Retrieve the port adapter object used to create this container.
 byte[] getAddress()
          Get the 1-Wire Network address of this device as an array of bytes.
 long getAddressAsLong()
          Get this device's 1-Wire Network address as a long.
 java.lang.String getAddressAsString()
          Get this device's 1-Wire Network address as a String.
 java.lang.String getAlternateNames()
          Retrieve the alternate Dallas Semiconductor part numbers or names.
 java.lang.String getDescription()
          Retrieve a short description of the function of the iButton type.
 int getMaxSpeed()
          Returns the maximum speed this iButton or 1-Wire device can communicate at.
 java.util.Enumeration getMemoryBanks()
          Return an enumeration of memory banks.
 java.lang.String getName()
          Retrieve the Dallas Semiconductor part number of the iButton as a string.
 boolean isAlarming()
          Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state.
 boolean isPresent()
          Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.
 void setSpeed(int newSpeed, boolean fallBack)
          This method takes an int representing the speed of data transfer on the 1-Wire Network.
 void setupContainer(DSPortAdapter sourceAdapter, byte[] newAddress)
          Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
 void setupContainer(DSPortAdapter sourceAdapter, long newAddress)
          Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
 void setupContainer(DSPortAdapter sourceAdapter, java.lang.String newAddress)
          Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneWireContainer

public OneWireContainer()
Constructor OneWireContainer

OneWireContainer

public OneWireContainer(DSPortAdapter sourceAdapter,
                        byte[] newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

OneWireContainer

public OneWireContainer(DSPortAdapter sourceAdapter,
                        long newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

OneWireContainer

public OneWireContainer(DSPortAdapter sourceAdapter,
                        java.lang.String newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device
Method Detail

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           byte[] newAddress)
Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           long newAddress)
Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

setupContainer

public void setupContainer(DSPortAdapter sourceAdapter,
                           java.lang.String newAddress)
Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

getAdapter

public DSPortAdapter getAdapter()
Retrieve the port adapter object used to create this container.
Returns:
DSPortAdapter for this container.

getName

public java.lang.String getName()
Retrieve the Dallas Semiconductor part number of the iButton as a string. For example 'Crypto iButton' or 'DS1992'.
Returns:
string represetation of the iButton name.

getAlternateNames

public java.lang.String getAlternateNames()
Retrieve 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'.
Returns:
String representation of the alternate names.

getDescription

public java.lang.String getDescription()
Retrieve a short description of the function of the iButton type.
Returns:
String representation of the function description.

setSpeed

public void setSpeed(int newSpeed,
                     boolean fallBack)
This method takes an int representing the speed of data transfer on the 1-Wire Network. Note this may be slower then the devices maximum speed. This method can be used by an application to restrict the communication rate due 1-Wire line conditions.

Parameters:
speed -
  • 0 (SPEED_REGULAR) set to normal communciation speed
  • 1 (SPEED_FLEX) set to flexible communciation speed used for long lines
  • 2 (SPEED_OVERDRIVE) set to normal communciation speed to overdrive
  • 3 (SPEED_HYPERDRIVE) set to normal communciation speed to hyperdrive
  • >3 future speeds
newSpeed -  
fallBack - boolean indicating it is OK to fall back to a slower speed if true.

getMaxSpeed

public int getMaxSpeed()
Returns the maximum speed this iButton or 1-Wire device can communicate at. Override this method if derived iButton type can go faster then SPEED_REGULAR(0).

getAddress

public byte[] getAddress()
Get the 1-Wire Network address of this device as an array of bytes.
Returns:
array of bytes containing the iButton address

getAddressAsString

public java.lang.String getAddressAsString()
Get this device's 1-Wire Network address as a String.
Returns:
String representation of the iButton address

getAddressAsLong

public long getAddressAsLong()
Get this device's 1-Wire Network address as a long.
Returns:
String representation of the iButton address

getMemoryBanks

public java.util.Enumeration getMemoryBanks()
Return an enumeration of memory banks. Default is no memory banks.
Returns:
enumeration of memory banks to read and write memory on this iButton or 1-Wire device.

isPresent

public boolean isPresent()
                  throws OneWireIOException,
                         OneWireException
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network.
Returns:
true if device present on the 1-Wire Network.
Throws:
OneWireIOException -  
OneWireException -  

isAlarming

public boolean isAlarming()
                   throws OneWireIOException,
                          OneWireException
Verifies that the iButton or 1-Wire device specified is present on the 1-Wire Network and in an alarm state. This does not apply to all iButton types.
Returns:
true if device present and in alarm condition.
Throws:
OneWireIOException -  
OneWireException -  

doSpeed

public void doSpeed()
             throws OneWireIOException,
                    OneWireException
Go to the specified speed for this container. This method uses the containers selected speed (method setSpeed(speed, fallback)) and will optionally fall back to a slower speed if communciation failed. Only call this method once to get the device into the desired speed as long as the device is still responding.
Throws:
OneWireIOException - WHEN selected speed fails and fallback is false
OneWireException - WHEN hypterdrive is selected speed