A library version of vna/J is available here for download.
You can embed this library in your own JAVA application and execute scans.
The usage is straight forward. For conveniece I've added two Windows command files:
- compile.cmd - to compile the sample LibrarySampleRunner
- run.cmd - to run the sample
Simply dig into the command files and the LibrarySampleRunner.java to get an idea.
import krause.vna.data.calibrated.VNACalibratedSampleBlock;
import krause.vna.library.VNALibrary;
public class LibrarySampleRunner {
/**
* Run some sample scans
*
* @param args [0] driver name, [1] serial port
*/
public static void main(String[] args) {
VNALibrary lib = null;
VNACalibratedSampleBlock rc = null;
try {
lib = new VNALibrary();
//
lib.loadDriverByName("miniVNA Tiny", "COM13");
// lib.loadDriverByName("miniVNA-pro", "COM3");
// lib.loadDriverByName("miniVNA-pro-extender", "COM3");
// lib.loadDriverByName("miniVNA", "COM3");
//
//
// test for transmission scan
lib.loadCalibrationFile("C:/Users/dietmar/vnaJ.3.1/calibration/TRAN_miniVNA Tiny.cal");
rc = lib.scan(1000000, 2000000, 100, "TRAN");
System.out.printf("num TRAN samples read = %d\n", rc.getCalibratedSamples().length);
lib.loadCalibrationFile("C:/Users/dietmar/vnaJ.3.1/calibration/REFL_miniVNA-pro.cal");
rc = lib.scan(1000000, 2000000, 1, "REFL");
System.out.printf("num TRAN samples read = %d\n", rc.getCalibratedSamples().length);
System.out.printf("[0] f =%d\n", rc.getCalibratedSamples()[0].getFrequency());
System.out.printf("[0] rl=%f\n", rc.getCalibratedSamples()[0].getReflectionLoss());
System.out.printf("[0] rp=%f\n", rc.getCalibratedSamples()[0].getReflectionPhase());
lib.loadCalibrationFile("C:/Users/dietmar/vnaJ.3.1/calibration/TRAN_miniVNA-pro.cal");
rc = lib.scan(1000000, 2000000, 1, "TRAN");
System.out.printf("num TRAN samples read = %d\n", rc.getCalibratedSamples().length);
System.out.printf("[0] f =%d\n", rc.getCalibratedSamples()[0].getFrequency());
System.out.printf("[0] tl=%f\n", rc.getCalibratedSamples()[0].getTransmissionLoss());
System.out.printf("[0] tp=%f\n", rc.getCalibratedSamples()[0].getTransmissionPhase());
} catch (Exception e) {
System.out.println("failed with " + e.getMessage());
} finally {
if (lib != null) {
lib.shutdown();
}
}
}
}
The calibration files must be created with the vna/J GUI. The list of supported analyser is printed during library initialization or check the JAVADOC for details.
For scan mode you can set "TRAN" for transmission measurement and "REFL" for reflection measurement.
The scan data is returned in a so called VNACalibratedSampleBlock that contains the array of calibrated samples. You can get the calibrated samples using getCalibratedSamples() on the VNACalibratedSampleBlock.
Each of the returned VNACalibratedSample contains the calibrated measurement data like transmissionLoss, transmissionPhase, ...
The complete JavaDOC can be found in the "javadoc.zip" file.
If you need more functions, please let me know.