OneWireSensor Interface Reference

Inherited by ADContainer, ClockContainer, HumidityContainer, PotentiometerContainer, SwitchContainer, and TemperatureContainer.

List of all members.


Detailed Description

1-Wire sensor interface class for basic sensor operations.

Typically the operations of 1-Wire Sensors are memory mapped so writing to a particular location causes the state to change. To accommodate this type of architecture and reduce the number of 1- Wire operations that need to take place, a 'read-modify-write' technique is used. Each Sensor interface is derived from this super-interface that contain just two methods: readDevice, writeDevice. The read returns a byte array and the write takes a byte array. The byte array is the state of the device. The interfaces that extend this interface have 'get' and 'set' methods that manipulate the byte array. So a OneWireSensor operation is:

  1. state = readDevice()
  2. 'get' and 'set' methods on state
  3. writeDevice(state)

Usage

Example 1

Read the sensed level of a SwitchContainer instance 'sw':

 
  byte[] state = sw.readDevice();
  if (sw.hasLevelSensing())
  {
     for (int ch = 0; ch < sw.getNumberChannels(state); ch++)
     {
        System.out.print("Level for channel " + ch + " is : ");
        if (sw.getLevel(ch, state))
           System.out.println("HIGH");
        else
           System.out.println("HIGH");
     }
  }
  else
      System.out.println("This SwitchContainer can not sense level");
  

Example 2

Set the clock of a ClockContainer instance 'cl':

 
  byte[] state = cl.readDevice();
  cl.setClock((new Date().getTime()), state);
  cl.setClockRunEnable(true, state);
  cl.writeDevice(state);
  

See also:
com.dalsemi.onewire.container.ADContainer

com.dalsemi.onewire.container.ClockContainer

com.dalsemi.onewire.container.PotentiometerContainer

com.dalsemi.onewire.container.SwitchContainer

com.dalsemi.onewire.container.TemperatureContainer

Version:
0.00, 28 Aug 2000
Author:
DS

Public Member Functions

byte[] readDevice () throws OneWireIOException, OneWireException
 Retrieves the 1-Wire device sensor state.
void writeDevice (byte[] state) throws OneWireIOException, OneWireException
 Writes the 1-Wire device sensor state that have been changed by 'set' methods.

Member Function Documentation

byte [] readDevice (  )  throws OneWireIOException, OneWireException

Retrieves the 1-Wire device sensor state.

This state is returned as a byte array. Pass this byte array to the 'get' and 'set' methods. If the device state needs to be changed then call the 'writeDevice' to finalize the changes.

Returns:
1-Wire device sensor state
Exceptions:
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

Implemented in OneWireContainer04, OneWireContainer05, OneWireContainer10, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer20, OneWireContainer21, OneWireContainer24, OneWireContainer28, OneWireContainer29, OneWireContainer2C, OneWireContainer30, OneWireContainer3A, OneWireContainer41, and OneWireContainer42.

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.

Parameters:
state 1-Wire device sensor state
Exceptions:
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

Implemented in OneWireContainer04, OneWireContainer05, OneWireContainer10, OneWireContainer12, OneWireContainer1C, OneWireContainer1F, OneWireContainer20, OneWireContainer21, OneWireContainer24, OneWireContainer28, OneWireContainer29, OneWireContainer2C, OneWireContainer30, OneWireContainer41, and OneWireContainer42.


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

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