简体   繁体   中英

Migrating OmniDriver from Matlab to Octave. Need to find librarypath.txt for Octave?

I currently use Matlab and the Ocean Optics Omnidriver ( http://oceanoptics.com/faq/controlling-usb-spectrometers-omnidriver-matlab/ ) to control a USB spectrometer on a windows 7 machine, and I'm trying to migrate to Octave.

Omnidriver is written in Java, and there is reasonable documentation for Matlab. After installing the driver the relevant Matlab commands are:

>> javaaddpath('C:\Program Files\Ocean Optics\OmniDriver\OOI_HOME\OmniDriver.jar');
>> wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
>> wrapper.openAllSpectrometers();

the first line seems to translate directly once the '\\' are replaced with '/', and I can see the file added to the dynamic java path.

The second line directly throws "error: 'com' undefined", but replacing with;

>> wrapper = javaObject ("com.oceanoptics.omnidriver.api.wrapper.Wrapper")

seems to work.

The third line directly then throws the error; "error: [java] java.lang.NoClassDefFoundError: Could not initialize class com.oceanoptics.uniusb.UniUSB"

which is where I'm stuck at the moment (UniUSB.jar is a file in OOI_HOME). On the OceanOptics page linked above, what I'm assuming is the same error is listed as a common problem caused by Matlab failing to find the required DLLs, and the solution is given as adding the path to OOI_HOME to matlabroot/toolbox/local/librarypath.txt

I'm assuming that if I can find the equivalent octave file then adding the path should solve my problem, but I can't find the file.

Any advice would be greatly appreciated!

The code

>> javaaddpath('C:\Program Files\Ocean Optics\OmniDriver\OOI_HOME\OmniDriver.jar');
>> wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
>> wrapper.openAllSpectrometers();

translates better with:

wrapper = javaObject ("com.oceanoptics.omnidriver.api.wrapper.Wrapper");
javaMethod ("openAllSpectrometers", wrapper);

Note that this is also valid Matlab syntax.

Another thing is that Octave handles java classes better if they are on the static classic path. So I'd recommend you add the path to OmniDriver.jar to your javaclasspath.txt file. See the manual for details .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM