com.dalsemi.onewire.container
Class OneWireContainer10

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer10
All Implemented Interfaces:
OneWireSensor, TemperatureContainer

public class OneWireContainer10
extends OneWireContainer
implements TemperatureContainer

iButton container for iButton family type 10 (hex). This family type is a 'temperature' iButton (DS1920 (can) DS1820 (plastic)).

Version:
0.01, 1 Sep 2000

Field Summary
static double RESOLUTION_MAXIMUM
          Useful constant for resolution of temperature reading.
static double RESOLUTION_NORMAL
          Useful constant for resolution of temperature reading.
 
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
ALARM_HIGH, ALARM_LOW
 
Constructor Summary
OneWireContainer10()
          Constructor OneWireContainer10
OneWireContainer10(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer10(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer10(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
static double convertToCelsius(double fahrenheitTemperature)
          Convert a temperature from Fahrenheit to Celsius.
static double convertToFahrenheit(double celsiusTemperature)
          Convert a temperature from Celsius to Fahrenheit.
 void doTemperatureConvert(byte[] state)
          Perform an temperature conversion.
 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.
 double getMaxTemperature()
          Query to get the maximum temperature in degrees C.
 double getMinTemperature()
          Query to get the minimum temperature in degrees C.
 java.lang.String getName()
          Retrieve the Dallas Semiconductor part number of the iButton as a string.
 double getTemperature(byte[] state)
          This method extracts the Temperature Value in degrees C from the state data retrieved from the 'readDevice()' method.
 double getTemperatureAlarm(int alarmType, byte[] state)
          This method extracts the specified Alarm value in degrees C from the state data retrieved from the 'readDevice()' method.
 double getTemperatureAlarmResolution()
          Query to get the high/low resolution in degrees C.
 double getTemperatureResolution(byte[] state)
          This method extracts the current resolution in degrees C from the state data retrieved from the 'readDevice()' method.
 double[] getTemperatureResolutions()
          Query to get an array of available resolutions in degrees C.
 boolean hasSelectableTemperatureResolution()
          Query to see if this device has selectable resolution.
 boolean hasTemperatureAlarms()
          Query to see if this temperature measuring device has high/low trip alarms.
 byte[] readDevice()
          This method retrieves the 1-Wire device sensor state.
 void setTemperatureAlarm(int alarmType, double alarmValue, byte[] state)
          This method sets the alarm value in degrees C in the provided state data.
 void setTemperatureResolution(double resolution, byte[] state)
          This method sets the current resolution in degrees C in the provided state data.
 void writeDevice(byte[] state)
          This method write the 1-Wire device sensor state that have been changed by the 'set' methods.
 
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer
doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, getMemoryBanks, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOLUTION_NORMAL

public static final double RESOLUTION_NORMAL
Useful constant for resolution of temperature reading. Pass this value to setResolution() to use normal, 0.5 C resolution.

RESOLUTION_MAXIMUM

public static final double RESOLUTION_MAXIMUM
Useful constant for resolution of temperature reading. Pass this value to setResolution() to use a higher resolution algorithm to calculate temperature.
Constructor Detail

OneWireContainer10

public OneWireContainer10()
Constructor OneWireContainer10

OneWireContainer10

public OneWireContainer10(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

OneWireContainer10

public OneWireContainer10(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

OneWireContainer10

public OneWireContainer10(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

getName

public java.lang.String getName()
Retrieve the Dallas Semiconductor part number of the iButton as a string. For example 'DS1992'.
Overrides:
getName in class OneWireContainer
Returns:
string representation 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'.
Overrides:
getAlternateNames in class OneWireContainer
Returns:
String representation of the alternate names.

getDescription

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

hasTemperatureAlarms

public boolean hasTemperatureAlarms()
Query to see if this temperature measuring device has high/low trip alarms.
Specified by:
hasTemperatureAlarms in interface TemperatureContainer
Returns:
boolean, true if has high/low trip alarms

hasSelectableTemperatureResolution

public boolean hasSelectableTemperatureResolution()
Query to see if this device has selectable resolution.
Specified by:
hasSelectableTemperatureResolution in interface TemperatureContainer
Returns:
boolean, true if has selectable resolution

getTemperatureResolutions

public double[] getTemperatureResolutions()
Query to get an array of available resolutions in degrees C.
Specified by:
getTemperatureResolutions in interface TemperatureContainer
Returns:
double[], available of resolutions in degrees C

getTemperatureAlarmResolution

public double getTemperatureAlarmResolution()
Query to get the high/low resolution in degrees C.
Specified by:
getTemperatureAlarmResolution in interface TemperatureContainer
Returns:
double, high/low resolution resolution in C

getMaxTemperature

public double getMaxTemperature()
Query to get the maximum temperature in degrees C.
Specified by:
getMaxTemperature in interface TemperatureContainer
Returns:
double, maximum temperature in C

getMinTemperature

public double getMinTemperature()
Query to get the minimum temperature in degrees C.
Specified by:
getMinTemperature in interface TemperatureContainer
Returns:
double, minimum temperature in C

doTemperatureConvert

public void doTemperatureConvert(byte[] state)
                          throws OneWireIOException,
                                 OneWireException
Perform an temperature conversion. Use this state information to calculate the conversion time.
Specified by:
doTemperatureConvert in interface TemperatureContainer
Parameters:
state - - byte array of device state
Throws:
OneWireIOException -  
OneWireException -  

getTemperature

public double getTemperature(byte[] state)
                      throws OneWireIOException
This method extracts the Temperature Value in degrees C from the state data retrieved from the 'readDevice()' method.
Specified by:
getTemperature in interface TemperatureContainer
Parameters:
state - - byte array of device state
Returns:
double, temperature in degrees C from the last 'doTemperature()'

getTemperatureAlarm

public double getTemperatureAlarm(int alarmType,
                                  byte[] state)
This method extracts the specified Alarm value in degrees C from the state data retrieved from the 'readDevice()' method.
Specified by:
getTemperatureAlarm in interface TemperatureContainer
Parameters:
alarmType - - integer, indicating trip type ALARM_HIGH (1) or ALARM_LOW (0)
state - - byte array of device state
Returns:
double, alarm trip temperature in degrees C

getTemperatureResolution

public double getTemperatureResolution(byte[] state)
This method extracts the current resolution in degrees C from the state data retrieved from the 'readDevice()' method.
Specified by:
getTemperatureResolution in interface TemperatureContainer
Parameters:
state - - byte array of device state
Returns:
double, temperature resolution in degrees C

setTemperatureAlarm

public void setTemperatureAlarm(int alarmType,
                                double alarmValue,
                                byte[] state)
This method sets the alarm value in degrees C in the provided state data. Use the method 'writeDevice()' with this data to finalize the change to the device.
Specified by:
setTemperatureAlarm in interface TemperatureContainer
Parameters:
alarmType - - integer, indicating trip type ALARM_HIGH (1) or ALARM_LOW (0)
alarmValue - - double, high trip value in degrees C
state - - byte array of device state

setTemperatureResolution

public void setTemperatureResolution(double resolution,
                                     byte[] state)
This method sets the current resolution in degrees C in the provided state data. Use the method 'writeDevice()' with this data to finalize the change to the device.
Specified by:
setTemperatureResolution in interface TemperatureContainer
Parameters:
resolution - - double, temperature resolution in degrees C. Use RESOLUTION_NORMAL or RESOLUTION_MAXIMUM.
state - - byte array of device state
See Also:
RESOLUTION_NORMAL, RESOLUTION_MAXIMUM

readDevice

public byte[] readDevice()
                  throws OneWireIOException,
                         OneWireException
This method retrieves the 1-Wire device sensor state. This state is returned as a byte array. Pass this byte array to the static query and set methods. If the device state needs to be changed then call the 'writeDevice' to finalize the one or more change.
Specified by:
readDevice in interface OneWireSensor
Returns:
byte[]<\code> 1-Wire device sensor state *
Throws:
OneWireIOException -  
OneWireException -  

writeDevice

public void writeDevice(byte[] state)
                 throws OneWireIOException,
                        OneWireException
This method write the 1-Wire device sensor state that have been changed by the 'set' methods. It knows which registers have changed by looking at the bitmap fields appended to the state data.
Specified by:
writeDevice in interface OneWireSensor
Parameters:
state - - byte array of clock register page contents
Throws:
OneWireIOException -  
OneWireException -  

convertToFahrenheit

public static double convertToFahrenheit(double celsiusTemperature)
Convert a temperature from Celsius to Fahrenheit.
Parameters:
celsiusTemperature - the temperature value to convert
Returns:
the fahrenheit conversion of the supplied temperature

convertToCelsius

public static double convertToCelsius(double fahrenheitTemperature)
Convert a temperature from Fahrenheit to Celsius.
Parameters:
fahrenheitTemperature - the temperature value to convert
Returns:
the celsius conversion of the supplied temperature