Package com.dalsemi.onewire.container
Interface ADContainer
-
- All Superinterfaces:
OneWireSensor
- All Known Implementing Classes:
OneWireContainer20
,OneWireContainer26
,OneWireContainer30
,OneWireContainer41
public interface ADContainer extends OneWireSensor
Interface class for 1-Wire® devices that perform analog measuring operations. This class should be implemented for each A/D type 1-Wire device.
Features
- Allows multi-channel voltage readings
- Supports A/D Alarm enabling on devices with A/D Alarms
- Supports selectable A/D ranges on devices with selectable ranges
- Supports selectable A/D resolutions on devices with selectable resolutions
Usage
ADContainer
extendsOneWireSensor
, so the general usage model applies to anyADContainer
:- readDevice()
- perform operations on the
ADContainer
- writeDevice(byte[])
Consider this interaction with an
ADContainer
that reads from all of its A/D channels, then tries to set its high alarm on its first channel (channel 0)://adcontainer is a com.dalsemi.onewire.container.ADContainer byte[] state = adcontainer.readDevice(); double[] voltages = new double[adcontainer.getNumberADChannels()]; for (int i=0; i < adcontainer.getNumberADChannels(); i++) { adcontainer.doADConvert(i, state); voltages[i] = adc.getADVoltage(i, state); } if (adcontainer.hasADAlarms()) { double highalarm = adcontainer.getADAlarm(0, ADContainer.ALARM_HIGH, state); adcontainer.setADAlarm(0, ADContainer.ALARM_HIGH, highalarm + 1.0, state); adcontainer.writeDevice(state); }
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALARM_HIGH
Indicates the high AD alarm.static int
ALARM_LOW
Indicates the low AD alarm.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canADMultiChannelRead()
Checks to see if this A/D supports doing multiple voltage conversions at the same time.void
doADConvert(boolean[] doConvert, byte[] state)
Performs voltage conversion on one or more specified channels.void
doADConvert(int channel, byte[] state)
Performs a voltage conversion on one specified channel.double
getADAlarm(int channel, int alarmType, byte[] state)
Reads the value of the specified A/D alarm on the specified channel.boolean
getADAlarmEnable(int channel, int alarmType, byte[] state)
Checks to see if the specified alarm on the specified channel is enabled.double
getADRange(int channel, byte[] state)
Returns the currently selected range for the specified channel.double[]
getADRanges(int channel)
Gets an array of available ranges for the specified A/D channel.double
getADResolution(int channel, byte[] state)
Returns the currently selected resolution for the specified channel.double[]
getADResolutions(int channel, double range)
Gets an array of available resolutions based on the specified range on the specified A/D channel.double[]
getADVoltage(byte[] state)
Reads the value of the voltages after adoADConvert(boolean[],byte[])
method call.double
getADVoltage(int channel, byte[] state)
Reads the value of the voltages after adoADConvert(int,byte[])
method call.int
getNumberADChannels()
Gets the number of channels supported by this A/D.boolean
hasADAlarmed(int channel, int alarmType, byte[] state)
Checks the state of the specified alarm on the specified channel.boolean
hasADAlarms()
Checks to see if this A/D measuring device has high/low alarms.void
setADAlarm(int channel, int alarmType, double alarm, byte[] state)
Sets the voltage value of the specified alarm on the specified channel.void
setADAlarmEnable(int channel, int alarmType, boolean alarmEnable, byte[] state)
Enables or disables the specified alarm on the specified channel.void
setADRange(int channel, double range, byte[] state)
Sets the input range for the specified channel.void
setADResolution(int channel, double resolution, byte[] state)
Sets the conversion resolution value for the specified channel.-
Methods inherited from interface com.dalsemi.onewire.container.OneWireSensor
readDevice, writeDevice
-
-
-
-
Field Detail
-
ALARM_HIGH
static final int ALARM_HIGH
Indicates the high AD alarm.- See Also:
- Constant Field Values
-
ALARM_LOW
static final int ALARM_LOW
Indicates the low AD alarm.- See Also:
- Constant Field Values
-
-
Method Detail
-
getNumberADChannels
int getNumberADChannels()
Gets the number of channels supported by this A/D. Channel specific methods will use a channel number specified by an integer from [0 to (getNumberADChannels()
- 1)].- Returns:
- the number of channels
-
hasADAlarms
boolean hasADAlarms()
Checks to see if this A/D measuring device has high/low alarms.- Returns:
- true if this device has high/low trip alarms
-
getADRanges
double[] getADRanges(int channel)
Gets an array of available ranges for the specified A/D channel.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]- Returns:
- array indicating the available ranges starting from the largest range to the smallest range
- See Also:
getNumberADChannels()
-
getADResolutions
double[] getADResolutions(int channel, double range)
Gets an array of available resolutions based on the specified range on the specified A/D channel.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]range
- A/D range setting from thegetADRanges(int)
method- Returns:
- array indicating the available resolutions on this
channel
for thisrange
- See Also:
getNumberADChannels()
,getADRanges(int)
-
canADMultiChannelRead
boolean canADMultiChannelRead()
Checks to see if this A/D supports doing multiple voltage conversions at the same time.- Returns:
- true if the device can do multi-channel voltage reads
- See Also:
doADConvert(boolean[],byte[])
-
doADConvert
void doADConvert(int channel, byte[] state) throws OneWireIOException, OneWireException
Performs a voltage conversion on one specified channel. Use the methodgetADVoltage(int,byte[])
to read the result of this conversion, using the samechannel
argument as this method uses.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]state
- current state of the device returned fromreadDevice()
- Throws:
OneWireIOException
- on a 1-Wire communication error such as no 1-Wire device present. 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'. This is usually a recoverable error.OneWireException
- on a communication or setup error with the 1-Wire adapter. This is usually a non-recoverable error.- See Also:
OneWireSensor.readDevice()
,getADVoltage(int,byte[])
-
doADConvert
void doADConvert(boolean[] doConvert, byte[] state) throws OneWireIOException, OneWireException
Performs voltage conversion on one or more specified channels. The methodgetADVoltage(byte[])
can be used to read the result of the conversion(s). This A/D must support multi-channel read, reported bycanADMultiChannelRead()
, if more then 1 channel is specified.- Parameters:
doConvert
- array of sizegetNumberADChannels()
representing which channels should perform conversionsstate
- current state of the device returned fromreadDevice()
- Throws:
OneWireIOException
- on a 1-Wire communication error such as no 1-Wire device present. 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'. This is usually a recoverable error.OneWireException
- on a communication or setup error with the 1-Wire adapter. This is usually a non-recoverable error.- See Also:
OneWireSensor.readDevice()
,getADVoltage(byte[])
,canADMultiChannelRead()
-
getADVoltage
double[] getADVoltage(byte[] state) throws OneWireIOException, OneWireException
Reads the value of the voltages after adoADConvert(boolean[],byte[])
method call. This A/D device must support multi-channel reading, reported bycanADMultiChannelRead()
, if more than 1 channel conversion was attempted bydoADConvert()
.- Parameters:
state
- current state of the device returned fromreadDevice()
- Returns:
- array with the voltage values for all channels
- Throws:
OneWireIOException
- on a 1-Wire communication error such as no 1-Wire device present. 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'. This is usually a recoverable error.OneWireException
- on a communication or setup error with the 1-Wire adapter. This is usually a non-recoverable error.- See Also:
doADConvert(boolean[],byte[])
-
getADVoltage
double getADVoltage(int channel, byte[] state) throws OneWireIOException, OneWireException
Reads the value of the voltages after adoADConvert(int,byte[])
method call. If more than one channel has been read it is more efficient to use thegetADVoltage(byte[])
method that returns all channel voltage values.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
- the voltage value for the specified channel
- Throws:
OneWireIOException
- on a 1-Wire communication error such as no 1-Wire device present. 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'. This is usually a recoverable error.OneWireException
- on a communication or setup error with the 1-Wire adapter. This is usually a non-recoverable error.- See Also:
doADConvert(int,byte[])
,getADVoltage(byte[])
-
getADAlarm
double getADAlarm(int channel, int alarmType, byte[] state) throws OneWireException
Reads the value of the specified A/D alarm on the specified channel. Not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]alarmType
- the desired alarm,ALARM_HIGH
orALARM_LOW
state
- current state of the device returned fromreadDevice()
- Returns:
- the alarm value in volts
- Throws:
OneWireException
- if this device does not have A/D alarms- See Also:
OneWireSensor.readDevice()
,hasADAlarms()
-
getADAlarmEnable
boolean getADAlarmEnable(int channel, int alarmType, byte[] state) throws OneWireException
Checks to see if the specified alarm on the specified channel is enabled. Not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]alarmType
- the desired alarm,ALARM_HIGH
orALARM_LOW
state
- current state of the device returned fromreadDevice()
- Returns:
- true if specified alarm is enabled
- Throws:
OneWireException
- if this device does not have A/D alarms- See Also:
OneWireSensor.readDevice()
,hasADAlarms()
-
hasADAlarmed
boolean hasADAlarmed(int channel, int alarmType, byte[] state) throws OneWireException
Checks the state of the specified alarm on the specified channel. Not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]alarmType
- the desired alarm,ALARM_HIGH
orALARM_LOW
state
- current state of the device returned fromreadDevice()
- Returns:
- true if specified alarm occurred
- Throws:
OneWireException
- if this device does not have A/D alarms- See Also:
OneWireSensor.readDevice()
,hasADAlarms()
,getADAlarmEnable(int,int,byte[])
,setADAlarmEnable(int,int,boolean,byte[])
-
getADResolution
double getADResolution(int channel, byte[] state)
Returns the currently selected resolution for the specified channel. This device may not have selectable resolutions, though this method will return a valid value.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
- the current resolution of
channel
in volts - See Also:
getADResolutions(int,double)
,setADResolution(int,double,byte[])
-
getADRange
double getADRange(int channel, byte[] state)
Returns the currently selected range for the specified channel. This device may not have selectable ranges, though this method will return a valid value.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]state
- current state of the device returned fromreadDevice()
- Returns:
- the input voltage range
- See Also:
getADRanges(int)
,setADRange(int,double,byte[])
-
setADAlarm
void setADAlarm(int channel, int alarmType, double alarm, byte[] state) throws OneWireException
Sets the voltage value of the specified alarm on the specified channel. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
. Also note that not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]alarmType
- the desired alarm,ALARM_HIGH
orALARM_LOW
alarm
- new alarm valuestate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- if this device does not have A/D alarms- See Also:
OneWireSensor.writeDevice(byte[])
,hasADAlarms()
,getADAlarm(int,int,byte[])
,getADAlarmEnable(int,int,byte[])
,setADAlarmEnable(int,int,boolean,byte[])
,hasADAlarmed(int,int,byte[])
-
setADAlarmEnable
void setADAlarmEnable(int channel, int alarmType, boolean alarmEnable, byte[] state) throws OneWireException
Enables or disables the specified alarm on the specified channel. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
. Also note that not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]alarmType
- the desired alarm,ALARM_HIGH
orALARM_LOW
alarmEnable
- true to enable the alarm, false to disablestate
- current state of the device returned fromreadDevice()
- Throws:
OneWireException
- if this device does not have A/D alarms- See Also:
OneWireSensor.writeDevice(byte[])
,hasADAlarms()
,getADAlarm(int,int,byte[])
,setADAlarm(int,int,double,byte[])
,getADAlarmEnable(int,int,byte[])
,hasADAlarmed(int,int,byte[])
-
setADResolution
void setADResolution(int channel, double resolution, byte[] state)
Sets the conversion resolution value for the specified channel. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
. Also note that not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]resolution
- one of the resolutions returned bygetADResolutions(int,double)
state
- current state of the device returned fromreadDevice()
- See Also:
getADResolutions(int,double)
,getADResolution(int,byte[])
-
setADRange
void setADRange(int channel, double range, byte[] state)
Sets the input range for the specified channel. The methodwriteDevice()
must be called to finalize changes to the device. Note that multiple 'set' methods can be called before one call towriteDevice()
. Also note that not all A/D devices have alarms. Check to see if this device has alarms first by calling thehasADAlarms()
method.- Parameters:
channel
- channel number in the range [0 to (getNumberADChannels()
- 1)]range
- one of the ranges returned bygetADRanges(int)
state
- current state of the device returned fromreadDevice()
- See Also:
getADRanges(int)
,getADRange(int,byte[])
-
-