OneWireAccessProvider Class Reference

List of all members.


Detailed Description

The OneWireAccessProvider class manages the Maxim adapter class derivatives of DSPortAdapter.

An enumeration of all available adapters can be accessed through the member function EnumerateAllAdapters. This enables an application to be adapter independent. There are also facilities to get a system appropriate default adapter/port combination.

Usage

Example 1

Get an instance of the default 1-Wire adapter. The adapter will be ready to use if no exceptions are thrown.

 
  try
  {
     DSPortAdapter adapter = OneWireAccessProvider.getDefaultAdapter();

     System.out.println("Adapter: " + adapter.getAdapterName() + " Port: " + adapter.getPortName());

     // use the adapter ...

  }
  catch(Exception e)
  {
     System.out.println("Default adapter not present: " + e);
  }
  

Example 2

Enumerate through the available adapters and ports.

 
  DSPortAdapter adapter;
  String        port;

  // get the adapters
  for (Enumeration adapter_enum = OneWireAccessProvider.enumerateAllAdapters();
                                  adapter_enum.hasMoreElements(); )
  {
     // cast the enum as a DSPortAdapter
     adapter = ( DSPortAdapter ) adapter_enum.nextElement();

     System.out.print("Adapter: " + adapter.getAdapterName() + " with ports: ");

     // get the ports
     for (Enumeration port_enum = adapter.getPortNames();
             port_enum.hasMoreElements(); )
     {
        // cast the enum as a String
        port = ( String ) port_enum.nextElement();

        System.out.print(port + " ");
     }

     System.out.println();
  }
  

Example 3

Display the default adapter name and port without getting an instance of the adapter.

 
  System.out.println("Default Adapter: " +
                      OneWireAccessProvider.getProperty("onewire.adapter.default"));
  System.out.println("Default Port: " +
                      OneWireAccessProvider.getProperty("onewire.port.default"));
  

See also:
com.dalsemi.onewire.adapter.DSPortAdapter
Version:
0.00, 30 August 2000
Author:
DS

Static Public Member Functions

static String getVersion ()
 Returns a version string, representing the release number on official releases, or release number and release date on incrememental releases.
static void main (String[] args)
 Main method returns current version info, and default adapter setting.
static Enumeration enumerateAllAdapters ()
 Gets an Enumeration of all 1-Wire adapter types supported.
static DSPortAdapter getAdapter (String adapterName, String portName) throws OneWireIOException, OneWireException
 Finds, opens, and verifies the specified adapter on the indicated port.
static DSPortAdapter getDefaultAdapter () throws OneWireIOException, OneWireException
 Finds, opens, and verifies the default adapter and port.
static String getProperty (String propName)
 Gets the specfied onewire property.
static void setUseOverridingAdapter (DSPortAdapter adapter)
 Sets an overriding adapter.
static void clearUseOverridingAdapter ()
 Clears the overriding adapter.

Member Function Documentation

static String getVersion (  )  [static]

Returns a version string, representing the release number on official releases, or release number and release date on incrememental releases.

Returns:
Current OneWireAPI version

static void main ( String[]  args  )  [static]

Main method returns current version info, and default adapter setting.

Parameters:
args cmd-line arguments, ignored for now.

static Enumeration enumerateAllAdapters (  )  [static]

Gets an Enumeration of all 1-Wire adapter types supported.

Using this enumeration with the port enumeration for each adapter, a search can be done to find all available hardware adapters.

Returns:
Enumeration of DSPortAdapters in the system

static DSPortAdapter getAdapter ( String  adapterName,
String  portName 
) throws OneWireIOException, OneWireException [static]

Finds, opens, and verifies the specified adapter on the indicated port.

Parameters:
adapterName string name of the adapter (match to result of call to getAdapterName() method in DSPortAdapter)
portName string name of the port used in the method selectPort() in DSPortAdapter
Returns:
DSPortAdapter if adapter present
Exceptions:
OneWireIOException when communcation with the adapter fails
OneWireException when the port or adapter not present

static DSPortAdapter getDefaultAdapter (  )  throws OneWireIOException, OneWireException [static]

Finds, opens, and verifies the default adapter and port.

Looks for the default adapter/port in the following locations:

  • Use adapter/port in System.properties for onewire.adapter.default, and onewire.port.default properties tags.
  • Use adapter/port from onewire.properties file in current directory or < java.home >/lib/ (Desktop) or /etc/ (TINI)
  • Use smart default
    • Desktop
      • First, TMEX default (Win32 only)
      • Second, if TMEX not present, then DS9097U/(first serial port)
    • TINI, TINIExternalAdapter on port serial1

Returns:
DSPortAdapter if default adapter present
Exceptions:
OneWireIOException when communcation with the adapter fails
OneWireException when the port or adapter not present

static String getProperty ( String  propName  )  [static]

Gets the specfied onewire property.

Looks for the property in the following locations:

  • In System.properties
  • In onewire.properties file in current directory or < java.home >/lib/ (Desktop) or /etc/ (TINI)
  • 'smart' default if property is 'onewire.adapter.default' or 'onewire.port.default'

Parameters:
propName string name of the property to read
Returns:
String representing the property value or null if it could not be found (onewire.adapter.default and onewire.port.default may return a 'smart' default even if property not present)

static void setUseOverridingAdapter ( DSPortAdapter  adapter  )  [static]

Sets an overriding adapter.

This adapter will be returned from getAdapter and getDefaultAdapter despite what was requested.

Parameters:
adapter adapter to be the override
See also:
getAdapter

getDefaultAdapter

clearUseOverridingAdapter

static void clearUseOverridingAdapter (  )  [static]

Clears the overriding adapter.

The operation of getAdapter and getDefaultAdapter will be returned to normal.

See also:
getAdapter

getDefaultAdapter

setUseOverridingAdapter


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

Generated on Thu Aug 28 15:42:29 2008 for 1-Wire API for .NET by  doxygen 1.5.6