Skip to content
/ JMCCUL Public

Java wrapper for Measurement Computing Corporation Universal Library

License

Notifications You must be signed in to change notification settings

pfroud/JMCCUL

Repository files navigation

JMCCUL

JMCCUL is a Java wrapper for Measurement Computing Corporation Universal Library.

Universal Library is software for PC-based data acquisition devices. JMCCUL is a JNA wrapper around the C API for Universal Library.

JMCCUL is not endorsed by, authorized by, sponsored by, maintained by, partnered with, affiliated with, or in any way officially connected with Measurement Computing Corporation.

To learn about other ways to use Universal Library, go to existing-UL-APIs-and-libraries.md.

To see a table of all Universal Library functions and their corresponding JMCCUL methods, go to implementation-status-of-UL-functions.

To see a list of all Universal Library configuration items and their corresponding JMCCUL implementation, go to implementation-status-of-config-items.

Getting started

Follow the steps in first-time-setup.md each time a DAQ device is connected to a computer which it has not been previously connected to.

Usage

For ready-to-use examples, see the xyz.froud.jmccul_examples package.

Open a DAQ device

To quickly open a DAQ device:

DaqDevice myDevice = new DaqDevice.findFirst().get();

To discover all connected DAQ devices then open the first one:

DaqDeviceDescriptor[] allDescriptors = DaqDeviceDescriptor.find();
DaqDevice myDevice = new DaqDevice(allDescriptors[0]);

Call myDevice.close() when finished.

Several more static methods are available in DaqDevice.java and DaqDeviceDescriptor.java to find and filter devices.

Difference between DaqDevice and DaqDeviceDescriptor

The Java class DaqDeviceDescriptor is a wrapper around the Universal Library C struct of the same name. The file DaqDeviceDescriptor.java was initially generated by JNAerator.

A DaqDeviceDescriptor represents a physical DAQ device which is connected to the computer and detected by Universal Library, but may not be opened by Universal Library yet.

The Java class DaqDevice represents a DAQ device which has been opened by Universal Library.

All DAQ device creation methods ultimately call the Universal Library function cbCreateDaqDevice() from the DaqDevice constructor.

Do stuff

Category Example file Important method(s) Wrapper class
Analog input AnalogInputExample.java myDevice.analog.input.read()
myDevice.analog.input.readVoltage()
AnalogInputWrapper.java
Analog output AnalogOutputExample.java myDevice.analog.output.write()
myDevice.analog.output.writeVoltage()
AnalogOutputWrapper.java
Digital input DigitalInputExample.java myDevice.digital.input.readPort()
myDevice.digital.input.readBit()
DigitalInputWrapper.java
Digital output DigitalOutputExample.java myDevice.digital.output.writePort()
myDevice.digital.output.writeBit()
DigitalOutputWrapper.java
Temperature input TemperatureExample.java myDevice.temperature.read() TemperatureWrapper.java

There is also partial implementation of counter and expansion.

Known bugs / limitations / future work

  • I don't know how to write the JNA bindings for some function.

  • I don't have hardware which supports some functions.

  • The counter functions look scary.

  • The device discovery stuff will be confusing for others. Need to document the difference between DaqDeviceDescriptor and DaqDevice.

    • I wrote some utility methods to filter stuff. I think I should either write a bunch more utility functions, or remove all of them.
  • Some class names are not great like Configuration.java. I'm not sure if everything should have a JMCCUL prefix.

  • Validate arguments a lot. In Java, we can tell a lot (for example if a channel is in range) which we can validate before passing it to the native C thing.

  • What's the deal with Port vs PortType??

  • I have a list of stuff to ask MCC.

Replace static block for enum valueMap with this line

= Arrays.stream(values()).collect(Collectors.toMap( alarmType -> alarmType.VALUE, Function.identity() ));

Releases

No releases published

Languages