TemperatureContainer Interface Reference

Inherits com::dalsemi::onewire::container::OneWireSensor.

Inherited by OneWireContainer10, OneWireContainer21, OneWireContainer22, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

List of all members.


Detailed Description

1-Wire temperature interface class for basic temperature measuring operations.

This class should be implemented for each temperature type 1-Wire device.

The TemperatureContainer methods can be organized into the following categories:

Usage

Example 1

Display some features of TemperatureContainer instance 'tc':

 
   // Read High and Low Alarms
   if (!tc.hasTemperatureAlarms())
      System.out.println("Temperature alarms not supported");
   else
   {
      byte[] state     = tc.readDevice();
      double alarmLow  = tc.getTemperatureAlarm(TemperatureContainer.ALARM_LOW, state);
      double alarmHigh = tc.getTemperatureAlarm(TemperatureContainer.ALARM_HIGH, state);
      System.out.println("Alarm: High = " + alarmHigh + ", Low = " + alarmLow);
   }             }
  

Example 2

Gets temperature reading from a TemperatureContainer instance 'tc':

 
   double lastTemperature;

   // get the current resolution and other settings of the device (done only once)
   byte[] state = tc.readDevice();

   do // loop to read the temp
   {
      // perform a temperature conversion
      tc.doTemperatureConvert(state);

      // read the result of the conversion
      state = tc.readDevice();

      // extract the result out of state
      lastTemperature = tc.getTemperature(state);
      ...

   }while (!done);
  

The reason the conversion and the reading are separated is that one may want to do a conversion without reading the result. One could take advantage of the alarm features of a device by setting a threshold and doing conversions until the device is alarming. For example:

 
   // get the current resolution of the device
   byte [] state = tc.readDevice();

   // set the trips
   tc.setTemperatureAlarm(TemperatureContainer.ALARM_HIGH, 50, state);
   tc.setTemperatureAlarm(TemperatureContainer.ALARM_LOW, 20, state);
   tc.writeDevice(state);

   do // loop on conversions until an alarm occurs
   {
      tc.doTemperatureConvert(state);
   } while (!tc.isAlarming());
    

Example 3

Sets the temperature resolution of a TemperatureContainer instance 'tc':

 
   byte[] state = tc.readDevice();
   if (tc.hasSelectableTemperatureResolution())
   {
      double[] resolution = tc.getTemperatureResolutions();
      tc.setTemperatureResolution(resolution [resolution.length - 1], state);
      tc.writeDevice(state);
   }
  

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

com.dalsemi.onewire.container.OneWireContainer21

com.dalsemi.onewire.container.OneWireContainer26

com.dalsemi.onewire.container.OneWireContainer28

com.dalsemi.onewire.container.OneWireContainer30

Version:
0.00, 27 August 2000
Author:
DS

Public Member Functions

boolean hasTemperatureAlarms ()
 Checks to see if this temperature measuring device has high/low trip alarms.
boolean hasSelectableTemperatureResolution ()
 Checks to see if this device has selectable temperature resolution.
double[] getTemperatureResolutions ()
 Get an array of available temperature resolutions in Celsius.
double getTemperatureAlarmResolution () throws OneWireException
 Gets the temperature alarm resolution in Celsius.
double getMaxTemperature ()
 Gets the maximum temperature in Celsius.
double getMinTemperature ()
 Gets the minimum temperature in Celsius.
void doTemperatureConvert (byte[] state) throws OneWireIOException, OneWireException
 Performs a temperature conversion.
double getTemperature (byte[] state) throws OneWireIOException
 Gets the temperature value in Celsius from the state data retrieved from the readDevice() method.
double getTemperatureAlarm (int alarmType, byte[] state) throws OneWireException
 Gets the specified temperature alarm value in Celsius from the state data retrieved from the readDevice() method.
double getTemperatureResolution (byte[] state)
 Gets the current temperature resolution in Celsius from the state data retrieved from the readDevice() method.
void setTemperatureAlarm (int alarmType, double alarmValue, byte[] state) throws OneWireException
 Sets the temperature alarm value in Celsius in the provided state data.
void setTemperatureResolution (double resolution, byte[] state) throws OneWireException
 Sets the current temperature resolution in Celsius in the provided state data.

Static Public Attributes

static final int ALARM_HIGH = 1
 high temperature alarm
static final int ALARM_LOW = 0
 low temperature alarm

Member Function Documentation

boolean hasTemperatureAlarms (  ) 

Checks to see if this temperature measuring device has high/low trip alarms.

Returns:
true if this TemperatureContainer has high/low trip alarms
See also:
getTemperatureAlarm

setTemperatureAlarm

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

boolean hasSelectableTemperatureResolution (  ) 

Checks to see if this device has selectable temperature resolution.

Returns:
true if this TemperatureContainer has selectable temperature resolution
See also:
getTemperatureResolution

getTemperatureResolutions

setTemperatureResolution

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double [] getTemperatureResolutions (  ) 

Get an array of available temperature resolutions in Celsius.

Returns:
byte array of available temperature resolutions in Celsius with minimum resolution as the first element and maximum resolution as the last element.
See also:
hasSelectableTemperatureResolution

getTemperatureResolution

setTemperatureResolution

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getTemperatureAlarmResolution (  )  throws OneWireException

Gets the temperature alarm resolution in Celsius.

Returns:
temperature alarm resolution in Celsius for this 1-wire device
Exceptions:
OneWireException Device does not support temperature alarms
See also:
hasTemperatureAlarms

getTemperatureAlarm

setTemperatureAlarm

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getMaxTemperature (  ) 

Gets the maximum temperature in Celsius.

Returns:
maximum temperature in Celsius for this 1-wire device

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getMinTemperature (  ) 

Gets the minimum temperature in Celsius.

Returns:
minimum temperature in Celsius for this 1-wire device

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

void doTemperatureConvert ( byte[]  state  )  throws OneWireIOException, OneWireException

Performs a temperature conversion.

Parameters:
state byte array with device state information
Exceptions:
OneWireException Part could not be found [ fatal ]
OneWireIOException Data wasn't transferred properly [ recoverable ]

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getTemperature ( byte[]  state  )  throws OneWireIOException

Gets the temperature value in Celsius from the state data retrieved from the readDevice() method.

Parameters:
state byte array with device state information
Returns:
temperature in Celsius from the last doTemperatureConvert()
Exceptions:
OneWireIOException In the case of invalid temperature data

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getTemperatureAlarm ( int  alarmType,
byte[]  state 
) throws OneWireException

Gets the specified temperature alarm value in Celsius from the state data retrieved from the readDevice() method.

Parameters:
alarmType valid value: ALARM_HIGH or ALARM_LOW
state byte array with device state information
Returns:
temperature alarm trip values in Celsius for this 1-wire device
Exceptions:
OneWireException Device does not support temperature alarms
See also:
hasTemperatureAlarms

setTemperatureAlarm

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

double getTemperatureResolution ( byte[]  state  ) 

Gets the current temperature resolution in Celsius from the state data retrieved from the readDevice() method.

Parameters:
state byte array with device state information
Returns:
temperature resolution in Celsius for this 1-wire device
See also:
hasSelectableTemperatureResolution

getTemperatureResolutions

setTemperatureResolution

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

void setTemperatureAlarm ( int  alarmType,
double  alarmValue,
byte[]  state 
) throws OneWireException

Sets the temperature alarm value in Celsius in the provided state data.

Use the method writeDevice() with this data to finalize the change to the device.

Parameters:
alarmType valid value: ALARM_HIGH or ALARM_LOW
alarmValue alarm trip value in Celsius
state byte array with device state information
Exceptions:
OneWireException Device does not support temperature alarms
See also:
hasTemperatureAlarms

getTemperatureAlarm

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, OneWireContainer30, OneWireContainer41, and OneWireContainer42.

void setTemperatureResolution ( double  resolution,
byte[]  state 
) throws OneWireException

Sets the current temperature resolution in Celsius in the provided state data.

Use the method writeDevice() with this data to finalize the change to the device.

Parameters:
resolution temperature resolution in Celsius
state byte array with device state information
Exceptions:
OneWireException Device does not support selectable temperature resolution
See also:
hasSelectableTemperatureResolution

getTemperatureResolution

getTemperatureResolutions

Implemented in OneWireContainer10, OneWireContainer21, OneWireContainer28, 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