public interface DACChannel extends Peripheral
DACChannel
interface provides methods for controlling a DAC (Digital to Analog Converter) channel.
One DAC device can have several channels. Raw digital output values (samples) are converted to analog output values
according to the DAC channel resolution. The raw digital output values may range from getMinValue()
to getMaxValue()
. Actual output voltage values can be calculated from the raw
digital output values and the Reference Voltage value as returned by getVRefValue()
.
Each DAC channel is identified by a numerical ID and by a name.
An DACChannel
instance can be opened by a call to one of the PeripheralManager.open()
methods.
Once opened, an application can write an output value to a DAC channel by calling the setValue(int)
method
or can write a series of output values to be converted over a period of time by calling the
setValues(int[], int, int)
method.
An application can also asynchronously write a series of output values (samples) to be converted at a certain rate by
calling the startGeneration
method with a
GenerationListener
instance which will get cyclicly and asynchronously invoked to fetch more values to be
converted. Analog output generation can be stopped by calling the stopGeneration()
method.
Only one output operation (synchronous or asynchronous) can be going on at any time.
When an application is no longer using an DAC channel it should call the DACChannel.close()
method
to release the DAC channel. Any further attempt to set or get the value of a DAC channel which has been closed will
result in a PeripheralNotAvailableException
been thrown.
Note that asynchronous notification of output generation completion is only loosely tied to hardware-level interrupt
requests. The platform does not guarantee notification in a deterministic/timely manner.GenerationListener
BIG_ENDIAN, LITTLE_ENDIAN, MIXED_ENDIAN, UNDEFINED_ID
Modifier and Type | Method and Description |
---|---|
int |
getMaxValue()
Returns the maximum raw value this channel can convert.
|
int |
getMinSamplingInterval()
Gets the minimum output sampling interval (in microseconds) that can be set using
setSamplingInterval(int) . |
int |
getMinValue()
Returns the minimum raw value this channel can convert.
|
int |
getSamplingInterval()
Gets the output sampling interval (in microseconds).
|
double |
getVRefValue()
Returns the Reference Voltage value of this DAC channel.
|
void |
setSamplingInterval(int interval)
Sets the output sampling interval (in microseconds).
|
void |
setValue(int value)
Writes the provided raw output value to this channel.
|
void |
setValues(int[] buffer,
int offset,
int count)
Writes
count raw output values from the designated array to this channel for conversion. |
void |
startGeneration(int[] buffer,
int offset,
int count,
boolean doubleBuffering,
GenerationListener listener)
Starts asynchronous analog output generation on this channel from a series of raw output values (samples).
|
void |
stopGeneration()
Stops the asynchronous analog output generation on this channel as started by a call to the
startGeneration method. |
close, getID, getName, getProperties, isOpen
int getMaxValue() throws java.io.IOException, PeripheralNotAvailableException
n
then the
min
value returned by getMinValue()
and the max
value returned by
getMaxValue()
are such that: (max - min) == (2^n - 1)
.
java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).int getMinSamplingInterval() throws java.io.IOException, PeripheralNotAvailableException
setSamplingInterval(int)
.java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).int getMinValue() throws java.io.IOException, PeripheralNotAvailableException
n
then the
min
value returned by getMinValue()
and the max
value returned by
getMaxValue()
are such that: (max - min) == (2^n - 1)
.
java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).int getSamplingInterval() throws java.io.IOException, PeripheralNotAvailableException
setSamplingInterval(int)
the peripheral configuration-specific default value is returned.java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).double getVRefValue() throws java.io.IOException, PeripheralNotAvailableException
vRef
and
the DAC device resolution is n
then the actual output voltage value corresponding to a raw value
value
written to this channel can be calculated as follows: vOutput = (value * vRef) / (2^n)
java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).void setSamplingInterval(int interval) throws java.io.IOException, PeripheralNotAvailableException
interval
- the output sampling interval (in microseconds).java.io.IOException
- if an IO error occurred.InvalidOutputSamplingRateException
- if the resulting sampling rate is higher than the maximum supported sampling rate.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).java.lang.IllegalArgumentException
- if interval
is negative or null.void setValue(int value) throws java.io.IOException, PeripheralNotAvailableException
value
- the raw value to be output.java.io.IOException
- if an IO error occurred.java.lang.IllegalArgumentException
- if the provided raw value is not between the range defined by getMinValue()
and
getMaxValue()
.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).InvalidStateException
- if an asynchronous output operation is already active.void setValues(int[] buffer, int offset, int count) throws java.io.IOException, PeripheralNotAvailableException
count
raw output values from the designated array to this channel for conversion.
The raw output values will be converted according to the current output sampling interval as returned by
getSamplingInterval()
.
This method may be invoked at any time. If another thread has already initiated an I/O operation upon this
channel, however, then an invocation of this method will block until the first operation is complete.
Only one output operation (synchronous or asynchronous) can be going on at any time.buffer
- the buffer for the raw values to be converted.offset
- the offset in buffer
where to start reading the raw values.count
- the number of raw values to converted.java.io.IOException
- if an IO error occurred.java.lang.NullPointerException
- If buffer
is null
.java.lang.IndexOutOfBoundsException
- offset
or count
points or results in pointing outside buffer
.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).InvalidStateException
- if an asynchronous output operation is already active.java.lang.IllegalArgumentException
- if any of the designated raw values is not between the range defined by getMinValue()
and
getMaxValue()
.void startGeneration(int[] buffer, int offset, int count, boolean doubleBuffering, GenerationListener listener) throws java.io.IOException, PeripheralNotAvailableException
GenerationListener
instance
once the initial count
raw output values have been converted. The initial raw output values to be
converted are read from the designated section of the provided buffer. Values subsequently fetched using the
provided GenerationListener
instance are read from that very same buffer section.
Analog output generation can be stopped by a call to stopGeneration()
.
If double buffering is enabled, notification will happen when ( count / 2
) raw output values have been
converted and conversion will proceed with the other half of the designated section of the provided buffer.
Conversion will only be suspended if the previous event has not yet been handled. if count
is not even
then one part of the designated buffer section may be longer (by 1
) than the other one.
The raw output values (samples) will be converted according to the current output sampling interval as returned
by getSamplingInterval()
.
Only one output operation (synchronous or asynchronous) can be going on at any time.buffer
- the buffer for the output values to be converted.offset
- the offset in buffer
where to start reading the output values.count
- the number of output values to convert.doubleBuffering
- whether double buffering should be used.listener
- the GenerationListener
instance to be notified when all the output values have been converted.java.io.IOException
- if an IO error occurred.java.lang.NullPointerException
- if listener
is null
.java.lang.IndexOutOfBoundsException
- if offset
or count
points or results in pointing outside buffer
.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).InvalidStateException
- if another synchronous or asynchronous output is already active.void stopGeneration() throws java.io.IOException, PeripheralNotAvailableException
startGeneration
method.java.io.IOException
- if an IO error occurred.PeripheralNotAvailableException
- if the peripheral is not currently available (has been closed).Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.