Package com.dalsemi.onewire.container
Interface HumidityContainer
-
- All Superinterfaces:
OneWireSensor
- All Known Implementing Classes:
OneWireContainer26
,OneWireContainer41
public interface HumidityContainer extends OneWireSensor
1-Wire Humidity interface class for basic Humidity measuring operations. This class should be implemented for each Humidity type 1-Wire device.The HumidityContainer methods can be organized into the following categories:
- Information
- Options
- I/O
Usage
Example
Gets humidity reading from a HumidityContainer instance 'hc
':double lastHumidity; // get the current resolution and other settings of the device (done only once) byte[] state = hc.readDevice(); // loop to read the humidity do { // perform a humidity conversion hc.doHumidityConvert(state); // read the result of the conversion state = hc.readDevice(); // extract the result out of state lastHumidity = hc.getHumidity(state); ... } while (!done);
- See Also:
OneWireContainer28
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALARM_HIGH
high temperature alarmstatic int
ALARM_LOW
low temperature alarm
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
doHumidityConvert(byte[] state)
Performs a Humidity conversion.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
getHumidityAlarmResolution()
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[]
getHumidityResolutions()
Get an array of available Humidity resolutions in percent humidity (0 to 100).boolean
hasHumidityAlarms()
Checks to see if this Humidity measuring device has high/low trip alarms.boolean
hasSelectableHumidityResolution()
Checks to see if this device has selectable Humidity resolution.boolean
isRelative()
Checks to see if humidity value given is a 'relative' humidity value.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.-
Methods inherited from interface com.dalsemi.onewire.container.OneWireSensor
readDevice, writeDevice
-
-
-
-
Field Detail
-
ALARM_HIGH
static final int ALARM_HIGH
high temperature alarm- See Also:
- Constant Field Values
-
ALARM_LOW
static final int ALARM_LOW
low temperature alarm- See Also:
- Constant Field Values
-
-
Method Detail
-
isRelative
boolean isRelative()
Checks to see if humidity value given is a 'relative' humidity value.- Returns:
true
if thisHumidityContainer
provides a relative humidity reading- See Also:
getHumidityResolution(byte[])
,getHumidityResolutions()
,setHumidityResolution(double, byte[])
-
hasHumidityAlarms
boolean hasHumidityAlarms()
Checks to see if this Humidity measuring device has high/low trip alarms.- Returns:
true
if thisHumidityContainer
has high/low trip alarms- See Also:
getHumidityAlarm(int, byte[])
,setHumidityAlarm(int, double, byte[])
-
hasSelectableHumidityResolution
boolean hasSelectableHumidityResolution()
Checks to see if this device has selectable Humidity resolution.- Returns:
true
if thisHumidityContainer
has selectable Humidity resolution- See Also:
getHumidityResolution(byte[])
,getHumidityResolutions()
,setHumidityResolution(double, byte[])
-
getHumidityResolutions
double[] getHumidityResolutions()
Get an array of available Humidity resolutions in percent humidity (0 to 100).- Returns:
- byte array of available Humidity resolutions in percent with minimum resolution as the first element and maximum resolution as the last element.
- See Also:
hasSelectableHumidityResolution()
,getHumidityResolution(byte[])
,setHumidityResolution(double, byte[])
-
getHumidityAlarmResolution
double getHumidityAlarmResolution() throws OneWireException
Gets the Humidity alarm resolution in percent.- Returns:
- Humidity alarm resolution in percent for this 1-wire device
- Throws:
OneWireException
- Device does not support Humidity alarms- See Also:
hasHumidityAlarms()
,getHumidityAlarm(int, byte[])
,setHumidityAlarm(int, double, byte[])
-
doHumidityConvert
void doHumidityConvert(byte[] state) throws OneWireIOException, OneWireException
Performs a Humidity conversion.- 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
double getHumidity(byte[] state)
Gets the humidity expressed as a percent value (0.0 to 100.0) of humidity.- Parameters:
state
- byte array with device state information- Returns:
- humidity expressed as a percent
- See Also:
hasSelectableHumidityResolution()
,getHumidityResolution(byte[])
,setHumidityResolution(double, byte[])
-
getHumidityResolution
double getHumidityResolution(byte[] state)
Gets the current Humidity resolution in percent from thestate
data retrieved from thereadDevice()
method.- Parameters:
state
- byte array with device state information- Returns:
- Humidity resolution in percent for this 1-wire device
- See Also:
hasSelectableHumidityResolution()
,getHumidityResolutions()
,setHumidityResolution(double, byte[])
-
getHumidityAlarm
double getHumidityAlarm(int alarmType, byte[] state) throws OneWireException
Gets the specified Humidity alarm value in percent from thestate
data retrieved from thereadDevice()
method.- 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:
hasHumidityAlarms()
,setHumidityAlarm(int, double, byte[])
-
setHumidityAlarm
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.- 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:
hasHumidityAlarms()
,getHumidityAlarm(int, byte[])
-
setHumidityResolution
void setHumidityResolution(double resolution, byte[] state) throws OneWireException
Sets the current Humidity resolution in percent in the providedstate
data. Use the methodwriteDevice()
with this data to finalize the change to the device.- Parameters:
resolution
- Humidity resolution in percentstate
- byte array with device state information- Throws:
OneWireException
- Device does not support selectable Humidity resolution- See Also:
hasSelectableHumidityResolution()
,getHumidityResolution(byte[])
,getHumidityResolutions()
-
-