mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Apply spotless for java formatting (#1768)
Update checkstyle config to be compatible with spotless. Co-authored-by: Austin Shalit <austinshalit@gmail.com>
This commit is contained in:
14
build.gradle
14
build.gradle
@@ -11,6 +11,7 @@ plugins {
|
||||
id 'visual-studio'
|
||||
id 'net.ltgt.errorprone' version '1.1.1' apply false
|
||||
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
|
||||
id 'com.diffplug.gradle.spotless' version '4.5.0'
|
||||
}
|
||||
|
||||
if (project.hasProperty('buildServer')) {
|
||||
@@ -131,6 +132,19 @@ ext.getCurrentArch = {
|
||||
return NativePlatforms.desktop
|
||||
}
|
||||
|
||||
spotless {
|
||||
java {
|
||||
target fileTree('.') {
|
||||
include '**/*.java'
|
||||
exclude '**/manualTests/**', '**/build*/**'
|
||||
}
|
||||
googleJavaFormat()
|
||||
removeUnusedImports()
|
||||
trimTrailingWhitespace()
|
||||
endWithNewline()
|
||||
}
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion = '6.0.1'
|
||||
}
|
||||
|
||||
@@ -4,49 +4,47 @@
|
||||
|
||||
package edu.wpi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import edu.wpi.cscore.VideoSource;
|
||||
import edu.wpi.first.cameraserver.CameraServer;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
JSON format:
|
||||
{
|
||||
"team": <team number>,
|
||||
"ntmode": <"client" or "server", "client" if unspecified>
|
||||
"cameras": [
|
||||
{
|
||||
"name": <camera name>
|
||||
"path": <path, e.g. "/dev/video0">
|
||||
"pixel format": <"MJPEG", "YUYV", etc> // optional
|
||||
"width": <video mode width> // optional
|
||||
"height": <video mode height> // optional
|
||||
"fps": <video mode fps> // optional
|
||||
"brightness": <percentage brightness> // optional
|
||||
"white balance": <"auto", "hold", value> // optional
|
||||
"exposure": <"auto", "hold", value> // optional
|
||||
"properties": [ // optional
|
||||
{
|
||||
"name": <property name>
|
||||
"value": <property value>
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
JSON format:
|
||||
{
|
||||
"team": <team number>,
|
||||
"ntmode": <"client" or "server", "client" if unspecified>
|
||||
"cameras": [
|
||||
{
|
||||
"name": <camera name>
|
||||
"path": <path, e.g. "/dev/video0">
|
||||
"pixel format": <"MJPEG", "YUYV", etc> // optional
|
||||
"width": <video mode width> // optional
|
||||
"height": <video mode height> // optional
|
||||
"fps": <video mode fps> // optional
|
||||
"brightness": <percentage brightness> // optional
|
||||
"white balance": <"auto", "hold", value> // optional
|
||||
"exposure": <"auto", "hold", value> // optional
|
||||
"properties": [ // optional
|
||||
{
|
||||
"name": <property name>
|
||||
"value": <property value>
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
public final class Main {
|
||||
private static String configFile = "/boot/frc.json";
|
||||
@@ -62,19 +60,14 @@ public final class Main {
|
||||
public static boolean server;
|
||||
public static List<CameraConfig> cameras = new ArrayList<>();
|
||||
|
||||
private Main() {
|
||||
}
|
||||
private Main() {}
|
||||
|
||||
/**
|
||||
* Report parse error.
|
||||
*/
|
||||
/** Report parse error. */
|
||||
public static void parseError(String str) {
|
||||
System.err.println("config error in '" + configFile + "': " + str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read single camera configuration.
|
||||
*/
|
||||
/** Read single camera configuration. */
|
||||
public static boolean readCameraConfig(JsonObject config) {
|
||||
CameraConfig cam = new CameraConfig();
|
||||
|
||||
@@ -100,9 +93,7 @@ public final class Main {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read configuration file.
|
||||
*/
|
||||
/** Read configuration file. */
|
||||
@SuppressWarnings("PMD.CyclomaticComplexity")
|
||||
public static boolean readConfig() {
|
||||
// parse file
|
||||
@@ -157,22 +148,17 @@ public final class Main {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start running the camera.
|
||||
*/
|
||||
/** Start running the camera. */
|
||||
public static void startCamera(CameraConfig config) {
|
||||
System.out.println("Starting camera '" + config.name + "' on " + config.path);
|
||||
VideoSource camera = CameraServer.getInstance().startAutomaticCapture(
|
||||
config.name, config.path);
|
||||
VideoSource camera = CameraServer.getInstance().startAutomaticCapture(config.name, config.path);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
camera.setConfigJson(gson.toJson(config.config));
|
||||
}
|
||||
|
||||
/**
|
||||
* Main.
|
||||
*/
|
||||
/** Main. */
|
||||
public static void main(String... args) {
|
||||
if (args.length > 0) {
|
||||
configFile = args[0];
|
||||
@@ -199,7 +185,7 @@ public final class Main {
|
||||
}
|
||||
|
||||
// loop forever
|
||||
for (;;) {
|
||||
for (; ; ) {
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
package edu.wpi.first.cameraserver;
|
||||
|
||||
public final class DevMain {
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) {}
|
||||
|
||||
}
|
||||
|
||||
private DevMain() {
|
||||
}
|
||||
private DevMain() {}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,6 @@
|
||||
|
||||
package edu.wpi.first.cameraserver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import edu.wpi.cscore.AxisCamera;
|
||||
import edu.wpi.cscore.CameraServerJNI;
|
||||
import edu.wpi.cscore.CvSink;
|
||||
@@ -29,27 +22,28 @@ import edu.wpi.first.networktables.EntryListenerFlags;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import edu.wpi.first.networktables.NetworkTableEntry;
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Singleton class for creating and keeping camera servers.
|
||||
* Also publishes camera information to NetworkTables.
|
||||
* Singleton class for creating and keeping camera servers. Also publishes camera information to
|
||||
* NetworkTables.
|
||||
*/
|
||||
public final class CameraServer {
|
||||
public static final int kBasePort = 1181;
|
||||
|
||||
@Deprecated
|
||||
public static final int kSize640x480 = 0;
|
||||
@Deprecated
|
||||
public static final int kSize320x240 = 1;
|
||||
@Deprecated
|
||||
public static final int kSize160x120 = 2;
|
||||
@Deprecated public static final int kSize640x480 = 0;
|
||||
@Deprecated public static final int kSize320x240 = 1;
|
||||
@Deprecated public static final int kSize160x120 = 2;
|
||||
|
||||
private static final String kPublishName = "/CameraPublisher";
|
||||
private static CameraServer server;
|
||||
|
||||
/**
|
||||
* Get the CameraServer instance.
|
||||
*/
|
||||
/** Get the CameraServer instance. */
|
||||
public static synchronized CameraServer getInstance() {
|
||||
if (server == null) {
|
||||
server = new CameraServer();
|
||||
@@ -61,12 +55,12 @@ public final class CameraServer {
|
||||
private String m_primarySourceName;
|
||||
private final Map<String, VideoSource> m_sources;
|
||||
private final Map<String, VideoSink> m_sinks;
|
||||
private final Map<Integer, NetworkTable> m_tables; // indexed by source handle
|
||||
private final Map<Integer, NetworkTable> m_tables; // indexed by source handle
|
||||
// source handle indexed by sink handle
|
||||
private final Map<Integer, Integer> m_fixedSources;
|
||||
private final NetworkTable m_publishTable;
|
||||
private final VideoListener m_videoListener; //NOPMD
|
||||
private final int m_tableListener; //NOPMD
|
||||
private final VideoListener m_videoListener; // NOPMD
|
||||
private final int m_tableListener; // NOPMD
|
||||
private int m_nextPort;
|
||||
private String[] m_addresses;
|
||||
|
||||
@@ -75,14 +69,15 @@ public final class CameraServer {
|
||||
switch (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))) {
|
||||
case kUsb:
|
||||
return "usb:" + CameraServerJNI.getUsbCameraPath(source);
|
||||
case kHttp: {
|
||||
String[] urls = CameraServerJNI.getHttpCameraUrls(source);
|
||||
if (urls.length > 0) {
|
||||
return "ip:" + urls[0];
|
||||
} else {
|
||||
return "ip:";
|
||||
case kHttp:
|
||||
{
|
||||
String[] urls = CameraServerJNI.getHttpCameraUrls(source);
|
||||
if (urls.length > 0) {
|
||||
return "ip:" + urls[0];
|
||||
} else {
|
||||
return "ip:";
|
||||
}
|
||||
}
|
||||
}
|
||||
case kCv:
|
||||
return "cv:";
|
||||
default:
|
||||
@@ -98,8 +93,7 @@ public final class CameraServer {
|
||||
@SuppressWarnings({"MissingJavadocMethod", "PMD.AvoidUsingHardCodedIP"})
|
||||
private synchronized String[] getSinkStreamValues(int sink) {
|
||||
// Ignore all but MjpegServer
|
||||
if (VideoSink.getKindFromInt(CameraServerJNI.getSinkKind(sink))
|
||||
!= VideoSink.Kind.kMjpeg) {
|
||||
if (VideoSink.getKindFromInt(CameraServerJNI.getSinkKind(sink)) != VideoSink.Kind.kMjpeg) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@@ -117,7 +111,7 @@ public final class CameraServer {
|
||||
values.add(makeStreamValue(CameraServerJNI.getHostname() + ".local", port));
|
||||
for (String addr : m_addresses) {
|
||||
if ("127.0.0.1".equals(addr)) {
|
||||
continue; // ignore localhost
|
||||
continue; // ignore localhost
|
||||
}
|
||||
values.add(makeStreamValue(addr, port));
|
||||
}
|
||||
@@ -130,7 +124,7 @@ public final class CameraServer {
|
||||
private synchronized String[] getSourceStreamValues(int source) {
|
||||
// Ignore all but HttpCamera
|
||||
if (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))
|
||||
!= VideoSource.Kind.kHttp) {
|
||||
!= VideoSource.Kind.kHttp) {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@@ -148,7 +142,7 @@ public final class CameraServer {
|
||||
int sinkSource = CameraServerJNI.getSinkSource(sink);
|
||||
if (source == sinkSource
|
||||
&& VideoSink.getKindFromInt(CameraServerJNI.getSinkKind(sink))
|
||||
== VideoSink.Kind.kMjpeg) {
|
||||
== VideoSink.Kind.kMjpeg) {
|
||||
// Add USB-only passthrough
|
||||
String[] finalValues = Arrays.copyOf(values, values.length + 1);
|
||||
int port = CameraServerJNI.getMjpegServerPort(sink);
|
||||
@@ -161,17 +155,20 @@ public final class CameraServer {
|
||||
return values;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MissingJavadocMethod",
|
||||
"PMD.AvoidUsingHardCodedIP",
|
||||
"PMD.CyclomaticComplexity"})
|
||||
@SuppressWarnings({
|
||||
"MissingJavadocMethod",
|
||||
"PMD.AvoidUsingHardCodedIP",
|
||||
"PMD.CyclomaticComplexity"
|
||||
})
|
||||
private synchronized void updateStreamValues() {
|
||||
// Over all the sinks...
|
||||
for (VideoSink i : m_sinks.values()) {
|
||||
int sink = i.getHandle();
|
||||
|
||||
// Get the source's subtable (if none exists, we're done)
|
||||
int source = Objects.requireNonNullElseGet(m_fixedSources.get(sink),
|
||||
() -> CameraServerJNI.getSinkSource(sink));
|
||||
int source =
|
||||
Objects.requireNonNullElseGet(
|
||||
m_fixedSources.get(sink), () -> CameraServerJNI.getSinkSource(sink));
|
||||
|
||||
if (source == 0) {
|
||||
continue;
|
||||
@@ -230,8 +227,14 @@ public final class CameraServer {
|
||||
/// The returned string is "{width}x{height} {format} {fps} fps".
|
||||
@SuppressWarnings("MissingJavadocMethod")
|
||||
private static String videoModeToString(VideoMode mode) {
|
||||
return mode.width + "x" + mode.height + " " + pixelFormatToString(mode.pixelFormat)
|
||||
+ " " + mode.fps + " fps";
|
||||
return mode.width
|
||||
+ "x"
|
||||
+ mode.height
|
||||
+ " "
|
||||
+ pixelFormatToString(mode.pixelFormat)
|
||||
+ " "
|
||||
+ mode.fps
|
||||
+ " fps";
|
||||
}
|
||||
|
||||
@SuppressWarnings("MissingJavadocMethod")
|
||||
@@ -270,14 +273,18 @@ public final class CameraServer {
|
||||
case kEnum:
|
||||
if (isNew) {
|
||||
entry.setDefaultDouble(event.value);
|
||||
table.getEntry(infoName + "/min").setDouble(
|
||||
CameraServerJNI.getPropertyMin(event.propertyHandle));
|
||||
table.getEntry(infoName + "/max").setDouble(
|
||||
CameraServerJNI.getPropertyMax(event.propertyHandle));
|
||||
table.getEntry(infoName + "/step").setDouble(
|
||||
CameraServerJNI.getPropertyStep(event.propertyHandle));
|
||||
table.getEntry(infoName + "/default").setDouble(
|
||||
CameraServerJNI.getPropertyDefault(event.propertyHandle));
|
||||
table
|
||||
.getEntry(infoName + "/min")
|
||||
.setDouble(CameraServerJNI.getPropertyMin(event.propertyHandle));
|
||||
table
|
||||
.getEntry(infoName + "/max")
|
||||
.setDouble(CameraServerJNI.getPropertyMax(event.propertyHandle));
|
||||
table
|
||||
.getEntry(infoName + "/step")
|
||||
.setDouble(CameraServerJNI.getPropertyStep(event.propertyHandle));
|
||||
table
|
||||
.getEntry(infoName + "/default")
|
||||
.setDouble(CameraServerJNI.getPropertyDefault(event.propertyHandle));
|
||||
} else {
|
||||
entry.setDouble(event.value);
|
||||
}
|
||||
@@ -297,8 +304,12 @@ public final class CameraServer {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"MissingJavadocMethod", "PMD.UnusedLocalVariable", "PMD.ExcessiveMethodLength",
|
||||
"PMD.NPathComplexity"})
|
||||
@SuppressWarnings({
|
||||
"MissingJavadocMethod",
|
||||
"PMD.UnusedLocalVariable",
|
||||
"PMD.ExcessiveMethodLength",
|
||||
"PMD.NPathComplexity"
|
||||
})
|
||||
private CameraServer() {
|
||||
m_defaultUsbDevice = new AtomicInteger();
|
||||
m_sources = new HashMap<>();
|
||||
@@ -321,176 +332,204 @@ public final class CameraServer {
|
||||
// - "PropertyInfo/{Property}" - Property supporting information
|
||||
|
||||
// Listener for video events
|
||||
m_videoListener = new VideoListener(event -> {
|
||||
switch (event.kind) {
|
||||
case kSourceCreated: {
|
||||
// Create subtable for the camera
|
||||
NetworkTable table = m_publishTable.getSubTable(event.name);
|
||||
m_tables.put(event.sourceHandle, table);
|
||||
table.getEntry("source").setString(makeSourceValue(event.sourceHandle));
|
||||
table.getEntry("description").setString(
|
||||
CameraServerJNI.getSourceDescription(event.sourceHandle));
|
||||
table.getEntry("connected").setBoolean(
|
||||
CameraServerJNI.isSourceConnected(event.sourceHandle));
|
||||
table.getEntry("streams").setStringArray(getSourceStreamValues(event.sourceHandle));
|
||||
try {
|
||||
VideoMode mode = CameraServerJNI.getSourceVideoMode(event.sourceHandle);
|
||||
table.getEntry("mode").setDefaultString(videoModeToString(mode));
|
||||
table.getEntry("modes").setStringArray(getSourceModeValues(event.sourceHandle));
|
||||
} catch (VideoException ignored) {
|
||||
// Do nothing. Let the other event handlers update this if there is an error.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceDestroyed: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("source").setString("");
|
||||
table.getEntry("streams").setStringArray(new String[0]);
|
||||
table.getEntry("modes").setStringArray(new String[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceConnected: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
// update the description too (as it may have changed)
|
||||
table.getEntry("description").setString(
|
||||
CameraServerJNI.getSourceDescription(event.sourceHandle));
|
||||
table.getEntry("connected").setBoolean(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceDisconnected: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("connected").setBoolean(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceVideoModesUpdated: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("modes").setStringArray(getSourceModeValues(event.sourceHandle));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceVideoModeChanged: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("mode").setString(videoModeToString(event.mode));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyCreated: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
putSourcePropertyValue(table, event, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyValueUpdated: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
putSourcePropertyValue(table, event, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyChoicesUpdated: {
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
try {
|
||||
String[] choices = CameraServerJNI.getEnumPropertyChoices(event.propertyHandle);
|
||||
table.getEntry("PropertyInfo/" + event.name + "/choices").setStringArray(choices);
|
||||
} catch (VideoException ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSinkSourceChanged:
|
||||
case kSinkCreated:
|
||||
case kSinkDestroyed:
|
||||
case kNetworkInterfacesChanged: {
|
||||
m_addresses = CameraServerJNI.getNetworkInterfaces();
|
||||
updateStreamValues();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, 0x4fff, true);
|
||||
m_videoListener =
|
||||
new VideoListener(
|
||||
event -> {
|
||||
switch (event.kind) {
|
||||
case kSourceCreated:
|
||||
{
|
||||
// Create subtable for the camera
|
||||
NetworkTable table = m_publishTable.getSubTable(event.name);
|
||||
m_tables.put(event.sourceHandle, table);
|
||||
table.getEntry("source").setString(makeSourceValue(event.sourceHandle));
|
||||
table
|
||||
.getEntry("description")
|
||||
.setString(CameraServerJNI.getSourceDescription(event.sourceHandle));
|
||||
table
|
||||
.getEntry("connected")
|
||||
.setBoolean(CameraServerJNI.isSourceConnected(event.sourceHandle));
|
||||
table
|
||||
.getEntry("streams")
|
||||
.setStringArray(getSourceStreamValues(event.sourceHandle));
|
||||
try {
|
||||
VideoMode mode = CameraServerJNI.getSourceVideoMode(event.sourceHandle);
|
||||
table.getEntry("mode").setDefaultString(videoModeToString(mode));
|
||||
table
|
||||
.getEntry("modes")
|
||||
.setStringArray(getSourceModeValues(event.sourceHandle));
|
||||
} catch (VideoException ignored) {
|
||||
// Do nothing. Let the other event handlers update this if there is an error.
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceDestroyed:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("source").setString("");
|
||||
table.getEntry("streams").setStringArray(new String[0]);
|
||||
table.getEntry("modes").setStringArray(new String[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceConnected:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
// update the description too (as it may have changed)
|
||||
table
|
||||
.getEntry("description")
|
||||
.setString(CameraServerJNI.getSourceDescription(event.sourceHandle));
|
||||
table.getEntry("connected").setBoolean(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceDisconnected:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("connected").setBoolean(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceVideoModesUpdated:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table
|
||||
.getEntry("modes")
|
||||
.setStringArray(getSourceModeValues(event.sourceHandle));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourceVideoModeChanged:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
table.getEntry("mode").setString(videoModeToString(event.mode));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyCreated:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
putSourcePropertyValue(table, event, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyValueUpdated:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
putSourcePropertyValue(table, event, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSourcePropertyChoicesUpdated:
|
||||
{
|
||||
NetworkTable table = m_tables.get(event.sourceHandle);
|
||||
if (table != null) {
|
||||
try {
|
||||
String[] choices =
|
||||
CameraServerJNI.getEnumPropertyChoices(event.propertyHandle);
|
||||
table
|
||||
.getEntry("PropertyInfo/" + event.name + "/choices")
|
||||
.setStringArray(choices);
|
||||
} catch (VideoException ignored) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kSinkSourceChanged:
|
||||
case kSinkCreated:
|
||||
case kSinkDestroyed:
|
||||
case kNetworkInterfacesChanged:
|
||||
{
|
||||
m_addresses = CameraServerJNI.getNetworkInterfaces();
|
||||
updateStreamValues();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
0x4fff,
|
||||
true);
|
||||
|
||||
// Listener for NetworkTable events
|
||||
// We don't currently support changing settings via NT due to
|
||||
// synchronization issues, so just update to current setting if someone
|
||||
// else tries to change it.
|
||||
m_tableListener = NetworkTableInstance.getDefault().addEntryListener(kPublishName + "/",
|
||||
event -> {
|
||||
String relativeKey = event.name.substring(kPublishName.length() + 1);
|
||||
m_tableListener =
|
||||
NetworkTableInstance.getDefault()
|
||||
.addEntryListener(
|
||||
kPublishName + "/",
|
||||
event -> {
|
||||
String relativeKey = event.name.substring(kPublishName.length() + 1);
|
||||
|
||||
// get source (sourceName/...)
|
||||
int subKeyIndex = relativeKey.indexOf('/');
|
||||
if (subKeyIndex == -1) {
|
||||
return;
|
||||
}
|
||||
String sourceName = relativeKey.substring(0, subKeyIndex);
|
||||
VideoSource source = m_sources.get(sourceName);
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
// get source (sourceName/...)
|
||||
int subKeyIndex = relativeKey.indexOf('/');
|
||||
if (subKeyIndex == -1) {
|
||||
return;
|
||||
}
|
||||
String sourceName = relativeKey.substring(0, subKeyIndex);
|
||||
VideoSource source = m_sources.get(sourceName);
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get subkey
|
||||
relativeKey = relativeKey.substring(subKeyIndex + 1);
|
||||
// get subkey
|
||||
relativeKey = relativeKey.substring(subKeyIndex + 1);
|
||||
|
||||
// handle standard names
|
||||
String propName;
|
||||
if ("mode".equals(relativeKey)) {
|
||||
// reset to current mode
|
||||
event.getEntry().setString(videoModeToString(source.getVideoMode()));
|
||||
return;
|
||||
} else if (relativeKey.startsWith("Property/")) {
|
||||
propName = relativeKey.substring(9);
|
||||
} else if (relativeKey.startsWith("RawProperty/")) {
|
||||
propName = relativeKey.substring(12);
|
||||
} else {
|
||||
return; // ignore
|
||||
}
|
||||
// handle standard names
|
||||
String propName;
|
||||
if ("mode".equals(relativeKey)) {
|
||||
// reset to current mode
|
||||
event.getEntry().setString(videoModeToString(source.getVideoMode()));
|
||||
return;
|
||||
} else if (relativeKey.startsWith("Property/")) {
|
||||
propName = relativeKey.substring(9);
|
||||
} else if (relativeKey.startsWith("RawProperty/")) {
|
||||
propName = relativeKey.substring(12);
|
||||
} else {
|
||||
return; // ignore
|
||||
}
|
||||
|
||||
// everything else is a property
|
||||
VideoProperty property = source.getProperty(propName);
|
||||
switch (property.getKind()) {
|
||||
case kNone:
|
||||
return;
|
||||
case kBoolean:
|
||||
// reset to current setting
|
||||
event.getEntry().setBoolean(property.get() != 0);
|
||||
return;
|
||||
case kInteger:
|
||||
case kEnum:
|
||||
// reset to current setting
|
||||
event.getEntry().setDouble(property.get());
|
||||
return;
|
||||
case kString:
|
||||
// reset to current setting
|
||||
event.getEntry().setString(property.getString());
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}, EntryListenerFlags.kImmediate | EntryListenerFlags.kUpdate);
|
||||
// everything else is a property
|
||||
VideoProperty property = source.getProperty(propName);
|
||||
switch (property.getKind()) {
|
||||
case kNone:
|
||||
return;
|
||||
case kBoolean:
|
||||
// reset to current setting
|
||||
event.getEntry().setBoolean(property.get() != 0);
|
||||
return;
|
||||
case kInteger:
|
||||
case kEnum:
|
||||
// reset to current setting
|
||||
event.getEntry().setDouble(property.get());
|
||||
return;
|
||||
case kString:
|
||||
// reset to current setting
|
||||
event.getEntry().setString(property.getString());
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
},
|
||||
EntryListenerFlags.kImmediate | EntryListenerFlags.kUpdate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* <p>You should call this method to see a camera feed on the dashboard.
|
||||
* If you also want to perform vision processing on the roboRIO, use
|
||||
* getVideo() to get access to the camera images.
|
||||
* <p>You should call this method to see a camera feed on the dashboard. If you also want to
|
||||
* perform vision processing on the roboRIO, use getVideo() to get access to the camera images.
|
||||
*
|
||||
* <p>The first time this overload is called, it calls
|
||||
* {@link #startAutomaticCapture(int)} with device 0, creating a camera
|
||||
* named "USB Camera 0". Subsequent calls increment the device number
|
||||
* <p>The first time this overload is called, it calls {@link #startAutomaticCapture(int)} with
|
||||
* device 0, creating a camera named "USB Camera 0". Subsequent calls increment the device number
|
||||
* (e.g. 1, 2, etc).
|
||||
*/
|
||||
public UsbCamera startAutomaticCapture() {
|
||||
@@ -502,8 +541,8 @@ public final class CameraServer {
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* <p>This overload calls {@link #startAutomaticCapture(String, int)} with
|
||||
* a name of "USB Camera {dev}".
|
||||
* <p>This overload calls {@link #startAutomaticCapture(String, int)} with a name of "USB Camera
|
||||
* {dev}".
|
||||
*
|
||||
* @param dev The device number of the camera interface
|
||||
*/
|
||||
@@ -541,8 +580,7 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard from
|
||||
* an existing camera.
|
||||
* Start automatically capturing images to send to the dashboard from an existing camera.
|
||||
*
|
||||
* @param camera Camera
|
||||
*/
|
||||
@@ -556,8 +594,7 @@ public final class CameraServer {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #addAxisCamera(String, String)} with
|
||||
* name "Axis Camera".
|
||||
* <p>This overload calls {@link #addAxisCamera(String, String)} with name "Axis Camera".
|
||||
*
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
*/
|
||||
@@ -568,8 +605,7 @@ public final class CameraServer {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #addAxisCamera(String, String[])} with
|
||||
* name "Axis Camera".
|
||||
* <p>This overload calls {@link #addAxisCamera(String, String[])} with name "Axis Camera".
|
||||
*
|
||||
* @param hosts Array of Camera host IPs/DNS names
|
||||
*/
|
||||
@@ -606,10 +642,9 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a virtual camera for switching between two streams. Unlike the
|
||||
* other addCamera methods, this returns a VideoSink rather than a
|
||||
* VideoSource. Calling setSource() on the returned object can be used
|
||||
* to switch the actual source of the stream.
|
||||
* Adds a virtual camera for switching between two streams. Unlike the other addCamera methods,
|
||||
* this returns a VideoSink rather than a VideoSource. Calling setSource() on the returned object
|
||||
* can be used to switch the actual source of the stream.
|
||||
*/
|
||||
public MjpegServer addSwitchedCamera(String name) {
|
||||
// create a dummy CvSource
|
||||
@@ -623,11 +658,11 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the primary camera feed. This allows you to
|
||||
* get images from the camera for image processing on the roboRIO.
|
||||
* Get OpenCV access to the primary camera feed. This allows you to get images from the camera for
|
||||
* image processing on the roboRIO.
|
||||
*
|
||||
* <p>This is only valid to call after a camera feed has been added
|
||||
* with startAutomaticCapture() or addServer().
|
||||
* <p>This is only valid to call after a camera feed has been added with startAutomaticCapture()
|
||||
* or addServer().
|
||||
*/
|
||||
public CvSink getVideo() {
|
||||
VideoSource source;
|
||||
@@ -644,8 +679,8 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get
|
||||
* images from the camera for image processing on the roboRIO.
|
||||
* Get OpenCV access to the specified camera. This allows you to get images from the camera for
|
||||
* image processing on the roboRIO.
|
||||
*
|
||||
* @param camera Camera (e.g. as returned by startAutomaticCapture).
|
||||
*/
|
||||
@@ -670,8 +705,8 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get
|
||||
* images from the camera for image processing on the roboRIO.
|
||||
* Get OpenCV access to the specified camera. This allows you to get images from the camera for
|
||||
* image processing on the roboRIO.
|
||||
*
|
||||
* @param name Camera name
|
||||
*/
|
||||
@@ -687,8 +722,8 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MJPEG stream with OpenCV input. This can be called to pass custom
|
||||
* annotated images to the dashboard.
|
||||
* Create a MJPEG stream with OpenCV input. This can be called to pass custom annotated images to
|
||||
* the dashboard.
|
||||
*
|
||||
* @param name Name to give the stream
|
||||
* @param width Width of the image being sent
|
||||
@@ -750,8 +785,8 @@ public final class CameraServer {
|
||||
/**
|
||||
* Get server for the primary camera feed.
|
||||
*
|
||||
* <p>This is only valid to call after a camera feed has been added
|
||||
* with startAutomaticCapture() or addServer().
|
||||
* <p>This is only valid to call after a camera feed has been added with startAutomaticCapture()
|
||||
* or addServer().
|
||||
*/
|
||||
public VideoSink getServer() {
|
||||
synchronized (this) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
package edu.wpi.first.cameraserver;
|
||||
|
||||
|
||||
public interface CameraServerShared {
|
||||
/**
|
||||
* get the main thread id func.
|
||||
|
||||
@@ -7,48 +7,36 @@ package edu.wpi.first.cameraserver;
|
||||
public final class CameraServerSharedStore {
|
||||
private static CameraServerShared cameraServerShared;
|
||||
|
||||
private CameraServerSharedStore() {
|
||||
}
|
||||
private CameraServerSharedStore() {}
|
||||
|
||||
/**
|
||||
* get the CameraServerShared object.
|
||||
*/
|
||||
/** get the CameraServerShared object. */
|
||||
public static synchronized CameraServerShared getCameraServerShared() {
|
||||
if (cameraServerShared == null) {
|
||||
cameraServerShared = new CameraServerShared() {
|
||||
cameraServerShared =
|
||||
new CameraServerShared() {
|
||||
|
||||
@Override
|
||||
public void reportVideoServer(int id) {
|
||||
@Override
|
||||
public void reportVideoServer(int id) {}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void reportUsbCamera(int id) {}
|
||||
|
||||
@Override
|
||||
public void reportUsbCamera(int id) {
|
||||
@Override
|
||||
public void reportDriverStationError(String error) {}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void reportAxisCamera(int id) {}
|
||||
|
||||
@Override
|
||||
public void reportDriverStationError(String error) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAxisCamera(int id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRobotMainThreadId() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public Long getRobotMainThreadId() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return cameraServerShared;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the CameraServerShared object.
|
||||
*/
|
||||
/** set the CameraServerShared object. */
|
||||
public static synchronized void setCameraServerShared(CameraServerShared shared) {
|
||||
cameraServerShared = shared;
|
||||
}
|
||||
|
||||
@@ -7,17 +7,16 @@ package edu.wpi.first.vision;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
* A vision pipeline is responsible for running a group of
|
||||
* OpenCV algorithms to extract data from an image.
|
||||
* A vision pipeline is responsible for running a group of OpenCV algorithms to extract data from an
|
||||
* image.
|
||||
*
|
||||
* @see VisionRunner
|
||||
* @see VisionThread
|
||||
*/
|
||||
public interface VisionPipeline {
|
||||
/**
|
||||
* Processes the image input and sets the result objects.
|
||||
* Implementations should make these objects accessible.
|
||||
* Processes the image input and sets the result objects. Implementations should make these
|
||||
* objects accessible.
|
||||
*/
|
||||
void process(Mat image);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
|
||||
package edu.wpi.first.vision;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import edu.wpi.cscore.CvSink;
|
||||
import edu.wpi.cscore.VideoSource;
|
||||
import edu.wpi.first.cameraserver.CameraServerSharedStore;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
* A vision runner is a convenient wrapper object to make it easy to run vision pipelines
|
||||
* from robot code. The easiest way to use this is to run it in a {@link VisionThread}
|
||||
* and use the listener to take snapshots of the pipeline's outputs.
|
||||
* A vision runner is a convenient wrapper object to make it easy to run vision pipelines from robot
|
||||
* code. The easiest way to use this is to run it in a {@link VisionThread} and use the listener to
|
||||
* take snapshots of the pipeline's outputs.
|
||||
*
|
||||
* @see VisionPipeline
|
||||
* @see VisionThread
|
||||
@@ -42,17 +41,16 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
* @param pipeline the vision pipeline that ran
|
||||
*/
|
||||
void copyPipelineOutputs(P pipeline);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new vision runner. It will take images from the {@code videoSource}, send them to
|
||||
* the {@code pipeline}, and call the {@code listener} when the pipeline has finished to alert
|
||||
* user code when it is safe to access the pipeline's outputs.
|
||||
* Creates a new vision runner. It will take images from the {@code videoSource}, send them to the
|
||||
* {@code pipeline}, and call the {@code listener} when the pipeline has finished to alert user
|
||||
* code when it is safe to access the pipeline's outputs.
|
||||
*
|
||||
* @param videoSource the video source to use to supply images for the pipeline
|
||||
* @param pipeline the vision pipeline to run
|
||||
* @param listener a function to call after the pipeline has finished running
|
||||
* @param pipeline the vision pipeline to run
|
||||
* @param listener a function to call after the pipeline has finished running
|
||||
*/
|
||||
public VisionRunner(VideoSource videoSource, P pipeline, Listener<? super P> listener) {
|
||||
this.m_pipeline = pipeline;
|
||||
@@ -61,15 +59,15 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the pipeline one time, giving it the next image from the video source specified
|
||||
* in the constructor. This will block until the source either has an image or throws an error.
|
||||
* If the source successfully supplied a frame, the pipeline's image input will be set,
|
||||
* the pipeline will run, and the listener specified in the constructor will be called to notify
|
||||
* it that the pipeline ran.
|
||||
* Runs the pipeline one time, giving it the next image from the video source specified in the
|
||||
* constructor. This will block until the source either has an image or throws an error. If the
|
||||
* source successfully supplied a frame, the pipeline's image input will be set, the pipeline will
|
||||
* run, and the listener specified in the constructor will be called to notify it that the
|
||||
* pipeline ran.
|
||||
*
|
||||
* <p>This method is exposed to allow teams to add additional functionality or have their own
|
||||
* ways to run the pipeline. Most teams, however, should just use {@link #runForever} in its own
|
||||
* thread using a {@link VisionThread}.</p>
|
||||
* <p>This method is exposed to allow teams to add additional functionality or have their own ways
|
||||
* to run the pipeline. Most teams, however, should just use {@link #runForever} in its own thread
|
||||
* using a {@link VisionThread}.
|
||||
*/
|
||||
public void runOnce() {
|
||||
Long id = CameraServerSharedStore.getCameraServerShared().getRobotMainThreadId();
|
||||
@@ -95,11 +93,11 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience method that calls {@link #runOnce()} in an infinite loop. This must
|
||||
* be run in a dedicated thread, and cannot be used in the main robot thread because
|
||||
* it will freeze the robot program.
|
||||
* A convenience method that calls {@link #runOnce()} in an infinite loop. This must be run in a
|
||||
* dedicated thread, and cannot be used in the main robot thread because it will freeze the robot
|
||||
* program.
|
||||
*
|
||||
* <p><strong>Do not call this method directly from the main thread.</strong></p>
|
||||
* <p><strong>Do not call this method directly from the main thread.</strong>
|
||||
*
|
||||
* @throws IllegalStateException if this is called from the main robot thread
|
||||
* @see VisionThread
|
||||
@@ -116,9 +114,7 @@ public class VisionRunner<P extends VisionPipeline> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a RunForever() loop.
|
||||
*/
|
||||
/** Stop a RunForever() loop. */
|
||||
public void stop() {
|
||||
m_enabled = false;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ package edu.wpi.first.vision;
|
||||
import edu.wpi.cscore.VideoSource;
|
||||
|
||||
/**
|
||||
* A vision thread is a special thread that runs a vision pipeline. It is a <i>daemon</i> thread;
|
||||
* it does not prevent the program from exiting when all other non-daemon threads
|
||||
* have finished running.
|
||||
* A vision thread is a special thread that runs a vision pipeline. It is a <i>daemon</i> thread; it
|
||||
* does not prevent the program from exiting when all other non-daemon threads have finished
|
||||
* running.
|
||||
*
|
||||
* @see VisionPipeline
|
||||
* @see VisionRunner
|
||||
@@ -31,14 +31,12 @@ public class VisionThread extends Thread {
|
||||
* equivalent to {@code new VisionThread(new VisionRunner<>(videoSource, pipeline, listener))}.
|
||||
*
|
||||
* @param videoSource the source for images the pipeline should process
|
||||
* @param pipeline the pipeline to run
|
||||
* @param listener the listener to copy outputs from the pipeline after it runs
|
||||
* @param <P> the type of the pipeline
|
||||
* @param pipeline the pipeline to run
|
||||
* @param listener the listener to copy outputs from the pipeline after it runs
|
||||
* @param <P> the type of the pipeline
|
||||
*/
|
||||
public <P extends VisionPipeline> VisionThread(VideoSource videoSource,
|
||||
P pipeline,
|
||||
VisionRunner.Listener<? super P> listener) {
|
||||
public <P extends VisionPipeline> VisionThread(
|
||||
VideoSource videoSource, P pipeline, VisionRunner.Listener<? super P> listener) {
|
||||
this(new VisionRunner<>(videoSource, pipeline, listener));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
/**
|
||||
* Classes in the {@code edu.wpi.first.vision} package are designed to
|
||||
* simplify using OpenCV vision processing code from a robot program.
|
||||
* Classes in the {@code edu.wpi.first.vision} package are designed to simplify using OpenCV vision
|
||||
* processing code from a robot program.
|
||||
*
|
||||
* <p>An example use case for grabbing a yellow tote from 2015 in autonomous: <br>
|
||||
*
|
||||
* <p>An example use case for grabbing a yellow tote from 2015 in autonomous:
|
||||
* <br>
|
||||
* <pre><code>
|
||||
* public class Robot extends IterativeRobot
|
||||
* implements VisionRunner.Listener<MyFindTotePipeline> {
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import edu.wpi.cscore.VideoMode.PixelFormat;
|
||||
import edu.wpi.cscore.raw.RawFrame;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
public class RawCVMatSink extends ImageSink {
|
||||
RawFrame frame = new RawFrame();
|
||||
@@ -24,26 +22,25 @@ public class RawCVMatSink extends ImageSink {
|
||||
private int getCVFormat(PixelFormat pixelFormat) {
|
||||
int type = 0;
|
||||
switch (pixelFormat) {
|
||||
case kYUYV:
|
||||
case kRGB565:
|
||||
type = CvType.CV_8UC2;
|
||||
break;
|
||||
case kBGR:
|
||||
type = CvType.CV_8UC3;
|
||||
break;
|
||||
case kGray:
|
||||
case kMJPEG:
|
||||
default:
|
||||
type = CvType.CV_8UC1;
|
||||
break;
|
||||
case kYUYV:
|
||||
case kRGB565:
|
||||
type = CvType.CV_8UC2;
|
||||
break;
|
||||
case kBGR:
|
||||
type = CvType.CV_8UC3;
|
||||
break;
|
||||
case kGray:
|
||||
case kMJPEG:
|
||||
default:
|
||||
type = CvType.CV_8UC1;
|
||||
break;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a sink for accepting OpenCV images.
|
||||
* WaitForFrame() must be called on the created sink to get each new
|
||||
* image.
|
||||
* Create a sink for accepting OpenCV images. WaitForFrame() must be called on the created sink to
|
||||
* get each new image.
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
*/
|
||||
@@ -52,24 +49,21 @@ public class RawCVMatSink extends ImageSink {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after 0.225 seconds.
|
||||
* The provided image will have three 3-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after 0.225 seconds. The
|
||||
* provided image will have three 3-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message)
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error message)
|
||||
*/
|
||||
public long grabFrame(Mat image) {
|
||||
return grabFrame(image, 0.225);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after timeout seconds.
|
||||
* The provided image will have three 3-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The
|
||||
* provided image will have three 3-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error message); the frame time
|
||||
* is in 1 us increments.
|
||||
*/
|
||||
public long grabFrame(Mat image, double timeout) {
|
||||
frame.setWidth(0);
|
||||
@@ -80,12 +74,20 @@ public class RawCVMatSink extends ImageSink {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (frame.getDataByteBuffer() != origByteBuffer || width != frame.getWidth() || height != frame.getHeight() || pixelFormat != frame.getPixelFormat()) {
|
||||
if (frame.getDataByteBuffer() != origByteBuffer
|
||||
|| width != frame.getWidth()
|
||||
|| height != frame.getHeight()
|
||||
|| pixelFormat != frame.getPixelFormat()) {
|
||||
origByteBuffer = frame.getDataByteBuffer();
|
||||
height = frame.getHeight();
|
||||
width = frame.getWidth();
|
||||
pixelFormat = frame.getPixelFormat();
|
||||
tmpMat = new Mat(frame.getHeight(), frame.getWidth(), getCVFormat(VideoMode.getPixelFormatFromInt(pixelFormat)), origByteBuffer);
|
||||
tmpMat =
|
||||
new Mat(
|
||||
frame.getHeight(),
|
||||
frame.getWidth(),
|
||||
getCVFormat(VideoMode.getPixelFormatFromInt(pixelFormat)),
|
||||
origByteBuffer);
|
||||
}
|
||||
tmpMat.copyTo(image);
|
||||
return rv;
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import edu.wpi.cscore.VideoMode.PixelFormat;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
public class RawCVMatSource extends ImageSource {
|
||||
/**
|
||||
@@ -16,11 +15,9 @@ public class RawCVMatSource extends ImageSource {
|
||||
* @param mode Video mode being generated
|
||||
*/
|
||||
public RawCVMatSource(String name, VideoMode mode) {
|
||||
super(CameraServerJNI.createRawSource(name,
|
||||
mode.pixelFormat.getValue(),
|
||||
mode.width,
|
||||
mode.height,
|
||||
mode.fps));
|
||||
super(
|
||||
CameraServerJNI.createRawSource(
|
||||
name, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,16 +29,17 @@ public class RawCVMatSource extends ImageSource {
|
||||
* @param height height
|
||||
* @param fps fps
|
||||
*/
|
||||
public RawCVMatSource(String name, VideoMode.PixelFormat pixelFormat, int width, int height, int fps) {
|
||||
public RawCVMatSource(
|
||||
String name, VideoMode.PixelFormat pixelFormat, int width, int height, int fps) {
|
||||
super(CameraServerJNI.createRawSource(name, pixelFormat.getValue(), width, height, fps));
|
||||
}
|
||||
|
||||
/**
|
||||
* Put an OpenCV image and notify sinks.
|
||||
*
|
||||
* <p>Only 8-bit single-channel or 3-channel (with BGR channel order) images
|
||||
* are supported. If the format, depth or channel order is different, use
|
||||
* Mat.convertTo() and/or cvtColor() to convert it first.
|
||||
* <p>Only 8-bit single-channel or 3-channel (with BGR channel order) images are supported. If the
|
||||
* format, depth or channel order is different, use Mat.convertTo() and/or cvtColor() to convert
|
||||
* it first.
|
||||
*
|
||||
* @param image OpenCV image
|
||||
*/
|
||||
@@ -51,6 +49,12 @@ public class RawCVMatSource extends ImageSource {
|
||||
throw new VideoException("Unsupported Image Type");
|
||||
}
|
||||
int imgType = channels == 1 ? PixelFormat.kGray.getValue() : PixelFormat.kBGR.getValue();
|
||||
CameraServerJNI.putRawSourceFrame(m_handle, image.dataAddr(), image.width(), image.height(), imgType, (int)image.total() * channels);
|
||||
CameraServerJNI.putRawSourceFrame(
|
||||
m_handle,
|
||||
image.dataAddr(),
|
||||
image.width(),
|
||||
image.height(),
|
||||
imgType,
|
||||
(int) image.total() * channels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,12 @@ package edu.wpi.cscore;
|
||||
import edu.wpi.first.wpiutil.RuntimeDetector;
|
||||
|
||||
public final class DevMain {
|
||||
/**
|
||||
* Main method.
|
||||
*/
|
||||
/** Main method. */
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
System.out.println(RuntimeDetector.getPlatformPath());
|
||||
System.out.println(CameraServerJNI.getHostname());
|
||||
}
|
||||
|
||||
private DevMain() {
|
||||
}
|
||||
private DevMain() {}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source that represents an Axis IP camera.
|
||||
*/
|
||||
/** A source that represents an Axis IP camera. */
|
||||
public class AxisCamera extends HttpCamera {
|
||||
private static String hostToUrl(String host) {
|
||||
return "http://" + host + "/mjpg/video.mjpg";
|
||||
|
||||
@@ -4,13 +4,11 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
|
||||
public class CameraServerCvJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
@@ -33,7 +31,8 @@ public class CameraServerCvJNI {
|
||||
if (Helper.getExtractOnStaticLoad()) {
|
||||
try {
|
||||
CameraServerJNI.forceLoad();
|
||||
loader = new RuntimeLoader<>(opencvName, RuntimeLoader.getDefaultExtractionRoot(), Core.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(opencvName, RuntimeLoader.getDefaultExtractionRoot(), Core.class);
|
||||
loader.loadLibraryHashed();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -43,27 +42,29 @@ public class CameraServerCvJNI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force load the library.
|
||||
*/
|
||||
/** Force load the library. */
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
if (libraryLoaded) {
|
||||
return;
|
||||
}
|
||||
CameraServerJNI.forceLoad();
|
||||
loader = new RuntimeLoader<>(Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class);
|
||||
loader.loadLibrary();
|
||||
libraryLoaded = true;
|
||||
}
|
||||
|
||||
public static native int createCvSource(String name, int pixelFormat, int width, int height, int fps);
|
||||
public static native int createCvSource(
|
||||
String name, int pixelFormat, int width, int height, int fps);
|
||||
|
||||
public static native void putSourceFrame(int source, long imageNativeObj);
|
||||
|
||||
public static native int createCvSink(String name);
|
||||
//public static native int createCvSinkCallback(String name,
|
||||
// public static native int createCvSinkCallback(String name,
|
||||
// void (*processFrame)(long time));
|
||||
|
||||
public static native long grabSinkFrame(int sink, long imageNativeObj);
|
||||
|
||||
public static native long grabSinkFrameTimeout(int sink, long imageNativeObj, double timeout);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import edu.wpi.cscore.raw.RawFrame;
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import edu.wpi.cscore.raw.RawFrame;
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
|
||||
public class CameraServerJNI {
|
||||
static boolean libraryLoaded = false;
|
||||
|
||||
@@ -32,7 +31,9 @@ public class CameraServerJNI {
|
||||
static {
|
||||
if (Helper.getExtractOnStaticLoad()) {
|
||||
try {
|
||||
loader = new RuntimeLoader<>("cscorejni", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"cscorejni", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class);
|
||||
loader.loadLibrary();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -42,14 +43,14 @@ public class CameraServerJNI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force load the library.
|
||||
*/
|
||||
/** Force load the library. */
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
if (libraryLoaded) {
|
||||
return;
|
||||
}
|
||||
loader = new RuntimeLoader<>("cscorejni", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"cscorejni", RuntimeLoader.getDefaultExtractionRoot(), CameraServerJNI.class);
|
||||
loader.loadLibrary();
|
||||
libraryLoaded = true;
|
||||
}
|
||||
@@ -58,89 +59,159 @@ public class CameraServerJNI {
|
||||
// Property Functions
|
||||
//
|
||||
public static native int getPropertyKind(int property);
|
||||
|
||||
public static native String getPropertyName(int property);
|
||||
|
||||
public static native int getProperty(int property);
|
||||
|
||||
public static native void setProperty(int property, int value);
|
||||
|
||||
public static native int getPropertyMin(int property);
|
||||
|
||||
public static native int getPropertyMax(int property);
|
||||
|
||||
public static native int getPropertyStep(int property);
|
||||
|
||||
public static native int getPropertyDefault(int property);
|
||||
|
||||
public static native String getStringProperty(int property);
|
||||
|
||||
public static native void setStringProperty(int property, String value);
|
||||
|
||||
public static native String[] getEnumPropertyChoices(int property);
|
||||
|
||||
//
|
||||
// Source Creation Functions
|
||||
//
|
||||
public static native int createUsbCameraDev(String name, int dev);
|
||||
|
||||
public static native int createUsbCameraPath(String name, String path);
|
||||
|
||||
public static native int createHttpCamera(String name, String url, int kind);
|
||||
|
||||
public static native int createHttpCameraMulti(String name, String[] urls, int kind);
|
||||
public static native int createRawSource(String name, int pixelFormat, int width, int height, int fps);
|
||||
|
||||
public static native int createRawSource(
|
||||
String name, int pixelFormat, int width, int height, int fps);
|
||||
|
||||
//
|
||||
// Source Functions
|
||||
//
|
||||
public static native int getSourceKind(int source);
|
||||
|
||||
public static native String getSourceName(int source);
|
||||
|
||||
public static native String getSourceDescription(int source);
|
||||
|
||||
public static native long getSourceLastFrameTime(int source);
|
||||
|
||||
public static native void setSourceConnectionStrategy(int source, int strategy);
|
||||
|
||||
public static native boolean isSourceConnected(int source);
|
||||
|
||||
public static native boolean isSourceEnabled(int source);
|
||||
|
||||
public static native int getSourceProperty(int source, String name);
|
||||
|
||||
public static native int[] enumerateSourceProperties(int source);
|
||||
|
||||
public static native VideoMode getSourceVideoMode(int source);
|
||||
public static native boolean setSourceVideoMode(int source, int pixelFormat, int width, int height, int fps);
|
||||
|
||||
public static native boolean setSourceVideoMode(
|
||||
int source, int pixelFormat, int width, int height, int fps);
|
||||
|
||||
public static native boolean setSourcePixelFormat(int source, int pixelFormat);
|
||||
|
||||
public static native boolean setSourceResolution(int source, int width, int height);
|
||||
|
||||
public static native boolean setSourceFPS(int source, int fps);
|
||||
|
||||
public static native boolean setSourceConfigJson(int source, String config);
|
||||
|
||||
public static native String getSourceConfigJson(int source);
|
||||
|
||||
public static native VideoMode[] enumerateSourceVideoModes(int source);
|
||||
|
||||
public static native int[] enumerateSourceSinks(int source);
|
||||
|
||||
public static native int copySource(int source);
|
||||
|
||||
public static native void releaseSource(int source);
|
||||
|
||||
//
|
||||
// Camera Source Common Property Fuctions
|
||||
//
|
||||
public static native void setCameraBrightness(int source, int brightness);
|
||||
|
||||
public static native int getCameraBrightness(int source);
|
||||
|
||||
public static native void setCameraWhiteBalanceAuto(int source);
|
||||
|
||||
public static native void setCameraWhiteBalanceHoldCurrent(int source);
|
||||
|
||||
public static native void setCameraWhiteBalanceManual(int source, int value);
|
||||
|
||||
public static native void setCameraExposureAuto(int source);
|
||||
|
||||
public static native void setCameraExposureHoldCurrent(int source);
|
||||
|
||||
public static native void setCameraExposureManual(int source, int value);
|
||||
|
||||
//
|
||||
// UsbCamera Source Functions
|
||||
//
|
||||
public static native void setUsbCameraPath(int source, String path);
|
||||
|
||||
public static native String getUsbCameraPath(int source);
|
||||
|
||||
public static native UsbCameraInfo getUsbCameraInfo(int source);
|
||||
|
||||
//
|
||||
// HttpCamera Source Functions
|
||||
//
|
||||
public static native int getHttpCameraKind(int source);
|
||||
|
||||
public static native void setHttpCameraUrls(int source, String[] urls);
|
||||
|
||||
public static native String[] getHttpCameraUrls(int source);
|
||||
|
||||
//
|
||||
// Image Source Functions
|
||||
//
|
||||
public static native void putRawSourceFrameBB(int source, ByteBuffer data, int width, int height, int pixelFormat, int totalData);
|
||||
public static native void putRawSourceFrame(int source, long data, int width, int height, int pixelFormat, int totalData);
|
||||
public static native void putRawSourceFrameBB(
|
||||
int source, ByteBuffer data, int width, int height, int pixelFormat, int totalData);
|
||||
|
||||
public static native void putRawSourceFrame(
|
||||
int source, long data, int width, int height, int pixelFormat, int totalData);
|
||||
|
||||
public static void putRawSourceFrame(int source, RawFrame raw) {
|
||||
putRawSourceFrame(source, raw.getDataPtr(), raw.getWidth(), raw.getHeight(), raw.getPixelFormat(), raw.getTotalData());
|
||||
putRawSourceFrame(
|
||||
source,
|
||||
raw.getDataPtr(),
|
||||
raw.getWidth(),
|
||||
raw.getHeight(),
|
||||
raw.getPixelFormat(),
|
||||
raw.getTotalData());
|
||||
}
|
||||
|
||||
public static native void notifySourceError(int source, String msg);
|
||||
|
||||
public static native void setSourceConnected(int source, boolean connected);
|
||||
|
||||
public static native void setSourceDescription(int source, String description);
|
||||
public static native int createSourceProperty(int source, String name, int kind, int minimum, int maximum, int step, int defaultValue, int value);
|
||||
public static native void setSourceEnumPropertyChoices(int source, int property, String[] choices);
|
||||
|
||||
public static native int createSourceProperty(
|
||||
int source,
|
||||
String name,
|
||||
int kind,
|
||||
int minimum,
|
||||
int maximum,
|
||||
int step,
|
||||
int defaultValue,
|
||||
int value);
|
||||
|
||||
public static native void setSourceEnumPropertyChoices(
|
||||
int source, int property, String[] choices);
|
||||
|
||||
//
|
||||
// Sink Creation Functions
|
||||
@@ -153,22 +224,34 @@ public class CameraServerJNI {
|
||||
// Sink Functions
|
||||
//
|
||||
public static native int getSinkKind(int sink);
|
||||
|
||||
public static native String getSinkName(int sink);
|
||||
|
||||
public static native String getSinkDescription(int sink);
|
||||
|
||||
public static native int getSinkProperty(int sink, String name);
|
||||
|
||||
public static native int[] enumerateSinkProperties(int sink);
|
||||
|
||||
public static native boolean setSinkConfigJson(int sink, String config);
|
||||
|
||||
public static native String getSinkConfigJson(int sink);
|
||||
|
||||
public static native void setSinkSource(int sink, int source);
|
||||
|
||||
public static native int getSinkSourceProperty(int sink, String name);
|
||||
|
||||
public static native int getSinkSource(int sink);
|
||||
|
||||
public static native int copySink(int sink);
|
||||
|
||||
public static native void releaseSink(int sink);
|
||||
|
||||
//
|
||||
// MjpegServer Sink Functions
|
||||
//
|
||||
public static native String getMjpegServerListenAddress(int sink);
|
||||
|
||||
public static native int getMjpegServerPort(int sink);
|
||||
|
||||
//
|
||||
@@ -176,23 +259,57 @@ public class CameraServerJNI {
|
||||
//
|
||||
public static native void setSinkDescription(int sink, String description);
|
||||
|
||||
private static native long grabRawSinkFrameImpl(int sink, RawFrame rawFrame, long rawFramePtr, ByteBuffer byteBuffer, int width, int height, int pixelFormat);
|
||||
private static native long grabRawSinkFrameTimeoutImpl(int sink, RawFrame rawFrame, long rawFramePtr, ByteBuffer byteBuffer, int width, int height, int pixelFormat, double timeout);
|
||||
private static native long grabRawSinkFrameImpl(
|
||||
int sink,
|
||||
RawFrame rawFrame,
|
||||
long rawFramePtr,
|
||||
ByteBuffer byteBuffer,
|
||||
int width,
|
||||
int height,
|
||||
int pixelFormat);
|
||||
|
||||
private static native long grabRawSinkFrameTimeoutImpl(
|
||||
int sink,
|
||||
RawFrame rawFrame,
|
||||
long rawFramePtr,
|
||||
ByteBuffer byteBuffer,
|
||||
int width,
|
||||
int height,
|
||||
int pixelFormat,
|
||||
double timeout);
|
||||
|
||||
public static long grabSinkFrame(int sink, RawFrame rawFrame) {
|
||||
return grabRawSinkFrameImpl(sink, rawFrame, rawFrame.getFramePtr(), rawFrame.getDataByteBuffer(), rawFrame.getWidth(), rawFrame.getHeight(), rawFrame.getPixelFormat());
|
||||
return grabRawSinkFrameImpl(
|
||||
sink,
|
||||
rawFrame,
|
||||
rawFrame.getFramePtr(),
|
||||
rawFrame.getDataByteBuffer(),
|
||||
rawFrame.getWidth(),
|
||||
rawFrame.getHeight(),
|
||||
rawFrame.getPixelFormat());
|
||||
}
|
||||
|
||||
public static long grabSinkFrameTimeout(int sink, RawFrame rawFrame, double timeout) {
|
||||
return grabRawSinkFrameTimeoutImpl(sink, rawFrame, rawFrame.getFramePtr(), rawFrame.getDataByteBuffer(), rawFrame.getWidth(), rawFrame.getHeight(), rawFrame.getPixelFormat(), timeout);
|
||||
return grabRawSinkFrameTimeoutImpl(
|
||||
sink,
|
||||
rawFrame,
|
||||
rawFrame.getFramePtr(),
|
||||
rawFrame.getDataByteBuffer(),
|
||||
rawFrame.getWidth(),
|
||||
rawFrame.getHeight(),
|
||||
rawFrame.getPixelFormat(),
|
||||
timeout);
|
||||
}
|
||||
|
||||
public static native String getSinkError(int sink);
|
||||
|
||||
public static native void setSinkEnabled(int sink, boolean enabled);
|
||||
|
||||
//
|
||||
// Listener Functions
|
||||
//
|
||||
public static native int addListener(Consumer<VideoEvent> listener,
|
||||
int eventMask, boolean immediateNotify);
|
||||
public static native int addListener(
|
||||
Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify);
|
||||
|
||||
public static native void removeListener(int handle);
|
||||
|
||||
@@ -213,13 +330,19 @@ public class CameraServerJNI {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public static native void setTelemetryPeriod(double seconds);
|
||||
|
||||
public static native double getTelemetryElapsedTime();
|
||||
|
||||
public static native long getTelemetryValue(int handle, int kind);
|
||||
|
||||
public static long getTelemetryValue(int handle, TelemetryKind kind) {
|
||||
return getTelemetryValue(handle, kind.getValue());
|
||||
}
|
||||
|
||||
public static native double getTelemetryAverageValue(int handle, int kind);
|
||||
|
||||
public static double getTelemetryAverageValue(int handle, TelemetryKind kind) {
|
||||
return getTelemetryAverageValue(handle, kind.getValue());
|
||||
}
|
||||
@@ -231,6 +354,7 @@ public class CameraServerJNI {
|
||||
public interface LoggerFunction {
|
||||
void apply(int level, String file, int line, String msg);
|
||||
}
|
||||
|
||||
public static native void setLogger(LoggerFunction func, int minLevel);
|
||||
|
||||
//
|
||||
|
||||
@@ -7,16 +7,13 @@ package edu.wpi.cscore;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
* A sink for user code to accept video frames as OpenCV images.
|
||||
* These sinks require the WPILib OpenCV builds.
|
||||
* For an alternate OpenCV, see the documentation how to build your own
|
||||
* with RawSink.
|
||||
* A sink for user code to accept video frames as OpenCV images. These sinks require the WPILib
|
||||
* OpenCV builds. For an alternate OpenCV, see the documentation how to build your own with RawSink.
|
||||
*/
|
||||
public class CvSink extends ImageSink {
|
||||
/**
|
||||
* Create a sink for accepting OpenCV images.
|
||||
* WaitForFrame() must be called on the created sink to get each new
|
||||
* image.
|
||||
* Create a sink for accepting OpenCV images. WaitForFrame() must be called on the created sink to
|
||||
* get each new image.
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
*/
|
||||
@@ -32,41 +29,38 @@ public class CvSink extends ImageSink {
|
||||
/// time=0 if an error occurred. processFrame should call GetImage()
|
||||
/// or GetError() as needed, but should not call (except in very
|
||||
/// unusual circumstances) WaitForImage().
|
||||
//public CvSink(wpi::StringRef name,
|
||||
// public CvSink(wpi::StringRef name,
|
||||
// std::function<void(uint64_t time)> processFrame) {
|
||||
// super(CameraServerJNI.createCvSinkCallback(name, processFrame));
|
||||
//}
|
||||
// }
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after 0.225 seconds.
|
||||
* The provided image will have three 3-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after 0.225 seconds. The
|
||||
* provided image will have three 3-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message)
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error message)
|
||||
*/
|
||||
public long grabFrame(Mat image) {
|
||||
return grabFrame(image, 0.225);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after timeout seconds.
|
||||
* The provided image will have three 3-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The
|
||||
* provided image will have three 3-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error message); the frame time
|
||||
* is in 1 us increments.
|
||||
*/
|
||||
public long grabFrame(Mat image, double timeout) {
|
||||
return CameraServerCvJNI.grabSinkFrameTimeout(m_handle, image.nativeObj, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image. May block forever.
|
||||
* The provided image will have three 3-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. May block forever. The provided image will have
|
||||
* three 3-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error message); the frame time
|
||||
* is in 1 us increments.
|
||||
*/
|
||||
public long grabFrameNoTimeout(Mat image) {
|
||||
return CameraServerCvJNI.grabSinkFrame(m_handle, image.nativeObj);
|
||||
|
||||
@@ -7,10 +7,8 @@ package edu.wpi.cscore;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
* A source that represents a video camera.
|
||||
* These sources require the WPILib OpenCV builds.
|
||||
* For an alternate OpenCV, see the documentation how to build your own
|
||||
* with RawSource.
|
||||
* A source that represents a video camera. These sources require the WPILib OpenCV builds. For an
|
||||
* alternate OpenCV, see the documentation how to build your own with RawSource.
|
||||
*/
|
||||
public class CvSource extends ImageSource {
|
||||
/**
|
||||
@@ -20,11 +18,9 @@ public class CvSource extends ImageSource {
|
||||
* @param mode Video mode being generated
|
||||
*/
|
||||
public CvSource(String name, VideoMode mode) {
|
||||
super(CameraServerCvJNI.createCvSource(name,
|
||||
mode.pixelFormat.getValue(),
|
||||
mode.width,
|
||||
mode.height,
|
||||
mode.fps));
|
||||
super(
|
||||
CameraServerCvJNI.createCvSource(
|
||||
name, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,14 +39,13 @@ public class CvSource extends ImageSource {
|
||||
/**
|
||||
* Put an OpenCV image and notify sinks.
|
||||
*
|
||||
* <p>Only 8-bit single-channel or 3-channel (with BGR channel order) images
|
||||
* are supported. If the format, depth or channel order is different, use
|
||||
* Mat.convertTo() and/or cvtColor() to convert it first.
|
||||
* <p>Only 8-bit single-channel or 3-channel (with BGR channel order) images are supported. If the
|
||||
* format, depth or channel order is different, use Mat.convertTo() and/or cvtColor() to convert
|
||||
* it first.
|
||||
*
|
||||
* @param image OpenCV image
|
||||
*/
|
||||
public void putFrame(Mat image) {
|
||||
CameraServerCvJNI.putSourceFrame(m_handle, image.nativeObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source that represents a MJPEG-over-HTTP (IP) camera.
|
||||
*/
|
||||
/** A source that represents a MJPEG-over-HTTP (IP) camera. */
|
||||
public class HttpCamera extends VideoCamera {
|
||||
public enum HttpCameraKind {
|
||||
kUnknown(0), kMJPGStreamer(1), kCSCore(2), kAxis(3);
|
||||
kUnknown(0),
|
||||
kMJPGStreamer(1),
|
||||
kCSCore(2),
|
||||
kAxis(3);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -30,10 +31,14 @@ public class HttpCamera extends VideoCamera {
|
||||
*/
|
||||
public static HttpCameraKind getHttpCameraKindFromInt(int kind) {
|
||||
switch (kind) {
|
||||
case 1: return HttpCameraKind.kMJPGStreamer;
|
||||
case 2: return HttpCameraKind.kCSCore;
|
||||
case 3: return HttpCameraKind.kAxis;
|
||||
default: return HttpCameraKind.kUnknown;
|
||||
case 1:
|
||||
return HttpCameraKind.kMJPGStreamer;
|
||||
case 2:
|
||||
return HttpCameraKind.kCSCore;
|
||||
case 3:
|
||||
return HttpCameraKind.kAxis;
|
||||
default:
|
||||
return HttpCameraKind.kUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,23 +87,18 @@ public class HttpCamera extends VideoCamera {
|
||||
/**
|
||||
* Get the kind of HTTP camera.
|
||||
*
|
||||
* <p>Autodetection can result in returning a different value than the camera
|
||||
* was created with.
|
||||
* <p>Autodetection can result in returning a different value than the camera was created with.
|
||||
*/
|
||||
public HttpCameraKind getHttpCameraKind() {
|
||||
return getHttpCameraKindFromInt(CameraServerJNI.getHttpCameraKind(m_handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the URLs used to connect to the camera.
|
||||
*/
|
||||
/** Change the URLs used to connect to the camera. */
|
||||
public void setUrls(String[] urls) {
|
||||
CameraServerJNI.setHttpCameraUrls(m_handle, urls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URLs used to connect to the camera.
|
||||
*/
|
||||
/** Get the URLs used to connect to the camera. */
|
||||
public String[] getUrls() {
|
||||
return CameraServerJNI.getHttpCameraUrls(m_handle);
|
||||
}
|
||||
|
||||
@@ -18,19 +18,15 @@ public abstract class ImageSink extends VideoSink {
|
||||
CameraServerJNI.setSinkDescription(m_handle, description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error string. Call this if WaitForFrame() returns 0 to determine
|
||||
* what the error is.
|
||||
*/
|
||||
/** Get error string. Call this if WaitForFrame() returns 0 to determine what the error is. */
|
||||
public String getError() {
|
||||
return CameraServerJNI.getSinkError(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable getting new frames.
|
||||
* Disabling will cause processFrame (for callback-based CvSinks) to not
|
||||
* be called and WaitForFrame() to not return. This can be used to save
|
||||
* processor resources when frames are not needed.
|
||||
* Enable or disable getting new frames. Disabling will cause processFrame (for callback-based
|
||||
* CvSinks) to not be called and WaitForFrame() to not return. This can be used to save processor
|
||||
* resources when frames are not needed.
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
CameraServerJNI.setSinkEnabled(m_handle, enabled);
|
||||
|
||||
@@ -10,15 +10,15 @@ public abstract class ImageSource extends VideoSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal sinks that an error has occurred. This should be called instead
|
||||
* of NotifyFrame when an error occurs.
|
||||
* Signal sinks that an error has occurred. This should be called instead of NotifyFrame when an
|
||||
* error occurs.
|
||||
*/
|
||||
public void notifyError(String msg) {
|
||||
CameraServerJNI.notifySourceError(m_handle, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set source connection status. Defaults to true.
|
||||
* Set source connection status. Defaults to true.
|
||||
*
|
||||
* @param connected True for connected, false for disconnected
|
||||
*/
|
||||
@@ -47,22 +47,17 @@ public abstract class ImageSource extends VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
public VideoProperty createProperty(String name,
|
||||
VideoProperty.Kind kind,
|
||||
int minimum,
|
||||
int maximum,
|
||||
int step,
|
||||
int defaultValue,
|
||||
int value) {
|
||||
public VideoProperty createProperty(
|
||||
String name,
|
||||
VideoProperty.Kind kind,
|
||||
int minimum,
|
||||
int maximum,
|
||||
int step,
|
||||
int defaultValue,
|
||||
int value) {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle,
|
||||
name,
|
||||
kind.getValue(),
|
||||
minimum,
|
||||
maximum,
|
||||
step,
|
||||
defaultValue,
|
||||
value));
|
||||
CameraServerJNI.createSourceProperty(
|
||||
m_handle, name, kind.getValue(), minimum, maximum, step, defaultValue, value));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,14 +71,11 @@ public abstract class ImageSource extends VideoSource {
|
||||
* @param value Current value
|
||||
* @return Property
|
||||
*/
|
||||
public VideoProperty createIntegerProperty(String name,
|
||||
int minimum,
|
||||
int maximum,
|
||||
int step,
|
||||
int defaultValue,
|
||||
int value) {
|
||||
public VideoProperty createIntegerProperty(
|
||||
String name, int minimum, int maximum, int step, int defaultValue, int value) {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle,
|
||||
CameraServerJNI.createSourceProperty(
|
||||
m_handle,
|
||||
name,
|
||||
VideoProperty.Kind.kInteger.getValue(),
|
||||
minimum,
|
||||
@@ -103,7 +95,8 @@ public abstract class ImageSource extends VideoSource {
|
||||
*/
|
||||
public VideoProperty createBooleanProperty(String name, boolean defaultValue, boolean value) {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle,
|
||||
CameraServerJNI.createSourceProperty(
|
||||
m_handle,
|
||||
name,
|
||||
VideoProperty.Kind.kBoolean.getValue(),
|
||||
0,
|
||||
@@ -121,15 +114,10 @@ public abstract class ImageSource extends VideoSource {
|
||||
* @return Property
|
||||
*/
|
||||
public VideoProperty createStringProperty(String name, String value) {
|
||||
VideoProperty prop = new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(m_handle,
|
||||
name,
|
||||
VideoProperty.Kind.kString.getValue(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0));
|
||||
VideoProperty prop =
|
||||
new VideoProperty(
|
||||
CameraServerJNI.createSourceProperty(
|
||||
m_handle, name, VideoProperty.Kind.kString.getValue(), 0, 0, 0, 0, 0));
|
||||
prop.setString(value);
|
||||
return prop;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A sink that acts as a MJPEG-over-HTTP network server.
|
||||
*/
|
||||
/** A sink that acts as a MJPEG-over-HTTP network server. */
|
||||
public class MjpegServer extends VideoSink {
|
||||
/**
|
||||
* Create a MJPEG-over-HTTP server sink.
|
||||
@@ -29,16 +27,12 @@ public class MjpegServer extends VideoSink {
|
||||
this(name, "", port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the listen address of the server.
|
||||
*/
|
||||
/** Get the listen address of the server. */
|
||||
public String getListenAddress() {
|
||||
return CameraServerJNI.getMjpegServerListenAddress(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the port number of the server.
|
||||
*/
|
||||
/** Get the port number of the server. */
|
||||
public int getPort() {
|
||||
return CameraServerJNI.getMjpegServerPort(m_handle);
|
||||
}
|
||||
@@ -46,13 +40,11 @@ public class MjpegServer extends VideoSink {
|
||||
/**
|
||||
* Set the stream resolution for clients that don't specify it.
|
||||
*
|
||||
* <p>It is not necessary to set this if it is the same as the source
|
||||
* resolution.
|
||||
* <p>It is not necessary to set this if it is the same as the source resolution.
|
||||
*
|
||||
* <p>Setting this different than the source resolution will result in
|
||||
* increased CPU usage, particularly for MJPEG source cameras, as it will
|
||||
* decompress, resize, and recompress the image, instead of using the
|
||||
* camera's MJPEG image directly.
|
||||
* <p>Setting this different than the source resolution will result in increased CPU usage,
|
||||
* particularly for MJPEG source cameras, as it will decompress, resize, and recompress the image,
|
||||
* instead of using the camera's MJPEG image directly.
|
||||
*
|
||||
* @param width width, 0 for unspecified
|
||||
* @param height height, 0 for unspecified
|
||||
@@ -76,26 +68,24 @@ public class MjpegServer extends VideoSink {
|
||||
/**
|
||||
* Set the compression for clients that don't specify it.
|
||||
*
|
||||
* <p>Setting this will result in increased CPU usage for MJPEG source cameras
|
||||
* as it will decompress and recompress the image instead of using the
|
||||
* camera's MJPEG image directly.
|
||||
* <p>Setting this will result in increased CPU usage for MJPEG source cameras as it will
|
||||
* decompress and recompress the image instead of using the camera's MJPEG image directly.
|
||||
*
|
||||
* @param quality JPEG compression quality (0-100), -1 for unspecified
|
||||
*/
|
||||
public void setCompression(int quality) {
|
||||
CameraServerJNI.setProperty(CameraServerJNI.getSinkProperty(m_handle, "compression"),
|
||||
quality);
|
||||
CameraServerJNI.setProperty(CameraServerJNI.getSinkProperty(m_handle, "compression"), quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default compression used for non-MJPEG sources. If not set,
|
||||
* 80 is used. This function has no effect on MJPEG source cameras; use
|
||||
* SetCompression() instead to force recompression of MJPEG source images.
|
||||
* Set the default compression used for non-MJPEG sources. If not set, 80 is used. This function
|
||||
* has no effect on MJPEG source cameras; use SetCompression() instead to force recompression of
|
||||
* MJPEG source images.
|
||||
*
|
||||
* @param quality JPEG compression quality (0-100)
|
||||
*/
|
||||
public void setDefaultCompression(int quality) {
|
||||
CameraServerJNI.setProperty(CameraServerJNI.getSinkProperty(m_handle, "default_compression"),
|
||||
quality);
|
||||
CameraServerJNI.setProperty(
|
||||
CameraServerJNI.getSinkProperty(m_handle, "default_compression"), quality);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source that represents a USB camera.
|
||||
*/
|
||||
/** A source that represents a USB camera. */
|
||||
public class UsbCamera extends VideoCamera {
|
||||
/**
|
||||
* Create a source for a USB camera based on device number.
|
||||
@@ -37,23 +35,17 @@ public class UsbCamera extends VideoCamera {
|
||||
return CameraServerJNI.enumerateUsbCameras();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the path to the device.
|
||||
*/
|
||||
/** Change the path to the device. */
|
||||
void setPath(String path) {
|
||||
CameraServerJNI.setUsbCameraPath(m_handle, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the device.
|
||||
*/
|
||||
/** Get the path to the device. */
|
||||
public String getPath() {
|
||||
return CameraServerJNI.getUsbCameraPath(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full camera information for the device.
|
||||
*/
|
||||
/** Get the full camera information for the device. */
|
||||
public UsbCameraInfo getInfo() {
|
||||
return CameraServerJNI.getUsbCameraInfo(m_handle);
|
||||
}
|
||||
@@ -64,7 +56,7 @@ public class UsbCamera extends VideoCamera {
|
||||
* @param level 0=don't display Connecting message, 1=do display message
|
||||
*/
|
||||
public void setConnectVerbose(int level) {
|
||||
CameraServerJNI.setProperty(CameraServerJNI.getSourceProperty(m_handle, "connect_verbose"),
|
||||
level);
|
||||
CameraServerJNI.setProperty(
|
||||
CameraServerJNI.getSourceProperty(m_handle, "connect_verbose"), level);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* USB camera information.
|
||||
*/
|
||||
/** USB camera information. */
|
||||
public class UsbCameraInfo {
|
||||
/**
|
||||
* Create a new set of UsbCameraInfo.
|
||||
@@ -19,8 +17,8 @@ public class UsbCameraInfo {
|
||||
* @param productId USB product id
|
||||
*/
|
||||
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
|
||||
public UsbCameraInfo(int dev, String path, String name, String[] otherPaths, int vendorId,
|
||||
int productId) {
|
||||
public UsbCameraInfo(
|
||||
int dev, String path, String name, String[] otherPaths, int vendorId, int productId) {
|
||||
this.dev = dev;
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
@@ -29,39 +27,27 @@ public class UsbCameraInfo {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device number (e.g. N in '/dev/videoN' on Linux).
|
||||
*/
|
||||
/** Device number (e.g. N in '/dev/videoN' on Linux). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int dev;
|
||||
|
||||
/**
|
||||
* Path to device if available (e.g. '/dev/video0' on Linux).
|
||||
*/
|
||||
/** Path to device if available (e.g. '/dev/video0' on Linux). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String path;
|
||||
|
||||
/**
|
||||
* Vendor/model name of the camera as provided by the USB driver.
|
||||
*/
|
||||
/** Vendor/model name of the camera as provided by the USB driver. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String name;
|
||||
|
||||
/**
|
||||
* Other path aliases to device (e.g. '/dev/v4l/by-id/...' etc on Linux).
|
||||
*/
|
||||
/** Other path aliases to device (e.g. '/dev/v4l/by-id/...' etc on Linux). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String[] otherPaths;
|
||||
|
||||
/**
|
||||
* USB vendor id.
|
||||
*/
|
||||
/** USB vendor id. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int vendorId;
|
||||
|
||||
/**
|
||||
* USB product id.
|
||||
*/
|
||||
/** USB product id. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int productId;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source that represents a video camera.
|
||||
*/
|
||||
/** A source that represents a video camera. */
|
||||
public class VideoCamera extends VideoSource {
|
||||
public static class WhiteBalance {
|
||||
public static final int kFixedIndoor = 3000;
|
||||
@@ -20,58 +18,42 @@ public class VideoCamera extends VideoSource {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the brightness, as a percentage (0-100).
|
||||
*/
|
||||
/** Set the brightness, as a percentage (0-100). */
|
||||
public synchronized void setBrightness(int brightness) {
|
||||
CameraServerJNI.setCameraBrightness(m_handle, brightness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the brightness, as a percentage (0-100).
|
||||
*/
|
||||
/** Get the brightness, as a percentage (0-100). */
|
||||
public synchronized int getBrightness() {
|
||||
return CameraServerJNI.getCameraBrightness(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the white balance to auto.
|
||||
*/
|
||||
/** Set the white balance to auto. */
|
||||
public synchronized void setWhiteBalanceAuto() {
|
||||
CameraServerJNI.setCameraWhiteBalanceAuto(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the white balance to hold current.
|
||||
*/
|
||||
/** Set the white balance to hold current. */
|
||||
public synchronized void setWhiteBalanceHoldCurrent() {
|
||||
CameraServerJNI.setCameraWhiteBalanceHoldCurrent(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the white balance to manual, with specified color temperature.
|
||||
*/
|
||||
/** Set the white balance to manual, with specified color temperature. */
|
||||
public synchronized void setWhiteBalanceManual(int value) {
|
||||
CameraServerJNI.setCameraWhiteBalanceManual(m_handle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exposure to auto aperture.
|
||||
*/
|
||||
/** Set the exposure to auto aperture. */
|
||||
public synchronized void setExposureAuto() {
|
||||
CameraServerJNI.setCameraExposureAuto(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exposure to hold current.
|
||||
*/
|
||||
/** Set the exposure to hold current. */
|
||||
public synchronized void setExposureHoldCurrent() {
|
||||
CameraServerJNI.setCameraExposureHoldCurrent(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the exposure to manual, as a percentage (0-100).
|
||||
*/
|
||||
/** Set the exposure to manual, as a percentage (0-100). */
|
||||
public synchronized void setExposureManual(int value) {
|
||||
CameraServerJNI.setCameraExposureManual(m_handle, value);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* Video event.
|
||||
*/
|
||||
/** Video event. */
|
||||
public class VideoEvent {
|
||||
public enum Kind {
|
||||
kUnknown(0x0000),
|
||||
@@ -50,32 +48,61 @@ public class VideoEvent {
|
||||
@SuppressWarnings("PMD.CyclomaticComplexity")
|
||||
public static Kind getKindFromInt(int kind) {
|
||||
switch (kind) {
|
||||
case 0x0001: return Kind.kSourceCreated;
|
||||
case 0x0002: return Kind.kSourceDestroyed;
|
||||
case 0x0004: return Kind.kSourceConnected;
|
||||
case 0x0008: return Kind.kSourceDisconnected;
|
||||
case 0x0010: return Kind.kSourceVideoModesUpdated;
|
||||
case 0x0020: return Kind.kSourceVideoModeChanged;
|
||||
case 0x0040: return Kind.kSourcePropertyCreated;
|
||||
case 0x0080: return Kind.kSourcePropertyValueUpdated;
|
||||
case 0x0100: return Kind.kSourcePropertyChoicesUpdated;
|
||||
case 0x0200: return Kind.kSinkSourceChanged;
|
||||
case 0x0400: return Kind.kSinkCreated;
|
||||
case 0x0800: return Kind.kSinkDestroyed;
|
||||
case 0x1000: return Kind.kSinkEnabled;
|
||||
case 0x2000: return Kind.kSinkDisabled;
|
||||
case 0x4000: return Kind.kNetworkInterfacesChanged;
|
||||
case 0x10000: return Kind.kSinkPropertyCreated;
|
||||
case 0x20000: return Kind.kSinkPropertyValueUpdated;
|
||||
case 0x40000: return Kind.kSinkPropertyChoicesUpdated;
|
||||
default: return Kind.kUnknown;
|
||||
case 0x0001:
|
||||
return Kind.kSourceCreated;
|
||||
case 0x0002:
|
||||
return Kind.kSourceDestroyed;
|
||||
case 0x0004:
|
||||
return Kind.kSourceConnected;
|
||||
case 0x0008:
|
||||
return Kind.kSourceDisconnected;
|
||||
case 0x0010:
|
||||
return Kind.kSourceVideoModesUpdated;
|
||||
case 0x0020:
|
||||
return Kind.kSourceVideoModeChanged;
|
||||
case 0x0040:
|
||||
return Kind.kSourcePropertyCreated;
|
||||
case 0x0080:
|
||||
return Kind.kSourcePropertyValueUpdated;
|
||||
case 0x0100:
|
||||
return Kind.kSourcePropertyChoicesUpdated;
|
||||
case 0x0200:
|
||||
return Kind.kSinkSourceChanged;
|
||||
case 0x0400:
|
||||
return Kind.kSinkCreated;
|
||||
case 0x0800:
|
||||
return Kind.kSinkDestroyed;
|
||||
case 0x1000:
|
||||
return Kind.kSinkEnabled;
|
||||
case 0x2000:
|
||||
return Kind.kSinkDisabled;
|
||||
case 0x4000:
|
||||
return Kind.kNetworkInterfacesChanged;
|
||||
case 0x10000:
|
||||
return Kind.kSinkPropertyCreated;
|
||||
case 0x20000:
|
||||
return Kind.kSinkPropertyValueUpdated;
|
||||
case 0x40000:
|
||||
return Kind.kSinkPropertyChoicesUpdated;
|
||||
default:
|
||||
return Kind.kUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.ExcessiveParameterList")
|
||||
VideoEvent(int kind, int source, int sink, String name, int pixelFormat,
|
||||
int width, int height, int fps, int property, int propertyKind,
|
||||
int value, String valueStr) {
|
||||
VideoEvent(
|
||||
int kind,
|
||||
int source,
|
||||
int sink,
|
||||
String name,
|
||||
int pixelFormat,
|
||||
int width,
|
||||
int height,
|
||||
int fps,
|
||||
int property,
|
||||
int propertyKind,
|
||||
int value,
|
||||
String valueStr) {
|
||||
this.kind = getKindFromInt(kind);
|
||||
this.sourceHandle = source;
|
||||
this.sinkHandle = sink;
|
||||
@@ -93,6 +120,7 @@ public class VideoEvent {
|
||||
// Valid for kSource* and kSink* respectively
|
||||
@SuppressWarnings("MemberName")
|
||||
public int sourceHandle;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public int sinkHandle;
|
||||
|
||||
@@ -107,10 +135,13 @@ public class VideoEvent {
|
||||
// Fields for kSourceProperty* events
|
||||
@SuppressWarnings("MemberName")
|
||||
public int propertyHandle;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public VideoProperty.Kind propertyKind;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public int value;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public String valueStr;
|
||||
|
||||
@@ -125,5 +156,4 @@ public class VideoEvent {
|
||||
public VideoProperty getProperty() {
|
||||
return new VideoProperty(propertyHandle, propertyKind);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* An exception raised by the camera server.
|
||||
*/
|
||||
/** An exception raised by the camera server. */
|
||||
public class VideoException extends RuntimeException {
|
||||
private static final long serialVersionUID = -9155939328084105145L;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ package edu.wpi.cscore;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* An event listener. This calls back to a desigated callback function when
|
||||
* an event matching the specified mask is generated by the library.
|
||||
* An event listener. This calls back to a desigated callback function when an event matching the
|
||||
* specified mask is generated by the library.
|
||||
*/
|
||||
public class VideoListener implements AutoCloseable {
|
||||
/**
|
||||
@@ -16,11 +16,10 @@ public class VideoListener implements AutoCloseable {
|
||||
*
|
||||
* @param listener Listener function
|
||||
* @param eventMask Bitmask of VideoEvent.Type values
|
||||
* @param immediateNotify Whether callback should be immediately called with
|
||||
* a representative set of events for the current library state.
|
||||
* @param immediateNotify Whether callback should be immediately called with a representative set
|
||||
* of events for the current library state.
|
||||
*/
|
||||
public VideoListener(Consumer<VideoEvent> listener, int eventMask,
|
||||
boolean immediateNotify) {
|
||||
public VideoListener(Consumer<VideoEvent> listener, int eventMask, boolean immediateNotify) {
|
||||
m_handle = CameraServerJNI.addListener(listener, eventMask, immediateNotify);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* Video mode.
|
||||
*/
|
||||
/** Video mode. */
|
||||
public class VideoMode {
|
||||
public enum PixelFormat {
|
||||
kUnknown(0), kMJPEG(1), kYUYV(2), kRGB565(3), kBGR(4), kGray(5);
|
||||
kUnknown(0),
|
||||
kMJPEG(1),
|
||||
kYUYV(2),
|
||||
kRGB565(3),
|
||||
kBGR(4),
|
||||
kGray(5);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -28,9 +31,7 @@ public class VideoMode {
|
||||
return m_pixelFormatValues[pixelFormat];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new video mode.
|
||||
*/
|
||||
/** Create a new video mode. */
|
||||
public VideoMode(int pixelFormat, int width, int height, int fps) {
|
||||
this.pixelFormat = getPixelFormatFromInt(pixelFormat);
|
||||
this.width = width;
|
||||
@@ -38,9 +39,7 @@ public class VideoMode {
|
||||
this.fps = fps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new video mode.
|
||||
*/
|
||||
/** Create a new video mode. */
|
||||
public VideoMode(PixelFormat pixelFormat, int width, int height, int fps) {
|
||||
this.pixelFormat = pixelFormat;
|
||||
this.width = width;
|
||||
@@ -48,27 +47,19 @@ public class VideoMode {
|
||||
this.fps = fps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pixel format.
|
||||
*/
|
||||
/** Pixel format. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public PixelFormat pixelFormat;
|
||||
|
||||
/**
|
||||
* Width in pixels.
|
||||
*/
|
||||
/** Width in pixels. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int width;
|
||||
|
||||
/**
|
||||
* Height in pixels.
|
||||
*/
|
||||
/** Height in pixels. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int height;
|
||||
|
||||
/**
|
||||
* Frames per second.
|
||||
*/
|
||||
/** Frames per second. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int fps;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source or sink property.
|
||||
*/
|
||||
/** A source or sink property. */
|
||||
public class VideoProperty {
|
||||
public enum Kind {
|
||||
kNone(0), kBoolean(1), kInteger(2), kString(4), kEnum(8);
|
||||
kNone(0),
|
||||
kBoolean(1),
|
||||
kInteger(2),
|
||||
kString(4),
|
||||
kEnum(8);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -30,11 +32,16 @@ public class VideoProperty {
|
||||
*/
|
||||
public static Kind getKindFromInt(int kind) {
|
||||
switch (kind) {
|
||||
case 1: return Kind.kBoolean;
|
||||
case 2: return Kind.kInteger;
|
||||
case 4: return Kind.kString;
|
||||
case 8: return Kind.kEnum;
|
||||
default: return Kind.kNone;
|
||||
case 1:
|
||||
return Kind.kBoolean;
|
||||
case 2:
|
||||
return Kind.kInteger;
|
||||
case 4:
|
||||
return Kind.kString;
|
||||
case 8:
|
||||
return Kind.kEnum;
|
||||
default:
|
||||
return Kind.kNone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source for video that provides a sequence of frames. Each frame may
|
||||
* consist of multiple images (e.g. from a stereo or depth camera); these
|
||||
* are called channels.
|
||||
* A source for video that provides a sequence of frames. Each frame may consist of multiple images
|
||||
* (e.g. from a stereo or depth camera); these are called channels.
|
||||
*/
|
||||
public class VideoSink implements AutoCloseable {
|
||||
public enum Kind {
|
||||
kUnknown(0), kMjpeg(2), kCv(4), kRaw(8);
|
||||
kUnknown(0),
|
||||
kMjpeg(2),
|
||||
kCv(4),
|
||||
kRaw(8);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -32,9 +34,12 @@ public class VideoSink implements AutoCloseable {
|
||||
*/
|
||||
public static Kind getKindFromInt(int kind) {
|
||||
switch (kind) {
|
||||
case 2: return Kind.kMjpeg;
|
||||
case 4: return Kind.kCv;
|
||||
default: return Kind.kUnknown;
|
||||
case 2:
|
||||
return Kind.kMjpeg;
|
||||
case 4:
|
||||
return Kind.kCv;
|
||||
default:
|
||||
return Kind.kUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,24 +83,20 @@ public class VideoSink implements AutoCloseable {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kind of the sink.
|
||||
*/
|
||||
/** Get the kind of the sink. */
|
||||
public Kind getKind() {
|
||||
return getKindFromInt(CameraServerJNI.getSinkKind(m_handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the sink. The name is an arbitrary identifier
|
||||
* provided when the sink is created, and should be unique.
|
||||
* Get the name of the sink. The name is an arbitrary identifier provided when the sink is
|
||||
* created, and should be unique.
|
||||
*/
|
||||
public String getName() {
|
||||
return CameraServerJNI.getSinkName(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sink description. This is sink-kind specific.
|
||||
*/
|
||||
/** Get the sink description. This is sink-kind specific. */
|
||||
public String getDescription() {
|
||||
return CameraServerJNI.getSinkDescription(m_handle);
|
||||
}
|
||||
@@ -104,16 +105,13 @@ public class VideoSink implements AutoCloseable {
|
||||
* Get a property of the sink.
|
||||
*
|
||||
* @param name Property name
|
||||
* @return Property (kind Property::kNone if no property with
|
||||
* the given name exists)
|
||||
* @return Property (kind Property::kNone if no property with the given name exists)
|
||||
*/
|
||||
public VideoProperty getProperty(String name) {
|
||||
return new VideoProperty(CameraServerJNI.getSinkProperty(m_handle, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate all properties of this sink.
|
||||
*/
|
||||
/** Enumerate all properties of this sink. */
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
public VideoProperty[] enumerateProperties() {
|
||||
int[] handles = CameraServerJNI.enumerateSinkProperties(m_handle);
|
||||
@@ -157,9 +155,8 @@ public class VideoSink implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure which source should provide frames to this sink. Each sink
|
||||
* can accept frames from only a single source, but a single source can
|
||||
* provide frames to multiple clients.
|
||||
* Configure which source should provide frames to this sink. Each sink can accept frames from
|
||||
* only a single source, but a single source can provide frames to multiple clients.
|
||||
*
|
||||
* @param source Source
|
||||
*/
|
||||
@@ -186,12 +183,11 @@ public class VideoSink implements AutoCloseable {
|
||||
* Get a property of the associated source.
|
||||
*
|
||||
* @param name Property name
|
||||
* @return Property (kind Property::kNone if no property with
|
||||
* the given name exists or no source connected)
|
||||
* @return Property (kind Property::kNone if no property with the given name exists or no source
|
||||
* connected)
|
||||
*/
|
||||
public VideoProperty getSourceProperty(String name) {
|
||||
return new VideoProperty(
|
||||
CameraServerJNI.getSinkSourceProperty(m_handle, name));
|
||||
return new VideoProperty(CameraServerJNI.getSinkSourceProperty(m_handle, name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/**
|
||||
* A source for video that provides a sequence of frames. Each frame may
|
||||
* consist of multiple images (e.g. from a stereo or depth camera); these
|
||||
* are called channels.
|
||||
* A source for video that provides a sequence of frames. Each frame may consist of multiple images
|
||||
* (e.g. from a stereo or depth camera); these are called channels.
|
||||
*/
|
||||
public class VideoSource implements AutoCloseable {
|
||||
public enum Kind {
|
||||
kUnknown(0), kUsb(1), kHttp(2), kCv(4), kRaw(8);
|
||||
kUnknown(0),
|
||||
kUsb(1),
|
||||
kHttp(2),
|
||||
kCv(4),
|
||||
kRaw(8);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -24,25 +27,19 @@ public class VideoSource implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection strategy.
|
||||
*/
|
||||
/** Connection strategy. */
|
||||
public enum ConnectionStrategy {
|
||||
/**
|
||||
* Automatically connect or disconnect based on whether any sinks are
|
||||
* connected to this source. This is the default behavior.
|
||||
* Automatically connect or disconnect based on whether any sinks are connected to this source.
|
||||
* This is the default behavior.
|
||||
*/
|
||||
kAutoManage(0),
|
||||
|
||||
/**
|
||||
* Try to keep the connection open regardless of whether any sinks are
|
||||
* connected.
|
||||
*/
|
||||
/** Try to keep the connection open regardless of whether any sinks are connected. */
|
||||
kKeepOpen(1),
|
||||
|
||||
/**
|
||||
* Never open the connection. If this is set when the connection is open,
|
||||
* close the connection.
|
||||
* Never open the connection. If this is set when the connection is open, close the connection.
|
||||
*/
|
||||
kForceClose(2);
|
||||
|
||||
@@ -65,10 +62,14 @@ public class VideoSource implements AutoCloseable {
|
||||
*/
|
||||
public static Kind getKindFromInt(int kind) {
|
||||
switch (kind) {
|
||||
case 1: return Kind.kUsb;
|
||||
case 2: return Kind.kHttp;
|
||||
case 4: return Kind.kCv;
|
||||
default: return Kind.kUnknown;
|
||||
case 1:
|
||||
return Kind.kUsb;
|
||||
case 2:
|
||||
return Kind.kHttp;
|
||||
case 4:
|
||||
return Kind.kCv;
|
||||
default:
|
||||
return Kind.kUnknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,30 +113,27 @@ public class VideoSource implements AutoCloseable {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the kind of the source.
|
||||
*/
|
||||
/** Get the kind of the source. */
|
||||
public Kind getKind() {
|
||||
return getKindFromInt(CameraServerJNI.getSourceKind(m_handle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the source. The name is an arbitrary identifier
|
||||
* provided when the source is created, and should be unique.
|
||||
* Get the name of the source. The name is an arbitrary identifier provided when the source is
|
||||
* created, and should be unique.
|
||||
*/
|
||||
public String getName() {
|
||||
return CameraServerJNI.getSourceName(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source description. This is source-kind specific.
|
||||
*/
|
||||
/** Get the source description. This is source-kind specific. */
|
||||
public String getDescription() {
|
||||
return CameraServerJNI.getSourceDescription(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last time a frame was captured.
|
||||
*
|
||||
* @return Time in 1 us increments.
|
||||
*/
|
||||
public long getLastFrameTime() {
|
||||
@@ -143,12 +141,11 @@ public class VideoSource implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection strategy. By default, the source will automatically
|
||||
* connect or disconnect based on whether any sinks are connected.
|
||||
* Sets the connection strategy. By default, the source will automatically connect or disconnect
|
||||
* based on whether any sinks are connected.
|
||||
*
|
||||
* <p>This function is non-blocking; look for either a connection open or
|
||||
* close event or call {@link #isConnected()} to determine the connection
|
||||
* state.
|
||||
* <p>This function is non-blocking; look for either a connection open or close event or call
|
||||
* {@link #isConnected()} to determine the connection state.
|
||||
*
|
||||
* @param strategy connection strategy (auto, keep open, or force close)
|
||||
*/
|
||||
@@ -156,16 +153,14 @@ public class VideoSource implements AutoCloseable {
|
||||
CameraServerJNI.setSourceConnectionStrategy(m_handle, strategy.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the source currently connected to whatever is providing the images.
|
||||
*/
|
||||
/** Returns if the source currently connected to whatever is providing the images. */
|
||||
public boolean isConnected() {
|
||||
return CameraServerJNI.isSourceConnected(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets source enable status. This is determined with a combination of
|
||||
* connection strategy and the number of sinks connected.
|
||||
* Gets source enable status. This is determined with a combination of connection strategy and the
|
||||
* number of sinks connected.
|
||||
*
|
||||
* @return True if enabled, false otherwise.
|
||||
*/
|
||||
@@ -177,16 +172,13 @@ public class VideoSource implements AutoCloseable {
|
||||
* Get a property.
|
||||
*
|
||||
* @param name Property name
|
||||
* @return Property contents (of kind Property::kNone if no property with
|
||||
* the given name exists)
|
||||
* @return Property contents (of kind Property::kNone if no property with the given name exists)
|
||||
*/
|
||||
public VideoProperty getProperty(String name) {
|
||||
return new VideoProperty(CameraServerJNI.getSourceProperty(m_handle, name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate all properties of this source.
|
||||
*/
|
||||
/** Enumerate all properties of this source. */
|
||||
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
|
||||
public VideoProperty[] enumerateProperties() {
|
||||
int[] handles = CameraServerJNI.enumerateSourceProperties(m_handle);
|
||||
@@ -197,23 +189,19 @@ public class VideoSource implements AutoCloseable {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current video mode.
|
||||
*/
|
||||
/** Get the current video mode. */
|
||||
public VideoMode getVideoMode() {
|
||||
return CameraServerJNI.getSourceVideoMode(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the video mode.
|
||||
*
|
||||
* @param mode Video mode
|
||||
*/
|
||||
public boolean setVideoMode(VideoMode mode) {
|
||||
return CameraServerJNI.setSourceVideoMode(m_handle,
|
||||
mode.pixelFormat.getValue(),
|
||||
mode.width,
|
||||
mode.height,
|
||||
mode.fps);
|
||||
return CameraServerJNI.setSourceVideoMode(
|
||||
m_handle, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,32 +290,30 @@ public class VideoSource implements AutoCloseable {
|
||||
/**
|
||||
* Get the actual FPS.
|
||||
*
|
||||
* <p>CameraServerJNI#setTelemetryPeriod() must be called for this to be valid
|
||||
* (throws VisionException if telemetry is not enabled).
|
||||
* <p>CameraServerJNI#setTelemetryPeriod() must be called for this to be valid (throws
|
||||
* VisionException if telemetry is not enabled).
|
||||
*
|
||||
* @return Actual FPS averaged over the telemetry period.
|
||||
*/
|
||||
public double getActualFPS() {
|
||||
return CameraServerJNI.getTelemetryAverageValue(m_handle,
|
||||
CameraServerJNI.TelemetryKind.kSourceFramesReceived);
|
||||
return CameraServerJNI.getTelemetryAverageValue(
|
||||
m_handle, CameraServerJNI.TelemetryKind.kSourceFramesReceived);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data rate (in bytes per second).
|
||||
*
|
||||
* <p>CameraServerJNI#setTelemetryPeriod() must be called for this to be valid
|
||||
* (throws VisionException if telemetry is not enabled).
|
||||
* <p>CameraServerJNI#setTelemetryPeriod() must be called for this to be valid (throws
|
||||
* VisionException if telemetry is not enabled).
|
||||
*
|
||||
* @return Data rate averaged over the telemetry period.
|
||||
*/
|
||||
public double getActualDataRate() {
|
||||
return CameraServerJNI.getTelemetryAverageValue(m_handle,
|
||||
CameraServerJNI.TelemetryKind.kSourceBytesReceived);
|
||||
return CameraServerJNI.getTelemetryAverageValue(
|
||||
m_handle, CameraServerJNI.TelemetryKind.kSourceBytesReceived);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate all known video modes for this source.
|
||||
*/
|
||||
/** Enumerate all known video modes for this source. */
|
||||
public VideoMode[] enumerateVideoModes() {
|
||||
return CameraServerJNI.enumerateSourceVideoModes(m_handle);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
package edu.wpi.cscore.raw;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import edu.wpi.cscore.CameraServerJNI;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Class for storing raw frame data between image read call.
|
||||
@@ -22,27 +21,28 @@ public class RawFrame implements AutoCloseable {
|
||||
private int m_height;
|
||||
private int m_pixelFormat;
|
||||
|
||||
/**
|
||||
* Construct a new RawFrame.
|
||||
*/
|
||||
/** Construct a new RawFrame. */
|
||||
public RawFrame() {
|
||||
m_framePtr = CameraServerJNI.allocateRawFrame();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the RawFrame, releasing native resources.
|
||||
* Any images currently using the data will be invalidated.
|
||||
* Close the RawFrame, releasing native resources. Any images currently using the data will be
|
||||
* invalidated.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
CameraServerJNI.freeRawFrame(m_framePtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from JNI to set data in class.
|
||||
*/
|
||||
public void setData(ByteBuffer dataByteBuffer, long dataPtr, int totalData,
|
||||
int width, int height, int pixelFormat) {
|
||||
/** Called from JNI to set data in class. */
|
||||
public void setData(
|
||||
ByteBuffer dataByteBuffer,
|
||||
long dataPtr,
|
||||
int totalData,
|
||||
int width,
|
||||
int height,
|
||||
int pixelFormat) {
|
||||
m_dataByteBuffer = dataByteBuffer;
|
||||
m_dataPtr = dataPtr;
|
||||
m_totalData = totalData;
|
||||
@@ -51,76 +51,60 @@ public class RawFrame implements AutoCloseable {
|
||||
m_pixelFormat = pixelFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer to native representation of this frame.
|
||||
*/
|
||||
/** Get the pointer to native representation of this frame. */
|
||||
public long getFramePtr() {
|
||||
return m_framePtr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a ByteBuffer pointing to the frame data.
|
||||
* This ByteBuffer is backed by the frame directly. Its lifetime is controlled by
|
||||
* the frame. If a new frame gets read, it will overwrite the current one.
|
||||
* Get a ByteBuffer pointing to the frame data. This ByteBuffer is backed by the frame directly.
|
||||
* Its lifetime is controlled by the frame. If a new frame gets read, it will overwrite the
|
||||
* current one.
|
||||
*/
|
||||
public ByteBuffer getDataByteBuffer() {
|
||||
return m_dataByteBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a long (is a char* in native code) pointing to the frame data.
|
||||
* This pointer is backed by the frame directly. Its lifetime is controlled by
|
||||
* the frame. If a new frame gets read, it will overwrite the current one.
|
||||
* Get a long (is a char* in native code) pointing to the frame data. This pointer is backed by
|
||||
* the frame directly. Its lifetime is controlled by the frame. If a new frame gets read, it will
|
||||
* overwrite the current one.
|
||||
*/
|
||||
public long getDataPtr() {
|
||||
return m_dataPtr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total length of the data stored in the frame.
|
||||
*/
|
||||
/** Get the total length of the data stored in the frame. */
|
||||
public int getTotalData() {
|
||||
return m_totalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the frame.
|
||||
*/
|
||||
/** Get the width of the frame. */
|
||||
public int getWidth() {
|
||||
return m_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of the frame.
|
||||
*/
|
||||
/** Set the width of the frame. */
|
||||
public void setWidth(int width) {
|
||||
this.m_width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the frame.
|
||||
*/
|
||||
/** Get the height of the frame. */
|
||||
public int getHeight() {
|
||||
return m_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the frame.
|
||||
*/
|
||||
/** Set the height of the frame. */
|
||||
public void setHeight(int height) {
|
||||
this.m_height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PixelFormat of the frame.
|
||||
*/
|
||||
/** Get the PixelFormat of the frame. */
|
||||
public int getPixelFormat() {
|
||||
return m_pixelFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the PixelFormat of the frame.
|
||||
*/
|
||||
/** Set the PixelFormat of the frame. */
|
||||
public void setPixelFormat(int pixelFormat) {
|
||||
this.m_pixelFormat = pixelFormat;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ public class RawSink extends ImageSink {
|
||||
/**
|
||||
* Create a sink for accepting raw images.
|
||||
*
|
||||
* <p>grabFrame() must be called on the created sink to get each new
|
||||
* image.
|
||||
* <p>grabFrame() must be called on the created sink to get each new image.
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
*/
|
||||
@@ -26,38 +25,33 @@ public class RawSink extends ImageSink {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after 0.225 seconds.
|
||||
* The provided image will have three 8-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after 0.225 seconds. The
|
||||
* provided image will have three 8-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* and is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error message); the frame time
|
||||
* is in the same time base as wpi::Now(), and is in 1 us increments.
|
||||
*/
|
||||
protected long grabFrame(RawFrame frame) {
|
||||
return grabFrame(frame, 0.225);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
* Times out (returning 0) after timeout seconds.
|
||||
* The provided image will have three 8-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The
|
||||
* provided image will have three 8-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* and is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error message); the frame time
|
||||
* is in the same time base as wpi::Now(), and is in 1 us increments.
|
||||
*/
|
||||
protected long grabFrame(RawFrame frame, double timeout) {
|
||||
return CameraServerJNI.grabSinkFrameTimeout(m_handle, frame, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image. May block forever.
|
||||
* The provided image will have three 8-bit channels stored in BGR order.
|
||||
* Wait for the next frame and get the image. May block forever. The provided image will have
|
||||
* three 8-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* and is in 1 us increments.
|
||||
* @return Frame time, or 0 on error (call getError() to obtain the error message); the frame time
|
||||
* is in the same time base as wpi::Now(), and is in 1 us increments.
|
||||
*/
|
||||
protected long grabFrameNoTimeout(RawFrame frame) {
|
||||
return CameraServerJNI.grabSinkFrame(m_handle, frame);
|
||||
|
||||
@@ -21,10 +21,9 @@ public class RawSource extends ImageSource {
|
||||
* @param mode Video mode being generated
|
||||
*/
|
||||
public RawSource(String name, VideoMode mode) {
|
||||
super(CameraServerJNI.createRawSource(name,
|
||||
mode.pixelFormat.getValue(),
|
||||
mode.width, mode.height,
|
||||
mode.fps));
|
||||
super(
|
||||
CameraServerJNI.createRawSource(
|
||||
name, mode.pixelFormat.getValue(), mode.width, mode.height, mode.fps));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,10 +36,7 @@ public class RawSource extends ImageSource {
|
||||
* @param fps fps
|
||||
*/
|
||||
public RawSource(String name, VideoMode.PixelFormat pixelFormat, int width, int height, int fps) {
|
||||
super(CameraServerJNI.createRawSource(name,
|
||||
pixelFormat.getValue(),
|
||||
width, height,
|
||||
fps));
|
||||
super(CameraServerJNI.createRawSource(name, pixelFormat.getValue(), width, height, fps));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,9 +70,9 @@ public class RawSource extends ImageSource {
|
||||
* @param pixelFormat pixel format
|
||||
* @param totalData length of data in total
|
||||
*/
|
||||
protected void putFrame(long data, int width, int height, VideoMode.PixelFormat pixelFormat,
|
||||
int totalData) {
|
||||
CameraServerJNI.putRawSourceFrame(m_handle, data, width, height, pixelFormat.getValue(),
|
||||
totalData);
|
||||
protected void putFrame(
|
||||
long data, int width, int height, VideoMode.PixelFormat pixelFormat, int totalData) {
|
||||
CameraServerJNI.putRawSourceFrame(
|
||||
m_handle, data, width, height, pixelFormat.getValue(), totalData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,21 +4,20 @@
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class UsbCameraTest {
|
||||
@Nested
|
||||
@EnabledOnOs(OS.LINUX)
|
||||
@@ -31,7 +30,8 @@ class UsbCameraTest {
|
||||
CompletableFuture<String> result = new CompletableFuture<>();
|
||||
CameraServerJNI.setLogger((level, file, line, message) -> result.complete(message), 20);
|
||||
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(5),
|
||||
assertTimeoutPreemptively(
|
||||
Duration.ofSeconds(5),
|
||||
() -> assertTrue(result.get().contains("Connecting to USB camera on ")));
|
||||
}
|
||||
}
|
||||
@@ -44,15 +44,16 @@ class UsbCameraTest {
|
||||
CompletableFuture<String> result = new CompletableFuture<>();
|
||||
CameraServerJNI.setLogger((level, file, line, message) -> result.complete(message), 20);
|
||||
|
||||
assertThrows(TimeoutException.class,
|
||||
() -> result.get(3, TimeUnit.SECONDS));
|
||||
assertThrows(TimeoutException.class, () -> result.get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int getNonexistentCameraDev() {
|
||||
return Arrays.stream(CameraServerJNI.enumerateUsbCameras())
|
||||
.mapToInt(info -> info.dev)
|
||||
.max().orElse(-1) + 20;
|
||||
.mapToInt(info -> info.dev)
|
||||
.max()
|
||||
.orElse(-1)
|
||||
+ 20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
public final class DevMain {
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) {}
|
||||
|
||||
}
|
||||
|
||||
private DevMain() {
|
||||
}
|
||||
private DevMain() {}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,16 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* Structure for holding the values stored in an accumulator.
|
||||
*/
|
||||
/** Structure for holding the values stored in an accumulator. */
|
||||
public class AccumulatorResult {
|
||||
/**
|
||||
* The total value accumulated.
|
||||
*/
|
||||
/** The total value accumulated. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public long value;
|
||||
/**
|
||||
* The number of sample value was accumulated over.
|
||||
*/
|
||||
/** The number of sample value was accumulated over. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public long count;
|
||||
|
||||
/**
|
||||
* Set the value and count.
|
||||
*/
|
||||
/** Set the value and count. */
|
||||
public void set(long value, long count) {
|
||||
this.value = value;
|
||||
this.count = count;
|
||||
|
||||
@@ -7,14 +7,19 @@ package edu.wpi.first.hal;
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public class AddressableLEDJNI extends JNIWrapper {
|
||||
public static native int initialize(int pwmHandle);
|
||||
|
||||
public static native void free(int handle);
|
||||
|
||||
public static native void setLength(int handle, int length);
|
||||
|
||||
public static native void setData(int handle, byte[] data);
|
||||
|
||||
public static native void setBitTiming(int handle, int lowTime0, int highTime0, int lowTime1, int highTime1);
|
||||
public static native void setBitTiming(
|
||||
int handle, int lowTime0, int highTime0, int lowTime1, int highTime1);
|
||||
|
||||
public static native void setSyncTime(int handle, int syncTime);
|
||||
|
||||
public static native void start(int handle);
|
||||
|
||||
public static native void stop(int handle);
|
||||
}
|
||||
|
||||
@@ -5,5 +5,10 @@
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
public enum AllianceStationID {
|
||||
Red1, Red2, Red3, Blue1, Blue2, Blue3
|
||||
Red1,
|
||||
Red2,
|
||||
Red3,
|
||||
Blue1,
|
||||
Blue2,
|
||||
Blue3
|
||||
}
|
||||
|
||||
@@ -11,12 +11,11 @@ public class AnalogGyroJNI extends JNIWrapper {
|
||||
|
||||
public static native void freeAnalogGyro(int handle);
|
||||
|
||||
public static native void setAnalogGyroParameters(int handle,
|
||||
double voltsPerDegreePerSecond,
|
||||
double offset, int center);
|
||||
public static native void setAnalogGyroParameters(
|
||||
int handle, double voltsPerDegreePerSecond, double offset, int center);
|
||||
|
||||
public static native void setAnalogGyroVoltsPerDegreePerSecond(int handle,
|
||||
double voltsPerDegreePerSecond);
|
||||
public static native void setAnalogGyroVoltsPerDegreePerSecond(
|
||||
int handle, double voltsPerDegreePerSecond);
|
||||
|
||||
public static native void resetAnalogGyro(int handle);
|
||||
|
||||
|
||||
@@ -6,24 +6,17 @@ package edu.wpi.first.hal;
|
||||
|
||||
public class AnalogJNI extends JNIWrapper {
|
||||
/**
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:58</i><br> enum values
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:58</i><br>
|
||||
* enum values
|
||||
*/
|
||||
public interface AnalogTriggerType {
|
||||
/**
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:54</i>
|
||||
*/
|
||||
/** <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:54</i> */
|
||||
int kInWindow = 0;
|
||||
/**
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:55</i>
|
||||
*/
|
||||
/** <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:55</i> */
|
||||
int kState = 1;
|
||||
/**
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:56</i>
|
||||
*/
|
||||
/** <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:56</i> */
|
||||
int kRisingPulse = 2;
|
||||
/**
|
||||
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:57</i>
|
||||
*/
|
||||
/** <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:57</i> */
|
||||
int kFallingPulse = 3;
|
||||
}
|
||||
|
||||
@@ -95,20 +88,20 @@ public class AnalogJNI extends JNIWrapper {
|
||||
|
||||
public static native void cleanAnalogTrigger(int analogTriggerHandle);
|
||||
|
||||
public static native void setAnalogTriggerLimitsRaw(int analogTriggerHandle, int lower,
|
||||
int upper);
|
||||
public static native void setAnalogTriggerLimitsRaw(
|
||||
int analogTriggerHandle, int lower, int upper);
|
||||
|
||||
public static native void setAnalogTriggerLimitsDutyCycle(int analogTriggerHandle, double lower,
|
||||
double higher);
|
||||
public static native void setAnalogTriggerLimitsDutyCycle(
|
||||
int analogTriggerHandle, double lower, double higher);
|
||||
|
||||
public static native void setAnalogTriggerLimitsVoltage(int analogTriggerHandle,
|
||||
double lower, double upper);
|
||||
public static native void setAnalogTriggerLimitsVoltage(
|
||||
int analogTriggerHandle, double lower, double upper);
|
||||
|
||||
public static native void setAnalogTriggerAveraged(int analogTriggerHandle,
|
||||
boolean useAveragedValue);
|
||||
public static native void setAnalogTriggerAveraged(
|
||||
int analogTriggerHandle, boolean useAveragedValue);
|
||||
|
||||
public static native void setAnalogTriggerFiltered(int analogTriggerHandle,
|
||||
boolean useFilteredValue);
|
||||
public static native void setAnalogTriggerFiltered(
|
||||
int analogTriggerHandle, boolean useFilteredValue);
|
||||
|
||||
public static native boolean getAnalogTriggerInWindow(int analogTriggerHandle);
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ public class CANAPIJNI extends JNIWrapper {
|
||||
|
||||
public static native void writeCANPacket(int handle, byte[] data, int apiId);
|
||||
|
||||
public static native void writeCANPacketRepeating(int handle, byte[] data, int apiId,
|
||||
int repeatMs);
|
||||
public static native void writeCANPacketRepeating(
|
||||
int handle, byte[] data, int apiId, int repeatMs);
|
||||
|
||||
public static native void writeCANRTRFrame(int handle, int length, int apiId);
|
||||
|
||||
public static native int writeCANPacketNoThrow(int handle, byte[] data, int apiId);
|
||||
|
||||
public static native int writeCANPacketRepeatingNoThrow(int handle, byte[] data, int apiId,
|
||||
int repeatMs);
|
||||
public static native int writeCANPacketRepeatingNoThrow(
|
||||
int handle, byte[] data, int apiId, int repeatMs);
|
||||
|
||||
public static native int writeCANRTRFrameNoThrow(int handle, int length, int apiId);
|
||||
|
||||
@@ -30,6 +30,6 @@ public class CANAPIJNI extends JNIWrapper {
|
||||
|
||||
public static native boolean readCANPacketLatest(int handle, int apiId, CANData data);
|
||||
|
||||
public static native boolean readCANPacketTimeout(int handle, int apiId, int timeoutMs,
|
||||
CANData data);
|
||||
public static native boolean readCANPacketTimeout(
|
||||
int handle, int apiId, int timeoutMs, CANData data);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ package edu.wpi.first.hal;
|
||||
public class CANData {
|
||||
@SuppressWarnings("MemberName")
|
||||
public final byte[] data = new byte[8];
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public int length;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public long timestamp;
|
||||
|
||||
/**
|
||||
* API used from JNI to set the data.
|
||||
*/
|
||||
/** API used from JNI to set the data. */
|
||||
@SuppressWarnings("PMD.MethodReturnsInternalArray")
|
||||
public byte[] setData(int length, long timestamp) {
|
||||
this.length = length;
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper for the HALControlWord bitfield.
|
||||
*/
|
||||
/** A wrapper for the HALControlWord bitfield. */
|
||||
public class ControlWord {
|
||||
private boolean m_enabled;
|
||||
private boolean m_autonomous;
|
||||
@@ -15,8 +13,13 @@ public class ControlWord {
|
||||
private boolean m_fmsAttached;
|
||||
private boolean m_dsAttached;
|
||||
|
||||
void update(boolean enabled, boolean autonomous, boolean test, boolean emergencyStop,
|
||||
boolean fmsAttached, boolean dsAttached) {
|
||||
void update(
|
||||
boolean enabled,
|
||||
boolean autonomous,
|
||||
boolean test,
|
||||
boolean emergencyStop,
|
||||
boolean fmsAttached,
|
||||
boolean dsAttached) {
|
||||
m_enabled = enabled;
|
||||
m_autonomous = autonomous;
|
||||
m_test = test;
|
||||
|
||||
@@ -13,19 +13,19 @@ public class CounterJNI extends JNIWrapper {
|
||||
|
||||
public static native void setCounterAverageSize(int counterHandle, int size);
|
||||
|
||||
public static native void setCounterUpSource(int counterHandle, int digitalSourceHandle,
|
||||
int analogTriggerType);
|
||||
public static native void setCounterUpSource(
|
||||
int counterHandle, int digitalSourceHandle, int analogTriggerType);
|
||||
|
||||
public static native void setCounterUpSourceEdge(int counterHandle, boolean risingEdge,
|
||||
boolean fallingEdge);
|
||||
public static native void setCounterUpSourceEdge(
|
||||
int counterHandle, boolean risingEdge, boolean fallingEdge);
|
||||
|
||||
public static native void clearCounterUpSource(int counterHandle);
|
||||
|
||||
public static native void setCounterDownSource(int counterHandle, int digitalSourceHandle,
|
||||
int analogTriggerType);
|
||||
public static native void setCounterDownSource(
|
||||
int counterHandle, int digitalSourceHandle, int analogTriggerType);
|
||||
|
||||
public static native void setCounterDownSourceEdge(int counterHandle, boolean risingEdge,
|
||||
boolean fallingEdge);
|
||||
public static native void setCounterDownSourceEdge(
|
||||
int counterHandle, boolean risingEdge, boolean fallingEdge);
|
||||
|
||||
public static native void clearCounterDownSource(int counterHandle);
|
||||
|
||||
@@ -33,15 +33,13 @@ public class CounterJNI extends JNIWrapper {
|
||||
|
||||
public static native void setCounterExternalDirectionMode(int counterHandle);
|
||||
|
||||
public static native void setCounterSemiPeriodMode(int counterHandle,
|
||||
boolean highSemiPeriod);
|
||||
public static native void setCounterSemiPeriodMode(int counterHandle, boolean highSemiPeriod);
|
||||
|
||||
public static native void setCounterPulseLengthMode(int counterHandle, double threshold);
|
||||
|
||||
public static native int getCounterSamplesToAverage(int counterHandle);
|
||||
|
||||
public static native void setCounterSamplesToAverage(int counterHandle,
|
||||
int samplesToAverage);
|
||||
public static native void setCounterSamplesToAverage(int counterHandle, int samplesToAverage);
|
||||
|
||||
public static native void resetCounter(int counterHandle);
|
||||
|
||||
@@ -57,6 +55,5 @@ public class CounterJNI extends JNIWrapper {
|
||||
|
||||
public static native boolean getCounterDirection(int counterHandle);
|
||||
|
||||
public static native void setCounterReverseDirection(int counterHandle,
|
||||
boolean reverseDirection);
|
||||
public static native void setCounterReverseDirection(int counterHandle, boolean reverseDirection);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,15 @@ package edu.wpi.first.hal;
|
||||
|
||||
public class DutyCycleJNI extends JNIWrapper {
|
||||
public static native int initialize(int digitalSourceHandle, int analogTriggerType);
|
||||
|
||||
public static native void free(int handle);
|
||||
|
||||
public static native int getFrequency(int handle);
|
||||
|
||||
public static native double getOutput(int handle);
|
||||
|
||||
public static native int getOutputRaw(int handle);
|
||||
|
||||
public static native int getOutputScaleFactor(int handle);
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
|
||||
@@ -5,9 +5,13 @@
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
public class EncoderJNI extends JNIWrapper {
|
||||
public static native int initializeEncoder(int digitalSourceHandleA, int analogTriggerTypeA,
|
||||
int digitalSourceHandleB, int analogTriggerTypeB,
|
||||
boolean reverseDirection, int encodingType);
|
||||
public static native int initializeEncoder(
|
||||
int digitalSourceHandleA,
|
||||
int analogTriggerTypeA,
|
||||
int digitalSourceHandleB,
|
||||
int analogTriggerTypeB,
|
||||
boolean reverseDirection,
|
||||
int encodingType);
|
||||
|
||||
public static native void freeEncoder(int encoderHandle);
|
||||
|
||||
@@ -37,16 +41,14 @@ public class EncoderJNI extends JNIWrapper {
|
||||
|
||||
public static native void setEncoderDistancePerPulse(int encoderHandle, double distancePerPulse);
|
||||
|
||||
public static native void setEncoderReverseDirection(int encoderHandle,
|
||||
boolean reverseDirection);
|
||||
public static native void setEncoderReverseDirection(int encoderHandle, boolean reverseDirection);
|
||||
|
||||
public static native void setEncoderSamplesToAverage(int encoderHandle,
|
||||
int samplesToAverage);
|
||||
public static native void setEncoderSamplesToAverage(int encoderHandle, int samplesToAverage);
|
||||
|
||||
public static native int getEncoderSamplesToAverage(int encoderHandle);
|
||||
|
||||
public static native void setEncoderIndexSource(int encoderHandle, int digitalSourceHandle,
|
||||
int analogTriggerType, int indexingType);
|
||||
public static native void setEncoderIndexSource(
|
||||
int encoderHandle, int digitalSourceHandle, int analogTriggerType, int indexingType);
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public static native int getEncoderFPGAIndex(int encoderHandle);
|
||||
|
||||
@@ -9,7 +9,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JNI Wrapper for HAL<br>.
|
||||
* JNI Wrapper for HAL<br>
|
||||
* .
|
||||
*/
|
||||
@SuppressWarnings({"AbbreviationAsWordInName", "MethodName"})
|
||||
public final class HAL extends JNIWrapper {
|
||||
@@ -30,8 +31,8 @@ public final class HAL extends JNIWrapper {
|
||||
public static final List<Runnable> s_simPeriodicBefore = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Runs SimPeriodicBefore callbacks. IterativeRobotBase calls this prior
|
||||
* to the user's simulationPeriodic code.
|
||||
* Runs SimPeriodicBefore callbacks. IterativeRobotBase calls this prior to the user's
|
||||
* simulationPeriodic code.
|
||||
*/
|
||||
public static void simPeriodicBefore() {
|
||||
simPeriodicBeforeNative();
|
||||
@@ -47,8 +48,8 @@ public final class HAL extends JNIWrapper {
|
||||
public static final List<Runnable> s_simPeriodicAfter = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Runs SimPeriodicAfter callbacks. IterativeRobotBase calls this after
|
||||
* the user's simulationPeriodic code.
|
||||
* Runs SimPeriodicAfter callbacks. IterativeRobotBase calls this after the user's
|
||||
* simulationPeriodic code.
|
||||
*/
|
||||
public static void simPeriodicAfter() {
|
||||
simPeriodicAfterNative();
|
||||
@@ -83,13 +84,12 @@ public final class HAL extends JNIWrapper {
|
||||
* <p>Original signature: <code>uint32_t report(tResourceType, uint8_t, uint8_t, const
|
||||
* char*)</code>
|
||||
*
|
||||
* @param resource one of the values in the tResourceType above (max value 51). <br>
|
||||
* @param resource one of the values in the tResourceType above (max value 51). <br>
|
||||
* @param instanceNumber an index that identifies the resource instance. <br>
|
||||
* @param context an optional additional context number for some cases (such as module
|
||||
* number). Set to 0 to omit. <br>
|
||||
* @param feature a string to be included describing features in use on a specific
|
||||
* resource. Setting the same resource more than once allows you to change
|
||||
* the feature string.
|
||||
* @param context an optional additional context number for some cases (such as module number).
|
||||
* Set to 0 to omit. <br>
|
||||
* @param feature a string to be included describing features in use on a specific resource.
|
||||
* Setting the same resource more than once allows you to change the feature string.
|
||||
*/
|
||||
public static native int report(int resource, int instanceNumber, int context, String feature);
|
||||
|
||||
@@ -98,8 +98,13 @@ public final class HAL extends JNIWrapper {
|
||||
@SuppressWarnings("MissingJavadocMethod")
|
||||
public static void getControlWord(ControlWord controlWord) {
|
||||
int word = nativeGetControlWord();
|
||||
controlWord.update((word & 1) != 0, ((word >> 1) & 1) != 0, ((word >> 2) & 1) != 0,
|
||||
((word >> 3) & 1) != 0, ((word >> 4) & 1) != 0, ((word >> 5) & 1) != 0);
|
||||
controlWord.update(
|
||||
(word & 1) != 0,
|
||||
((word >> 1) & 1) != 0,
|
||||
((word >> 2) & 1) != 0,
|
||||
((word >> 3) & 1) != 0,
|
||||
((word >> 4) & 1) != 0,
|
||||
((word >> 5) & 1) != 0);
|
||||
}
|
||||
|
||||
private static native int nativeGetAllianceStation();
|
||||
@@ -142,8 +147,8 @@ public final class HAL extends JNIWrapper {
|
||||
|
||||
public static native int getJoystickButtons(byte joystickNum, ByteBuffer count);
|
||||
|
||||
public static native int setJoystickOutputs(byte joystickNum, int outputs, short leftRumble,
|
||||
short rightRumble);
|
||||
public static native int setJoystickOutputs(
|
||||
byte joystickNum, int outputs, short leftRumble, short rightRumble);
|
||||
|
||||
public static native int getJoystickIsXbox(byte joystickNum);
|
||||
|
||||
@@ -161,9 +166,14 @@ public final class HAL extends JNIWrapper {
|
||||
|
||||
public static native int getMatchInfo(MatchInfoData info);
|
||||
|
||||
public static native int sendError(boolean isError, int errorCode, boolean isLVCode,
|
||||
String details, String location, String callStack,
|
||||
boolean printMsg);
|
||||
public static native int sendError(
|
||||
boolean isError,
|
||||
int errorCode,
|
||||
boolean isLVCode,
|
||||
String details,
|
||||
String location,
|
||||
String callStack,
|
||||
boolean printMsg);
|
||||
|
||||
public static native int sendConsoleLine(String line);
|
||||
|
||||
@@ -171,7 +181,5 @@ public final class HAL extends JNIWrapper {
|
||||
|
||||
public static native int getPort(byte channel);
|
||||
|
||||
private HAL() {
|
||||
|
||||
}
|
||||
private HAL() {}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,5 @@ public final class HALUtil extends JNIWrapper {
|
||||
return getHALstrerror(getHALErrno());
|
||||
}
|
||||
|
||||
private HALUtil() {
|
||||
|
||||
}
|
||||
private HALUtil() {}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@ public final class HALValue {
|
||||
m_long = value;
|
||||
}
|
||||
|
||||
private HALValue() {
|
||||
|
||||
}
|
||||
private HALValue() {}
|
||||
|
||||
/**
|
||||
* Get the type of the value.
|
||||
@@ -41,7 +39,7 @@ public final class HALValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value as a boolean. Does not perform type checking.
|
||||
* Get the value as a boolean. Does not perform type checking.
|
||||
*
|
||||
* @return value contents
|
||||
*/
|
||||
@@ -50,7 +48,7 @@ public final class HALValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value as a long. Does not perform type checking.
|
||||
* Get the value as a long. Does not perform type checking.
|
||||
*
|
||||
* @return value contents
|
||||
*/
|
||||
@@ -59,7 +57,7 @@ public final class HALValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value as a double. Does not perform type checking.
|
||||
* Get the value as a double. Does not perform type checking.
|
||||
*
|
||||
* @return value contents
|
||||
*/
|
||||
@@ -68,7 +66,7 @@ public final class HALValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the native long value. Does not perform type checking.
|
||||
* Get the native long value. Does not perform type checking.
|
||||
*
|
||||
* @return value contents
|
||||
*/
|
||||
@@ -77,7 +75,7 @@ public final class HALValue {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the native double value. Does not perform type checking.
|
||||
* Get the native double value. Does not perform type checking.
|
||||
*
|
||||
* @return value contents
|
||||
*/
|
||||
|
||||
@@ -10,21 +10,30 @@ import java.nio.ByteBuffer;
|
||||
public class I2CJNI extends JNIWrapper {
|
||||
public static native void i2CInitialize(int port);
|
||||
|
||||
public static native int i2CTransaction(int port, byte address, ByteBuffer dataToSend,
|
||||
byte sendSize, ByteBuffer dataReceived, byte receiveSize);
|
||||
public static native int i2CTransaction(
|
||||
int port,
|
||||
byte address,
|
||||
ByteBuffer dataToSend,
|
||||
byte sendSize,
|
||||
ByteBuffer dataReceived,
|
||||
byte receiveSize);
|
||||
|
||||
public static native int i2CTransactionB(int port, byte address, byte[] dataToSend,
|
||||
byte sendSize, byte[] dataReceived, byte receiveSize);
|
||||
public static native int i2CTransactionB(
|
||||
int port,
|
||||
byte address,
|
||||
byte[] dataToSend,
|
||||
byte sendSize,
|
||||
byte[] dataReceived,
|
||||
byte receiveSize);
|
||||
|
||||
public static native int i2CWrite(int port, byte address, ByteBuffer dataToSend, byte sendSize);
|
||||
|
||||
public static native int i2CWriteB(int port, byte address, byte[] dataToSend, byte sendSize);
|
||||
|
||||
public static native int i2CRead(int port, byte address, ByteBuffer dataReceived,
|
||||
byte receiveSize);
|
||||
public static native int i2CRead(
|
||||
int port, byte address, ByteBuffer dataReceived, byte receiveSize);
|
||||
|
||||
public static native int i2CReadB(int port, byte address, byte[] dataReceived,
|
||||
byte receiveSize);
|
||||
public static native int i2CReadB(int port, byte address, byte[] dataReceived, byte receiveSize);
|
||||
|
||||
public static native void i2CClose(int port);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public class InterruptJNI extends JNIWrapper {
|
||||
|
||||
public static native void cleanInterrupts(int interruptHandle);
|
||||
|
||||
public static native int waitForInterrupt(int interruptHandle, double timeout,
|
||||
boolean ignorePrevious);
|
||||
public static native int waitForInterrupt(
|
||||
int interruptHandle, double timeout, boolean ignorePrevious);
|
||||
|
||||
public static native void enableInterrupts(int interruptHandle);
|
||||
|
||||
@@ -26,15 +26,14 @@ public class InterruptJNI extends JNIWrapper {
|
||||
|
||||
public static native long readInterruptFallingTimestamp(int interruptHandle);
|
||||
|
||||
public static native void requestInterrupts(int interruptHandle, int digitalSourceHandle,
|
||||
int analogTriggerType);
|
||||
public static native void requestInterrupts(
|
||||
int interruptHandle, int digitalSourceHandle, int analogTriggerType);
|
||||
|
||||
public static native void attachInterruptHandler(int interruptHandle,
|
||||
InterruptJNIHandlerFunction handler,
|
||||
Object param);
|
||||
public static native void attachInterruptHandler(
|
||||
int interruptHandle, InterruptJNIHandlerFunction handler, Object param);
|
||||
|
||||
public static native void setInterruptUpSourceEdge(int interruptHandle, boolean risingEdge,
|
||||
boolean fallingEdge);
|
||||
public static native void setInterruptUpSourceEdge(
|
||||
int interruptHandle, boolean risingEdge, boolean fallingEdge);
|
||||
|
||||
public static native void releaseWaitingInterrupt(int interruptHandle);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import edu.wpi.first.wpiutil.RuntimeLoader;
|
||||
|
||||
/**
|
||||
* Base class for all JNI wrappers.
|
||||
*/
|
||||
/** Base class for all JNI wrappers. */
|
||||
public class JNIWrapper {
|
||||
static boolean libraryLoaded = false;
|
||||
static RuntimeLoader<JNIWrapper> loader = null;
|
||||
@@ -31,7 +28,9 @@ public class JNIWrapper {
|
||||
static {
|
||||
if (Helper.getExtractOnStaticLoad()) {
|
||||
try {
|
||||
loader = new RuntimeLoader<>("wpiHaljni", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"wpiHaljni", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class);
|
||||
loader.loadLibrary();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -41,14 +40,14 @@ public class JNIWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Force load the library.
|
||||
*/
|
||||
/** Force load the library. */
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
if (libraryLoaded) {
|
||||
return;
|
||||
}
|
||||
loader = new RuntimeLoader<>("wpiHaljni", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class);
|
||||
loader =
|
||||
new RuntimeLoader<>(
|
||||
"wpiHaljni", RuntimeLoader.getDefaultExtractionRoot(), JNIWrapper.class);
|
||||
loader.loadLibrary();
|
||||
libraryLoaded = true;
|
||||
}
|
||||
|
||||
@@ -4,46 +4,36 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* Structure for holding the match info data request.
|
||||
*/
|
||||
/** Structure for holding the match info data request. */
|
||||
public class MatchInfoData {
|
||||
/**
|
||||
* Stores the event name.
|
||||
*/
|
||||
/** Stores the event name. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String eventName = "";
|
||||
|
||||
/**
|
||||
* Stores the game specific message.
|
||||
*/
|
||||
/** Stores the game specific message. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public String gameSpecificMessage = "";
|
||||
|
||||
/**
|
||||
* Stores the match number.
|
||||
*/
|
||||
/** Stores the match number. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int matchNumber;
|
||||
|
||||
/**
|
||||
* Stores the replay number.
|
||||
*/
|
||||
/** Stores the replay number. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int replayNumber;
|
||||
|
||||
/**
|
||||
* Stores the match type.
|
||||
*/
|
||||
/** Stores the match type. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int matchType;
|
||||
|
||||
/**
|
||||
* Called from JNI to set the structure data.
|
||||
*/
|
||||
/** Called from JNI to set the structure data. */
|
||||
@SuppressWarnings("MissingJavadocMethod")
|
||||
public void setData(String eventName, String gameSpecificMessage,
|
||||
int matchNumber, int replayNumber, int matchType) {
|
||||
public void setData(
|
||||
String eventName,
|
||||
String gameSpecificMessage,
|
||||
int matchNumber,
|
||||
int replayNumber,
|
||||
int matchType) {
|
||||
this.eventName = eventName;
|
||||
this.gameSpecificMessage = gameSpecificMessage;
|
||||
this.matchNumber = matchNumber;
|
||||
|
||||
@@ -11,40 +11,30 @@ package edu.wpi.first.hal;
|
||||
* class, which corresponds to the C++ Notifier class, should be used.
|
||||
*/
|
||||
public class NotifierJNI extends JNIWrapper {
|
||||
/**
|
||||
* Initializes the notifier.
|
||||
*/
|
||||
/** Initializes the notifier. */
|
||||
public static native int initializeNotifier();
|
||||
|
||||
/**
|
||||
* Sets the name of the notifier.
|
||||
*/
|
||||
/** Sets the name of the notifier. */
|
||||
public static native void setNotifierName(int notifierHandle, String name);
|
||||
|
||||
/**
|
||||
* Wakes up the waiter with time=0. Note: after this function is called, all
|
||||
* calls to waitForNotifierAlarm() will immediately start returning 0.
|
||||
* Wakes up the waiter with time=0. Note: after this function is called, all calls to
|
||||
* waitForNotifierAlarm() will immediately start returning 0.
|
||||
*/
|
||||
public static native void stopNotifier(int notifierHandle);
|
||||
|
||||
/**
|
||||
* Deletes the notifier object when we are done with it.
|
||||
*/
|
||||
/** Deletes the notifier object when we are done with it. */
|
||||
public static native void cleanNotifier(int notifierHandle);
|
||||
|
||||
/**
|
||||
* Sets the notifier to wakeup the waiter in another triggerTime microseconds.
|
||||
*/
|
||||
/** Sets the notifier to wakeup the waiter in another triggerTime microseconds. */
|
||||
public static native void updateNotifierAlarm(int notifierHandle, long triggerTime);
|
||||
|
||||
/**
|
||||
* Cancels any pending wakeups set by updateNotifierAlarm(). Does NOT wake
|
||||
* up any waiters.
|
||||
*/
|
||||
/** Cancels any pending wakeups set by updateNotifierAlarm(). Does NOT wake up any waiters. */
|
||||
public static native void cancelNotifierAlarm(int notifierHandle);
|
||||
|
||||
/**
|
||||
* Block until woken up by an alarm (or stop).
|
||||
*
|
||||
* @return Time when woken up.
|
||||
*/
|
||||
public static native long waitForNotifierAlarm(int notifierHandle);
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* Structure for holding the config data result for PWM.
|
||||
*/
|
||||
/** Structure for holding the config data result for PWM. */
|
||||
public class PWMConfigDataResult {
|
||||
PWMConfigDataResult(int max, int deadbandMax, int center, int deadbandMin, int min) {
|
||||
this.max = max;
|
||||
@@ -16,33 +14,23 @@ public class PWMConfigDataResult {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum PWM value.
|
||||
*/
|
||||
/** The maximum PWM value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int max;
|
||||
|
||||
/**
|
||||
* The deadband maximum PWM value.
|
||||
*/
|
||||
/** The deadband maximum PWM value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int deadbandMax;
|
||||
|
||||
/**
|
||||
* The center PWM value.
|
||||
*/
|
||||
/** The center PWM value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int center;
|
||||
|
||||
/**
|
||||
* The deadband minimum PWM value.
|
||||
*/
|
||||
/** The deadband minimum PWM value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int deadbandMin;
|
||||
|
||||
/**
|
||||
* The minimum PWM value.
|
||||
*/
|
||||
/** The minimum PWM value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int min;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,21 @@ public class PWMJNI extends DIOJNI {
|
||||
|
||||
public static native void freePWMPort(int pwmPortHandle);
|
||||
|
||||
public static native void setPWMConfigRaw(int pwmPortHandle, int maxPwm,
|
||||
int deadbandMaxPwm, int centerPwm,
|
||||
int deadbandMinPwm, int minPwm);
|
||||
public static native void setPWMConfigRaw(
|
||||
int pwmPortHandle,
|
||||
int maxPwm,
|
||||
int deadbandMaxPwm,
|
||||
int centerPwm,
|
||||
int deadbandMinPwm,
|
||||
int minPwm);
|
||||
|
||||
public static native void setPWMConfig(int pwmPortHandle, double maxPwm,
|
||||
double deadbandMaxPwm, double centerPwm,
|
||||
double deadbandMinPwm, double minPwm);
|
||||
public static native void setPWMConfig(
|
||||
int pwmPortHandle,
|
||||
double maxPwm,
|
||||
double deadbandMaxPwm,
|
||||
double centerPwm,
|
||||
double deadbandMinPwm,
|
||||
double minPwm);
|
||||
|
||||
public static native PWMConfigDataResult getPWMConfigRaw(int pwmPortHandle);
|
||||
|
||||
@@ -38,7 +46,7 @@ public class PWMJNI extends DIOJNI {
|
||||
|
||||
public static native double getPWMPosition(int pwmPortHandle);
|
||||
|
||||
public static native void setPWMDisabled(int pwmPortHandle);
|
||||
public static native void setPWMDisabled(int pwmPortHandle);
|
||||
|
||||
public static native void latchPWMZero(int pwmPortHandle);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import java.nio.ByteBuffer;
|
||||
public class SPIJNI extends JNIWrapper {
|
||||
public static native void spiInitialize(int port);
|
||||
|
||||
public static native int spiTransaction(int port, ByteBuffer dataToSend,
|
||||
ByteBuffer dataReceived, byte size);
|
||||
public static native int spiTransaction(
|
||||
int port, ByteBuffer dataToSend, ByteBuffer dataReceived, byte size);
|
||||
|
||||
public static native int spiTransactionB(int port, byte[] dataToSend,
|
||||
byte[] dataReceived, byte size);
|
||||
public static native int spiTransactionB(
|
||||
int port, byte[] dataToSend, byte[] dataReceived, byte size);
|
||||
|
||||
public static native int spiWrite(int port, ByteBuffer dataToSend, byte sendSize);
|
||||
|
||||
@@ -28,8 +28,8 @@ public class SPIJNI extends JNIWrapper {
|
||||
|
||||
public static native void spiSetSpeed(int port, int speed);
|
||||
|
||||
public static native void spiSetOpts(int port, int msbFirst, int sampleOnTrailing,
|
||||
int clkIdleHigh);
|
||||
public static native void spiSetOpts(
|
||||
int port, int msbFirst, int sampleOnTrailing, int clkIdleHigh);
|
||||
|
||||
public static native void spiSetChipSelectActiveHigh(int port);
|
||||
|
||||
@@ -41,9 +41,12 @@ public class SPIJNI extends JNIWrapper {
|
||||
|
||||
public static native void spiStartAutoRate(int port, double period);
|
||||
|
||||
public static native void spiStartAutoTrigger(int port, int digitalSourceHandle,
|
||||
int analogTriggerType, boolean triggerRising,
|
||||
boolean triggerFalling);
|
||||
public static native void spiStartAutoTrigger(
|
||||
int port,
|
||||
int digitalSourceHandle,
|
||||
int analogTriggerType,
|
||||
boolean triggerRising,
|
||||
boolean triggerFalling);
|
||||
|
||||
public static native void spiStopAuto(int port);
|
||||
|
||||
@@ -51,13 +54,14 @@ public class SPIJNI extends JNIWrapper {
|
||||
|
||||
public static native void spiForceAutoRead(int port);
|
||||
|
||||
public static native int spiReadAutoReceivedData(int port, ByteBuffer buffer, int numToRead,
|
||||
double timeout);
|
||||
public static native int spiReadAutoReceivedData(
|
||||
int port, ByteBuffer buffer, int numToRead, double timeout);
|
||||
|
||||
public static native int spiReadAutoReceivedData(int port, int[] buffer, int numToRead,
|
||||
double timeout);
|
||||
public static native int spiReadAutoReceivedData(
|
||||
int port, int[] buffer, int numToRead, double timeout);
|
||||
|
||||
public static native int spiGetAutoDroppedCount(int port);
|
||||
|
||||
public static native void spiConfigureAutoStall(int port, int csToSclkTicks, int stallTicks, int pow2BytesPerRead);
|
||||
public static native void spiConfigureAutoStall(
|
||||
int port, int csToSclkTicks, int stallTicks, int pow2BytesPerRead);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper around a simulator boolean value handle.
|
||||
*/
|
||||
/** A wrapper around a simulator boolean value handle. */
|
||||
public class SimBoolean extends SimValue {
|
||||
/**
|
||||
* Wraps a simulated value handle as returned by SimDeviceJNI.createSimValueBoolean().
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper around a simulator device handle.
|
||||
*/
|
||||
/** A wrapper around a simulator device handle. */
|
||||
public class SimDevice implements AutoCloseable {
|
||||
public enum Direction {
|
||||
kInput(SimDeviceJNI.kInput),
|
||||
@@ -23,10 +21,9 @@ public class SimDevice implements AutoCloseable {
|
||||
/**
|
||||
* Creates a simulated device.
|
||||
*
|
||||
* <p>The device name must be unique. Returns null if the device name
|
||||
* already exists. If multiple instances of the same device are desired,
|
||||
* recommend appending the instance/unique identifer in brackets to the base
|
||||
* name, e.g. "device[1]".
|
||||
* <p>The device name must be unique. Returns null if the device name already exists. If multiple
|
||||
* instances of the same device are desired, recommend appending the instance/unique identifer in
|
||||
* brackets to the base name, e.g. "device[1]".
|
||||
*
|
||||
* <p>null is returned if not in simulation.
|
||||
*
|
||||
@@ -44,10 +41,9 @@ public class SimDevice implements AutoCloseable {
|
||||
/**
|
||||
* Creates a simulated device.
|
||||
*
|
||||
* <p>The device name must be unique. Returns null if the device name
|
||||
* already exists. This is a convenience method that appends index in
|
||||
* brackets to the device name, e.g. passing index=1 results in "device[1]"
|
||||
* for the device name.
|
||||
* <p>The device name must be unique. Returns null if the device name already exists. This is a
|
||||
* convenience method that appends index in brackets to the device name, e.g. passing index=1
|
||||
* results in "device[1]" for the device name.
|
||||
*
|
||||
* <p>null is returned if not in simulation.
|
||||
*
|
||||
@@ -62,10 +58,9 @@ public class SimDevice implements AutoCloseable {
|
||||
/**
|
||||
* Creates a simulated device.
|
||||
*
|
||||
* <p>The device name must be unique. Returns null if the device name
|
||||
* already exists. This is a convenience method that appends index and
|
||||
* channel in brackets to the device name, e.g. passing index=1 and channel=2
|
||||
* results in "device[1,2]" for the device name.
|
||||
* <p>The device name must be unique. Returns null if the device name already exists. This is a
|
||||
* convenience method that appends index and channel in brackets to the device name, e.g. passing
|
||||
* index=1 and channel=2 results in "device[1,2]" for the device name.
|
||||
*
|
||||
* <p>null is returned if not in simulation.
|
||||
*
|
||||
@@ -110,7 +105,6 @@ public class SimDevice implements AutoCloseable {
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated value object
|
||||
*
|
||||
* @deprecated Use direction function instead
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -145,7 +139,6 @@ public class SimDevice implements AutoCloseable {
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated double value object
|
||||
*
|
||||
* @deprecated Use direction function instead
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -183,7 +176,6 @@ public class SimDevice implements AutoCloseable {
|
||||
* @param options array of option descriptions
|
||||
* @param initialValue initial value (selection)
|
||||
* @return simulated enum value object
|
||||
*
|
||||
* @deprecated Use direction function instead
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -205,8 +197,8 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated enum value object
|
||||
*/
|
||||
public SimEnum createEnum(String name, Direction direction, String[] options, int initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueEnum(m_handle, name, direction.m_value, options,
|
||||
initialValue);
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueEnum(m_handle, name, direction.m_value, options, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -227,10 +219,11 @@ public class SimDevice implements AutoCloseable {
|
||||
* @param initialValue initial value (selection)
|
||||
* @return simulated enum value object
|
||||
*/
|
||||
public SimEnum createEnumDouble(String name, Direction direction, String[] options,
|
||||
double[] optionValues, int initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueEnumDouble(m_handle, name, direction.m_value, options,
|
||||
optionValues, initialValue);
|
||||
public SimEnum createEnumDouble(
|
||||
String name, Direction direction, String[] options, double[] optionValues, int initialValue) {
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueEnumDouble(
|
||||
m_handle, name, direction.m_value, options, optionValues, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -246,7 +239,6 @@ public class SimDevice implements AutoCloseable {
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated boolean value object
|
||||
*
|
||||
* @deprecated Use direction function instead
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -265,8 +257,8 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated boolean value object
|
||||
*/
|
||||
public SimBoolean createBoolean(String name, Direction direction, boolean initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueBoolean(m_handle, name, direction.m_value,
|
||||
initialValue);
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueBoolean(m_handle, name, direction.m_value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
/**
|
||||
* Creates a simulated device.
|
||||
*
|
||||
* <p>The device name must be unique. 0 is returned if the device name
|
||||
* already exists. If multiple instances of the same device are desired,
|
||||
* recommend appending the instance/unique identifer in brackets to the base
|
||||
* name, e.g. "device[1]".
|
||||
* <p>The device name must be unique. 0 is returned if the device name already exists. If multiple
|
||||
* instances of the same device are desired, recommend appending the instance/unique identifer in
|
||||
* brackets to the base name, e.g. "device[1]".
|
||||
*
|
||||
* <p>0 is returned if not in simulation.
|
||||
*
|
||||
@@ -27,42 +26,44 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
/**
|
||||
* Frees a simulated device.
|
||||
*
|
||||
* <p>This also allows the same device name to be used again.
|
||||
* This also frees all the simulated values created on the device.
|
||||
* <p>This also allows the same device name to be used again. This also frees all the simulated
|
||||
* values created on the device.
|
||||
*
|
||||
* @param handle simulated device handle
|
||||
*/
|
||||
public static native void freeSimDevice(int handle);
|
||||
|
||||
private static native int createSimValueNative(int device, String name, int direction,
|
||||
int type, long value1, double value2);
|
||||
private static native int createSimValueNative(
|
||||
int device, String name, int direction, int type, long value1, double value2);
|
||||
|
||||
/**
|
||||
* Creates a value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*
|
||||
* @deprecated Use direction-taking function instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int createSimValue(int device, String name, boolean readonly,
|
||||
HALValue initialValue) {
|
||||
return createSimValueNative(device, name, readonly ? kOutput : kInput, initialValue.getType(),
|
||||
initialValue.getNativeLong(), initialValue.getNativeDouble());
|
||||
public static int createSimValue(
|
||||
int device, String name, boolean readonly, HALValue initialValue) {
|
||||
return createSimValueNative(
|
||||
device,
|
||||
name,
|
||||
readonly ? kOutput : kInput,
|
||||
initialValue.getType(),
|
||||
initialValue.getNativeLong(),
|
||||
initialValue.getNativeDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -70,37 +71,39 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*/
|
||||
public static int createSimValue(int device, String name, int direction,
|
||||
HALValue initialValue) {
|
||||
return createSimValueNative(device, name, direction, initialValue.getType(),
|
||||
initialValue.getNativeLong(), initialValue.getNativeDouble());
|
||||
public static int createSimValue(int device, String name, int direction, HALValue initialValue) {
|
||||
return createSimValueNative(
|
||||
device,
|
||||
name,
|
||||
direction,
|
||||
initialValue.getType(),
|
||||
initialValue.getNativeLong(),
|
||||
initialValue.getNativeDouble());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a double value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*
|
||||
* @deprecated Use direction-taking function instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int createSimValueDouble(int device, String name, boolean readonly,
|
||||
double initialValue) {
|
||||
return createSimValueNative(device, name, readonly ? kOutput : kInput, HALValue.kDouble, 0, initialValue);
|
||||
public static int createSimValueDouble(
|
||||
int device, String name, boolean readonly, double initialValue) {
|
||||
return createSimValueNative(
|
||||
device, name, readonly ? kOutput : kInput, HALValue.kDouble, 0, initialValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a double value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -108,8 +111,8 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*/
|
||||
public static int createSimValueDouble(int device, String name, int direction,
|
||||
double initialValue) {
|
||||
public static int createSimValueDouble(
|
||||
int device, String name, int direction, double initialValue) {
|
||||
return createSimValueNative(device, name, direction, HALValue.kDouble, 0, initialValue);
|
||||
}
|
||||
|
||||
@@ -118,8 +121,7 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
*
|
||||
* <p>Enumerated values are always in the range 0 to numOptions-1.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -127,12 +129,11 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param options array of option descriptions
|
||||
* @param initialValue initial value (selection)
|
||||
* @return simulated value handle
|
||||
*
|
||||
* @deprecated Use direction-taking function instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int createSimValueEnum(int device, String name, boolean readonly,
|
||||
String[] options, int initialValue) {
|
||||
public static int createSimValueEnum(
|
||||
int device, String name, boolean readonly, String[] options, int initialValue) {
|
||||
return createSimValueEnum(device, name, readonly ? kOutput : kInput, options, initialValue);
|
||||
}
|
||||
|
||||
@@ -141,8 +142,7 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
*
|
||||
* <p>Enumerated values are always in the range 0 to numOptions-1.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -151,16 +151,15 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param initialValue initial value (selection)
|
||||
* @return simulated value handle
|
||||
*/
|
||||
public static native int createSimValueEnum(int device, String name, int direction,
|
||||
String[] options, int initialValue);
|
||||
public static native int createSimValueEnum(
|
||||
int device, String name, int direction, String[] options, int initialValue);
|
||||
|
||||
/**
|
||||
* Creates an enumerated value on a simulated device with double values.
|
||||
*
|
||||
* <p>Enumerated values are always in the range 0 to numOptions-1.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -170,35 +169,37 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param initialValue initial value (selection)
|
||||
* @return simulated value handle
|
||||
*/
|
||||
public static native int createSimValueEnumDouble(int device, String name, int direction,
|
||||
String[] options, double[] optionValues, int initialValue);
|
||||
public static native int createSimValueEnumDouble(
|
||||
int device,
|
||||
String name,
|
||||
int direction,
|
||||
String[] options,
|
||||
double[] optionValues,
|
||||
int initialValue);
|
||||
|
||||
/**
|
||||
* Creates a boolean value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
* @param readonly if the value should not be written from simulation side
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*
|
||||
* @deprecated Use direction-taking function instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int createSimValueBoolean(int device, String name, boolean readonly,
|
||||
boolean initialValue) {
|
||||
return createSimValueNative(device, name, readonly ? kOutput : kInput, HALValue.kBoolean,
|
||||
initialValue ? 1 : 0, 0.0);
|
||||
public static int createSimValueBoolean(
|
||||
int device, String name, boolean readonly, boolean initialValue) {
|
||||
return createSimValueNative(
|
||||
device, name, readonly ? kOutput : kInput, HALValue.kBoolean, initialValue ? 1 : 0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a boolean value on a simulated device.
|
||||
*
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls
|
||||
* to Set/Get functions.
|
||||
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
|
||||
*
|
||||
* @param device simulated device handle
|
||||
* @param name value name
|
||||
@@ -206,10 +207,10 @@ public class SimDeviceJNI extends JNIWrapper {
|
||||
* @param initialValue initial value
|
||||
* @return simulated value handle
|
||||
*/
|
||||
public static int createSimValueBoolean(int device, String name, int direction,
|
||||
boolean initialValue) {
|
||||
return createSimValueNative(device, name, direction, HALValue.kBoolean,
|
||||
initialValue ? 1 : 0, 0.0);
|
||||
public static int createSimValueBoolean(
|
||||
int device, String name, int direction, boolean initialValue) {
|
||||
return createSimValueNative(
|
||||
device, name, direction, HALValue.kBoolean, initialValue ? 1 : 0, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper around a simulator double value handle.
|
||||
*/
|
||||
/** A wrapper around a simulator double value handle. */
|
||||
public class SimDouble extends SimValue {
|
||||
/**
|
||||
* Wraps a simulated value handle as returned by SimDeviceJNI.createSimValueDouble().
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper around a simulator enum value handle.
|
||||
*/
|
||||
/** A wrapper around a simulator enum value handle. */
|
||||
public class SimEnum extends SimValue {
|
||||
/**
|
||||
* Wraps a simulated value handle as returned by SimDeviceJNI.createSimValueEnum().
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* A wrapper around a simulator value handle.
|
||||
*/
|
||||
/** A wrapper around a simulator value handle. */
|
||||
public class SimValue {
|
||||
/**
|
||||
* Wraps a simulated value handle as returned by SimDeviceJNI.createSimValue().
|
||||
|
||||
@@ -15,8 +15,9 @@ public final class CANExceptionFactory {
|
||||
static final int ERR_CANSessionMux_NotInitialized = -44089;
|
||||
|
||||
@SuppressWarnings({"MissingJavadocMethod", "PMD.CyclomaticComplexity"})
|
||||
public static void checkStatus(int status, int messageID) throws CANInvalidBufferException,
|
||||
CANMessageNotAllowedException, CANNotInitializedException, UncleanStatusException {
|
||||
public static void checkStatus(int status, int messageID)
|
||||
throws CANInvalidBufferException, CANMessageNotAllowedException, CANNotInitializedException,
|
||||
UncleanStatusException {
|
||||
switch (status) {
|
||||
case NIRioStatus.kRioStatusSuccess:
|
||||
// Everything is ok... don't throw.
|
||||
@@ -38,7 +39,5 @@ public final class CANExceptionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private CANExceptionFactory() {
|
||||
|
||||
}
|
||||
private CANExceptionFactory() {}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
package edu.wpi.first.hal.can;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
@SuppressWarnings("AbbreviationAsWordInName")
|
||||
public class CANJNI extends JNIWrapper {
|
||||
public static final int CAN_SEND_PERIOD_NO_REPEAT = 0;
|
||||
@@ -19,15 +18,13 @@ public class CANJNI extends JNIWrapper {
|
||||
public static final int CAN_IS_FRAME_11BIT = 0x40000000;
|
||||
|
||||
@SuppressWarnings("MethodName")
|
||||
public static native void FRCNetCommCANSessionMuxSendMessage(int messageID,
|
||||
byte[] data,
|
||||
int periodMs);
|
||||
public static native void FRCNetCommCANSessionMuxSendMessage(
|
||||
int messageID, byte[] data, int periodMs);
|
||||
|
||||
@SuppressWarnings("MethodName")
|
||||
public static native byte[] FRCNetCommCANSessionMuxReceiveMessage(
|
||||
IntBuffer messageID, int messageIDMask, ByteBuffer timeStamp);
|
||||
|
||||
|
||||
@SuppressWarnings("MethodName")
|
||||
public static native void GetCANStatus(CANStatus status);
|
||||
}
|
||||
|
||||
@@ -4,43 +4,35 @@
|
||||
|
||||
package edu.wpi.first.hal.can;
|
||||
|
||||
/**
|
||||
* Structure for holding the result of a CAN Status request.
|
||||
*/
|
||||
/** Structure for holding the result of a CAN Status request. */
|
||||
public class CANStatus {
|
||||
/**
|
||||
* The utilization of the CAN Bus.
|
||||
*/
|
||||
/** The utilization of the CAN Bus. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public double percentBusUtilization;
|
||||
|
||||
/**
|
||||
* The CAN Bus off count.
|
||||
*/
|
||||
/** The CAN Bus off count. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int busOffCount;
|
||||
|
||||
/**
|
||||
* The CAN Bus TX full count.
|
||||
*/
|
||||
/** The CAN Bus TX full count. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int txFullCount;
|
||||
|
||||
/**
|
||||
* The CAN Bus receive error count.
|
||||
*/
|
||||
/** The CAN Bus receive error count. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int receiveErrorCount;
|
||||
|
||||
/**
|
||||
* The CAN Bus transmit error count.
|
||||
*/
|
||||
/** The CAN Bus transmit error count. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int transmitErrorCount;
|
||||
|
||||
@SuppressWarnings("MissingJavadocMethod")
|
||||
public void setStatus(double percentBusUtilization, int busOffCount, int txFullCount,
|
||||
int receiveErrorCount, int transmitErrorCount) {
|
||||
public void setStatus(
|
||||
double percentBusUtilization,
|
||||
int busOffCount,
|
||||
int txFullCount,
|
||||
int receiveErrorCount,
|
||||
int transmitErrorCount) {
|
||||
this.percentBusUtilization = percentBusUtilization;
|
||||
this.busOffCount = busOffCount;
|
||||
this.txFullCount = txFullCount;
|
||||
|
||||
@@ -7,29 +7,49 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AccelerometerDataJNI extends JNIWrapper {
|
||||
public static native int registerActiveCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerActiveCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelActiveCallback(int index, int uid);
|
||||
|
||||
public static native boolean getActive(int index);
|
||||
|
||||
public static native void setActive(int index, boolean active);
|
||||
|
||||
public static native int registerRangeCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerRangeCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelRangeCallback(int index, int uid);
|
||||
|
||||
public static native int getRange(int index);
|
||||
|
||||
public static native void setRange(int index, int range);
|
||||
|
||||
public static native int registerXCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerXCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelXCallback(int index, int uid);
|
||||
|
||||
public static native double getX(int index);
|
||||
|
||||
public static native void setX(int index, double x);
|
||||
|
||||
public static native int registerYCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerYCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelYCallback(int index, int uid);
|
||||
|
||||
public static native double getY(int index);
|
||||
|
||||
public static native void setY(int index, double y);
|
||||
|
||||
public static native int registerZCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerZCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelZCallback(int index, int uid);
|
||||
|
||||
public static native double getZ(int index);
|
||||
|
||||
public static native void setZ(int index, double z);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,29 +7,48 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AddressableLEDDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerOutputPortCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerOutputPortCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelOutputPortCallback(int index, int uid);
|
||||
|
||||
public static native int getOutputPort(int index);
|
||||
|
||||
public static native void setOutputPort(int index, int outputPort);
|
||||
|
||||
public static native int registerLengthCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerLengthCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelLengthCallback(int index, int uid);
|
||||
|
||||
public static native int getLength(int index);
|
||||
|
||||
public static native void setLength(int index, int length);
|
||||
|
||||
public static native int registerRunningCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerRunningCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelRunningCallback(int index, int uid);
|
||||
|
||||
public static native boolean getRunning(int index);
|
||||
|
||||
public static native void setRunning(int index, boolean running);
|
||||
|
||||
public static native int registerDataCallback(int index, ConstBufferCallback callback);
|
||||
|
||||
public static native void cancelDataCallback(int index, int uid);
|
||||
|
||||
public static native byte[] getData(int index);
|
||||
|
||||
public static native void setData(int index, byte[] data);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,19 +7,31 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AnalogGyroDataJNI extends JNIWrapper {
|
||||
public static native int registerAngleCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAngleCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAngleCallback(int index, int uid);
|
||||
|
||||
public static native double getAngle(int index);
|
||||
|
||||
public static native void setAngle(int index, double angle);
|
||||
|
||||
public static native int registerRateCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerRateCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelRateCallback(int index, int uid);
|
||||
|
||||
public static native double getRate(int index);
|
||||
|
||||
public static native void setRate(int index, double rate);
|
||||
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,49 +7,85 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AnalogInDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerAverageBitsCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAverageBitsCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAverageBitsCallback(int index, int uid);
|
||||
|
||||
public static native int getAverageBits(int index);
|
||||
|
||||
public static native void setAverageBits(int index, int averageBits);
|
||||
|
||||
public static native int registerOversampleBitsCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerOversampleBitsCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelOversampleBitsCallback(int index, int uid);
|
||||
|
||||
public static native int getOversampleBits(int index);
|
||||
|
||||
public static native void setOversampleBits(int index, int oversampleBits);
|
||||
|
||||
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerVoltageCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelVoltageCallback(int index, int uid);
|
||||
|
||||
public static native double getVoltage(int index);
|
||||
|
||||
public static native void setVoltage(int index, double voltage);
|
||||
|
||||
public static native int registerAccumulatorInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAccumulatorInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAccumulatorInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getAccumulatorInitialized(int index);
|
||||
|
||||
public static native void setAccumulatorInitialized(int index, boolean accumulatorInitialized);
|
||||
|
||||
public static native int registerAccumulatorValueCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAccumulatorValueCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAccumulatorValueCallback(int index, int uid);
|
||||
|
||||
public static native long getAccumulatorValue(int index);
|
||||
|
||||
public static native void setAccumulatorValue(int index, long accumulatorValue);
|
||||
|
||||
public static native int registerAccumulatorCountCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAccumulatorCountCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAccumulatorCountCallback(int index, int uid);
|
||||
|
||||
public static native long getAccumulatorCount(int index);
|
||||
|
||||
public static native void setAccumulatorCount(int index, long accumulatorCount);
|
||||
|
||||
public static native int registerAccumulatorCenterCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAccumulatorCenterCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAccumulatorCenterCallback(int index, int uid);
|
||||
|
||||
public static native int getAccumulatorCenter(int index);
|
||||
|
||||
public static native void setAccumulatorCenter(int index, int AccumulatorCenter);
|
||||
|
||||
public static native int registerAccumulatorDeadbandCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAccumulatorDeadbandCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAccumulatorDeadbandCallback(int index, int uid);
|
||||
|
||||
public static native int getAccumulatorDeadband(int index);
|
||||
|
||||
public static native void setAccumulatorDeadband(int index, int AccumulatorDeadband);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,14 +7,22 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AnalogOutDataJNI extends JNIWrapper {
|
||||
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerVoltageCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelVoltageCallback(int index, int uid);
|
||||
|
||||
public static native double getVoltage(int index);
|
||||
|
||||
public static native void setVoltage(int index, double voltage);
|
||||
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,19 +7,31 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class AnalogTriggerDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerTriggerLowerBoundCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerTriggerLowerBoundCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelTriggerLowerBoundCallback(int index, int uid);
|
||||
|
||||
public static native double getTriggerLowerBound(int index);
|
||||
|
||||
public static native void setTriggerLowerBound(int index, double triggerLowerBound);
|
||||
|
||||
public static native int registerTriggerUpperBoundCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerTriggerUpperBoundCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelTriggerUpperBoundCallback(int index, int uid);
|
||||
|
||||
public static native double getTriggerUpperBound(int index);
|
||||
|
||||
public static native void setTriggerUpperBound(int index, double triggerUpperBound);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,29 +7,49 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class DIODataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerValueCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerValueCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelValueCallback(int index, int uid);
|
||||
|
||||
public static native boolean getValue(int index);
|
||||
|
||||
public static native void setValue(int index, boolean value);
|
||||
|
||||
public static native int registerPulseLengthCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPulseLengthCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPulseLengthCallback(int index, int uid);
|
||||
|
||||
public static native double getPulseLength(int index);
|
||||
|
||||
public static native void setPulseLength(int index, double pulseLength);
|
||||
|
||||
public static native int registerIsInputCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerIsInputCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelIsInputCallback(int index, int uid);
|
||||
|
||||
public static native boolean getIsInput(int index);
|
||||
|
||||
public static native void setIsInput(int index, boolean isInput);
|
||||
|
||||
public static native int registerFilterIndexCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerFilterIndexCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelFilterIndexCallback(int index, int uid);
|
||||
|
||||
public static native int getFilterIndex(int index);
|
||||
|
||||
public static native void setFilterIndex(int index, int filterIndex);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,19 +7,31 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class DigitalPWMDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerDutyCycleCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerDutyCycleCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelDutyCycleCallback(int index, int uid);
|
||||
|
||||
public static native double getDutyCycle(int index);
|
||||
|
||||
public static native void setDutyCycle(int index, double dutyCycle);
|
||||
|
||||
public static native int registerPinCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPinCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPinCallback(int index, int uid);
|
||||
|
||||
public static native int getPin(int index);
|
||||
|
||||
public static native void setPin(int index, int pin);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -8,76 +8,129 @@ import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class DriverStationDataJNI extends JNIWrapper {
|
||||
public static native int registerEnabledCallback(NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelEnabledCallback(int uid);
|
||||
|
||||
public static native boolean getEnabled();
|
||||
|
||||
public static native void setEnabled(boolean enabled);
|
||||
|
||||
public static native int registerAutonomousCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAutonomousCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAutonomousCallback(int uid);
|
||||
|
||||
public static native boolean getAutonomous();
|
||||
|
||||
public static native void setAutonomous(boolean autonomous);
|
||||
|
||||
public static native int registerTestCallback(NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelTestCallback(int uid);
|
||||
|
||||
public static native boolean getTest();
|
||||
|
||||
public static native void setTest(boolean test);
|
||||
|
||||
public static native int registerEStopCallback(NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelEStopCallback(int uid);
|
||||
|
||||
public static native boolean getEStop();
|
||||
|
||||
public static native void setEStop(boolean eStop);
|
||||
|
||||
public static native int registerFmsAttachedCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerFmsAttachedCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelFmsAttachedCallback(int uid);
|
||||
|
||||
public static native boolean getFmsAttached();
|
||||
|
||||
public static native void setFmsAttached(boolean fmsAttached);
|
||||
|
||||
public static native int registerDsAttachedCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerDsAttachedCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelDsAttachedCallback(int uid);
|
||||
|
||||
public static native boolean getDsAttached();
|
||||
|
||||
public static native void setDsAttached(boolean dsAttached);
|
||||
|
||||
public static native int registerAllianceStationIdCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerAllianceStationIdCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelAllianceStationIdCallback(int uid);
|
||||
|
||||
public static native int getAllianceStationId();
|
||||
|
||||
public static native void setAllianceStationId(int allianceStationId);
|
||||
|
||||
public static native int registerMatchTimeCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerMatchTimeCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelMatchTimeCallback(int uid);
|
||||
|
||||
public static native double getMatchTime();
|
||||
|
||||
public static native void setMatchTime(double matchTime);
|
||||
|
||||
public static native void setJoystickAxes(byte joystickNum, float[] axesArray);
|
||||
|
||||
public static native void setJoystickPOVs(byte joystickNum, short[] povsArray);
|
||||
|
||||
public static native void setJoystickButtons(byte joystickNum, int buttons, int count);
|
||||
|
||||
public static native long getJoystickOutputs(int stick);
|
||||
|
||||
public static native int getJoystickRumble(int stick, int rumbleNum);
|
||||
|
||||
public static native void setMatchInfo(String eventName, String gameSpecificMessage, int matchNumber, int replayNumber, int matchType);
|
||||
public static native void setMatchInfo(
|
||||
String eventName,
|
||||
String gameSpecificMessage,
|
||||
int matchNumber,
|
||||
int replayNumber,
|
||||
int matchType);
|
||||
|
||||
public static native void registerAllCallbacks(NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void notifyNewData();
|
||||
|
||||
public static native void setSendError(boolean shouldSend);
|
||||
|
||||
public static native void setSendConsoleLine(boolean shouldSend);
|
||||
|
||||
public static native void setJoystickButton(int stick, int button, boolean state);
|
||||
|
||||
public static native void setJoystickAxis(int stick, int axis, double value);
|
||||
|
||||
public static native void setJoystickPOV(int stick, int pov, int value);
|
||||
|
||||
public static native void setJoystickButtonsValue(int stick, int buttons);
|
||||
|
||||
public static native void setJoystickAxisCount(int stick, int count);
|
||||
|
||||
public static native void setJoystickPOVCount(int stick, int count);
|
||||
|
||||
public static native void setJoystickButtonCount(int stick, int count);
|
||||
|
||||
public static native void setJoystickIsXbox(int stick, boolean isXbox);
|
||||
|
||||
public static native void setJoystickType(int stick, int type);
|
||||
|
||||
public static native void setJoystickName(int stick, String name);
|
||||
|
||||
public static native void setJoystickAxisType(int stick, int axis, int type);
|
||||
|
||||
public static native void setGameSpecificMessage(String message);
|
||||
|
||||
public static native void setEventName(String name);
|
||||
|
||||
public static native void setMatchType(int type);
|
||||
|
||||
public static native void setMatchNumber(int matchNumber);
|
||||
|
||||
public static native void setReplayNumber(int replayNumber);
|
||||
|
||||
public static native void resetData();
|
||||
|
||||
@@ -7,19 +7,31 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class DutyCycleDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerFrequencyCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerFrequencyCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelFrequencyCallback(int index, int uid);
|
||||
|
||||
public static native int getFrequency(int index);
|
||||
|
||||
public static native void setFrequency(int index, int frequency);
|
||||
|
||||
public static native int registerOutputCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerOutputCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelOutputCallback(int index, int uid);
|
||||
|
||||
public static native double getOutput(int index);
|
||||
|
||||
public static native void setOutput(int index, double output);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,49 +7,84 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class EncoderDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerCountCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerCountCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelCountCallback(int index, int uid);
|
||||
|
||||
public static native int getCount(int index);
|
||||
|
||||
public static native void setCount(int index, int count);
|
||||
|
||||
public static native int registerPeriodCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPeriodCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPeriodCallback(int index, int uid);
|
||||
|
||||
public static native double getPeriod(int index);
|
||||
|
||||
public static native void setPeriod(int index, double period);
|
||||
|
||||
public static native int registerResetCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerResetCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelResetCallback(int index, int uid);
|
||||
|
||||
public static native boolean getReset(int index);
|
||||
|
||||
public static native void setReset(int index, boolean reset);
|
||||
|
||||
public static native int registerMaxPeriodCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerMaxPeriodCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelMaxPeriodCallback(int index, int uid);
|
||||
|
||||
public static native double getMaxPeriod(int index);
|
||||
|
||||
public static native void setMaxPeriod(int index, double maxPeriod);
|
||||
|
||||
public static native int registerDirectionCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerDirectionCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelDirectionCallback(int index, int uid);
|
||||
|
||||
public static native boolean getDirection(int index);
|
||||
|
||||
public static native void setDirection(int index, boolean direction);
|
||||
|
||||
public static native int registerReverseDirectionCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerReverseDirectionCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelReverseDirectionCallback(int index, int uid);
|
||||
|
||||
public static native boolean getReverseDirection(int index);
|
||||
|
||||
public static native void setReverseDirection(int index, boolean reverseDirection);
|
||||
|
||||
public static native int registerSamplesToAverageCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerSamplesToAverageCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSamplesToAverageCallback(int index, int uid);
|
||||
|
||||
public static native int getSamplesToAverage(int index);
|
||||
|
||||
public static native void setSamplesToAverage(int index, int samplesToAverage);
|
||||
|
||||
public static native void setDistance(int index, double distance);
|
||||
|
||||
public static native double getDistance(int index);
|
||||
|
||||
public static native void setRate(int index, double rate);
|
||||
|
||||
public static native double getRate(int index);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,15 +7,21 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class I2CDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerReadCallback(int index, BufferCallback callback);
|
||||
|
||||
public static native void cancelReadCallback(int index, int uid);
|
||||
|
||||
public static native int registerWriteCallback(int index, ConstBufferCallback callback);
|
||||
|
||||
public static native void cancelWriteCallback(int index, int uid);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -8,5 +8,6 @@ import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class NotifierDataJNI extends JNIWrapper {
|
||||
public static native long getNextTimeout();
|
||||
|
||||
public static native int getNumNotifiers();
|
||||
}
|
||||
|
||||
@@ -7,43 +7,75 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class PCMDataJNI extends JNIWrapper {
|
||||
public static native int registerSolenoidInitializedCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelSolenoidInitializedCallback(int index, int channel, int uid);
|
||||
public static native boolean getSolenoidInitialized(int index, int channel);
|
||||
public static native void setSolenoidInitialized(int index, int channel, boolean solenoidInitialized);
|
||||
public static native int registerSolenoidInitializedCallback(
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSolenoidInitializedCallback(int index, int channel, int uid);
|
||||
|
||||
public static native boolean getSolenoidInitialized(int index, int channel);
|
||||
|
||||
public static native void setSolenoidInitialized(
|
||||
int index, int channel, boolean solenoidInitialized);
|
||||
|
||||
public static native int registerSolenoidOutputCallback(
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native int registerSolenoidOutputCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelSolenoidOutputCallback(int index, int channel, int uid);
|
||||
|
||||
public static native boolean getSolenoidOutput(int index, int channel);
|
||||
|
||||
public static native void setSolenoidOutput(int index, int channel, boolean solenoidOutput);
|
||||
|
||||
public static native int registerCompressorInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerCompressorInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelCompressorInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getCompressorInitialized(int index);
|
||||
|
||||
public static native void setCompressorInitialized(int index, boolean compressorInitialized);
|
||||
|
||||
public static native int registerCompressorOnCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerCompressorOnCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelCompressorOnCallback(int index, int uid);
|
||||
|
||||
public static native boolean getCompressorOn(int index);
|
||||
|
||||
public static native void setCompressorOn(int index, boolean compressorOn);
|
||||
|
||||
public static native int registerClosedLoopEnabledCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerClosedLoopEnabledCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelClosedLoopEnabledCallback(int index, int uid);
|
||||
|
||||
public static native boolean getClosedLoopEnabled(int index);
|
||||
|
||||
public static native void setClosedLoopEnabled(int index, boolean closeLoopEnabled);
|
||||
|
||||
public static native int registerPressureSwitchCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPressureSwitchCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPressureSwitchCallback(int index, int uid);
|
||||
|
||||
public static native boolean getPressureSwitch(int index);
|
||||
|
||||
public static native void setPressureSwitch(int index, boolean pressureSwitch);
|
||||
|
||||
public static native int registerCompressorCurrentCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerCompressorCurrentCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelCompressorCurrentCallback(int index, int uid);
|
||||
|
||||
public static native double getCompressorCurrent(int index);
|
||||
|
||||
public static native void setCompressorCurrent(int index, double compressorCurrent);
|
||||
|
||||
public static native void registerAllNonSolenoidCallbacks(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void registerAllSolenoidCallbacks(int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void registerAllNonSolenoidCallbacks(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void registerAllSolenoidCallbacks(
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void resetData(int index);
|
||||
}
|
||||
|
||||
@@ -7,25 +7,40 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class PDPDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerTemperatureCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerTemperatureCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelTemperatureCallback(int index, int uid);
|
||||
|
||||
public static native double getTemperature(int index);
|
||||
|
||||
public static native void setTemperature(int index, double temperature);
|
||||
|
||||
public static native int registerVoltageCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerVoltageCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelVoltageCallback(int index, int uid);
|
||||
|
||||
public static native double getVoltage(int index);
|
||||
|
||||
public static native void setVoltage(int index, double voltage);
|
||||
|
||||
public static native int registerCurrentCallback(
|
||||
int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native int registerCurrentCallback(int index, int channel, NotifyCallback callback, boolean initialNotify);
|
||||
public static native void cancelCurrentCallback(int index, int channel, int uid);
|
||||
|
||||
public static native double getCurrent(int index, int channel);
|
||||
|
||||
public static native void setCurrent(int index, int channel, double current);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,34 +7,58 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class PWMDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerRawValueCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerRawValueCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelRawValueCallback(int index, int uid);
|
||||
|
||||
public static native int getRawValue(int index);
|
||||
|
||||
public static native void setRawValue(int index, int rawValue);
|
||||
|
||||
public static native int registerSpeedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerSpeedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSpeedCallback(int index, int uid);
|
||||
|
||||
public static native double getSpeed(int index);
|
||||
|
||||
public static native void setSpeed(int index, double speed);
|
||||
|
||||
public static native int registerPositionCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPositionCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPositionCallback(int index, int uid);
|
||||
|
||||
public static native double getPosition(int index);
|
||||
|
||||
public static native void setPosition(int index, double position);
|
||||
|
||||
public static native int registerPeriodScaleCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerPeriodScaleCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelPeriodScaleCallback(int index, int uid);
|
||||
|
||||
public static native int getPeriodScale(int index);
|
||||
|
||||
public static native void setPeriodScale(int index, int periodScale);
|
||||
|
||||
public static native int registerZeroLatchCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerZeroLatchCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelZeroLatchCallback(int index, int uid);
|
||||
|
||||
public static native boolean getZeroLatch(int index);
|
||||
|
||||
public static native void setZeroLatch(int index, boolean zeroLatch);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,24 +7,40 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class RelayDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedForwardCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedForwardCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedForwardCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitializedForward(int index);
|
||||
|
||||
public static native void setInitializedForward(int index, boolean initializedForward);
|
||||
|
||||
public static native int registerInitializedReverseCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedReverseCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedReverseCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitializedReverse(int index);
|
||||
|
||||
public static native void setInitializedReverse(int index, boolean initializedReverse);
|
||||
|
||||
public static native int registerForwardCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerForwardCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelForwardCallback(int index, int uid);
|
||||
|
||||
public static native boolean getForward(int index);
|
||||
|
||||
public static native void setForward(int index, boolean forward);
|
||||
|
||||
public static native int registerReverseCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerReverseCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelReverseCallback(int index, int uid);
|
||||
|
||||
public static native boolean getReverse(int index);
|
||||
|
||||
public static native void setReverse(int index, boolean reverse);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,79 +7,139 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class RoboRioDataJNI extends JNIWrapper {
|
||||
public static native int registerFPGAButtonCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerFPGAButtonCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelFPGAButtonCallback(int uid);
|
||||
|
||||
public static native boolean getFPGAButton();
|
||||
|
||||
public static native void setFPGAButton(boolean fPGAButton);
|
||||
|
||||
public static native int registerVInVoltageCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerVInVoltageCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelVInVoltageCallback(int uid);
|
||||
|
||||
public static native double getVInVoltage();
|
||||
|
||||
public static native void setVInVoltage(double vInVoltage);
|
||||
|
||||
public static native int registerVInCurrentCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerVInCurrentCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelVInCurrentCallback(int uid);
|
||||
|
||||
public static native double getVInCurrent();
|
||||
|
||||
public static native void setVInCurrent(double vInCurrent);
|
||||
|
||||
public static native int registerUserVoltage6VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserVoltage6VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserVoltage6VCallback(int uid);
|
||||
|
||||
public static native double getUserVoltage6V();
|
||||
|
||||
public static native void setUserVoltage6V(double userVoltage6V);
|
||||
|
||||
public static native int registerUserCurrent6VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserCurrent6VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserCurrent6VCallback(int uid);
|
||||
|
||||
public static native double getUserCurrent6V();
|
||||
|
||||
public static native void setUserCurrent6V(double userCurrent6V);
|
||||
|
||||
public static native int registerUserActive6VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserActive6VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserActive6VCallback(int uid);
|
||||
|
||||
public static native boolean getUserActive6V();
|
||||
|
||||
public static native void setUserActive6V(boolean userActive6V);
|
||||
|
||||
public static native int registerUserVoltage5VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserVoltage5VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserVoltage5VCallback(int uid);
|
||||
|
||||
public static native double getUserVoltage5V();
|
||||
|
||||
public static native void setUserVoltage5V(double userVoltage5V);
|
||||
|
||||
public static native int registerUserCurrent5VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserCurrent5VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserCurrent5VCallback(int uid);
|
||||
|
||||
public static native double getUserCurrent5V();
|
||||
|
||||
public static native void setUserCurrent5V(double userCurrent5V);
|
||||
|
||||
public static native int registerUserActive5VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserActive5VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserActive5VCallback(int uid);
|
||||
|
||||
public static native boolean getUserActive5V();
|
||||
|
||||
public static native void setUserActive5V(boolean userActive5V);
|
||||
|
||||
public static native int registerUserVoltage3V3Callback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserVoltage3V3Callback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserVoltage3V3Callback(int uid);
|
||||
|
||||
public static native double getUserVoltage3V3();
|
||||
|
||||
public static native void setUserVoltage3V3(double userVoltage3V3);
|
||||
|
||||
public static native int registerUserCurrent3V3Callback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserCurrent3V3Callback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserCurrent3V3Callback(int uid);
|
||||
|
||||
public static native double getUserCurrent3V3();
|
||||
|
||||
public static native void setUserCurrent3V3(double userCurrent3V3);
|
||||
|
||||
public static native int registerUserActive3V3Callback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserActive3V3Callback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserActive3V3Callback(int uid);
|
||||
|
||||
public static native boolean getUserActive3V3();
|
||||
|
||||
public static native void setUserActive3V3(boolean userActive3V3);
|
||||
|
||||
public static native int registerUserFaults6VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserFaults6VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserFaults6VCallback(int uid);
|
||||
|
||||
public static native int getUserFaults6V();
|
||||
|
||||
public static native void setUserFaults6V(int userFaults6V);
|
||||
|
||||
public static native int registerUserFaults5VCallback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserFaults5VCallback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserFaults5VCallback(int uid);
|
||||
|
||||
public static native int getUserFaults5V();
|
||||
|
||||
public static native void setUserFaults5V(int userFaults5V);
|
||||
|
||||
public static native int registerUserFaults3V3Callback(NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerUserFaults3V3Callback(
|
||||
NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelUserFaults3V3Callback(int uid);
|
||||
|
||||
public static native int getUserFaults3V3();
|
||||
|
||||
public static native void setUserFaults3V3(int userFaults3V3);
|
||||
|
||||
public static native void resetData();
|
||||
|
||||
@@ -7,29 +7,49 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class SPIAccelerometerDataJNI extends JNIWrapper {
|
||||
public static native int registerActiveCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerActiveCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelActiveCallback(int index, int uid);
|
||||
|
||||
public static native boolean getActive(int index);
|
||||
|
||||
public static native void setActive(int index, boolean active);
|
||||
|
||||
public static native int registerRangeCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerRangeCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelRangeCallback(int index, int uid);
|
||||
|
||||
public static native int getRange(int index);
|
||||
|
||||
public static native void setRange(int index, int range);
|
||||
|
||||
public static native int registerXCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerXCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelXCallback(int index, int uid);
|
||||
|
||||
public static native double getX(int index);
|
||||
|
||||
public static native void setX(int index, double x);
|
||||
|
||||
public static native int registerYCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerYCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelYCallback(int index, int uid);
|
||||
|
||||
public static native double getY(int index);
|
||||
|
||||
public static native void setY(int index, double y);
|
||||
|
||||
public static native int registerZCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerZCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelZCallback(int index, int uid);
|
||||
|
||||
public static native double getZ(int index);
|
||||
|
||||
public static native void setZ(int index, double z);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -7,18 +7,26 @@ package edu.wpi.first.hal.simulation;
|
||||
import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class SPIDataJNI extends JNIWrapper {
|
||||
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
|
||||
public static native int registerInitializedCallback(
|
||||
int index, NotifyCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelInitializedCallback(int index, int uid);
|
||||
|
||||
public static native boolean getInitialized(int index);
|
||||
|
||||
public static native void setInitialized(int index, boolean initialized);
|
||||
|
||||
public static native int registerReadCallback(int index, BufferCallback callback);
|
||||
|
||||
public static native void cancelReadCallback(int index, int uid);
|
||||
|
||||
public static native int registerWriteCallback(int index, ConstBufferCallback callback);
|
||||
|
||||
public static native void cancelWriteCallback(int index, int uid);
|
||||
|
||||
public static native int registerReadAutoReceiveBufferCallback(int index, SpiReadAutoReceiveBufferCallback callback);
|
||||
public static native int registerReadAutoReceiveBufferCallback(
|
||||
int index, SpiReadAutoReceiveBufferCallback callback);
|
||||
|
||||
public static native void cancelReadAutoReceiveBufferCallback(int index, int uid);
|
||||
|
||||
public static native void resetData(int index);
|
||||
|
||||
@@ -9,12 +9,17 @@ import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class SimDeviceDataJNI extends JNIWrapper {
|
||||
public static native void setSimDeviceEnabled(String prefix, boolean enabled);
|
||||
|
||||
public static native boolean isSimDeviceEnabled(String name);
|
||||
|
||||
public static native int registerSimDeviceCreatedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify);
|
||||
public static native int registerSimDeviceCreatedCallback(
|
||||
String prefix, SimDeviceCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSimDeviceCreatedCallback(int uid);
|
||||
|
||||
public static native int registerSimDeviceFreedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify);
|
||||
public static native int registerSimDeviceFreedCallback(
|
||||
String prefix, SimDeviceCallback callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSimDeviceFreedCallback(int uid);
|
||||
|
||||
public static native int getSimDeviceHandle(String name);
|
||||
@@ -35,20 +40,30 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
@SuppressWarnings("MemberName")
|
||||
public int handle;
|
||||
}
|
||||
|
||||
public static native SimDeviceInfo[] enumerateSimDevices(String prefix);
|
||||
|
||||
public static native int registerSimValueCreatedCallback(int device, SimValueCallback callback, boolean initialNotify);
|
||||
public static native int registerSimValueCreatedCallback2(int device, SimValueCallback2 callback, boolean initialNotify);
|
||||
public static native int registerSimValueCreatedCallback(
|
||||
int device, SimValueCallback callback, boolean initialNotify);
|
||||
|
||||
public static native int registerSimValueCreatedCallback2(
|
||||
int device, SimValueCallback2 callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSimValueCreatedCallback(int uid);
|
||||
|
||||
public static native int registerSimValueChangedCallback(int handle, SimValueCallback callback, boolean initialNotify);
|
||||
public static native int registerSimValueChangedCallback2(int handle, SimValueCallback2 callback, boolean initialNotify);
|
||||
public static native int registerSimValueChangedCallback(
|
||||
int handle, SimValueCallback callback, boolean initialNotify);
|
||||
|
||||
public static native int registerSimValueChangedCallback2(
|
||||
int handle, SimValueCallback2 callback, boolean initialNotify);
|
||||
|
||||
public static native void cancelSimValueChangedCallback(int uid);
|
||||
|
||||
public static native int getSimValueHandle(int device, String name);
|
||||
|
||||
public static class SimValueInfo {
|
||||
public SimValueInfo(String name, int handle, int direction, int type, long value1, double value2) {
|
||||
public SimValueInfo(
|
||||
String name, int handle, int direction, int type, long value1, double value2) {
|
||||
this.name = name;
|
||||
this.handle = handle;
|
||||
this.readonly = direction == 1;
|
||||
@@ -72,6 +87,7 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
@SuppressWarnings("MemberName")
|
||||
public HALValue value;
|
||||
}
|
||||
|
||||
public static native SimValueInfo[] enumerateSimValues(int device);
|
||||
|
||||
public static native String[] getSimValueEnumOptions(int handle);
|
||||
|
||||
@@ -10,7 +10,8 @@ import edu.wpi.first.hal.HALValue;
|
||||
public interface SimValueCallback {
|
||||
void callback(String name, int handle, boolean readonly, HALValue value);
|
||||
|
||||
default void callbackNative(String name, int handle, boolean readonly, int type, long value1, double value2) {
|
||||
default void callbackNative(
|
||||
String name, int handle, boolean readonly, int type, long value1, double value2) {
|
||||
callback(name, handle, readonly, HALValue.fromNative(type, value1, value2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import edu.wpi.first.hal.HALValue;
|
||||
public interface SimValueCallback2 {
|
||||
void callback(String name, int handle, int direction, HALValue value);
|
||||
|
||||
default void callbackNative(String name, int handle, int direction, int type, long value1, double value2) {
|
||||
default void callbackNative(
|
||||
String name, int handle, int direction, int type, long value1, double value2) {
|
||||
callback(name, handle, direction, HALValue.fromNative(type, value1, value2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,25 @@ import edu.wpi.first.hal.JNIWrapper;
|
||||
|
||||
public class SimulatorJNI extends JNIWrapper {
|
||||
public static native void setRuntimeType(int type);
|
||||
|
||||
public static native void waitForProgramStart();
|
||||
|
||||
public static native void setProgramStarted();
|
||||
|
||||
public static native boolean getProgramStarted();
|
||||
|
||||
public static native void restartTiming();
|
||||
|
||||
public static native void pauseTiming();
|
||||
|
||||
public static native void resumeTiming();
|
||||
|
||||
public static native boolean isTimingPaused();
|
||||
|
||||
public static native void stepTiming(long delta);
|
||||
|
||||
public static native void stepTimingAsync(long delta);
|
||||
|
||||
public static native void resetHandles();
|
||||
|
||||
public static class SimPeriodicBeforeCallback implements AutoCloseable {
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal.util;
|
||||
|
||||
/**
|
||||
* Exception indicating that the resource is already allocated.
|
||||
*/
|
||||
/** Exception indicating that the resource is already allocated. */
|
||||
@SuppressWarnings("serial")
|
||||
public class AllocationException extends RuntimeException {
|
||||
/**
|
||||
|
||||
@@ -28,8 +28,8 @@ public class BoundaryException extends RuntimeException {
|
||||
*/
|
||||
public static void assertWithinBounds(double value, double lower, double upper) {
|
||||
if (value < lower || value > upper) {
|
||||
throw new BoundaryException("Value must be between " + lower + " and " + upper + ", " + value
|
||||
+ " given");
|
||||
throw new BoundaryException(
|
||||
"Value must be between " + lower + " and " + upper + ", " + value + " given");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal.util;
|
||||
|
||||
/**
|
||||
* Exception indicating that an error has occurred with a HAL Handle.
|
||||
*/
|
||||
/** Exception indicating that an error has occurred with a HAL Handle. */
|
||||
@SuppressWarnings("serial")
|
||||
public class HalHandleException extends RuntimeException {
|
||||
/**
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
|
||||
package edu.wpi.first.hal.util;
|
||||
|
||||
/**
|
||||
* Exception for bad status codes from the chip object.
|
||||
*/
|
||||
/** Exception for bad status codes from the chip object. */
|
||||
@SuppressWarnings("serial")
|
||||
public final class UncleanStatusException extends IllegalStateException {
|
||||
private final int m_statusCode;
|
||||
@@ -14,7 +12,7 @@ public final class UncleanStatusException extends IllegalStateException {
|
||||
/**
|
||||
* Create a new UncleanStatusException.
|
||||
*
|
||||
* @param status the status code that caused the exception
|
||||
* @param status the status code that caused the exception
|
||||
* @param message A message describing the exception
|
||||
*/
|
||||
public UncleanStatusException(int status, String message) {
|
||||
@@ -40,9 +38,7 @@ public final class UncleanStatusException extends IllegalStateException {
|
||||
this(-1, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new UncleanStatusException.
|
||||
*/
|
||||
/** Create a new UncleanStatusException. */
|
||||
public UncleanStatusException() {
|
||||
this(-1, "Status code was non-zero");
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ package frc.robot;
|
||||
import edu.wpi.first.wpilibj.RobotBase;
|
||||
|
||||
public final class Main {
|
||||
private Main() {
|
||||
}
|
||||
private Main() {}
|
||||
|
||||
/**
|
||||
* Main initialization function. Do not perform any initialization here.
|
||||
|
||||
@@ -9,45 +9,33 @@ import edu.wpi.first.wpilibj.TimedRobot;
|
||||
@SuppressWarnings("all")
|
||||
public class MyRobot extends TimedRobot {
|
||||
/**
|
||||
* This function is run when the robot is first started up and should be
|
||||
* used for any initialization code.
|
||||
* This function is run when the robot is first started up and should be used for any
|
||||
* initialization code.
|
||||
*/
|
||||
@Override
|
||||
public void robotInit() {}
|
||||
|
||||
/**
|
||||
* This function is run once each time the robot enters autonomous mode
|
||||
*/
|
||||
/** This function is run once each time the robot enters autonomous mode */
|
||||
@Override
|
||||
public void autonomousInit() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically during autonomous
|
||||
*/
|
||||
/** This function is called periodically during autonomous */
|
||||
@Override
|
||||
public void autonomousPeriodic() {}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters tele-operated mode
|
||||
*/
|
||||
/** This function is called once each time the robot enters tele-operated mode */
|
||||
@Override
|
||||
public void teleopInit() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically during operator control
|
||||
*/
|
||||
/** This function is called periodically during operator control */
|
||||
@Override
|
||||
public void teleopPeriodic() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically during test mode
|
||||
*/
|
||||
/** This function is called periodically during test mode */
|
||||
@Override
|
||||
public void testPeriodic() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically during all modes
|
||||
*/
|
||||
/** This function is called periodically during all modes */
|
||||
@Override
|
||||
public void robotPeriodic() {}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,12 @@ import edu.wpi.first.networktables.NetworkTablesJNI;
|
||||
import edu.wpi.first.wpiutil.RuntimeDetector;
|
||||
|
||||
public final class DevMain {
|
||||
/**
|
||||
* Main method.
|
||||
*/
|
||||
/** Main method. */
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
System.out.println(RuntimeDetector.getPlatformPath());
|
||||
NetworkTablesJNI.flush(NetworkTablesJNI.getDefaultInstance());
|
||||
}
|
||||
|
||||
private DevMain() {
|
||||
}
|
||||
private DevMain() {}
|
||||
}
|
||||
|
||||
@@ -4,45 +4,39 @@
|
||||
|
||||
package edu.wpi.first.networktables;
|
||||
|
||||
/**
|
||||
* NetworkTables Connection information.
|
||||
*/
|
||||
/** NetworkTables Connection information. */
|
||||
public final class ConnectionInfo {
|
||||
/**
|
||||
* The remote identifier (as set on the remote node by
|
||||
* {@link NetworkTableInstance#setNetworkIdentity(String)}).
|
||||
* The remote identifier (as set on the remote node by {@link
|
||||
* NetworkTableInstance#setNetworkIdentity(String)}).
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String remote_id;
|
||||
|
||||
/**
|
||||
* The IP address of the remote node.
|
||||
*/
|
||||
/** The IP address of the remote node. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String remote_ip;
|
||||
|
||||
/**
|
||||
* The port number of the remote node.
|
||||
*/
|
||||
/** The port number of the remote node. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int remote_port;
|
||||
|
||||
/**
|
||||
* The last time any update was received from the remote node (same scale as
|
||||
* returned by {@link NetworkTablesJNI#now()}).
|
||||
* The last time any update was received from the remote node (same scale as returned by {@link
|
||||
* NetworkTablesJNI#now()}).
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long last_update;
|
||||
|
||||
/**
|
||||
* The protocol version being used for this connection. This is in protocol
|
||||
* layer format, so 0x0200 = 2.0, 0x0300 = 3.0).
|
||||
* The protocol version being used for this connection. This is in protocol layer format, so
|
||||
* 0x0200 = 2.0, 0x0300 = 3.0).
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int protocol_version;
|
||||
|
||||
/** Constructor.
|
||||
* This should generally only be used internally to NetworkTables.
|
||||
/**
|
||||
* Constructor. This should generally only be used internally to NetworkTables.
|
||||
*
|
||||
* @param remoteId Remote identifier
|
||||
* @param remoteIp Remote IP address
|
||||
@@ -50,8 +44,8 @@ public final class ConnectionInfo {
|
||||
* @param lastUpdate Last time an update was received
|
||||
* @param protocolVersion The protocol version used for the connection
|
||||
*/
|
||||
public ConnectionInfo(String remoteId, String remoteIp, int remotePort, long lastUpdate,
|
||||
int protocolVersion) {
|
||||
public ConnectionInfo(
|
||||
String remoteId, String remoteIp, int remotePort, long lastUpdate, int protocolVersion) {
|
||||
remote_id = remoteId;
|
||||
remote_ip = remoteIp;
|
||||
remote_port = remotePort;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user