See: Description
Interface | Description |
---|---|
CountingListener |
The
CountingListener interface defines methods for getting notified of pulse counter
counting conditions such as counter terminal value reached or counting session time interval
expired as well of device errors. |
PulseCounter |
The
PulseCounter interface provides methods for controlling a pulse counter. |
Class | Description |
---|---|
CounterPermission |
The
CounterPermission class defines permissions for pulse counter access. |
CountingEvent |
The
CountingEvent class encapsulates pulse counting conditions such as counter terminal
value reached or counting session time interval expired. |
PulseCounterConfig |
The
PulseCounterConfig class encapsulates the hardware addressing information, and static
and dynamic configuration parameters of a pulse counter. |
PulseCounter
instance for the pulse counter the
application wants to access and control, using its numerical ID, name, type (interface) and/or
properties:
PulseCounter counter = (PulseCounter) DeviceManager.open(8);
PulseCounter counter = DeviceManager.open("ENCODER", PulseCounter.class, null);
startCounting
method and
retrieve the current pulse count on-the-fly by calling the
PulseCounter.getCount()
method; or it can start a pulse
counting session with a terminal count value and a counting time interval using the
PulseCounter.startCounting(int, long, jdk.dio.counter.CountingListener)
and get asynchronously notified once the terminal count value has been reached or the counting
time interval has expired. In both cases, the application can retrieve the current pulse count
value at any time (on-the-fly) by calling the getCount
. When done, the application should call thecounter.startCounting(); // Start counting pulses // Perform some task... int count = counter.getCount(); // Retrieve the number of pulses that occurred while performing the task counter.stopCounting(); // Stop counting pulses
close
method to close Pulse counter.
The following sample codes give examples of using the counter/timer API:counter.close();
Because of performance issue, procedures handling pulse counting events, and especially event listeners, should be implemented to be as fast as possible. Unless otherwise noted, passing aclass PulseCounting implements CountingListener { private PulseCounter counter = null; public void start(int counterID) throws IOException, NonAvailableDeviceException, DeviceNotFoundException { counter = (PulseCounter) DeviceManager.open(counterID); counter.startCounting(-1, 1000, this); // Count events occuring during 1 second (without terminal count value) } public void countValueAvailable(CountingEvent event) { int count = event.getValue(); // Handle pulse count... } public void stop() throws IOException { if (counter != null) { counter.stopCounting(); counter.close(); } } }
null
argument to a constructor or method in any class
or interface in this package will cause a NullPointerException
to be thrown.Copyright © 2012, 2014, Oracle and/or its affiliates. All rights reserved.
Legal Notices