Package 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), Maxim Integrated Products part number: DS2438, Smart Battery Monitor.
Features
- direct-to-digital temperature sensor
- A/D converters which measures the battery voltage and current
- integrated current accumulator which keeps a running total of all current going into and out of the battery
- elapsed time meter
- 40 bytes of nonvolatile EEPROM memory for storage of important parameters
- Operating temperature range from -40@htmlonly °C @endhtmlonly to +85@htmlonly °C @endhtmlonlyi
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
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 final byte
Flag to check whether or not the A/D converter is busy using getFlag().static final byte
Flag to set/check the Current Accumulator bit with setFlag/getFlag.static final int
Channel selector for the VAD input.static final int
Channel selector for the VDD input.static final int
Channel selectro the the IAD input.static final byte
Flag to set/check the Current Accumulator Shadow Selector bit with setFlag/getFlag.static final byte
Flag to set/check the Current A/D Control bit with setFlag/getFlag.static final byte
Flag to check whether or not an operation is being performed on the nonvolatile memory using getFlag.static final byte
Flag to check whether or not a temperature conversion is in progress using getFlag().Fields inherited from class com.dalsemi.onewire.container.OneWireContainer
adapter, address, speed, speedFallBackOK
Fields inherited from interface com.dalsemi.onewire.container.ADContainer
ALARM_HIGH, ALARM_LOW
Fields inherited from interface com.dalsemi.onewire.container.HumidityContainer
ALARM_HIGH, ALARM_LOW
Fields inherited from interface com.dalsemi.onewire.container.TemperatureContainer
ALARM_HIGH, ALARM_LOW
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorOneWireContainer26
(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
Modifier and TypeMethodDescriptionvoid
Calibrate the current ADC.boolean
Query to see if this A/D supports doing multiple voltage conversions at the same time.boolean
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.Return the alternate Maxim Integrated Products 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 thereadDevice()
method.long
getClockAlarm
(byte[] state) This method extracts the Clock Alarm Value from the provided state data retrieved from thereadDevice()
method.long
Query to get the clock resolution in millisecondsdouble
getCurrent
(byte[] state) Get the instantaneous current.int
getDCA()
Retrieves the value of the DCA in mVHr.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 thereadDevice()
method.long
getEndOfChargeTime
(byte[] state) This method extracts the Clock Value in milliseconds from the state data retrieved from thereadDevice()
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 thestate
data retrieved from thereadDevice()
method.double
Gets the Humidity alarm resolution in percent.double
getHumidityResolution
(byte[] state) Gets the current Humidity resolution in percent from thestate
data retrieved from thereadDevice()
method.double[]
Get an array of available Humidity resolutions in percent humidity (0 to 100).int
getICA()
Retrieves the current ICA value in mVHr.double
Query to get the maximum temperature in degrees C.Gets an enumeration of memory bank instances that implement one or more of the following interfaces:MemoryBank
,PagedMemoryBank
, andOTPMemoryBank
.double
Query to get the minimum temperature in degrees C.getName()
Returns the Maxim Integrated Products part number of this 1-Wire device as a string.int
Query to get the number of channels supported by this A/D.double
Calculate the remaining capacity in mAH as outlined in the data sheet.double
Get the value used for the sense resistor in thegetCurrent()
calculations.double
getTemperature
(byte[] state) This method extracts the Temperature Value in degrees C from the state data retrieved from thereadDevice()
method.double
getTemperatureAlarm
(int alarmType, byte[] state) This method extracts the specified Alarm value in degrees C from the state data retrieved from thereadDevice()
method.double
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 thereadDevice()
method.double[]
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
Query to see if this A/D measuring device has high/low alarms.boolean
Query to see if the clock has an alarm feature.boolean
Checks to see if this Humidity measuring device has high/low trip alarms.boolean
Checks to see if this device has selectable Humidity resolution.boolean
Query to see if this device has selectable resolution.boolean
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 thereadDevice()
method.boolean
isClockAlarming
(byte[] state) This method checks if the Clock Alarm flag has been set from the state data retrieved from thereadDevice()
method.boolean
isClockRunning
(byte[] state) This method checks if the device's oscillator is enabled.boolean
Checks to see if humidity value given is a 'relative' humidity value.byte[]
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 methodwriteDevice()
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 providedstate
data.void
setHumidityResolution
(double resolution, byte[] state) Sets the current Humidity resolution in percent in the providedstate
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, equals, getAdapter, getAddress, getAddressAsLong, getAddressAsString, getMaxSpeed, hashCode, isAlarming, isPresent, setSpeed, setupContainer, setupContainer, setupContainer, toString
-
Field Details
-
CHANNEL_VDD
public static final int CHANNEL_VDDChannel selector for the VDD input. Meant to be used with a battery.- See Also:
-
CHANNEL_VAD
public static final int CHANNEL_VADChannel selector for the VAD input. This is the general purpose A-D input.- See Also:
-
CHANNEL_VSENSE
public static final int CHANNEL_VSENSEChannel selectro the the IAD input. Measures voltage across a resistor, Rsense, for calculating current.- See Also:
-
IAD_FLAG
public static final byte IAD_FLAGFlag 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.- See Also:
-
CA_FLAG
public static final byte CA_FLAGFlag 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 separate 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.- See Also:
-
EE_FLAG
public static final byte EE_FLAGFlag 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.- See Also:
-
AD_FLAG
public static final byte AD_FLAGFlag 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.- See Also:
-
TB_FLAG
public static final byte TB_FLAGFlag to check whether or not a temperature conversion is in progress using getFlag().- See Also:
-
NVB_FLAG
public static final byte NVB_FLAGFlag to check whether or not an operation is being performed on the nonvolatile memory using getFlag.- See Also:
-
ADB_FLAG
public static final byte ADB_FLAGFlag to check whether or not the A/D converter is busy using getFlag().- See Also:
-
-
Constructor Details
-
OneWireContainer26
public OneWireContainer26()Default constructor -
OneWireContainer26
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 devicenewAddress
- address of this 1-Wire device
-
OneWireContainer26
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 devicenewAddress
- address of this 1-Wire device
-
OneWireContainer26
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 devicenewAddress
- address of this 1-Wire device
-
-
Method Details
-
getMemoryBanks
Gets an enumeration of memory bank instances that implement one or more of the following interfaces:MemoryBank
,PagedMemoryBank
, andOTPMemoryBank
.- Overrides:
getMemoryBanks
in classOneWireContainer
- Returns:
Enumeration
of memory banks- See Also:
-
getName
Returns the Maxim Integrated Products part number of this 1-Wire device as a string.- Overrides:
getName
in classOneWireContainer
- Returns:
- representation of this 1-Wire device's name
-
getAlternateNames
Return the alternate Maxim Integrated Products part number or name. ie. Smart Battery Monitor- Overrides:
getAlternateNames
in classOneWireContainer
- Returns:
- representation of the alternate name(s)
-
getDescription
Return a short description of the function of this 1-Wire device type.- Overrides:
getDescription
in classOneWireContainer
- 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 thegetCurrent()
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 thegetCurrent()
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 todoSpeed()
. However, this is an expensive operation. If a user manages the bus speed in an application, call this method withdoSpeedCheck
asfalse
. The default behavior is to calldoSpeed()
.- Parameters:
doSpeedCheck
-true
fordoSpeed()
to be called before every 1-Wire bus access,false
to skip this expensive call- See Also:
-
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 dataOneWireException
- Could not find partIllegalArgumentException
- 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) withsetFlag()
.- Parameters:
page
- the page numbersource
- data to be written to pageoffset
- offset with page to begin writing- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find partIllegalArgumentException
- 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 dataOneWireException
- Could not find partIllegalArgumentException
- 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 writing dataOneWireException
- Could not find partIllegalArgumentException
- 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 usingsetSenseResitor(double)
.- Parameters:
state
- current state of device- Returns:
- current value in Amperes
-
getRemainingCapacity
public double getRemainingCapacity() throws OneWireIOException, OneWireException, IllegalArgumentExceptionCalculate the remaining capacity in mAH as outlined in the data sheet.- Returns:
- battery capacity remaining in mAH
- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find partIllegalArgumentException
- 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 dataOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
calibrateCurrentADC
public void calibrateCurrentADC() throws OneWireIOException, OneWireException, IllegalArgumentExceptionCalibrate 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 calibratingOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
setThreshold
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 thresholdOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
getICA
Retrieves the current ICA value in mVHr.- Returns:
- value in the ICA register
- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
getCCA
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 dataOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
getDCA
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 dataOneWireException
- Could not find partIllegalArgumentException
- 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 dataOneWireException
- Could not find partIllegalArgumentException
- 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 dataOneWireException
- Could not find partIllegalArgumentException
- 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 dataOneWireException
- Could not find partIllegalArgumentException
- Bad parameters passed
-
getDisconnectTime
public long getDisconnectTime(byte[] state) This method extracts the Clock Value in milliseconds from the state data retrieved from thereadDevice()
method.- Parameters:
state
- device state- Returns:
- time in milliseconds that have occurred since 1970
-
getEndOfChargeTime
public long getEndOfChargeTime(byte[] state) This method extracts the Clock Value in milliseconds from the state data retrieved from thereadDevice()
method.- Parameters:
state
- device state- Returns:
- time in milliseconds that have occurred 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 interfaceADContainer
- 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 interfaceADContainer
- 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 interfaceADContainer
- Parameters:
channel
- channel in the range [0 to (getNumberChannels() - 1)]- Returns:
- available ranges
- See Also:
-
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 interfaceADContainer
- Parameters:
channel
- channel in the range [0 to (getNumberChannels() - 1)]range
- A/D range- Returns:
- available resolutions
- See Also:
-
canADMultiChannelRead
public boolean canADMultiChannelRead()Query to see if this A/D supports doing multiple voltage conversions at the same time.- Specified by:
canADMultiChannelRead
in interfaceADContainer
- Returns:
- true if device can do multi-channel voltage reads
- See Also:
-
doADConvert
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 interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
state
- current state of the device returned fromreadDevice()
- Throws:
OneWireIOException
- Error writing dataOneWireException
- Could not find part- See Also:
-
doADConvert
public void doADConvert(boolean[] doConvert, byte[] state) throws OneWireIOException, OneWireException This method is used to perform voltage conversion on all specified channels. The methodgetVoltage()
can be used to read the result of the conversion. This A/D must support multi-channel readcanMultiChannelRead()
if there are more then 1 channel is specified.- Specified by:
doADConvert
in interfaceADContainer
- Parameters:
doConvert
- channels to perform conversion onstate
- current state of the device returned fromreadDevice()
- Throws:
OneWireIOException
- Error writing dataOneWireException
- Could not find part- See Also:
-
getADVoltage
This method is used to read the voltage values. Must be used after adoADConvert()
method call. Also must include the last valid state from thereadDevice()
method and this A/D must support multi-channel readcanMultiChannelRead()
if there are more then 1 channel.- Specified by:
getADVoltage
in interfaceADContainer
- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- voltage values for all channels
- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find part- See Also:
-
getADVoltage
This method is used to read a channels voltage value. Must be used after adoADConvert()
method call. Also must include the last valid state from thereadDevice()
method. Note, if more then one channel is to be read then it is more efficient to use thegetVoltage()
method that returns all channel values.- Specified by:
getADVoltage
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
state
- current state of the device returned fromreadDevice()
- Returns:
- voltage value for the specified channel
- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find part- See Also:
-
getADAlarm
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 thereadDevice()
method.- Specified by:
getADAlarm
in interfaceADContainer
- 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 fromreadDevice()
- Returns:
- alarm_value in volts
- Throws:
OneWireException
- Device does not support A/D alarms- See Also:
-
getADAlarmEnable
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 thereadDevice()
method.- Specified by:
getADAlarmEnable
in interfaceADContainer
- 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 fromreadDevice()
- Returns:
- true if specified alarm is enabled
- Throws:
OneWireException
- Device does not support A/D alarms- See Also:
-
hasADAlarmed
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 thereadDevice()
method.- Specified by:
hasADAlarmed
in interfaceADContainer
- 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 fromreadDevice()
- Returns:
- true if specified alarm occurred
- Throws:
OneWireException
- Device does not support A/D alarms- See Also:
-
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 thereadDevice()
method.- Specified by:
getADResolution
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
state
- current state of the state returned fromreadDevice()
- Returns:
- resolution of channel in volts
- See Also:
-
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 thereadDevice()
method.- Specified by:
getADRange
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
state
- current state of the state returned fromreadDevice()
- Returns:
- input voltage range
- See Also:
-
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 thereadDevice()
method. The methodwriteDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Specified by:
setADAlarm
in interfaceADContainer
- 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 fromreadDevice()
- Throws:
OneWireException
- Device does not support A/D alarms- See Also:
-
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 thereadDevice()
method. The methodwriteDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Specified by:
setADAlarmEnable
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
alarmType
- desired alarm,ALARM_HIGH (1) or ALARM_LOW (0)
alarmEnable
- alarm enable valuestate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- Device does not support A/D alarms- See Also:
-
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 thereadDevice()
method. The methodwriteDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Specified by:
setADResolution
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
resolution
- resolution to use in voltsstate
- current state of the device returned fromreadDevice()
- See Also:
-
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 thereadDevice()
method. The methodwriteDevice()
must be called to finalize these changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
.- Specified by:
setADRange
in interfaceADContainer
- Parameters:
channel
- channel in the range[0 to (getNumberChannels() - 1)]
range
- maximum volt range, usegetRanges()
method to get available rangesstate
- current state of the device returned fromreadDevice()
- See Also:
-
readDevice
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 thewriteDevice()
to finalize the one or more change.- Specified by:
readDevice
in interfaceOneWireSensor
- Returns:
- 1-Wire device's state
- Throws:
OneWireIOException
- Error reading dataOneWireException
- Could not find part
-
writeDevice
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 interfaceOneWireSensor
- Parameters:
state
- device's state- Throws:
OneWireIOException
- Error writing dataOneWireException
- 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 interfaceTemperatureContainer
- Returns:
- true if has high/low trip alarms
- See Also:
-
hasSelectableTemperatureResolution
public boolean hasSelectableTemperatureResolution()Query to see if this device has selectable resolution.- Specified by:
hasSelectableTemperatureResolution
in interfaceTemperatureContainer
- Returns:
- true if device has selectable resolution
- See Also:
-
getTemperatureResolutions
public double[] getTemperatureResolutions()Query to get an array of available resolutions in degrees C.- Specified by:
getTemperatureResolutions
in interfaceTemperatureContainer
- Returns:
- available resolutions in degrees C
- See Also:
-
getTemperatureAlarmResolution
Query to get the high/low resolution in degrees C.- Specified by:
getTemperatureAlarmResolution
in interfaceTemperatureContainer
- Returns:
- high/low resolution resolution in degrees C
- Throws:
OneWireException
- Device does not have temperature alarms- See Also:
-
getMaxTemperature
public double getMaxTemperature()Query to get the maximum temperature in degrees C.- Specified by:
getMaxTemperature
in interfaceTemperatureContainer
- Returns:
- maximum temperature in degrees C
-
getMinTemperature
public double getMinTemperature()Query to get the minimum temperature in degrees C.- Specified by:
getMinTemperature
in interfaceTemperatureContainer
- Returns:
- minimum temperature in degrees C
-
doTemperatureConvert
Perform an temperature conversion. Use this state information to calculate the conversion time.- Specified by:
doTemperatureConvert
in interfaceTemperatureContainer
- Parameters:
state
- device state- Throws:
OneWireIOException
- Error writing dataOneWireException
- 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 thereadDevice()
method.- Specified by:
getTemperature
in interfaceTemperatureContainer
- Parameters:
state
- device state- Returns:
- temperature in degrees C from the last
doTemperature()
-
getTemperatureAlarm
This method extracts the specified Alarm value in degrees C from the state data retrieved from thereadDevice()
method.- Specified by:
getTemperatureAlarm
in interfaceTemperatureContainer
- Parameters:
alarmType
- alarm trip typeALARM_HIGH (1) or ALARM_LOW (0)
state
- device state- Returns:
- alarm trip temperature in degrees C
- Throws:
OneWireException
- Device does not have temperature alarms- See Also:
-
getTemperatureResolution
public double getTemperatureResolution(byte[] state) This method extracts the current resolution in degrees C from the state data retrieved from thereadDevice()
method.- Specified by:
getTemperatureResolution
in interfaceTemperatureContainer
- Parameters:
state
- device state- Returns:
- temperature resolution in degrees C
- See Also:
-
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 methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setTemperatureAlarm
in interfaceTemperatureContainer
- Parameters:
alarmType
- alarm typeALARM_HIGH (1) or ALARM_LOW (0)
alarmValue
- trip value in degrees Cstate
- device state- Throws:
OneWireException
- Device does not have temperature alarmsOneWireIOException
- See Also:
-
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 methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setTemperatureResolution
in interfaceTemperatureContainer
- Parameters:
resolution
- temperature resolution in degrees Cstate
- device state- Throws:
OneWireIOException
- Error writing dataOneWireException
- Could not find part- See Also:
-
hasClockAlarm
public boolean hasClockAlarm()Query to see if the clock has an alarm feature.- Specified by:
hasClockAlarm
in interfaceClockContainer
- Returns:
- true if real-time-clock has an alarm
- See Also:
-
canDisableClock
public boolean canDisableClock()Query to see if the clock can be disabled. See the methodsisClockRunning()
andsetClockRunEnable()
.- Specified by:
canDisableClock
in interfaceClockContainer
- Returns:
- true if the clock can be enabled and disabled
- See Also:
-
getClockResolution
public long getClockResolution()Query to get the clock resolution in milliseconds- Specified by:
getClockResolution
in interfaceClockContainer
- 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 thereadDevice()
method.- Specified by:
getClock
in interfaceClockContainer
- Parameters:
state
- device state- Returns:
- time in milliseconds that have occurred since 1970
- See Also:
-
getClockAlarm
This method extracts the Clock Alarm Value from the provided state data retrieved from thereadDevice()
method.- Specified by:
getClockAlarm
in interfaceClockContainer
- Parameters:
state
- device state- Returns:
- time in milliseconds that have the clock alarm is set to
- Throws:
OneWireException
- Device does not have clock alarm- See Also:
-
isClockAlarming
public boolean isClockAlarming(byte[] state) This method checks if the Clock Alarm flag has been set from the state data retrieved from thereadDevice()
method.- Specified by:
isClockAlarming
in interfaceClockContainer
- Parameters:
state
- device state- Returns:
- true if clock is alarming
- See Also:
-
isClockAlarmEnabled
public boolean isClockAlarmEnabled(byte[] state) This method checks if the Clock Alarm is enabled from the provided state data retrieved from thereadDevice()
method.- Specified by:
isClockAlarmEnabled
in interfaceClockContainer
- Parameters:
state
- device state- Returns:
- true if clock alarm is enabled
- See Also:
-
isClockRunning
public boolean isClockRunning(byte[] state) This method checks if the device's oscillator is enabled. The clock will not increment if the clock is not enabled. This value is read from the provided state data retrieved from thereadDevice()
method.- Specified by:
isClockRunning
in interfaceClockContainer
- Parameters:
state
- device state- Returns:
- true if clock is running
- See Also:
-
setClock
public void setClock(long time, byte[] state) This method sets the Clock time in the provided state data Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setClock
in interfaceClockContainer
- Parameters:
time
- new clock setting in millisecondsstate
- device state- See Also:
-
setClockAlarm
This method sets the Clock Alarm in the provided state data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setClockAlarm
in interfaceClockContainer
- Parameters:
time
- new clock setting in mllisecondsstate
- device state- Throws:
OneWireException
- Device does not support clock alarm- See Also:
-
setClockRunEnable
This method sets the oscillator enable to the specified value. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setClockRunEnable
in interfaceClockContainer
- Parameters:
runEnable
- true to enable clock oscillatorstate
- device state- Throws:
OneWireException
- Device does not support disabled clock- See Also:
-
setClockAlarmEnable
This method sets the Clock Alarm enable. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setClockAlarmEnable
in interfaceClockContainer
- Parameters:
alarmEnable
- - true to enable clock alarmstate
- device state- Throws:
OneWireException
- Device does not support clock alarm- See Also:
-
isRelative
public boolean isRelative()Checks to see if humidity value given is a 'relative' humidity value.- Specified by:
isRelative
in interfaceHumidityContainer
- Returns:
true
if thisHumidityContainer
provides a relative humidity reading- See Also:
-
hasHumidityAlarms
public boolean hasHumidityAlarms()Checks to see if this Humidity measuring device has high/low trip alarms.- Specified by:
hasHumidityAlarms
in interfaceHumidityContainer
- Returns:
true
if thisHumidityContainer
has high/low trip alarms- See Also:
-
hasSelectableHumidityResolution
public boolean hasSelectableHumidityResolution()Checks to see if this device has selectable Humidity resolution.- Specified by:
hasSelectableHumidityResolution
in interfaceHumidityContainer
- Returns:
true
if thisHumidityContainer
has selectable Humidity resolution- See Also:
-
getHumidityResolutions
public double[] getHumidityResolutions()Get an array of available Humidity resolutions in percent humidity (0 to 100).- Specified by:
getHumidityResolutions
in interfaceHumidityContainer
- 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:
-
getHumidityAlarmResolution
Gets the Humidity alarm resolution in percent.- Specified by:
getHumidityAlarmResolution
in interfaceHumidityContainer
- Returns:
- Humidity alarm resolution in percent for this 1-wire device
- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
-
doHumidityConvert
Performs a Humidity conversion.- Specified by:
doHumidityConvert
in interfaceHumidityContainer
- 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 interfaceHumidityContainer
- Parameters:
state
- byte array with device state information- Returns:
- humidity expressed as a percent
- See Also:
-
getHumidityResolution
public double getHumidityResolution(byte[] state) Gets the current Humidity resolution in percent from thestate
data retrieved from thereadDevice()
method.- Specified by:
getHumidityResolution
in interfaceHumidityContainer
- Parameters:
state
- byte array with device state information- Returns:
- Humidity resolution in percent for this 1-wire device
- See Also:
-
getHumidityAlarm
Gets the specified Humidity alarm value in percent from thestate
data retrieved from thereadDevice()
method.- Specified by:
getHumidityAlarm
in interfaceHumidityContainer
- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_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:
-
setHumidityAlarm
public void setHumidityAlarm(int alarmType, double alarmValue, byte[] state) throws OneWireException Sets the Humidity alarm value in percent in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setHumidityAlarm
in interfaceHumidityContainer
- Parameters:
alarmType
- valid value:ALARM_HIGH
orALARM_LOW
alarmValue
- alarm trip value in percentstate
- byte array with device state information- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
-
setHumidityResolution
Sets the current Humidity resolution in percent in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Specified by:
setHumidityResolution
in interfaceHumidityContainer
- Parameters:
resolution
- Humidity resolution in percentstate
- byte array with device state information- Throws:
OneWireException
- Device does not support selectable Humidity resolution- See Also:
-