diff --git a/asyncapi-template/filters/DeviceFilter.js b/asyncapi-template/filters/DeviceFilter.js index 6ef6029..27ef4bf 100644 --- a/asyncapi-template/filters/DeviceFilter.js +++ b/asyncapi-template/filters/DeviceFilter.js @@ -16,7 +16,7 @@ function filterProps(props) { function aAn(str) { //Credit: https://stackoverflow.com/questions/37896484/multiple-conditions-for-javascript-includes-method - return ['a', 'e', 'i', 'o', 'u'].some(el => str.includes(el)); + return ['a', 'e', 'i', 'o', 'u'].some(el => str.includes(el)) ? "an" : "a"; } function formatName(type) { diff --git a/asyncapi-template/filters/PropertyFilter.js b/asyncapi-template/filters/PropertyFilter.js index e8b4094..f728c2b 100644 --- a/asyncapi-template/filters/PropertyFilter.js +++ b/asyncapi-template/filters/PropertyFilter.js @@ -75,4 +75,12 @@ function formatPropInitialValue(prop) { } } -module.exports = { formatPropName, cap1, formatPropType, formatPropTypeArr, formatPropPrimType, formatPropInitialValue } +function isRobotInput(prop) { + return prop.startsWith(">") || prop.startsWith("<>"); +} + +function isRobotOutput(prop) { + return prop.startsWith("<"); +} + +module.exports = { formatPropName, cap1, formatPropType, formatPropTypeArr, formatPropPrimType, formatPropInitialValue, isRobotInput, isRobotOutput } diff --git a/asyncapi-template/partials/initVars.java b/asyncapi-template/partials/initVars.java index 1b78955..b9da4b1 100644 --- a/asyncapi-template/partials/initVars.java +++ b/asyncapi-template/partials/initVars.java @@ -6,3 +6,5 @@ {% set parrtype = prop | formatPropTypeArr %} {% set pprimtype = prop | formatPropPrimType %} {% set pinit = prop | formatPropInitialValue | safe %} +{% set isRobotInput = pfname | isRobotInput %} +{% set isRobotOutput = pfname | isRobotOutput %} diff --git a/asyncapi-template/template/$$schema$$.java b/asyncapi-template/template/$$schema$$.java index b9be953..24c154d 100644 --- a/asyncapi-template/template/$$schema$$.java +++ b/asyncapi-template/template/$$schema$$.java @@ -15,13 +15,16 @@ // EDIT THAT FILE INSTEAD. package org.team199.wpiws.devices; +import java.util.List; {% if hasId -%} -import java.util.HashMap; +import java.util.Map; {% endif -%} -import java.util.List; import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; +{% if hasId -%} +import java.util.concurrent.ConcurrentHashMap; +{% endif -%} import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.CopyOnWriteArraySet; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -36,32 +39,33 @@ */ {% if hasId -%} public class {{ name }}Sim extends StateDevice<{{ name }}Sim.State> { -{% else -%} +{%- else %} public class {{ name }}Sim { -{% endif -%} - {% if hasInit %} - private static final CopyOnWriteArrayList INITIALIZED_DEVICES = new CopyOnWriteArrayList<>(); - private static final CopyOnWriteArrayList STATIC_INITIALIZED_CALLBACKS = new CopyOnWriteArrayList<>(); +{%- endif %} + + {% if hasInit -%} + private static final Set INITIALIZED_DEVICES = new ConcurrentSkipListSet<>(); + private static final Set STATIC_INITIALIZED_CALLBACKS = new CopyOnWriteArraySet<>(); {% endif -%} - {% if hasId %} - private static final HashMap STATE_MAP = new HashMap<>(); - {%- else %} + {% if hasId -%} + private static final Map STATE_MAP = new ConcurrentHashMap<>(); + {% else -%} private static final {{ name }}Sim.State STATE = new State(); {% endif -%} private static final Set UNKNOWN_KEYS = new ConcurrentSkipListSet<>(); - - {% if hasId %} + {% if hasId -%} /** * Creates a new {{ name }}Sim - * @param id the device identifier of this {{ name }}Sim + * @param id the device identifier of this {{ name }}Sim */ public {{ name }}Sim(String id) { super(id, STATE_MAP); } - {% endif -%} + {%- endif -%} + + {%- if hasInit %} - {% if hasInit %} /** * Registers a BooleanCallback to be called whenever {{ a }} {{ name }}Sim device is initialized or uninitialized * @param callback the callback function to call @@ -71,7 +75,7 @@ public class {{ name }}Sim { * @see #registerInitializedCallback(BooleanCallback, boolean) */ public static ScopedObject registerStaticInitializedCallback(BooleanCallback callback, boolean initialNotify) { - STATIC_INITIALIZED_CALLBACKS.addIfAbsent(callback); + STATIC_INITIALIZED_CALLBACKS.add(callback); if(initialNotify) { INITIALIZED_DEVICES.forEach(device -> callback.callback(device, true)); } @@ -90,7 +94,7 @@ public static ScopedObject registerStaticInitializedCallback(Bo public static void cancelStaticInitializedCallback(BooleanCallback callback) { STATIC_INITIALIZED_CALLBACKS.remove(callback); } - + /** * Registers a BooleanCallback to be called whenever this device is initialized or uninitialized * @param callback the callback function to call @@ -100,7 +104,7 @@ public static void cancelStaticInitializedCallback(BooleanCallback callback) { * @see #registerStaticInitializedCallback(BooleanCallback, boolean) */ public ScopedObject registerInitializedCallback(BooleanCallback callback, boolean initialNotify) { - getState().INITIALIZED_CALLBACKS.addIfAbsent(callback); + getState().INITIALIZED_CALLBACKS.add(callback); if(initialNotify) { callback.callback(id, getState().init); } @@ -144,7 +148,7 @@ private void setInitialized(boolean initialized, boolean notifyRobot) { if(initialized) { STATIC_INITIALIZED_CALLBACKS.forEach(CALL_INITIALIZED_CALLBACK); getState().INITIALIZED_CALLBACKS.forEach(CALL_INITIALIZED_CALLBACK); - INITIALIZED_DEVICES.addIfAbsent(id); + INITIALIZED_DEVICES.add(id); } else { INITIALIZED_DEVICES.remove(id); } @@ -159,19 +163,21 @@ private void setInitialized(boolean initialized, boolean notifyRobot) { public static String[] enumerateDevices() { return INITIALIZED_DEVICES.toArray(new String[INITIALIZED_DEVICES.size()]); } - {% endif -%} + {%- endif -%} + + {%- if hasId %} - {% if hasId %} @Override protected State generateState() { return new State(); } - - {% else %} + + {% else -%} + protected static {{ name }}Sim.State getState() { return STATE; } - + {% endif -%} {% for propName, prop in props -%} @@ -184,7 +190,7 @@ protected State generateState() { * @see #cancel{{ varInfo.pname }}Callback({{ varInfo.ptype }}Callback) */ public{{ cstatic }}ScopedObject<{{ varInfo.ptype }}Callback> register{{ varInfo.pname }}Callback({{ varInfo.ptype }}Callback callback, boolean initialNotify) { - getState().{{ varInfo.pnameu }}_CALLBACKS.addIfAbsent(callback); + getState().{{ varInfo.pnameu }}_CALLBACKS.add(callback); if(initialNotify) { callback.callback({{ cid }}, getState().{{ varInfo.pnamel }}); } @@ -205,20 +211,23 @@ protected State generateState() { } /** - * @return {{ prop.description() | lower }} + * @return {{ prop.description() | lower | trim }} * @see #set{{ varInfo.pname }}({{ varInfo.pprimtype }}) */ public{{ cstatic }}{{ varInfo.pprimtype }} get{{ varInfo.pname }}() { return getState().{{ varInfo.pnamel }}; } + {%- if varInfo.isRobotInput %} + /** - * Set {{ prop.description() | lower }} + * Set {{ prop.description() | lower | trim }} * @see #get{{ varInfo.pname }}() */ public{{ cstatic }}void set{{ varInfo.pname }}({{ varInfo.pprimtype }} {{ varInfo.pnamel }}) { set{{ varInfo.pname }}({{ varInfo.pnamel }}, true); } + {%- endif %} /** * A Consumer which calls the given callback with the current {{ varInfo.pnamel }} value of this PWMSim @@ -230,6 +239,9 @@ protected State generateState() { getState().{{ varInfo.pnameu }}_CALLBACKS.forEach(CALL_{{ varInfo.pnameu }}_CALLBACK); } if(notifyRobot) { + {%- if not varInfo.isRobotInput %} + System.err.println("WARNING: {{ name }}Sim#set{{ varInfo.pname }}({{ varInfo.pprimtype }}, true) was called, but {{ varInfo.pfname }} is not a robot input!"); + {%- endif %} ConnectionProcessor.broadcastMessage({{ cid }}, "{{ type }}", new WSValue("{{ varInfo.pfname }}", {{ varInfo.pnamel }})); } } @@ -279,7 +291,7 @@ public static void processMessage(String device, List data) { private{{ cstatic }}void processValue(WSValue value) { if(value.getKey() instanceof String && value.getValue() != null) { switch((String)value.getKey()) { - {% if hasInit -%} + {%- if hasInit %} case " data) { } {%- endfor %} default: { - if (!UNKNOWN_KEYS.contains(value.getKey())) { + if (UNKNOWN_KEYS.add(value.getKey())) { System.err.println("{{ name }}Sim received value '" + value.getKey() + ":" + value.getValue() + "' but does not recognize '" + value.getKey() + "'. Values with that key will be ignored."); - UNKNOWN_KEYS.add(value.getKey()); } } } @@ -307,22 +318,22 @@ public static void processMessage(String device, List data) { } /** - * Contains all information about the state of a {{ name }}Sim + * Contains all information about the state of {{ a }} {{ name }}Sim */ public static class State { {% if hasInit -%} public boolean init = false; - {% endif -%} - {% for propName, prop in props -%} - {% import "../partials/initVars.java" as varInfo with context -%} + {%- endif -%} + {%- for propName, prop in props -%} + {%- import "../partials/initVars.java" as varInfo with context %} public {{ varInfo.pprimtype }} {{ varInfo.pnamel }} = {{ varInfo.pinit }}; - {% endfor -%} + {%- endfor %} {% if hasInit -%} - public final CopyOnWriteArrayList INITIALIZED_CALLBACKS = new CopyOnWriteArrayList<>(); - {% endif -%} - {% for propName, prop in props -%} - {% import "../partials/initVars.java" as varInfo with context -%} - public final CopyOnWriteArrayList<{{ varInfo.ptype }}Callback> {{ varInfo.pnameu }}_CALLBACKS = new CopyOnWriteArrayList<>(); + public final Set INITIALIZED_CALLBACKS = new CopyOnWriteArraySet<>(); + {%- endif -%} + {%- for propName, prop in props -%} + {%- import "../partials/initVars.java" as varInfo with context %} + public final Set<{{ varInfo.ptype }}Callback> {{ varInfo.pnameu }}_CALLBACKS = new CopyOnWriteArraySet<>(); {%- endfor %} } diff --git a/asyncapi-template/template/SimDeviceSim.java b/asyncapi-template/template/SimDeviceSim.java index f3a1fe4..0310520 100644 --- a/asyncapi-template/template/SimDeviceSim.java +++ b/asyncapi-template/template/SimDeviceSim.java @@ -6,11 +6,13 @@ import java.math.BigDecimal; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.CopyOnWriteArraySet; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; @@ -28,9 +30,9 @@ */ public class SimDeviceSim extends StateDevice { - private static final HashMap STATE_MAP = new HashMap<>(); - private static final CopyOnWriteArrayList EXISTING_DEVICES = new CopyOnWriteArrayList<>(); - private static final CopyOnWriteArrayList> DEVICE_CALLBACKS = new CopyOnWriteArrayList<>(); + private static final Map STATE_MAP = new ConcurrentHashMap<>(); + private static final Set EXISTING_DEVICES = new ConcurrentSkipListSet<>(); + private static final Set> DEVICE_CALLBACKS = new CopyOnWriteArraySet<>(); /** * Creates a new SimDeviceSim @@ -75,9 +77,40 @@ public void set(String name, boolean value) { */ public void set(String name, double value) { getState().valueTypes.put(name, "d"); + getState().valueBidirectionality.putIfAbsent(name, false); set(name, String.valueOf(value), true); } + /** + * Sets the specified value to be bidirectional on the SimDeviceSim. This means that the value can be set from the robot code as well as from the simulation code. + * This method MUST be called before the value is set from simulation code. If the value is first set by robot code, this is handled automatically. + * For more information, see DeepBlueRobotics/WPIWebSockets#30. + * @param name the name of the value + */ + public void setBidirectional(String name) { + if(Boolean.FALSE.equals(getState().valueBidirectionality.put(name, true))) { // This is the same as oldValue == false, but also accounts for null + System.err.println("WARNING: SimDeviceSim (" + id + "): User code is setting " + name + " to be bidirectional, but it has already been used non-bidirectionally! This may cause unexpected behavior. (See DeepBlueRobotics/WPIWebSockets#30)"); + } + } + + /** + * Checks whether the specified value is bidirectional on the SimDeviceSim. + * @param name the name of the value + * @return true if the value is bidirectional, false if it is non-bidirectional or if the value does not yet exist + */ + public boolean isBidirectional(String name) { + return getState().valueBidirectionality.getOrDefault(name, false); + } + + /** + * Determines the prefix to use for the specified value when sending it to the robot code. + * @param name the name of the value + * @return the prefix to use for the specified value + */ + public String getPrefix(String name) { + return isBidirectional(name) ? "<>" : ">"; + } + /** * Calls the specified callback with the device identifier of this device */ @@ -95,14 +128,13 @@ public void set(String name, double value) { */ public static final Function, StringCallback> FETCH_VALUE_CALLBACK = pair -> pair.val2; private void set(String name, String value, boolean notifyRobot) { - if(!EXISTING_DEVICES.contains(id)) { + if(EXISTING_DEVICES.add(id)) { DEVICE_CALLBACKS.stream().filter(APPLIES_TO_ME).map(FETCH_DEVICE_CALLBACK).forEach(CALL_DEVICE_CALLBACK); } - EXISTING_DEVICES.addIfAbsent(id); getState().values.put(name, value); Consumer callCallback = callback -> callback.callback(name, value); if(!getState().existingValues.contains(name)) { - getState().existingValues.addIfAbsent(name); + getState().existingValues.add(name); getState().valueCreatedCallbacks.forEach(callCallback); } if(get(value) == null || !value.equals(get(value))) { @@ -128,7 +160,7 @@ private void set(String name, String value, boolean notifyRobot) { } else { valueObj = value; } - ConnectionProcessor.broadcastMessage(id, "SimDevice", new WSValue(">" + name, valueObj)); + ConnectionProcessor.broadcastMessage(id, "SimDevice", new WSValue(getPrefix(name) + name, valueObj)); } } @@ -140,7 +172,7 @@ private void set(String name, String value, boolean notifyRobot) { * @see #cancelValueCreatedCallback(StringCallback) */ public ScopedObject registerValueCreatedCallback(StringCallback callback, boolean initialNotify) { - getState().valueCreatedCallbacks.addIfAbsent(callback); + getState().valueCreatedCallbacks.add(callback); if(initialNotify) { getState().existingValues.forEach(value -> callback.callback(value, get(value))); } @@ -159,7 +191,7 @@ public ScopedObject registerValueCreatedCallback(StringCallback public void cancelValueCreatedCallback(StringCallback callback) { getState().valueCreatedCallbacks.remove(callback); } - + /** * Registers a SimValueCallback to be called whenever the specified value of this device is changed * @param callback the callback function to call @@ -169,7 +201,7 @@ public void cancelValueCreatedCallback(StringCallback callback) { */ public ScopedObject> registerValueChangedCallback(String value, StringCallback callback, boolean initialNotify) { Pair callbackPair = new Pair<>(value, callback); - getState().valueChangedCallbacks.addIfAbsent(callbackPair); + getState().valueChangedCallbacks.add(callbackPair); if(initialNotify) { callback.callback(value, get(value)); } @@ -188,21 +220,21 @@ public ScopedObject> registerValueChangedCallback(S public void cancelValueChangedCallback(Pair callback) { getState().valueChangedCallbacks.remove(callback); } - + /** * @return an array of the identifiers of all created SimDeviceSims. A SimDeviceSim is determined to be created if a value on it has been set. */ public static String[] enumerateDevices(String prefix) { return EXISTING_DEVICES.stream().filter(name -> name.startsWith(prefix)).toArray(CREATE_STRING_ARRAY); } - + /** * @return an array of the value names of all values of this SimDeviceSim */ public String[] enumerateValues(String prefix) { return getState().existingValues.stream().filter(name -> name.startsWith(prefix)).toArray(CREATE_STRING_ARRAY); } - + /** * Registers a SimDeviceCallback to be called whenever a new SimDeviceSim is created. A SimDeviceSim is determined to be created if a value on it has been set. * @param callback the callback function to call @@ -241,7 +273,19 @@ public static void processMessage(String device, List data) { SimDeviceSim simDevice = new SimDeviceSim(device); data.stream().filter(Objects::nonNull).forEach(value -> { String key = value.getKey(); - value.setKey(key.substring(key.startsWith("<>") ? 2 : 1)); + String formattedKey; + if(key.startsWith("<>")) { + formattedKey = key.substring(2); + if(Boolean.FALSE.equals(simDevice.getState().valueBidirectionality.put(formattedKey, true))) { // This is the same as oldValue == false, but also accounts for null + System.err.println("WARNING: SimDeviceSim (" + device + "): WPILib is setting " + formattedKey + " to be bidirectional, but it has already been used non-bidirectionally! This may cause unexpected behavior. (See DeepBlueRobotics/WPIWebSockets#30)"); + } + } else { + formattedKey = key.substring(1); + if(Boolean.TRUE.equals(simDevice.getState().valueBidirectionality.put(formattedKey, false))) { // This is the same as oldValue == true, but also accounts for null + System.err.println("WARNING: SimDeviceSim (" + device + "): WPILib is setting " + formattedKey + " to be non-bidirectional, but it has already been used bidirectionally! This may cause unexpected behavior. (See DeepBlueRobotics/WPIWebSockets#30)"); + } + } + value.setKey(formattedKey); if(Boolean.class.isAssignableFrom(value.getValue().getClass())) { simDevice.getState().valueTypes.put(value.getKey(), "b"); } else if(BigDecimal.class.isAssignableFrom(value.getValue().getClass())) { @@ -256,21 +300,22 @@ public static void processMessage(String device, List data) { simDevice.set(value.getKey(), value.getValue().toString(), false); }); } - + @Override public State generateState() { return new State(); } - + /** * Contains all information about the state of a SimDeviceSim */ public static class State { - public final Map values = new HashMap<>(); - public final Map valueTypes = new HashMap<>(); - public final CopyOnWriteArrayList existingValues = new CopyOnWriteArrayList<>(); - public final CopyOnWriteArrayList valueCreatedCallbacks = new CopyOnWriteArrayList<>(); - public final CopyOnWriteArrayList> valueChangedCallbacks = new CopyOnWriteArrayList<>(); + public final Map values = new ConcurrentHashMap<>(); + public final Map valueTypes = new ConcurrentHashMap<>(); + public final Map valueBidirectionality = new ConcurrentHashMap<>(); + public final Set existingValues = new ConcurrentSkipListSet<>(); + public final Set valueCreatedCallbacks = new CopyOnWriteArraySet<>(); + public final Set> valueChangedCallbacks = new CopyOnWriteArraySet<>(); } } diff --git a/build.gradle b/build.gradle index 2b3d7fc..0a8efcd 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ task generateDeviceFiles(type: NpxTask) { // Define the command line that npx should use workingDir = buildDir // Because templateDir can't be under it - command = '@asyncapi/generator' + command = '@asyncapi/generator@1.17.25' args = ['--force-write', '-o', "${outputDir}/org/team199/wpiws/devices", "https://raw.githubusercontent.com/wpilibsuite/allwpilib/master/simulation/halsim_ws_core/doc/wpilib-ws.yaml", @@ -63,8 +63,8 @@ sourceSets.main.java.srcDirs generateDeviceFiles.outputs // Use a version of node and npm that is known to work. node { download = true - version = '14.15.1' - npmVersion = '6.14.8' + version = '18.17.0' + npmVersion = '9.8.1' } publishing { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index cc4fdc2..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9492014..84a0b92 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7..c53aefa 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/org/team199/wpiws/Pair.java b/src/main/java/org/team199/wpiws/Pair.java index ca7e6bd..0011382 100644 --- a/src/main/java/org/team199/wpiws/Pair.java +++ b/src/main/java/org/team199/wpiws/Pair.java @@ -1,5 +1,7 @@ package org.team199.wpiws; +import java.util.Objects; + /** * Binds two objects as one * @param T the type of the first object @@ -30,7 +32,7 @@ public Pair(T val1, U val2) { public boolean equals(Object obj) { if(obj instanceof Pair) { Pair other = (Pair)obj; - return val1.equals(other.val1) && val2.equals(other.val2); + return Objects.equals(val1, other.val1) && Objects.equals(val2, other.val2); } return false; } diff --git a/src/main/java/org/team199/wpiws/ScopedObject.java b/src/main/java/org/team199/wpiws/ScopedObject.java index b6702cf..5ba5ffe 100644 --- a/src/main/java/org/team199/wpiws/ScopedObject.java +++ b/src/main/java/org/team199/wpiws/ScopedObject.java @@ -9,11 +9,11 @@ * @param T the object type held by this ScopedObject */ public class ScopedObject implements AutoCloseable { - + private final T object; private final Consumer closer; private boolean isClosed; - + /** * Creates a ScopedObject from an AutoClosable and assigns its close method to {@link AutoCloseable#close()} * @param the type of the object @@ -34,10 +34,10 @@ public ScopedObject(T object, Consumer closer) { this.closer = closer; this.isClosed = false; } - + /** * Retrieves the object associeated with this ScopedObject - * @return the object associeated with this ScopedObject + * @return the object associated with this ScopedObject */ public T getObject() { return object; @@ -59,8 +59,11 @@ public void close() { } } + public boolean isClosed() { + return isClosed; + } + @Override - @SuppressWarnings("deprecation") protected void finalize() throws Throwable { close(); super.finalize(); @@ -81,5 +84,5 @@ public static Consumer createCloser(ExceptionConsumer closer) { } }; } - + } diff --git a/src/main/java/org/team199/wpiws/StateDevice.java b/src/main/java/org/team199/wpiws/StateDevice.java index 047e627..45a7df8 100644 --- a/src/main/java/org/team199/wpiws/StateDevice.java +++ b/src/main/java/org/team199/wpiws/StateDevice.java @@ -11,15 +11,15 @@ * Represents a device which has a number of internal states based on a given id */ public abstract class StateDevice { - + /** - * An IntFunction which is equivilent to String[]::new + * An IntFunction which is equivalent to String[]::new */ public static final IntFunction CREATE_STRING_ARRAY = String[]::new; /** - * The identifier associated with this StateEvent + * The identifier associated with this StateDevice */ - protected final String id; + public final String id; private final T state; /** @@ -35,7 +35,7 @@ public StateDevice(String id, Map stateMap) { } this.state = stateMap.get(id); } - + /** * Retrieves the state from the state map based on this StateDevice's unique identifier * @return the state from the state map based on this StateDevice's unique identifier @@ -44,7 +44,7 @@ public StateDevice(String id, Map stateMap) { protected T getState() { return state; } - + /** * Generates a blank state to be stored in this device type's state map */ diff --git a/src/main/java/org/team199/wpiws/UniqueArrayList.java b/src/main/java/org/team199/wpiws/UniqueArrayList.java deleted file mode 100644 index ff6fdbc..0000000 --- a/src/main/java/org/team199/wpiws/UniqueArrayList.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.team199.wpiws; - -import java.util.ArrayList; - -/** - * An implementation of ArrayList which prevents {@link java.util.List#add(Object)} from altering the list if the specified element already exists in the list - */ -public class UniqueArrayList extends ArrayList { - - private static final long serialVersionUID = 7526197689969175318L; - - @Override - public boolean add(T e) { - if(!contains(e)) { - return super.add(e); - } - return false; - } - -} diff --git a/src/main/java/org/team199/wpiws/connection/ConnectionProcessor.java b/src/main/java/org/team199/wpiws/connection/ConnectionProcessor.java index 8962341..791c7d9 100644 --- a/src/main/java/org/team199/wpiws/connection/ConnectionProcessor.java +++ b/src/main/java/org/team199/wpiws/connection/ConnectionProcessor.java @@ -18,13 +18,13 @@ * Manages Websocket Connections */ public final class ConnectionProcessor { - + private static final CopyOnWriteArrayList sockets = new CopyOnWriteArrayList<>(); private static Consumer threadExecutor = Runnable::run; private static Object threadExecutorLock = new Object(); - + /** - * Allows custom handling of message processing. This allows for syncronous execution of callbacks with another thread. + * Allows custom handling of message processing. This allows for synchronous execution of callbacks with another thread. * @param executor A Consumer which will be fed Runnable calls which forward messages to the rest of the code */ public static void setThreadExecutor(Consumer executor) { @@ -103,14 +103,14 @@ public static void onMessage(WebSocket socket, String message) { /** * Called when an error occurs while processing data for a Websocket - * @param socket the WebSocket on which the error occured + * @param socket the WebSocket on which the error occurred * @param e the Exception which was thrown */ public static void onError(WebSocket socket, Exception e) { System.err.println("Error on: " + (socket == null ? "" : getSocketInfo(socket))); e.printStackTrace(System.err); } - + /** * Broadcasts a message to all connected WebSockets * @param device the device name of the device which sent the message @@ -120,7 +120,7 @@ public static void onError(WebSocket socket, Exception e) { public static void broadcastMessage(Object device, String type, WSValue data) { broadcastMessage(device, type, Arrays.asList(new WSValue[] {data})); } - + /** * Broadcasts a message to all connected WebSockets * @param device the device name of the device which sent the message @@ -138,7 +138,7 @@ public static void broadcastMessage(Object device, String type, List da String messageJson = message.toJson(); broadcastMessage(messageJson); } - + /** * Broadcasts a message to all connected WebSockets * @param message the message to send @@ -146,15 +146,15 @@ public static void broadcastMessage(Object device, String type, List da public static void broadcastMessage(String message) { sockets.stream().filter(WebSocket::isOpen).forEach(socket -> socket.send(message)); } - + /** - * Retrieves info about the specifed WebSocket to display to the user + * Retrieves info about the specified WebSocket to display to the user * @param socket the WebSocket */ public static String getSocketInfo(WebSocket socket) { return "local: " + (socket.getLocalSocketAddress() == null ? "" : socket.getLocalSocketAddress().toString()) + " remote: " + (socket.getRemoteSocketAddress() == null ? "" : socket.getRemoteSocketAddress().toString()); } - + private ConnectionProcessor() {} } diff --git a/src/main/java/org/team199/wpiws/connection/MessageProcessor.java b/src/main/java/org/team199/wpiws/connection/MessageProcessor.java index b6616cb..dc3541f 100644 --- a/src/main/java/org/team199/wpiws/connection/MessageProcessor.java +++ b/src/main/java/org/team199/wpiws/connection/MessageProcessor.java @@ -1,8 +1,10 @@ package org.team199.wpiws.connection; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListSet; import org.team199.wpiws.devices.AccelerometerSim; import org.team199.wpiws.devices.AnalogInputSim; @@ -24,10 +26,10 @@ * Manages a list of {@link DeviceMessageProcessor} objects which handle messages for different device types */ public final class MessageProcessor { - - private static final HashMap processors = new HashMap<>(); - private static final ArrayList unknownTypes = new ArrayList<>(); - + + private static final Map processors = new ConcurrentHashMap<>(); + private static final Set unknownTypes = new ConcurrentSkipListSet<>(); + static { registerProcessor("Accel", AccelerometerSim::processMessage); registerProcessor("AI", AnalogInputSim::processMessage); @@ -70,15 +72,14 @@ public static void registerProcessor(String type, DeviceMessageProcessor process public static void process(String device, String type, List data) { DeviceMessageProcessor processor = processors.get(type); if(processor == null) { - if(!unknownTypes.contains(type)) { - unknownTypes.add(type); + if(unknownTypes.add(type)) { System.err.println("No processor found for device of type: \"" + type + "\" messages for devices of this type will be ignored"); } return; } processor.processMessage(device, data); } - + private MessageProcessor() {} } diff --git a/src/main/java/org/team199/wpiws/connection/WSConnection.java b/src/main/java/org/team199/wpiws/connection/WSConnection.java index b3183f9..f673d17 100644 --- a/src/main/java/org/team199/wpiws/connection/WSConnection.java +++ b/src/main/java/org/team199/wpiws/connection/WSConnection.java @@ -16,7 +16,7 @@ * Sets up Websockets and forwards their calls to {@link ConnectionProcessor} */ public final class WSConnection { - + /** * Connects to a WebSocket server on the given URI * @param uri the URI to which to connect @@ -25,9 +25,9 @@ public final class WSConnection { public static RunningObject connect(URI uri, boolean autoReconnect) { return new RunningObject<>(new WSClientImpl(uri, autoReconnect)); } - + /** - * Connects to a the WPI HALSim server using either its default location or the environment variables: HALSIMWS_HOST, HALSIMWS_PORT, and HALSIMWS_URI + * Connects to a the WPI HALSim server using either its default location or the environment variables: HALSIMWS_HOST, HALSIMWS_PORT, and HALSIMWS_URI * @return a running WebSocketClient connected to the WPI HALSim server */ public static RunningObject connectHALSim(boolean autoReconnect) throws URISyntaxException { @@ -40,7 +40,7 @@ public static RunningObject connectHALSim(boolean autoReconnect client.object.setConnectionLostTimeout(0); return client; } - + /** * Starts a WebSocketServer on the given address * @param addr the address on which to start the server @@ -49,9 +49,9 @@ public static RunningObject connectHALSim(boolean autoReconnect public static RunningObject startServer(InetSocketAddress addr) { return new RunningObject<>(new WSServerImpl(addr)); } - + /** - * Starts a server on either the default location of the WPI HALSim or a generated address based on the environment variables: HALSIMWS_HOST and HALSIMWS_PORT + * Starts a server on either the default location of the WPI HALSim or a generated address based on the environment variables: HALSIMWS_HOST and HALSIMWS_PORT * @return a running WebSocketClient connected to the WPI HALSim server */ public static RunningObject startHALSimServer() { @@ -71,9 +71,9 @@ public static RunningObject startHALSimServer() { server.object.setConnectionLostTimeout(0); return server; } - + private WSConnection() {} - + /** * A WebSocketClient which forwards its method calls to {@link ConnectionProcessor} */ @@ -87,7 +87,7 @@ public WSClientImpl(URI serverURI, boolean autoReconnect) { this.autoReconnect = autoReconnect; retryTimeout = 1; } - + @Override public void onOpen(ServerHandshake handshake) { retryTimeout = 0; @@ -103,7 +103,7 @@ public void onMessage(String message) { public void onClose(int code, String reason, boolean remote) { ConnectionProcessor.onClose(this, code, reason, remote); if(autoReconnect && remote) { - System.out.println("Reconnnecting..."); + System.out.println("Reconnecting..."); RunningObject.start(this::tryReconnect); } } @@ -135,9 +135,9 @@ public void tryReconnect(long delay) { System.err.println("Interrupted while reconnecting!"); } } - + } - + /** * A WebSocketServer which forwards its method calls to {@link ConnectionProcessor} */ @@ -146,7 +146,7 @@ private static class WSServerImpl extends WebSocketServer { public WSServerImpl(InetSocketAddress addr) { super(addr); } - + @Override public void onOpen(WebSocket socket, ClientHandshake handshake) { ConnectionProcessor.onOpen(socket); @@ -171,7 +171,7 @@ public void onError(WebSocket socket, Exception e) { public void onStart() { System.out.println("Starting Server on: " + getAddress().toString()); } - + } - + } diff --git a/src/main/java/org/team199/wpiws/connection/WSValue.java b/src/main/java/org/team199/wpiws/connection/WSValue.java index 273d36b..fdfd2bc 100644 --- a/src/main/java/org/team199/wpiws/connection/WSValue.java +++ b/src/main/java/org/team199/wpiws/connection/WSValue.java @@ -51,5 +51,5 @@ public Object getValue() { public void setValue(Object value) { this.value = value; } - + } diff --git a/src/main/java/org/team199/wpiws/interfaces/ExceptionConsumer.java b/src/main/java/org/team199/wpiws/interfaces/ExceptionConsumer.java index d80851d..b61217f 100644 --- a/src/main/java/org/team199/wpiws/interfaces/ExceptionConsumer.java +++ b/src/main/java/org/team199/wpiws/interfaces/ExceptionConsumer.java @@ -7,5 +7,5 @@ public interface ExceptionConsumer { public void accept(T t) throws Exception; - + } diff --git a/src/main/java/org/team199/wpiws/interfaces/SimDeviceCallback.java b/src/main/java/org/team199/wpiws/interfaces/SimDeviceCallback.java index 83683f0..866ea1a 100644 --- a/src/main/java/org/team199/wpiws/interfaces/SimDeviceCallback.java +++ b/src/main/java/org/team199/wpiws/interfaces/SimDeviceCallback.java @@ -5,7 +5,7 @@ */ @FunctionalInterface public interface SimDeviceCallback { - + /** * Calls the callback * @param name the device identifier of the device calling the callback diff --git a/src/main/java/org/team199/wpiws/interfaces/StringArrayCallback.java b/src/main/java/org/team199/wpiws/interfaces/StringArrayCallback.java index e311dd6..d7cd8bb 100644 --- a/src/main/java/org/team199/wpiws/interfaces/StringArrayCallback.java +++ b/src/main/java/org/team199/wpiws/interfaces/StringArrayCallback.java @@ -12,5 +12,5 @@ public interface StringArrayCallback { * @param value the String data values */ public void callback(String name, String value); - + } diff --git a/src/main/java/org/team199/wpiws/interfaces/StringCallback.java b/src/main/java/org/team199/wpiws/interfaces/StringCallback.java index a60e346..7dd5191 100644 --- a/src/main/java/org/team199/wpiws/interfaces/StringCallback.java +++ b/src/main/java/org/team199/wpiws/interfaces/StringCallback.java @@ -12,5 +12,5 @@ public interface StringCallback { * @param value the String data value */ public void callback(String name, String value); - + }