1-Wire API for .NET Version 4.00
Public Member Functions | Protected Attributes

OneWireContainer Class Reference

A OneWireContainer encapsulates the DSPortAdapter, the 1-Wire® network address, and methods to manipulate a specific 1-Wire device. More...

Inherited by OneWireContainer01, OneWireContainer02, OneWireContainer04, OneWireContainer05, OneWireContainer06, OneWireContainer08, OneWireContainer09, OneWireContainer0A, OneWireContainer0B, OneWireContainer0C, OneWireContainer0F, OneWireContainer10, OneWireContainer12, OneWireContainer13, OneWireContainer14, OneWireContainer18, OneWireContainer1A, OneWireContainer1C, OneWireContainer1D, OneWireContainer1F, OneWireContainer20, OneWireContainer21, OneWireContainer23, OneWireContainer24, OneWireContainer28, OneWireContainer29, OneWireContainer2C, OneWireContainer2D, OneWireContainer30, OneWireContainer33, OneWireContainer37, OneWireContainer3A, OneWireContainer41, OneWireContainer42, and OneWireContainer43.

List of all members.

Public Member Functions

 OneWireContainer ()
 Create an empty container.
 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, String newAddress)
 Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
void setupContainer (DSPortAdapter sourceAdapter, byte[] newAddress)
 Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
void setupContainer (DSPortAdapter sourceAdapter, long newAddress)
 Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
void setupContainer (DSPortAdapter sourceAdapter, String newAddress)
 Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.
DSPortAdapter getAdapter ()
 Retrieves the port adapter object used to create this container.
String getName ()
 Retrieves the Maxim Integrated Products part number of the 1-Wire device as a String.
String getAlternateNames ()
 Retrieves the alternate Maxim Integrated Products part numbers or names.
String getDescription ()
 Retrieves a short description of the function of the 1-Wire device type.
void setSpeed (int newSpeed, boolean fallBack)
 Sets the maximum speed for this container.
int getMaxSpeed ()
 Returns the maximum speed this iButton or 1-Wire device can communicate at.
byte[] getAddress ()
 Gets the 1-Wire Network address of this device as an array of bytes.
String getAddressAsString ()
 Gets this device's 1-Wire Network address as a String.
long getAddressAsLong ()
 Gets this device's 1-Wire Network address as a long.
Enumeration getMemoryBanks ()
 Returns an Enumeration of MemoryBank.
boolean isPresent () throws OneWireIOException,OneWireException
 Verifies that the iButton or 1-Wire device is present on the 1-Wire Network.
boolean isAlarming () throws OneWireIOException,OneWireException
 Verifies that the iButton or 1-Wire device is present on the 1-Wire Network and in an alarm state.
void doSpeed () throws OneWireIOException, OneWireException
 Go to the specified speed for this container.
int hashCode ()
 Returns a hash code value for the object.
boolean equals (Object obj)
 Indicates whether some other object is "equal to" this one.
String toString ()
 Returns a string representation of the object.

Protected Attributes

DSPortAdapter adapter
 Reference to the adapter that is needed to communicate with this iButton or 1-Wire device.
byte[] address
 1-Wire Network Address of this iButton or 1-Wire device.
int speed
 Communication speed requested.
boolean speedFallBackOK
 Flag to indicate that falling back to a slower speed then requested is OK.

Detailed Description

A OneWireContainer encapsulates the DSPortAdapter, the 1-Wire® network address, and methods to manipulate a specific 1-Wire device.

A 1-Wire device may be in the form of a stainless steel armored can, called an iButton®, or in standard IC plastic packaging.

General 1-Wire device 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.

1-Wire devices with memory can be accessed through the objects that are returned from the getMemoryBanks method. See the usage example below.

Usage

Example 1

Enumerate memory banks retrieved from the OneWireContainer instance 'owd' and cast to the highest interface. See the interface descriptions MemoryBank, PagedMemoryBank, and OTPMemoryBank for specific examples.

 
  MemoryBank      mb;
  PagedMemoryBank pg_mb;
  OTPMemoryBank   otp_mb;
  for(Enumeration bank_enum = owd.getMemoryBanks();
                      bank_enum.hasMoreElements(); )
  {
     // get the next memory bank, cast to MemoryBank
     mb = (MemoryBank)bank_enum.nextElement();
     // check if has paged services
     if (mb instanceof PagedMemoryBank)
         pg_mb = (PagedMemoryBank)mb;
     // check if has One-Time-Programable services
     if (mb instanceof OTPMemoryBank)
         otp_mb = (OTPMemoryBank)mb;
  }
  
See also:
com.dalsemi.onewire.container.MemoryBank
com.dalsemi.onewire.container.PagedMemoryBank
com.dalsemi.onewire.container.OTPMemoryBank
Version:
0.00, 28 Aug 2000
Author:
DS

Constructor & Destructor Documentation

Create an empty container.

Must call setupContainer before using this new container.

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

See also:
OneWireContainer(DSPortAdapter,byte[])
OneWireContainer(DSPortAdapter,long)
OneWireContainer(DSPortAdapter,String)
setupContainer(DSPortAdapter,byte[])
setupContainer(DSPortAdapter,long)
setupContainer(DSPortAdapter,String)
OneWireContainer ( DSPortAdapter  sourceAdapter,
byte[]  newAddress 
)

Create a container with a provided adapter object 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:
sourceAdapteradapter object required to communicate with this iButton.
newAddressaddress of this 1-Wire device
See also:
OneWireContainer()
com.dalsemi.onewire.utils.Address
OneWireContainer ( DSPortAdapter  sourceAdapter,
long  newAddress 
)

Create a container with a provided adapter object 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:
sourceAdapteradapter object required to communicate with this iButton.
newAddressaddress of this 1-Wire device
See also:
OneWireContainer()
com.dalsemi.onewire.utils.Address
OneWireContainer ( DSPortAdapter  sourceAdapter,
String  newAddress 
)

Create a container with a provided adapter object 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:
sourceAdapteradapter object required to communicate with this iButton.
newAddressaddress of this 1-Wire device
See also:
OneWireContainer()
com.dalsemi.onewire.utils.Address

Member Function Documentation

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.

Exceptions:
OneWireIOExceptionWHEN selected speed fails and fallback is false
OneWireExceptionWHEN hypterdrive is selected speed
See also:
setSpeed(int,boolean)
boolean equals ( Object  obj)

Indicates whether some other object is "equal to" this one.

Parameters:
objthe reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
DSPortAdapter getAdapter ( )

Retrieves the port adapter object used to create this container.

Returns:
port adapter instance
byte [] getAddress ( )

Gets the 1-Wire Network address of this device as an array of bytes.

Returns:
1-Wire address
See also:
com.dalsemi.onewire.utils.Address
long getAddressAsLong ( )

Gets this device's 1-Wire Network address as a long.

Returns:
1-Wire address
See also:
com.dalsemi.onewire.utils.Address
String getAddressAsString ( )

Gets this device's 1-Wire Network address as a String.

Returns:
1-Wire address
See also:
com.dalsemi.onewire.utils.Address
String getAlternateNames ( )
String getDescription ( )
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).

Returns:
maximum speed
See also:
DSPortAdapter.setSpeed

Reimplemented in OneWireContainer0A, OneWireContainer0C, OneWireContainer0F, OneWireContainer18, OneWireContainer1A, OneWireContainer1D, OneWireContainer20, OneWireContainer21, OneWireContainer23, OneWireContainer29, OneWireContainer2C, OneWireContainer2D, OneWireContainer33, OneWireContainer37, OneWireContainer3A, OneWireContainer41, OneWireContainer42, and OneWireContainer43.

Enumeration getMemoryBanks ( )
String getName ( )
int hashCode ( )

Returns a hash code value for the object.

This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Returns:
a hash code value for this object.
See also:
java.util.Hashtable
boolean isAlarming ( ) throws OneWireIOException,OneWireException

Verifies that the iButton or 1-Wire device is present on the 1-Wire Network and in an alarm state.

This does not apply to all device types.

Returns:
true if device present and in alarm condition
Exceptions:
OneWireIOExceptionon a 1-Wire communication error such as a read back verification fails.
OneWireExceptionif adapter is not open
boolean isPresent ( ) throws OneWireIOException,OneWireException

Verifies that the iButton or 1-Wire device is present on the 1-Wire Network.

Returns:
true if device present on the 1-Wire Network
Exceptions:
OneWireIOExceptionon a 1-Wire communication error such as a read back verification fails.
OneWireExceptionif adapter is not open
void setSpeed ( int  newSpeed,
boolean  fallBack 
)

Sets the maximum speed for this container.

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:
newSpeed
  • 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
fallBackboolean indicating it is OK to fall back to a slower speed if true
void setupContainer ( DSPortAdapter  sourceAdapter,
byte[]  newAddress 
)

Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.

Parameters:
sourceAdapteradapter object required to communicate with this iButton
newAddressaddress of this 1-Wire device
See also:
com.dalsemi.onewire.utils.Address

Reimplemented in OneWireContainer18, OneWireContainer21, OneWireContainer2D, OneWireContainer33, OneWireContainer37, OneWireContainer41, and OneWireContainer43.

void setupContainer ( DSPortAdapter  sourceAdapter,
String  newAddress 
)

Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.

Parameters:
sourceAdapteradapter object required to communicate with this iButton
newAddressaddress of this 1-Wire device
See also:
com.dalsemi.onewire.utils.Address

Reimplemented in OneWireContainer2D, OneWireContainer33, OneWireContainer37, OneWireContainer41, and OneWireContainer43.

void setupContainer ( DSPortAdapter  sourceAdapter,
long  newAddress 
)

Provides this container with the adapter object used to access this device and the address of the iButton or 1-Wire device.

Parameters:
sourceAdapteradapter object required to communicate with this iButton
newAddressaddress of this 1-Wire device
See also:
com.dalsemi.onewire.utils.Address

Reimplemented in OneWireContainer21, OneWireContainer2D, OneWireContainer33, OneWireContainer37, OneWireContainer41, and OneWireContainer43.

String toString ( )

Returns a string representation of the object.

Returns:
a string representation of the object.

Member Data Documentation

byte [] address [protected]

1-Wire Network Address of this iButton or 1-Wire device.

Family code is byte at offset 0.

See also:
com.dalsemi.onewire.utils.Address
int speed [protected]

Communication speed requested.

  • 0 (SPEED_REGULAR)
  • 1 (SPEED_FLEX)
  • 2 (SPEED_OVERDRIVE)
  • 3 (SPEED_HYPERDRIVE)
  • >3 future speeds
See also:
DSPortAdapter.setSpeed

The documentation for this class was generated from the following file: