com.dalsemi.onewire.container
Class OneWireContainer26

java.lang.Object
  |
  +--com.dalsemi.onewire.container.OneWireContainer
        |
        +--com.dalsemi.onewire.container.OneWireContainer26
All Implemented Interfaces:
ADContainer, ClockContainer, HumidityContainer, OneWireSensor, TemperatureContainer

public class OneWireContainer26
extends OneWireContainer
implements ADContainer, TemperatureContainer, ClockContainer, HumidityContainer

1-Wire® container that encapsulates the functionality of the 1-Wire family type 26 (hex), Dallas Semiconductor part number: DS2438, Smart Battery Monitor.

Features

Note

Sometimes the VAD input will report 10.23 V even if nothing is attached. This value is also the maximum voltage that part can report.

DataSheet

http://pdfserv.maxim-ic.com/arpdf/DS2438.pdf (not active yet, Sep-06-2001)
http://www.ibutton.com/weather/humidity.html

Version:
0.00, 28 Aug 2000

Field Summary
static byte AD_FLAG
          Flag to set/check the voltage A/D Input Select Bit with setFlag/getFlag When this bit is true the battery input is (VDD) is selected as input for the voltage A/D input.
static byte ADB_FLAG
          Flag to check whether or not the A/D converter is busy using getFlag().
static byte CA_FLAG
          Flag to set/check the Current Accumulator bit with setFlag/getFlag.
static int CHANNEL_VAD
          Channel selector for the VAD input.
static int CHANNEL_VDD
          Channel selector for the VDD input.
static byte EE_FLAG
          Flag to set/check the Current Accumulator Shadow Selector bit with setFlag/getFlag.
static byte IAD_FLAG
          Flag to set/check the Current A/D Control bit with setFlag/getFlag.
static byte NVB_FLAG
          Flag to check whether or not an operation is being performed on the nonvolatile memory using getFlag.
static byte TB_FLAG
          Flag to check whether or not a temperature conversion is in progress using getFlag().
 
Fields inherited from interface com.dalsemi.onewire.container.ADContainer
ALARM_HIGH, ALARM_LOW
 
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
ALARM_HIGH, ALARM_LOW
 
Fields inherited from interface com.dalsemi.onewire.container.HumidityContainer
ALARM_HIGH, ALARM_LOW
 
Constructor Summary
OneWireContainer26()
          Default constructor
OneWireContainer26(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the 1-Wire device.
OneWireContainer26(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the 1-Wire device.
OneWireContainer26(DSPortAdapter sourceAdapter, String newAddress)
          Create a container with a provided adapter object and the address of the 1-Wire device.
 
Method Summary
 void calibrateCurrentADC()
          Calibrate the current ADC.
 boolean canADMultiChannelRead()
          Query to see if this A/D supports doing multiple voltage conversions at the same time.
 boolean canDisableClock()
          Query to see if the clock can be disabled.
 void doADConvert(boolean[] doConvert, byte[] state)
          This method is used to perform voltage conversion on all specified channels.
 void doADConvert(int channel, byte[] state)
          This method is used to perform voltage conversion on all specified channels.
 void doHumidityConvert(byte[] state)
          Performs a Humidity conversion.
 void doTemperatureConvert(byte[] state)
          Perform an temperature conversion.
 double getADAlarm(int channel, int alarmType, byte[] state)
          This method is used to extract the alarm voltage value of the specified channel from the provided state buffer.
 boolean getADAlarmEnable(int channel, int alarmType, byte[] state)
          This method is used to extract the alarm enable value of the specified channel from the provided state buffer.
 double getADRange(int channel, byte[] state)
          This method is used to extract the input voltage range of the specified channel from the provided state buffer.
 double[] getADRanges(int channel)
          Query to get an array of available ranges for the specified A/D channel.
 double getADResolution(int channel, byte[] state)
          This method is used to extract the conversion resolution of the specified channel from the provided state buffer expressed in volts.
 double[] getADResolutions(int channel, double range)
          Query to get an array of available resolutions based on the specified range on the specified A/D channel.
 double[] getADVoltage(byte[] state)
          This method is used to read the voltage values.
 double getADVoltage(int channel, byte[] state)
          This method is used to read a channels voltage value.
 String getAlternateNames()
          Return the alternate Dallas Semiconductor part number or name.
 int getCCA()
          Retrieves the current CCA value in mVHr.
 long getClock(byte[] state)
          This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
 long getClockAlarm(byte[] state)
          This method extracts the Clock Alarm Value from the provided state data retrieved from the readDevice() method.
 long getClockResolution()
          Query to get the clock resolution in milliseconds
 double getCurrent(byte[] state)
          Get the instantaneous current.
 int getDCA()
          Retrieves the value of the DCA in mVHr.
 String getDescription()
          Return a short description of the function of this 1-Wire device type.
 long getDisconnectTime(byte[] state)
          This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
 long getEndOfChargeTime(byte[] state)
          This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
 boolean getFlag(byte flagToGet)
          Checks the specified flag in the status/configuration register and returns its status as a boolean.
 double getHumidity(byte[] state)
          Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.
 double getHumidityAlarm(int alarmType, byte[] state)
          Gets the specified Humidity alarm value in percent from the state data retrieved from the readDevice() method.
 double getHumidityAlarmResolution()
          Gets the Humidity alarm resolution in percent.
 double getHumidityResolution(byte[] state)
          Gets the current Humidity resolution in percent from the state data retrieved from the readDevice() method.
 double[] getHumidityResolutions()
          Get an array of available Humidity resolutions in percent humidity (0 to 100).
 int getICA()
          Retrieves the current ICA value in mVHr.
 double getMaxTemperature()
          Query to get the maximum temperature in degrees C.
 double getMinTemperature()
          Query to get the minimum temperature in degrees C.
 String getName()
          Returns the Dallas Semiconductor part number of this 1-Wire device as a string.
 int getNumberADChannels()
          Query to get the number of channels supported by this A/D.
 double getRemainingCapacity()
          Calculate the remaining capacity in mAH as outlined in the data sheet.
 double getSenseResistor()
          Get the value used for the sense resistor in the getCurrent() calculations.
 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 hasADAlarmed(int channel, int alarmType, byte[] state)
          This method is used to check the alarm event value of the specified channel from the provided state buffer.
 boolean hasADAlarms()
          Query to see if this A/D measuring device has high/low alarms.
 boolean hasClockAlarm()
          Query to see if the clock has an alarm feature.
 boolean hasHumidityAlarms()
          Checks to see if this Humidity measuring device has high/low trip alarms.
 boolean hasSelectableHumidityResolution()
          Checks to see if this device has selectable Humidity resolution.
 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 isCharging(byte[] state)
          Determines if the battery is charging and returns a boolean.
 boolean isClockAlarmEnabled(byte[] state)
          This method checks if the Clock Alarm is enabled from the provided state data retrieved from the readDevice() method.
 boolean isClockAlarming(byte[] state)
          This method checks if the Clock Alarm flag has been set from the state data retrieved from the readDevice() method.
 boolean isClockRunning(byte[] state)
          This method checks if the device's oscilator is enabled.
 boolean isRelative()
          Checks to see if humidity value given is a 'relative' humidity value.
 byte[] readDevice()
          This method retrieves the 1-Wire device sensor state.
 byte[] readPage(int page)
          Reads the specified 8 byte page and returns the data in an array.
 void setADAlarm(int channel, int alarmType, double alarm, byte[] state)
          This method is used to set the alarm voltage value of the specified channel in the provided state buffer.
 void setADAlarmEnable(int channel, int alarmType, boolean alarmEnable, byte[] state)
          This method is used to set the alarm enable value of the specified channel in the provided state buffer.
 void setADRange(int channel, double range, byte[] state)
          This method is used to set the input range for the specified channel in the provided state buffer.
 void setADResolution(int channel, double resolution, byte[] state)
          This method is used to set the conversion resolution value for the specified channel in the provided state buffer.
 void setCCA(int ccaValue)
          Set the value of the CCA.
 void setClock(long time, byte[] state)
          This method sets the Clock time in the provided state data Use the method writeDevice() with this data to finalize the change to the device.
 void setClockAlarm(long time, byte[] state)
          This method sets the Clock Alarm in the provided state data.
 void setClockAlarmEnable(boolean alarmEnable, byte[] state)
          This method sets the Clock Alarm enable.
 void setClockRunEnable(boolean runEnable, byte[] state)
          This method sets the oscillator enable to the specified value.
 void setDCA(int dcaValue)
          Set the value of the DCA.
 void setFlag(byte flagToSet, boolean flagValue)
          Set one of the flags in the STATUS/CONFIGURATION register.
 void setHumidityAlarm(int alarmType, double alarmValue, byte[] state)
          Sets the Humidity alarm value in percent in the provided state data.
 void setHumidityResolution(double resolution, byte[] state)
          Sets the current Humidity resolution in percent in the provided state data.
 void setICA(int icaValue)
          Set the value of the ICA.
 void setSenseResistor(double resistance)
          Set the value of the sense resistor used to determine battery current.
 void setSpeedCheck(boolean doSpeedCheck)
          Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron.
 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 setThreshold(byte thresholdValue)
          Set the minimum current measurement magnitude for which the ICA/CCA/DCA are incremented.
 void writeDevice(byte[] state)
          This method write the 1-Wire device sensor state that have been changed by the 'set' methods.
 void writePage(int page, byte[] source, int offset)
          Writes a page of memory to this device.
 
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

CHANNEL_VDD

public static final int CHANNEL_VDD
Channel selector for the VDD input. Meant to be used with a battery.

CHANNEL_VAD

public static final int CHANNEL_VAD
Channel selector for the VAD input. This is the general purpose A-D input.

IAD_FLAG

public static final byte IAD_FLAG
Flag to set/check the Current A/D Control bit with setFlag/getFlag. When this bit is true, the current A/D and the ICA are enabled and current measurements will be taken at the rate of 36.41 Hz.

CA_FLAG

public static final byte CA_FLAG
Flag to set/check the Current Accumulator bit with setFlag/getFlag. When this bit is true, both the total discharging and charging current are integrated into seperate registers and can be used for determining full/empty levels. When this bit is zero the memory (page 7) can be used as user memory.

EE_FLAG

public static final byte EE_FLAG
Flag to set/check the Current Accumulator Shadow Selector bit with setFlag/getFlag. When this bit is true the CCA/DCA registers used to add up charging/discharging current are shadowed to EEPROM to protect against loss of data if the battery pack becomes discharged.

AD_FLAG

public static final byte AD_FLAG
Flag to set/check the voltage A/D Input Select Bit with setFlag/getFlag When this bit is true the battery input is (VDD) is selected as input for the voltage A/D input. When false the general purpose A/D input (VAD) is selected as the voltage A/D input.

TB_FLAG

public static final byte TB_FLAG
Flag to check whether or not a temperature conversion is in progress using getFlag().

NVB_FLAG

public static final byte NVB_FLAG
Flag to check whether or not an operation is being performed on the nonvolatile memory using getFlag.

ADB_FLAG

public static final byte ADB_FLAG
Flag to check whether or not the A/D converter is busy using getFlag().
Constructor Detail

OneWireContainer26

public OneWireContainer26()
Default constructor

OneWireContainer26

public OneWireContainer26(DSPortAdapter sourceAdapter,
                          byte[] newAddress)
Create a container with a provided adapter object and the address of the 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this 1-Wire device
newAddress - address of this 1-Wire device

OneWireContainer26

public OneWireContainer26(DSPortAdapter sourceAdapter,
                          long newAddress)
Create a container with a provided adapter object and the address of the 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this 1-Wire device
newAddress - address of this 1-Wire device

OneWireContainer26

public OneWireContainer26(DSPortAdapter sourceAdapter,
                          String newAddress)
Create a container with a provided adapter object and the address of the 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this 1-Wire device
newAddress - address of this 1-Wire device
Method Detail

getName

public String getName()
Returns the Dallas Semiconductor part number of this 1-Wire device as a string.
Overrides:
getName in class OneWireContainer
Returns:
representation of this 1-Wire device's name

getAlternateNames

public String getAlternateNames()
Return the alternate Dallas Semiconductor part number or name. ie. Smart Battery Monitor
Overrides:
getAlternateNames in class OneWireContainer
Returns:
representation of the alternate name(s)

getDescription

public String getDescription()
Return a short description of the function of this 1-Wire device type.
Overrides:
getDescription in class OneWireContainer
Returns:
representation of the functional description

setSenseResistor

public void setSenseResistor(double resistance)
Set the value of the sense resistor used to determine battery current. This value is used in the getCurrent() calculation. See the DS2438 datasheet for more information on sensing battery current.
Parameters:
resistance - Value of the sense resistor in Ohms.

getSenseResistor

public double getSenseResistor()
Get the value used for the sense resistor in the getCurrent() calculations.
Returns:
currently stored value of the sense resistor in Ohms

setSpeedCheck

public void setSpeedCheck(boolean doSpeedCheck)
Directs the container to avoid the calls to doSpeed() in methods that communicate with the Thermocron. To ensure that all parts can talk to the 1-Wire bus at their desired speed, each method contains a call to doSpeed(). However, this is an expensive operation. If a user manages the bus speed in an application, call this method with doSpeedCheck as false. The default behavior is to call doSpeed().
Parameters:
doSpeedCheck - true for doSpeed() to be called before every 1-Wire bus access, false to skip this expensive call
See Also:
OneWireContainer.doSpeed()

readPage

public byte[] readPage(int page)
                throws OneWireIOException,
                       OneWireException,
                       IllegalArgumentException
Reads the specified 8 byte page and returns the data in an array.
Parameters:
page - the page number to read
Returns:
eight byte array that make up the page
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

writePage

public void writePage(int page,
                      byte[] source,
                      int offset)
               throws OneWireIOException,
                      OneWireException
Writes a page of memory to this device. Pages 3-6 are always available for user storage and page 7 is available if the CA bit is set to 0 (false) with setFlag().
Parameters:
page - the page number
source - data to be written to page
offset - offset with page to begin writting
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getFlag

public boolean getFlag(byte flagToGet)
                throws OneWireIOException,
                       OneWireException,
                       IllegalArgumentException
Checks the specified flag in the status/configuration register and returns its status as a boolean.
Parameters:
flagToGet - flag bitmask. Acceptable parameters: IAD_FLAG, CA_FLAG, EE_FLAG, AD_FLAG, TB_FLAG, NVB_FLAG, ADB_FLAG (may be ORed with | to check the status of more than one).
Returns:
state of flag
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

setFlag

public void setFlag(byte flagToSet,
                    boolean flagValue)
             throws OneWireIOException,
                    OneWireException,
                    IllegalArgumentException
Set one of the flags in the STATUS/CONFIGURATION register.
Parameters:
bitmask - of the flag to set Acceptable parameters: IAD_FLAG, CA_FLAG, EE_FLAG, AD_FLAG, TB_FLAG, NVB_FLAG, ADB_FLAG.
flagValue - value to set flag to
Throws:
OneWireIOException - Error writting data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getCurrent

public double getCurrent(byte[] state)
Get the instantaneous current. The IAD flag must be true!! Remember to set the Sense resistor value using setSenseResitor(double).
Parameters:
state - current state of device
Returns:
current value in Amperes

getRemainingCapacity

public double getRemainingCapacity()
                            throws OneWireIOException,
                                   OneWireException,
                                   IllegalArgumentException
Calculate the remaining capacity in mAH as outlined in the data sheet.
Returns:
battery capacity remaining in mAH
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

isCharging

public boolean isCharging(byte[] state)
                   throws OneWireIOException,
                          OneWireException,
                          IllegalArgumentException
Determines if the battery is charging and returns a boolean.
Parameters:
state - current state of device
Returns:
true if battery is changing, false if battery is idle or discharging
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

calibrateCurrentADC

public void calibrateCurrentADC()
                         throws OneWireIOException,
                                OneWireException,
                                IllegalArgumentException
Calibrate the current ADC. Although the part is shipped calibrated, calibrations should be done whenever possible for best results. NOTE: You MUST force zero current through Rsens (the sensor resistor) while calibrating.
Throws:
OneWireIOException - Error calibrating
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

setThreshold

public void setThreshold(byte thresholdValue)
                  throws OneWireIOException,
                         OneWireException
Set the minimum current measurement magnitude for which the ICA/CCA/DCA are incremented. This is important for applications where the current may get very small for long periods of time. Small currents can be inaccurate by a high percentage, which leads to very inaccurate accumulations.
Parameters:
threshold - minimum number of bits a current measurement must have to be accumulated, Only 0,2,4 and 8 are valid parameters
Throws:
OneWireIOException - Error setting the threshold
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getICA

public int getICA()
           throws OneWireIOException,
                  OneWireException,
                  IllegalArgumentException
Retrieves the current ICA value in mVHr.
Returns:
value in the ICA register
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getCCA

public int getCCA()
           throws OneWireIOException,
                  OneWireException,
                  IllegalArgumentException
Retrieves the current CCA value in mVHr. This value is accumulated over the lifetime of the part (until it is set to 0 or the CA flag is set to false) and includes only charging current (positive).
Returns:
CCA value
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getDCA

public int getDCA()
           throws OneWireIOException,
                  OneWireException,
                  IllegalArgumentException
Retrieves the value of the DCA in mVHr. This value is accumulated over the lifetime of the part (until explicitly set to 0 or if the CA flag is set to false) and includes only discharging current (negative).
Returns:
DCA value
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

setICA

public void setICA(int icaValue)
            throws OneWireIOException,
                   OneWireException,
                   IllegalArgumentException
Set the value of the ICA.
Parameters:
icaValue - new ICA value
Throws:
OneWireIOException - Error writing data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

setCCA

public void setCCA(int ccaValue)
            throws OneWireIOException,
                   OneWireException,
                   IllegalArgumentException
Set the value of the CCA.
Parameters:
ccaValue - new CCA value
Throws:
OneWireIOException - Error writing data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

setDCA

public void setDCA(int dcaValue)
            throws OneWireIOException,
                   OneWireException,
                   IllegalArgumentException
Set the value of the DCA.
Parameters:
dcaValue - new DCA value
Throws:
OneWireIOException - Error writing data
OneWireException - Could not find part
IllegalArgumentException - Bad parameters passed

getDisconnectTime

public long getDisconnectTime(byte[] state)
This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
Parameters:
state - device state
Returns:
time in milliseconds that have occured since 1970

getEndOfChargeTime

public long getEndOfChargeTime(byte[] state)
This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
Parameters:
state - device state
Returns:
time in milliseconds that have occured since 1970

getNumberADChannels

public int getNumberADChannels()
Query to get the number of channels supported by this A/D. Channel specific methods will use a channel number specified by an integer from [0 to (getNumberChannels() - 1)].
Specified by:
getNumberADChannels in interface ADContainer
Returns:
number of channels

hasADAlarms

public boolean hasADAlarms()
Query to see if this A/D measuring device has high/low alarms.
Specified by:
hasADAlarms in interface ADContainer
Returns:
true if has high/low trips

getADRanges

public double[] getADRanges(int channel)
Query to get an array of available ranges for the specified A/D channel.
Specified by:
getADRanges in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
Returns:
available ranges

getADResolutions

public double[] getADResolutions(int channel,
                                 double range)
Query to get an array of available resolutions based on the specified range on the specified A/D channel.
Specified by:
getADResolutions in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
range - A/D range
Returns:
available resolutions

canADMultiChannelRead

public boolean canADMultiChannelRead()
Query to see if this A/D supports doing multiple voltage conversions at the same time.
Specified by:
canADMultiChannelRead in interface ADContainer
Returns:
true if device can do multi-channel voltage reads

doADConvert

public void doADConvert(int channel,
                        byte[] state)
                 throws OneWireIOException,
                        OneWireException
This method is used to perform voltage conversion on all specified channels. The method 'getVoltage()' can be used to read the result of the conversion.
Specified by:
doADConvert in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
state - current state of the device returned from readDevice()
Throws:
OneWireIOException - Error writing data
OneWireException - Could not find part

doADConvert

public void doADConvert(boolean[] doConvert,
                        byte[] state)
                 throws OneWireIOException,
                        OneWireException
This method is used to perform voltage conversion on all specified channels. The method getVoltage() can be used to read the result of the conversion. This A/D must support multi-channel read canMultiChannelRead() if there are more then 1 channel is specified.
Specified by:
doADConvert in interface ADContainer
Parameters:
doConvert - channels to perform conversion on
state - current state of the device returned from readDevice()
Throws:
OneWireIOException - Error writing data
OneWireException - Could not find part

getADVoltage

public double[] getADVoltage(byte[] state)
                      throws OneWireIOException,
                             OneWireException
This method is used to read the voltage values. Must be used after a doADConvert() method call. Also must include the last valid state from the readDevice() method and this A/D must support multi-channel read canMultiChannelRead() if there are more then 1 channel.
Specified by:
getADVoltage in interface ADContainer
Parameters:
state - current state of the device returned from readDevice()
Returns:
voltage values for all channels
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part

getADVoltage

public double getADVoltage(int channel,
                           byte[] state)
                    throws OneWireIOException,
                           OneWireException
This method is used to read a channels voltage value. Must be used after a doADConvert() method call. Also must include the last valid state from the readDevice() method. Note, if more then one channel is to be read then it is more efficient to use the getVoltage() method that returns all channel values.
Specified by:
getADVoltage in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
state - current state of the device returned from readDevice()
Returns:
voltage value for the specified channel
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part

getADAlarm

public double getADAlarm(int channel,
                         int alarmType,
                         byte[] state)
                  throws OneWireException
This method is used to extract the alarm voltage value of the specified channel from the provided state buffer. The state buffer is retrieved from the readDevice() method.
Specified by:
getADAlarm in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
alarmType - desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - current state of the device returned from readDevice()
Returns:
alarm_value in volts
Throws:
OneWireException - Device does not support A/D alarms

getADAlarmEnable

public boolean getADAlarmEnable(int channel,
                                int alarmType,
                                byte[] state)
                         throws OneWireException
This method is used to extract the alarm enable value of the specified channel from the provided state buffer. The state buffer is retrieved from the readDevice() method.
Specified by:
getADAlarmEnable in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
alarmType - desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - current state of the state returned from readDevice()
Returns:
true if specified alarm is enabled
Throws:
OneWireException - Device does not support A/D alarms

hasADAlarmed

public boolean hasADAlarmed(int channel,
                            int alarmType,
                            byte[] state)
                     throws OneWireException
This method is used to check the alarm event value of the specified channel from the provided state buffer. The state buffer is retrieved from the readDevice() method.
Specified by:
hasADAlarmed in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
alarmType - desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - current state of the state returned from readDevice()
Returns:
true if specified alarm occurred
Throws:
OneWireException - Device does not support A/D alarms

getADResolution

public double getADResolution(int channel,
                              byte[] state)
This method is used to extract the conversion resolution of the specified channel from the provided state buffer expressed in volts. The state is retrieved from the readDevice() method.
Specified by:
getADResolution in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
state - current state of the state returned from readDevice()
Returns:
resolution of channel in volts

getADRange

public double getADRange(int channel,
                         byte[] state)
This method is used to extract the input voltage range of the specified channel from the provided state buffer. The state buffer is retrieved from the readDevice() method.
Specified by:
getADRange in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
state - current state of the state returned from readDevice()
Returns:
input voltage range

setADAlarm

public void setADAlarm(int channel,
                       int alarmType,
                       double alarm,
                       byte[] state)
                throws OneWireException
This method is used to set the alarm voltage value of the specified channel in the provided state buffer. The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().
Specified by:
setADAlarm in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
alarmType - desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarm - alarm value (will be reduced to 8 bit resolution)
state - current state of the device returned from readDevice()
Throws:
OneWireException - Device does not support A/D alarms

setADAlarmEnable

public void setADAlarmEnable(int channel,
                             int alarmType,
                             boolean alarmEnable,
                             byte[] state)
                      throws OneWireException
This method is used to set the alarm enable value of the specified channel in the provided state buffer. The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().
Specified by:
setADAlarmEnable in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
alarmType - desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarmEnable - alarm enable value
state - current state of the device returned from readDevice()
Throws:
OneWireException - Device does not support A/D alarms

setADResolution

public void setADResolution(int channel,
                            double resolution,
                            byte[] state)
This method is used to set the conversion resolution value for the specified channel in the provided state buffer. The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().
Specified by:
setADResolution in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
resolution - resolution to use in volts
state - current state of the device returned from readDevice()

setADRange

public void setADRange(int channel,
                       double range,
                       byte[] state)
This method is used to set the input range for the specified channel in the provided state buffer. The state buffer is retrieved from the readDevice() method. The method writeDevice() must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call to writeDevice().
Specified by:
setADRange in interface ADContainer
Parameters:
channel - channel in the range [0 to (getNumberChannels() - 1)]
range - maximum volt range, use getRanges() method to get available ranges
state - current state of the device returned from readDevice()

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:
1-Wire device's state
Throws:
OneWireIOException - Error reading data
OneWireException - Could not find part

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 - device's state
Throws:
OneWireIOException - Error writting data
OneWireException - Could not find part

hasTemperatureAlarms

public boolean hasTemperatureAlarms()
Query to see if this temperature measuring device has high/low trip alarms.
Specified by:
hasTemperatureAlarms in interface TemperatureContainer
Returns:
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:
true if device 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:
available resolutions in degrees C

getTemperatureAlarmResolution

public double getTemperatureAlarmResolution()
                                     throws OneWireException
Query to get the high/low resolution in degrees C.
Specified by:
getTemperatureAlarmResolution in interface TemperatureContainer
Returns:
high/low resolution resolution in degrees C
Throws:
OneWireException - Device does not have temperature alarms

getMaxTemperature

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

getMinTemperature

public double getMinTemperature()
Query to get the minimum temperature in degrees C.
Specified by:
getMinTemperature in interface TemperatureContainer
Returns:
minimum temperature in degrees 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 - device state
Throws:
OneWireIOException - Error writting data
OneWireException - Could not find part

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 - device state
Returns:
temperature in degrees C from the last doTemperature()

getTemperatureAlarm

public double getTemperatureAlarm(int alarmType,
                                  byte[] state)
                           throws OneWireException
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 - alarm trip type ALARM_HIGH (1) or ALARM_LOW (0)
state - device state
Returns:
alarm trip temperature in degrees C
Throws:
OneWireException - Device does not have temperature alarms

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 - device state
Returns:
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 - alarm type ALARM_HIGH (1) or ALARM_LOW (0)
alarmValue - trip value in degrees C
state - device state
Throws:
OneWireException - Device does not have temperature alarms

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 - temperature resolution in degrees C
state - device state
Throws:
OneWireIOException - Error writting data
OneWireException - Could not find part

hasClockAlarm

public boolean hasClockAlarm()
Query to see if the clock has an alarm feature.
Specified by:
hasClockAlarm in interface ClockContainer
Returns:
true if real-time-clock has an alarm

canDisableClock

public boolean canDisableClock()
Query to see if the clock can be disabled. See the methods isClockRunning() and setClockRunEnable().
Specified by:
canDisableClock in interface ClockContainer
Returns:
true if the clock can be enabled and disabled

getClockResolution

public long getClockResolution()
Query to get the clock resolution in milliseconds
Specified by:
getClockResolution in interface ClockContainer
Returns:
clock resolution in milliseconds.

getClock

public long getClock(byte[] state)
This method extracts the Clock Value in milliseconds from the state data retrieved from the readDevice() method.
Specified by:
getClock in interface ClockContainer
Parameters:
state - device state
Returns:
time in milliseconds that have occured since 1970

getClockAlarm

public long getClockAlarm(byte[] state)
                   throws OneWireException
This method extracts the Clock Alarm Value from the provided state data retrieved from the readDevice() method.
Specified by:
getClockAlarm in interface ClockContainer
Parameters:
state - device state
Returns:
time in milliseconds that have the clock alarm is set to
Throws:
OneWireException - Device does not have clock alarm

isClockAlarming

public boolean isClockAlarming(byte[] state)
This method checks if the Clock Alarm flag has been set from the state data retrieved from the readDevice() method.
Specified by:
isClockAlarming in interface ClockContainer
Parameters:
state - device state
Returns:
true if clock is alarming

isClockAlarmEnabled

public boolean isClockAlarmEnabled(byte[] state)
This method checks if the Clock Alarm is enabled from the provided state data retrieved from the readDevice() method.
Specified by:
isClockAlarmEnabled in interface ClockContainer
Parameters:
state - device state
Returns:
true if clock alarm is enabled

isClockRunning

public boolean isClockRunning(byte[] state)
This method checks if the device's oscilator is enabled. The clock will not increment if the clock is not enabled. This value is read from the provided state data retrieved from the readDevice() method.
Specified by:
isClockRunning in interface ClockContainer
Parameters:
state - device state
Returns:
true if clock is running

setClock

public void setClock(long time,
                     byte[] state)
This method sets the Clock time in the provided state data Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setClock in interface ClockContainer
Parameters:
time - new clock setting in milliseconds
state - device state

setClockAlarm

public void setClockAlarm(long time,
                          byte[] state)
                   throws OneWireException
This method sets the Clock Alarm in the provided state data. Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setClockAlarm in interface ClockContainer
Parameters:
time - new clock setting in mlliseconds
state - device state
Throws:
OneWireException - Device does not support clock alarm

setClockRunEnable

public void setClockRunEnable(boolean runEnable,
                              byte[] state)
                       throws OneWireException
This method sets the oscillator enable to the specified value. Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setClockRunEnable in interface ClockContainer
Parameters:
runEnable - true to enable clock oscillator
state - device state
Throws:
OneWireException - Device does not support disabled clock

setClockAlarmEnable

public void setClockAlarmEnable(boolean alarmEnable,
                                byte[] state)
                         throws OneWireException
This method sets the Clock Alarm enable. Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setClockAlarmEnable in interface ClockContainer
Parameters:
alarmEnable - - true to enable clock alarm
state - device state
Throws:
OneWireException - Device does not support clock alarm

isRelative

public boolean isRelative()
Checks to see if humidity value given is a 'relative' humidity value.
Specified by:
isRelative in interface HumidityContainer
Returns:
true if this HumidityContainer provides a relative humidity reading
See Also:
getHumidityResolution(byte[]), getHumidityResolutions(), setHumidityResolution(double, byte[])

hasHumidityAlarms

public boolean hasHumidityAlarms()
Checks to see if this Humidity measuring device has high/low trip alarms.
Specified by:
hasHumidityAlarms in interface HumidityContainer
Returns:
true if this HumidityContainer has high/low trip alarms
See Also:
getHumidityAlarm(int, byte[]), setHumidityAlarm(int, double, byte[])

hasSelectableHumidityResolution

public boolean hasSelectableHumidityResolution()
Checks to see if this device has selectable Humidity resolution.
Specified by:
hasSelectableHumidityResolution in interface HumidityContainer
Returns:
true if this HumidityContainer has selectable Humidity resolution
See Also:
getHumidityResolution(byte[]), getHumidityResolutions(), setHumidityResolution(double, byte[])

getHumidityResolutions

public double[] getHumidityResolutions()
Get an array of available Humidity resolutions in percent humidity (0 to 100).
Specified by:
getHumidityResolutions in interface HumidityContainer
Returns:
byte array of available Humidity resolutions in percent with minimum resolution as the first element and maximum resolution as the last element.
See Also:
hasSelectableHumidityResolution(), getHumidityResolution(byte[]), setHumidityResolution(double, byte[])

getHumidityAlarmResolution

public double getHumidityAlarmResolution()
                                  throws OneWireException
Gets the Humidity alarm resolution in percent.
Specified by:
getHumidityAlarmResolution in interface HumidityContainer
Returns:
Humidity alarm resolution in percent for this 1-wire device
Throws:
OneWireException - Device does not support Humidity alarms
See Also:
hasHumidityAlarms(), getHumidityAlarm(int, byte[]), setHumidityAlarm(int, double, byte[])

doHumidityConvert

public void doHumidityConvert(byte[] state)
                       throws OneWireIOException,
                              OneWireException
Performs a Humidity conversion.
Specified by:
doHumidityConvert in interface HumidityContainer
Parameters:
state - byte array with device state information
Throws:
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

getHumidity

public double getHumidity(byte[] state)
Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.
Specified by:
getHumidity in interface HumidityContainer
Parameters:
state - byte array with device state information
Returns:
humidity expressed as a percent
See Also:
hasSelectableHumidityResolution(), getHumidityResolution(byte[]), setHumidityResolution(double, byte[])

getHumidityResolution

public double getHumidityResolution(byte[] state)
Gets the current Humidity resolution in percent from the state data retrieved from the readDevice() method.
Specified by:
getHumidityResolution in interface HumidityContainer
Parameters:
state - byte array with device state information
Returns:
Humidity resolution in percent for this 1-wire device
See Also:
hasSelectableHumidityResolution(), getHumidityResolutions(), setHumidityResolution(double, byte[])

getHumidityAlarm

public double getHumidityAlarm(int alarmType,
                               byte[] state)
                        throws OneWireException
Gets the specified Humidity alarm value in percent from the state data retrieved from the readDevice() method.
Specified by:
getHumidityAlarm in interface HumidityContainer
Parameters:
alarmType - valid value: ALARM_HIGH or ALARM_LOW
state - byte array with device state information
Returns:
Humidity alarm trip values in percent for this 1-wire device
Throws:
OneWireException - Device does not support Humidity alarms
See Also:
hasHumidityAlarms(), setHumidityAlarm(int, double, byte[])

setHumidityAlarm

public void setHumidityAlarm(int alarmType,
                             double alarmValue,
                             byte[] state)
                      throws OneWireException
Sets the Humidity alarm value in percent in the provided state data. Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setHumidityAlarm in interface HumidityContainer
Parameters:
alarmType - valid value: ALARM_HIGH or ALARM_LOW
alarmValue - alarm trip value in percent
state - byte array with device state information
Throws:
OneWireException - Device does not support Humidity alarms
See Also:
hasHumidityAlarms(), getHumidityAlarm(int, byte[])

setHumidityResolution

public void setHumidityResolution(double resolution,
                                  byte[] state)
                           throws OneWireException
Sets the current Humidity resolution in percent in the provided state data. Use the method writeDevice() with this data to finalize the change to the device.
Specified by:
setHumidityResolution in interface HumidityContainer
Parameters:
resolution - Humidity resolution in percent
state - byte array with device state information
Throws:
OneWireException - Device does not support selectable Humidity resolution
See Also:
hasSelectableHumidityResolution(), getHumidityResolution(byte[]), getHumidityResolutions()