See: Description
Interface | Description |
---|---|
DACChannel |
The
DACChannel interface provides methods for controlling a DAC (Digital to Analog
Converter) channel. |
GenerationRoundListener |
The
GenerationRoundListener interface defines methods for getting notified of the
completion of the conversion of a set of raw output values and that more output values to be
converted may be provided. |
Class | Description |
---|---|
DACChannelConfig |
The
DACChannelConfig class encapsulates the hardware addressing information, and static
and dynamic configuration parameters of an DAC channel. |
DACChannelConfig.Builder |
The
Builder class allows for creating and initializing DACChannelConfig objects. |
DACPermission |
The
DACPermission class defines permissions for DAC channel access. |
Exception | Description |
---|---|
InvalidOutputSamplingRateException |
Thrown by an instance of
DACChannel in case the requested sampling interval results
in a sampling rate higher or lower than
the maximum, respectively minimum, sampling interval/rate the DAC device can support. |
One DAC converter can have several channels. Each channel can generate an analog output from numeric values that are converted to output voltages.
In order to access and control a specific DAC channel, an application should first open and obtain an
DACChannel
instance for the DAC channel the application wants to
access and control, using its numeric ID, name, type (interface) and/or properties:
- Using its ID
DACChannel channel = (DACChannel) DeviceManager.open(5);- Using its name and interface
DACChannel channel = (DACChannel) DeviceManager.open("LED", DACChannel.class, null);
Once the device opened, an application can write output values to a DAC channel using methods of the
DACChannel
interface such as the
generate
method.
When done, the application should call thechannel.generate(brightness);
DACChannel.close
method to close the DAC channel. channel.close();
The following sample codes give examples of using the DAC API:
class VaryingDimmer implements GenerationRoundListener { private DACChannel channel = null; public void start(int channelID) throws IOException, NonAvailableDeviceException, DeviceNotFoundException { if (channel != null) { throw new InvalidStateException(); } channel = (DACChannel) DeviceManager.open(channelID); channel.setSamplingInterval(1000); // every 1000 milliseconds // Creates a series of samples varying from min value to max value int[] values = new int[10]; int min = channel.getMinValue(); int max = channel.getMaxValue(); IntBuffer values = IntBuffer.wrap(new int[10]); createSamples(values, channel.getMinValue(), channel.getMaxValue(), 10); channel.startGeneration(values, this); } public void outputRoundCompleted(RoundCompletionEvent<DACChannel, IntBuffer> event) { try { // Replay the same sample series createSamples(event.getBuffer(), event.getDevice().getMinValue(), event.getDevice().getMaxValue(), 10); } catch (IOException ioe) { // Ignored } } // Creates a series of samples varying from min value to max value private void createSamples(IntBuffer buffer, int min, int max, int count) { for (int i = 0; i < count; i++) { buffer.put(min + (((max - min) / (count - 1)) * i)); } buffer.flip(); } public void stop() throws IOException { if (channel != null) { channel.stopGeneration(); channel.close(); } } public void failed(Throwable exception, DACChannel source) { // Ignored } }
Because of performance issue, procedures handling analog outputs, and especially event listeners, should be implemented to be as fast as possible.
Unless otherwise noted, permission and security checks that may cause
a SecurityException
to be thrown must be performed
in priority to any other checks or operations once performed the checking of the input parameters
from which the permission target names and action lists are retrieved and assembled.
Unless otherwise noted, passing a null
argument to a constructor or method in any class
or interface in this package will cause a NullPointerException
to be thrown.
Copyright © 2012, 2015, Oracle and/or its affiliates. All rights reserved.
Legal Notices