diff --git a/.gitignore b/.gitignore index b79f6c2f8c..4919c92565 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ bin/ .project .classpath **/dependency-reduced-pom.xml +wpilibj/wpilibJavaJNI/nivision/*.c +wpilibj/wpilibJavaJNI/nivision/*.java # Created by the jenkins test script test-reports @@ -155,6 +157,10 @@ local.properties .settings/ .loadpath +### Python ### +*.pyc +__pycache__ + # External tool builders .externalToolBuilders/ diff --git a/wpilibj/wpilibJavaDevices/src/main/java/com/ni/vision/NIVision.java b/wpilibj/wpilibJavaDevices/src/main/java/com/ni/vision/NIVision.java new file mode 100644 index 0000000000..bc549d0d0a --- /dev/null +++ b/wpilibj/wpilibJavaDevices/src/main/java/com/ni/vision/NIVision.java @@ -0,0 +1,24555 @@ +// +// This file is auto-generated by wpilibj/wpilibJavaJNI/nivision/gen_java.py +// Please do not edit! +// + +package com.ni.vision; + +import java.lang.reflect.*; +import java.io.UnsupportedEncodingException; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class NIVision { + private NIVision() {} + + private static native void imaqDispose(long addr); + + private static Constructor constructDirectByteBuffer; + private static Field bufferAddressField; + + static { + try { + Class[] cArg = new Class[2]; + cArg[0] = long.class; + cArg[1] = int.class; + constructDirectByteBuffer = Class.forName("java.nio.DirectByteBuffer").getDeclaredConstructor(cArg); + constructDirectByteBuffer.setAccessible(true); + + bufferAddressField = Buffer.class.getDeclaredField("address"); + bufferAddressField.setAccessible(true); + } catch (ReflectiveOperationException e) { + throw new ExceptionInInitializerError(e); + } + } + + private static ByteBuffer newDirectByteBuffer(long addr, int cap) { + try { + return ((ByteBuffer)(constructDirectByteBuffer.newInstance(addr, cap))).order(ByteOrder.nativeOrder()); + } catch (ReflectiveOperationException e) { + throw new ExceptionInInitializerError(e); + } + } + + private static long getByteBufferAddress(ByteBuffer bb) { + try { + return bufferAddressField.getLong(bb); + } catch (IllegalAccessException e) { + return 0; + } + } + + public static ByteBuffer sliceByteBuffer(ByteBuffer bb, int offset, int size) { + ByteBuffer new_bb = bb.duplicate(); + new_bb.position(offset); + new_bb.limit(size); + return new_bb; + } + + public static ByteBuffer getBytes(ByteBuffer bb, byte[] dst, int offset, int size) { + for (int i=offset; i