com.dalsemi.onewire.container
Class OneWireContainer28

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

public class OneWireContainer28
extends OneWireContainer
implements TemperatureContainer

iButton container for iButton family type 28 (hex). This family type is a 'temperature' 1-Wire chip device DS18B20 (plastic)).

Version:
1.00, 15 September 2000

Field Summary
static byte CONVERT_TEMPERATURE_COMMAND
          DS18B20 convert temperature command
static byte COPY_SCRATCHPAD_COMMAND
          DS18B20 copy scratchpad command
static byte READ_POWER_SUPPLY_COMMAND
          DS18B20 write scratchpad command
static byte READ_SCRATCHPAD_COMMAND
          DS18B20 read scratchpad command
static byte RECALL_E2MEMORY_COMMAND
          DS18B20 recall E-squared memory command
static byte RESOLUTION_10_BIT
          DS18B20 10-bit resolution constant for CONFIG byte
static byte RESOLUTION_11_BIT
          DS18B20 11-bit resolution constant for CONFIG byte
static byte RESOLUTION_12_BIT
          DS18B20 12-bit resolution constant for CONFIG byte
static byte RESOLUTION_9_BIT
          DS18B20 9-bit resolution constant for CONFIG byte
static byte WRITE_SCRATCHPAD_COMMAND
          DS18B20 write scratchpad command
 
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
ALARM_HIGH, ALARM_LOW
 
Constructor Summary
OneWireContainer28()
          Constructor OneWireContainer28
OneWireContainer28(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer28(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer28(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
 float convertToFahrenheit(float celsiusTemperature)
          Convert a temperature from celsius to fahrenheit.
 void copyScratchpad()
          Copy the Scratchpad to the Esquared memory of the DS18B20.
 void doTemperatureConvert(byte[] state)
          Perform a 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 Temperature 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.
 boolean isExternalPowerSupplied()
          Reads the way power is supplied to the DS18B20.
 byte[] readDevice()
          This method retrieves the 1-Wire device sensor state.
 byte[] readScratchpad()
          Read the Scratchpad of the DS18B20.
 byte[] recallE2()
          Recalls the DS18B20 temperature trigger values (th & tl) and the configuration register to the scratchpad and reads the scratchpad.
 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 writes the 1-Wire device sensor state that has been changed by the 'set' methods.
 void writeScratchpad(byte[] data)
          Write to the Scratchpad of the DS18B20.
 
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

WRITE_SCRATCHPAD_COMMAND

public static final byte WRITE_SCRATCHPAD_COMMAND
DS18B20 write scratchpad command

READ_SCRATCHPAD_COMMAND

public static final byte READ_SCRATCHPAD_COMMAND
DS18B20 read scratchpad command

COPY_SCRATCHPAD_COMMAND

public static final byte COPY_SCRATCHPAD_COMMAND
DS18B20 copy scratchpad command

CONVERT_TEMPERATURE_COMMAND

public static final byte CONVERT_TEMPERATURE_COMMAND
DS18B20 convert temperature command

RECALL_E2MEMORY_COMMAND

public static final byte RECALL_E2MEMORY_COMMAND
DS18B20 recall E-squared memory command

READ_POWER_SUPPLY_COMMAND

public static final byte READ_POWER_SUPPLY_COMMAND
DS18B20 write scratchpad command

RESOLUTION_12_BIT

public static final byte RESOLUTION_12_BIT
DS18B20 12-bit resolution constant for CONFIG byte

RESOLUTION_11_BIT

public static final byte RESOLUTION_11_BIT
DS18B20 11-bit resolution constant for CONFIG byte

RESOLUTION_10_BIT

public static final byte RESOLUTION_10_BIT
DS18B20 10-bit resolution constant for CONFIG byte

RESOLUTION_9_BIT

public static final byte RESOLUTION_9_BIT
DS18B20 9-bit resolution constant for CONFIG byte
Constructor Detail

OneWireContainer28

public OneWireContainer28()
Constructor OneWireContainer28

OneWireContainer28

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

OneWireContainer28

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

OneWireContainer28

public OneWireContainer28(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 MicroLAN 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. This value ONLY has to do with the temp high and temp low trigger values.
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 a temperature conversion. Use this state information to calculate the conversion time.
Specified by:
doTemperatureConvert in interface TemperatureContainer
Parameters:
state - - byte array of device state device state looks like this: 0 : temperature LSB 1 : temperature MSB 2 : trip high 3 : trip low 4 : configuration register (for resolution) 5 : reserved 6 : reserved 7 : reserved 8 : the final byte is an 8 bit CRC
Throws:
OneWireIOException -  
OneWireException -  

getTemperature

public double getTemperature(byte[] state)
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 Temperature 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)
                         throws OneWireException,
                                OneWireIOException
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)
                              throws OneWireException,
                                     OneWireIOException
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
state - - byte array of device state

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 writes the 1-Wire device sensor state that has been changed by the 'set' methods.
Specified by:
writeDevice in interface OneWireSensor
Parameters:
state - - byte array to write to the DS18B20
Throws:
OneWireIOException -  
OneWireException -  

readScratchpad

public byte[] readScratchpad()
                      throws OneWireIOException,
                             OneWireException
Read the Scratchpad of the DS18B20.
Returns:
9-byte buffer representing the scratchpad
Throws:
OneWireIOException -  
OneWireException -  

writeScratchpad

public void writeScratchpad(byte[] data)
                     throws OneWireIOException,
                            OneWireException
Write to the Scratchpad of the DS18B20.
Parameters:
data - byte[]<\code> this is the data to be written to the scratchpad. First byte of data must be the temperature High Trip Point, the second byte must be the temperature Low Trip Point, and the third must be the Resolution (configuration register).
Throws:
OneWireIOException -  
OneWireException -  

copyScratchpad

public void copyScratchpad()
                    throws OneWireIOException,
                           OneWireException
Copy the Scratchpad to the Esquared memory of the DS18B20.
Throws:
OneWireIOException -  
OneWireException -  

recallE2

public byte[] recallE2()
                throws OneWireIOException,
                       OneWireException
Recalls the DS18B20 temperature trigger values (th & tl) and the configuration register to the scratchpad and reads the scratchpad.
Returns:
byte array representing the device's scratchpad.
Throws:
OneWireIOException -  
OneWireException -  

isExternalPowerSupplied

public boolean isExternalPowerSupplied()
                                throws OneWireIOException,
                                       OneWireException
Reads the way power is supplied to the DS18B20.
Returns:
true for external power, false for parasite power
Throws:
OneWireIOException -  
OneWireException -  

convertToFahrenheit

public float convertToFahrenheit(float celsiusTemperature)
Convert a temperature from celsius to fahrenheit.
Parameters:
celsiusTemperature -  
Returns:
the fahrenheit conversion of the supplied temperature