See: Description
Interface | Description |
---|---|
AcquisitionListener |
The
AcquisitionListener interface defines methods for getting notified of the availability of sampled input
values. |
ADCChannel |
The
ADCChannel interface provides methods for controlling an ADC (Analog to Digital Converter) channel. |
MonitoringListener |
The
MonitoringListener interface defines methods for getting notified of ADC channel under- and
over-threshold input value conditions. |
Class | Description |
---|---|
AcquisitionEvent |
The
AcquisitionEvent class encapsulates ADC channel input acquisition conditions. |
ADCChannelConfig |
The
ADCChannelConfig class encapsulates the hardware addressing information, and static and dynamic
configuration parameters of an ADC channel. |
MonitoringEvent |
The
MonitoringEvent class encapsulates ADC channel under- and over-threshold value conditions. |
Exception | Description |
---|---|
InvalidInputSamplingRateException |
Thrown by an instance of
ADCChannel in case the requested sampling rate is higher than the maximum input
sampling rate the ADC device can support. |
ADCChannel
instance for the ADC channel the application wants to
access and control, using its numerical ID, name, type (interface) and/or properties:
ADCChannel channel = (ADCChannel) PeripheralManager.open(8);
ADCChannel channel = (ADCChannel) PeripheralManager.open("TEMPERATURE", ADCChannel.class, null);
ADCChannel
interface such as the
getValue
method. When done, the application should call theint temp = channel.getValue();
ADCChannel.close()
method to release ADC channel. The following sample codes give examples of using the ADC API:channel.close();
class ADCAcquisition implements AcquisitionListener { private ADCChannel channel = null; public void start(int channelID) throws IOException, PeripheralNotAvailableException, PeripheralNotFoundException { channel = (ADCChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(100); // every 100 milliseconds int[] values = new int[10]; channel.startAcquisition(values, 0, values.length, this); } public void inputAcquired(AcquisitionEvent event) { for (int i = 0; i < event.getCount(); i++) { int value = event.getValues()[event.getOffset() + i]; // Handle value... } } public void stop() throws IOException, PeripheralNotAvailableException { if (channel != null) { channel.stopAcquisition(); channel.close(); } } }
Because of performance issue, procedures handling analog inputs, and especially event listeners, should be implemented to be as fast as possible.class ADCThreshold implements MonitoringListener { private ADCChannel channel = null; public void start(int channelID, int low, int high) throws IOException, PeripheralNotAvailableException, PeripheralNotFoundException { channel = (ADCChannel) PeripheralManager.open(channelID); channel.setSamplingInterval(100); // every 100 milliseconds channel.startMonitoring(low, high, this); } public void thresholdReached(MonitoringEvent event) { if (event.getType() == MonitoringEvent.OUT_OF_RANGE) { int value = event.getValue(); // Handle condition... } } public void stop() throws IOException, PeripheralNotAvailableException { if (channel != null) { channel.stopMonitoring(); channel.close(); } } }
com.oracle.deviceaccess.PeripheralManager.open
methods. The "com.oracle.deviceaccess.adc"
permission allows
access to be granted to ADC channels as a whole.Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.