com.dalsemi.onewire.container
Class OneWireContainer26

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

public class OneWireContainer26
extends OneWireContainer
implements ADContainer, TemperatureContainer, ClockContainer

The DS2438 Smart Battery Monitor provides several functions that are desirable to carry in a battery pack: a means of tagging a battery pack with a unique serial number, a direct-to-digital tmperature sensor which eliminates the need for thermistors in the pack, an A/D converter which measures the battery voltage and current, an integrated current accumulator which keeps a running total of all current going into and out of the battery, an elapsed time meter, and 40 bytes of nonvolatile EEPROM memory for storage of important parameters. 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.

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
 
Constructor Summary
OneWireContainer26()
          Default constructor
OneWireContainer26(DSPortAdapter sourceAdapter, byte[] newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer26(DSPortAdapter sourceAdapter, long newAddress)
          Create a container with a provided adapter object and the address of the iButton or 1-Wire device.
OneWireContainer26(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
 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 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.
 java.lang.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.
 java.lang.String getDescription()
          Return a short description of the function of the iButton 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.
 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.
 java.lang.String getName()
          Returns the Dallas Semiconductor part number of the iButton 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 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.
 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 setICA(int icaValue)
          Set the value of the ICA.
 void setSenseResitor(double resistance)
          Set the value of the sense resistor you are using to determine battery current.
 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 the DS2438.
 
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 iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
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 iButton or 1-Wire device.
Parameters:
sourceAdapter - adapter object required to communicate with this iButton.
newAddress - address of this 1-Wire device

OneWireContainer26

public OneWireContainer26(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()
Returns the Dallas Semiconductor part number of the iButton as a string.
Overrides:
getName in class OneWireContainer
Returns:
String representation of the iButton name

getAlternateNames

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

getDescription

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

setSenseResitor

public void setSenseResitor(double resistance)
Set the value of the sense resistor you are using 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.

readPage

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

writePage

public void writePage(int page,
                      byte[] source,
                      int offset)
               throws OneWireIOException,
                      OneWireException
Writes a page of memory to the DS2438. 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:
int - indicating the page number.
byte[] - containing the 8 bytes of the page.
offset -  
page -  
source -  
Throws:
OneWireIOException - Error writing data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

getFlag

public boolean getFlag(byte flagToGet)
                throws OneWireIOException,
                       OneWireException,
                       java.lang.IllegalArgumentException
Checks the specified flag in the status/configuration register and returns its status as a boolean.
Parameters:
byte - containing the 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).

flagToGet -  
Returns:
 
Throws:
OneWireIOException - Error reading data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

setFlag

public void setFlag(byte flagToSet,
                    boolean flagValue)
             throws OneWireIOException,
                    OneWireException,
                    java.lang.IllegalArgumentException
Set one of the flags in the STATUS/CONFIGURATION register.
Parameters:
byte - with bitmask of the flag to set.

Acceptable parameters: IAD_FLAG, CA_FLAG, EE_FLAG, AD_FLAG, TB_FLAG, NVB_FLAG, ADB_FLAG.

boolean - indicating the value of the flag to set.
flagToSet -  
flagValue -  
Throws:
OneWireIOException - Error setting flag [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

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 -  
Returns:
double containing the current in Amperes.
Throws:
OneWireIOException - Error reading data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

getRemainingCapacity

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

isCharging

public boolean isCharging(byte[] state)
                   throws OneWireIOException,
                          OneWireException,
                          java.lang.IllegalArgumentException
Determines if the battery is charging and returns a boolean.
Parameters:
state -  
Returns:
boolean indicating recharging status.
Throws:
OneWireIOException - Error reading data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

calibrateCurrentADC

public void calibrateCurrentADC()
                         throws OneWireIOException,
                                OneWireException,
                                java.lang.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 [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

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:
byte - specifying whether 0,2,4 or 8 should be the minimum number of bits a current measurement must have to be accumulated.

Only 0,2,4 and 8 are valid parameters.

thresholdValue -  
Throws:
OneWireIOException - Error setting the threshold [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

getICA

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

getCCA

public int getCCA()
           throws OneWireIOException,
                  OneWireException,
                  java.lang.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:
int representation of the CCA value.
Throws:
OneWireIOException - Error reading data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

getDCA

public int getDCA()
           throws OneWireIOException,
                  OneWireException,
                  java.lang.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:
int representation of the DCA value.
Throws:
OneWireIOException - Error reading data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

setICA

public void setICA(int icaValue)
            throws OneWireIOException,
                   OneWireException,
                   java.lang.IllegalArgumentException
Set the value of the ICA.
Parameters:
int - ranging from 0-255 to store in ICA.
icaValue -  
Throws:
OneWireIOException - Error writing data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

setCCA

public void setCCA(int ccaValue)
            throws OneWireIOException,
                   OneWireException,
                   java.lang.IllegalArgumentException
Set the value of the CCA.
Parameters:
int - ranging from 0-255 to store in CCA.
ccaValue -  
Throws:
OneWireIOException - Error writing data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

setDCA

public void setDCA(int dcaValue)
            throws OneWireIOException,
                   OneWireException,
                   java.lang.IllegalArgumentException
Set the value of the DCA.
Parameters:
int - ranging from 0-255 to store in DCA.
dcaValue -  
Throws:
OneWireIOException - Error writing data [ recoverable ]
OneWireException - Could not find part [ fatal ]
java.lang.IllegalArgumentException - Bad parameters passed [recoverable ]

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 - - byte array of device state
Returns:
long<\code> 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 - - byte array of device state
Returns:
long<\code> 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:
int containing the 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:
boolean, 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
Returns:
array of double indicated the 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
range -  
Returns:
array of double, indicated the 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:
boolean, true if 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
state - - byte array of the current state of the device returned from 'readDevice()'.
Throws:
OneWireIOException -  
OneWireException -  

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 - - boolean array representing which channels to perform conversion on.
state - - byte array of the current state of the device returned from 'readDevice()'.
Throws:
OneWireIOException -  
OneWireException -  

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 - - byte array of the current state of the device returned from 'readDevice()'.
Returns:
- double[] representing the voltage values for all channels
Throws:
OneWireIOException -  
OneWireException -  

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
state - - byte array of the current state of the device returned from 'readDevice()'.
Returns:
- double representing the voltage value for the specified channel
Throws:
OneWireIOException -  
OneWireException -  

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
alarmType - - int, representing the desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - - byte array of the current state of the device returned from 'readDevice()'.
Returns:
- double representing the alarm_value in volts

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
alarmType - - int, representing the desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - - byte array of the current state of the state returned from 'readDevice()'.
Returns:
- boolean, true if specified alarm is enabled

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
alarmType - - int, representing the desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
state - - byte array of the current state of the state returned from 'readDevice()'.
Returns:
- boolean, true if specified alarm occurred

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
state - - byte array of the current state of the state returned from 'readDevice()'.
Returns:
- double, 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
state - - byte array of the current state of the state returned from 'readDevice()'.
Returns:
- double representing the 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
alarmType - - int, representing the desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarm - - double, alarm value (will be reduced to 8 bit resolution).
state - - byte array of the current state of the device returned from 'readDevice()'.

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
alarmType - - int, representing the desired alarm, ALARM_HIGH (1) or ALARM_LOW (0)
alarmEnable - - boolean, alarm enable value
state - - byte array of the current state of the device returned from 'readDevice()'.

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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
resolution - - double, resolution to use in volts
state - - byte array of the 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 - - integer specifying channel in the range [0 to (getNumberChannels() - 1)].
range - - double, representing the max volt range, use 'getRanges()' method to get available ranges
state - - byte array of the 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:
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 -  

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()
                                     throws OneWireException
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)
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)
                           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 - - 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

hasClockAlarm

public boolean hasClockAlarm()
Query to see if the clock has an alarm feature.
Specified by:
hasClockAlarm in interface ClockContainer
Returns:
boolean, 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:
boolean, 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:
long, get the 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 - - byte array of device state
Returns:
long<\code> 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 - - byte array of device state
Returns:
long<\code> time - in milliseconds that have the clock alarm is set to.

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 - - byte array of device state
Returns:
boolean<\code> 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 - - byte array of device state
Returns:
boolean<\code> 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 - - byte array of device state
Returns:
boolean<\code> true

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 - - long<\code> milliseconds the user wants the Clock set to.
state - - byte array of 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 - - long<\code> milliseconds the user wants the Clock alarm set to.
state - - byte array of device state

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 - - boolean, true if want the clock oscillator to be enabled.
state - - byte array of device state

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 - - boolean, true to enable the clock alarm
state - - byte array of device state