diff --git a/.clang-format b/.clang-format index 0492da8fe8..ed38227927 100644 --- a/.clang-format +++ b/.clang-format @@ -20,7 +20,7 @@ AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true -BraceWrapping: +BraceWrapping: AfterClass: false AfterControlStatement: false AfterEnum: false @@ -46,7 +46,7 @@ DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: +IncludeCategories: - Regex: '^<.*\.h>' Priority: 1 - Regex: '^<.*' diff --git a/configure.bat b/configure.bat index 21bac69ecf..f308fa37a6 100644 --- a/configure.bat +++ b/configure.bat @@ -1,46 +1,46 @@ -:: This file is a helper for allC++Sim -:: -:: Usage: cd /build && ../configure -:: -:: WARNING -- this is only temporary, and only meant for debug, and only works on my computer -@set WS=C:\Users\peter\gz-ws -@set BOOST_PATH=%WS%\boost_1_56_0 -@set BOOST_LIBRARY_DIR=%BOOST_PATH%\lib64-msvc-12.0 - -@set PROTOBUF_PATH=%WS%\protobuf-2.6.0-win64-vc12 - -@set OGRE_PATH=%WS%\ogre_src_v1-8-1-vc12-x64-release-debug\build\install\Debug -@set OGRE_INCLUDE_DIR=%OGRE_PATH%\include;%OGRE_PATH%\include\OGRE;%OGRE_PATH%\include\OGRE\RTShaderSystem;%OGRE_PATH%\include\OGRE\Terrain;%OGRE_PATH%\include\OGRE\Paging -@set OGRE_LIBRARY_DIR=%OGRE_PATH%\lib\Debug -set OGRE_LIB_SUFFIX=_d.lib -@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreOverlay%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% -@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% - -@set FREEIMAGE_PATH=%WS%\FreeImage-vc12-x64-release-debug -@set FREEIMAGE_INCLUDE_DIR=%FREEIMAGE_PATH%\Source - -@set TBB_PATH=%WS%\tbb43_20141023oss -@set TBB_INCLUDEDIR=%TBB_PATH%\include - -@set DLFCN_WIN32_PATH=%WS%\dlfcn-win32-vc12-x64-release-debug\build\install\Debug -@set DLFCN_WIN32_INCLUDE_DIR=%DLFCN_WIN32_PATH%\include - -@set TINY_XML_INCLUDE_DIR=%WS%\sdformat\src\win\tinyxml - -@set GAZEBO_PATH=%WS%\gazebo\build\install\Debug\lib\cmake\gazebo -@set SDFORMAT_PATH=%WS%\sdformat\build\install\Debug\lib\cmake\sdformat -@set IGNITION-MATH_PATH=%WS%\ign-math\build\install\Debug\lib\cmake\ignition-math2 - -@set INCLUDE=%TINY_XML_INCLUDE_DIR%;%FREEIMAGE_INCLUDE_DIR%;%TBB_INCLUDEDIR%;%DLFCN_WIN32_INCLUDE_DIR%;%INCLUDE% -@set LIB=%LIB% - -cmake -G "NMake Makefiles"^ - -DCMAKE_INSTALL_PREFIX=build^ - -DCMAKE_PREFIX_PATH="%GAZEBO_PATH%;%SDFORMAT_PATH%;%IGNITION-MATH_PATH%"^ - -DOGRE_FOUND=1^ - -DOGRE_INCLUDE_DIRS="%OGRE_INCLUDE_DIR%"^ - -DOGRE_LIBRARIES="%OGRE_LIBS%"^ - -DPROTOBUF_SRC_ROOT_FOLDER="%PROTOBUF_PATH%"^ - -DBOOST_ROOT="%BOOST_PATH%"^ - -DBOOST_LIBRARYDIR="%BOOST_LIBRARY_DIR%"^ - .. +:: This file is a helper for allC++Sim +:: +:: Usage: cd /build && ../configure +:: +:: WARNING -- this is only temporary, and only meant for debug, and only works on my computer +@set WS=C:\Users\peter\gz-ws +@set BOOST_PATH=%WS%\boost_1_56_0 +@set BOOST_LIBRARY_DIR=%BOOST_PATH%\lib64-msvc-12.0 + +@set PROTOBUF_PATH=%WS%\protobuf-2.6.0-win64-vc12 + +@set OGRE_PATH=%WS%\ogre_src_v1-8-1-vc12-x64-release-debug\build\install\Debug +@set OGRE_INCLUDE_DIR=%OGRE_PATH%\include;%OGRE_PATH%\include\OGRE;%OGRE_PATH%\include\OGRE\RTShaderSystem;%OGRE_PATH%\include\OGRE\Terrain;%OGRE_PATH%\include\OGRE\Paging +@set OGRE_LIBRARY_DIR=%OGRE_PATH%\lib\Debug +set OGRE_LIB_SUFFIX=_d.lib +@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreOverlay%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% +@set OGRE_LIBS=%OGRE_LIBRARY_DIR%\OgreMain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreRTShaderSystem%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgreTerrain%OGRE_LIB_SUFFIX%;%OGRE_LIBRARY_DIR%\OgrePaging%OGRE_LIB_SUFFIX% + +@set FREEIMAGE_PATH=%WS%\FreeImage-vc12-x64-release-debug +@set FREEIMAGE_INCLUDE_DIR=%FREEIMAGE_PATH%\Source + +@set TBB_PATH=%WS%\tbb43_20141023oss +@set TBB_INCLUDEDIR=%TBB_PATH%\include + +@set DLFCN_WIN32_PATH=%WS%\dlfcn-win32-vc12-x64-release-debug\build\install\Debug +@set DLFCN_WIN32_INCLUDE_DIR=%DLFCN_WIN32_PATH%\include + +@set TINY_XML_INCLUDE_DIR=%WS%\sdformat\src\win\tinyxml + +@set GAZEBO_PATH=%WS%\gazebo\build\install\Debug\lib\cmake\gazebo +@set SDFORMAT_PATH=%WS%\sdformat\build\install\Debug\lib\cmake\sdformat +@set IGNITION-MATH_PATH=%WS%\ign-math\build\install\Debug\lib\cmake\ignition-math2 + +@set INCLUDE=%TINY_XML_INCLUDE_DIR%;%FREEIMAGE_INCLUDE_DIR%;%TBB_INCLUDEDIR%;%DLFCN_WIN32_INCLUDE_DIR%;%INCLUDE% +@set LIB=%LIB% + +cmake -G "NMake Makefiles"^ + -DCMAKE_INSTALL_PREFIX=build^ + -DCMAKE_PREFIX_PATH="%GAZEBO_PATH%;%SDFORMAT_PATH%;%IGNITION-MATH_PATH%"^ + -DOGRE_FOUND=1^ + -DOGRE_INCLUDE_DIRS="%OGRE_INCLUDE_DIR%"^ + -DOGRE_LIBRARIES="%OGRE_LIBS%"^ + -DPROTOBUF_SRC_ROOT_FOLDER="%PROTOBUF_PATH%"^ + -DBOOST_ROOT="%BOOST_PATH%"^ + -DBOOST_LIBRARYDIR="%BOOST_LIBRARY_DIR%"^ + .. diff --git a/license-update.py b/license-update.py deleted file mode 100755 index 24e61a01aa..0000000000 --- a/license-update.py +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env python3 - -# If there is already a comment block, a year range through the current year is -# created using the first year in the comment. If there is no comment block, a -# new one is added containing just the current year. - -from datetime import date -import os -import re -import sys - -sep = os.sep -# If directory separator is backslash, escape it for regexes -if sep == "\\": - sep += "\\" - -# Files and directories which should be included in or excluded from the update -regexInclude = re.compile("\.cpp$|\.h$|\.hpp$|\.inc$|\.java$") -folderExclude = "build" + sep + "|\.git" + sep + "|gradle" + sep + \ - "|\.gradle" + sep + "|ni-libraries" + sep + "|ctre" + sep + \ - "|frccansae" + sep + "|FRC_FPGA_ChipObject" + sep + \ - "|gtest" + sep + "|msgs" + sep + "|i2clib" + sep + \ - "|NetworkCommunication" + sep + "|ni" + sep + \ - "|spilib" + sep + "|visa" + sep -regexExclude = re.compile(folderExclude + - "|NIIMAQdx\.h$|nivision\.h$|NIVisionJNI\.cpp$|" - "can_proto\.h$|jni\.h$|jni_md\.h$") - -currentYear = str(date.today().year) - -# Recursively create list of files in given directory -files = [os.path.join(dp, f) for dp, dn, fn in - os.walk(os.path.expanduser(".")) for f in fn] - -# Apply regex filters to list -files = [f for f in files if regexInclude.search(f)] -files = [f for f in files if not regexExclude.search(f)] - -if not files: - print("Error: no files to format", file=sys.stderr) - sys.exit(1) - -for name in files: - # List names of files as they are processed if verbose flag was given - if len(sys.argv) > 1 and sys.argv[1] == "-v": - print("Processing", name,) - with open(name, "r", encoding = "ISO-8859-1") as file: - modifyCopyright = False - year = "" - - # Get first line of file - line = file.readline() - - # If first line is copyright comment - if line[0:2] == "/*": - modifyCopyright = True - - # Get next line - line = file.readline() - - # Search for start of copyright year - pos = line.find("20") - - # Extract it if found - if pos != -1: - year = line[pos:pos + 4] - else: - continue - - # Retrieve lines until one past end of comment block - inComment = True - inBlock = True - while inBlock: - if not inComment: - pos = line.find("/*", pos) - if pos != -1: - inComment = True - else: - inBlock = False - else: - pos = line.find("*/", pos) - if pos != -1: - inComment = False - - # This assumes no comments are started on the same line after - # another ends - line = file.readline() - pos = 0 - - with open(name + ".tmp", "w", encoding = "ISO-8859-1") as temp: - # Write first line of comment - temp.write("/*") - for i in range(0, 76): - temp.write("-") - temp.write("*/\n") - - # Write second line of comment - temp.write("/* Copyright (c) FIRST ") - if modifyCopyright and year != currentYear: - temp.write(year) - temp.write("-") - temp.write(currentYear) - temp.write(". All Rights Reserved.") - for i in range(0, 24): - temp.write(" ") - if not modifyCopyright or year == currentYear: - for i in range(0, 5): - temp.write(" ") - temp.write("*/\n") - - # Write rest of lines of comment - temp.write("/* Open Source Software - may be modified and shared by FRC teams. The code */\n" - "/* must be accompanied by the FIRST BSD license file in the root directory of */\n" - "/* the project. */\n" - "/*") - for i in range(0, 76): - temp.write("-") - temp.write("*/\n") - - # If line after comment block isn't empty - if len(line) > 1 and line[0] != " ": - temp.write("\n") - temp.write(line) - - # Copy rest of original file into new one - for line in file: - temp.write(line) - - # Replace old file - os.remove(name) - os.rename(name + ".tmp", name) - diff --git a/license.txt b/license.txt index 5d3484be80..9c33de44a3 100644 --- a/license.txt +++ b/license.txt @@ -14,8 +14,8 @@ * * THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR +* WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR +* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java index 8ab6fff74e..38edebe24c 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Connection.java @@ -34,15 +34,15 @@ import com.google.protobuf.Message; */ public class Connection { private static int HEADER_SIZE = 8; - + public String host; public int port; - + private Socket socket; private ServerSocket ssocket; private InputStream is; private OutputStream os; - + private static final Logger LOG = Logger.getLogger("Gazebo Transport"); public void connect(String host, int port) throws UnknownHostException, IOException { @@ -114,7 +114,7 @@ public class Connection { ssocket = null; } } - + public byte[] rawRead() throws IOException { synchronized (is) { // Figure out the message size @@ -125,18 +125,18 @@ public class Connection { return null; } int size = Integer.parseInt(new String(buff), 16); - + // Read in the actual message buff = new byte[size]; n = is.read(buff); if (n != size) { throw new IOException("Failed to read whole message"); } - + return buff; } } - + public Packet read() throws IOException { byte[] buff = rawRead(); if (buff == null) { diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Msgs.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Msgs.java index cd20d4021c..9681abaf99 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Msgs.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Msgs.java @@ -15,23 +15,23 @@ public class Msgs { public static GzString.String String() { return GzString.String.getDefaultInstance(); } - + public static GzString.String String(String s) { return GzString.String.newBuilder().setData(s).build(); } - + public static GzFloat64.Float64 Float64() { return GzFloat64.Float64.getDefaultInstance(); } - + public static GzFloat64.Float64 Float64(double d) { return GzFloat64.Float64.newBuilder().setData(d).build(); } - + public static Bool Bool() { return Bool.getDefaultInstance(); } - + public static Bool Bool(boolean b) { return Bool.newBuilder().setData(b).build(); } diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java index fccc65d02e..0e19ea167a 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/Publisher.java @@ -21,9 +21,9 @@ public class Publisher implements PublisherRecord { private List listeners; private boolean latching = false; private T lastMsg = null; - + private static final Logger LOG = Logger.getLogger("Gazebo Transport"); - + public Publisher(String topic, String msgType, String localHost, int localPort) { this.topic = topic; this.msgType = msgType; diff --git a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/RemotePublisherRecord.java b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/RemotePublisherRecord.java index 86adf16bed..a92afbd4d3 100644 --- a/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/RemotePublisherRecord.java +++ b/simulation/JavaGazebo/src/main/java/org/gazebosim/transport/RemotePublisherRecord.java @@ -35,9 +35,9 @@ public class RemotePublisherRecord implements PublisherRecord { public String getMsgType() { return pub.getMsgType(); } - + public String toString() { - return String.format("%s (%s) %s:%s", getTopic(), getMsgType(), getHost(), getPort()); + return String.format("%s (%s) %s:%s", getTopic(), getMsgType(), getHost(), getPort()); } @Override diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/DS.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/DS.java index d62958a718..e10a1b46ad 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/DS.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/DS.java @@ -32,13 +32,13 @@ import gazebo.msgs.GzDriverStation.DriverStation; public class DS { private JoystickProvider joystickProvider; private JoystickList joysticks; - + private JFrame mainframe; private JPanel modePanel; private ActionListener modeListener; private ButtonGroup modes; private JButton enable, refresh; - + public enum State { Disabled, Teleop, Autonomous, Test; } @@ -46,14 +46,14 @@ public class DS { private State state = State.Teleop; private DriverStation.State protoState = DriverStation.State.TELEOP; private Publisher pub; - + public DS(JoystickProvider joystickProvider) { this.joystickProvider = joystickProvider; mainframe = new JFrame(); mainframe.setTitle("FRC Simulation DriverStation"); mainframe.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); - + makeModeButtons(constraints); mainframe.pack(); constraints.gridy = 1; @@ -65,15 +65,15 @@ public class DS { mainframe.pack(); constraints.gridy = 1; makeRefreshButton(constraints); - + mainframe.pack(); mainframe.setVisible(true); } - + private void makeModeButtons(GridBagConstraints constraints) { modePanel = new JPanel(); modePanel.setLayout(new BoxLayout(modePanel, BoxLayout.PAGE_AXIS)); - + modeListener = new ModeAction(this); JRadioButton teleop = new JRadioButton("Teleop"); teleop.setActionCommand(State.Teleop.toString()); @@ -85,7 +85,7 @@ public class DS { test.setActionCommand(State.Test.toString()); test.addActionListener(modeListener); teleop.setSelected(true); - + modes = new ButtonGroup(); modes.add(teleop); modes.add(auto); @@ -95,14 +95,14 @@ public class DS { modePanel.add(test); mainframe.add(modePanel, constraints); } - + private void makeEnableButton(GridBagConstraints constraints) { enable = new JButton("Enable"); enable.addActionListener(new EnableAction(this)); enable.setPreferredSize(new Dimension(modePanel.getSize().width, 50)); mainframe.add(enable, constraints); } - + private void makeJoystickUI(GridBagConstraints constraints) { joysticks = new JoystickList(joystickProvider); mainframe.add(joysticks, constraints); @@ -117,19 +117,19 @@ public class DS { } joysticks.setListData(sticks); } - + private void makeRefreshButton(GridBagConstraints constraints) { refresh = new JButton("Refresh Joysticks"); refresh.addActionListener(new RefreshAction(this)); refresh.setPreferredSize(new Dimension(joysticks.getSize().width, 50)); mainframe.add(refresh, constraints); } - + public void setEnabled(boolean enabled) { this.enabled = enabled; enable.setText(enabled ? "Disable" : "Enable"); } - + public State getState() { return enabled ? state : State.Disabled; } diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/EnableAction.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/EnableAction.java index 9751e74fe2..c82724aceb 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/EnableAction.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/EnableAction.java @@ -12,7 +12,7 @@ import java.awt.event.ActionListener; public class EnableAction implements ActionListener { private DS ds; - + public EnableAction(DS ds) { this.ds = ds; } diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/FakeJoystick.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/FakeJoystick.java index b5489306d4..eef5846749 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/FakeJoystick.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/FakeJoystick.java @@ -15,7 +15,7 @@ public class FakeJoystick implements ISimJoystick { public String getName() { return "Empty Joystick"; } - + public String toString() { return getName(); } diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickList.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickList.java index f1bd684dc7..513a87691a 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickList.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickList.java @@ -116,7 +116,7 @@ public class JoystickList extends JList { int index = Integer.parseInt(indexString); JList.DropLocation dl = (JList.DropLocation) support.getDropLocation(); int dropTargetIndex = dl.getIndex(); - + list.moveElement(index, dropTargetIndex); return true; diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickProvider.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickProvider.java index 80119d0b9f..22eed2e741 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickProvider.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/JoystickProvider.java @@ -18,11 +18,11 @@ import net.java.games.input.ControllerEnvironment; public class JoystickProvider { List joysticks; - + public JoystickProvider() { scanForJoysticks(); } - + public List scanForJoysticks() { List foundControllers = new ArrayList<>(); Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers(); @@ -30,21 +30,21 @@ public class JoystickProvider { for(int i = 0; i < controllers.length; i++){ Controller controller = controllers[i]; if (controller.getType() == Controller.Type.STICK - || controller.getType() == Controller.Type.GAMEPAD + || controller.getType() == Controller.Type.GAMEPAD || controller.getType() == Controller.Type.WHEEL || controller.getType() == Controller.Type.FINGERSTICK) { foundControllers.add(new SimJoystick(controller)); } } - + joysticks = foundControllers; return foundControllers; } - + public List getJoysticks() { return joysticks; } - + public void setJoysticks(List joysticks) { this.joysticks = joysticks; } diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/Main.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/Main.java index b93bdd0235..059c2073ed 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/Main.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/Main.java @@ -17,7 +17,7 @@ import org.gazebosim.transport.SubscriberCallback; public class Main { private static double simTime = 0; private static Subscriber sub; - + public static void main(String args[]) { Node node = new Node("frc"); try { diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/ModeAction.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/ModeAction.java index 362e8c6415..84adfa43e6 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/ModeAction.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/ModeAction.java @@ -12,11 +12,11 @@ import java.awt.event.ActionListener; public class ModeAction implements ActionListener { private DS ds; - + public ModeAction(DS ds) { this.ds = ds; } - + @Override public void actionPerformed(ActionEvent e) { ds.setState(DS.State.valueOf(e.getActionCommand())); diff --git a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/SimJoystick.java b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/SimJoystick.java index 7239cacb10..f2ab69567b 100644 --- a/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/SimJoystick.java +++ b/simulation/SimDS/src/main/java/edu/wpi/first/wpilibj/simulation/ds/SimJoystick.java @@ -42,7 +42,7 @@ public class SimJoystick implements ISimJoystick { return controller.getName(); } - @Override + @Override public String toString() { return getName(); } @@ -60,7 +60,7 @@ public class SimJoystick implements ISimJoystick { prevNode = node; prevI = i; } - + @Override public void publish() { controller.poll(); diff --git a/simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy b/simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy index b8912497eb..887c9c1535 100644 --- a/simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy +++ b/simulation/frc_gazebo_plugins/frc_gazebo_plugins.doxy @@ -144,7 +144,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -743,7 +743,7 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = +INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/styleguide/clangformat.py b/styleguide/clangformat.py new file mode 100644 index 0000000000..d61bd0accc --- /dev/null +++ b/styleguide/clangformat.py @@ -0,0 +1,15 @@ +# This task runs clang-format on all C++ source files. + +import subprocess +import sys +from task import Task + +class ClangFormat(Task): + def getIncludeExtensions(self): + return ["cpp", "h", "inc"] + + def run(self, name): + # Run clang-format + if subprocess.call(["clang-format", "-i", "-style=file", name]) == -1: + print("Error: clang-format not found in PATH. Is it installed?", + file = sys.stderr) diff --git a/styleguide/format.py b/styleguide/format.py index ad94c5ec39..feec02f167 100755 --- a/styleguide/format.py +++ b/styleguide/format.py @@ -1,53 +1,66 @@ #!/usr/bin/env python3 -from subprocess import call +# This script runs all formatting tasks on the code base. +# +# Passing "-v" as an argument enables verbosity. Otherwise, this script takes no +# arguments. This should be invoked from either the styleguide directory or the +# root directory of the project. + import os -import re +import subprocess import sys -sep = os.sep -# If directory separator is backslash, escape it for regexes -if sep == "\\": - sep += "\\" +from clangformat import ClangFormat +from licenseupdate import LicenseUpdate +from newline import Newline +from whitespace import Whitespace +from task import Task -# Files and directories which should be included in or excluded from the update -regexInclude = re.compile("\.cpp$|\.h$|\.hpp$|\.inc$") -folderExclude = "build" + sep + "|\.git" + sep + "|gradle" + sep + \ - "|\.gradle" + sep + "|ni-libraries" + sep + "|ctre" + sep + \ - "|frccansae" + sep + "|FRC_FPGA_ChipObject" + sep + \ - "|gtest" + sep + "|i2clib" + sep + \ - "|NetworkCommunication" + sep + "|spilib" + sep + \ - "|visa" + sep + "|wpilibj" + sep -regexExclude = re.compile(folderExclude + - "|NIIMAQdx\.h$|nivision\.h$|can_proto\.h$|" - "CanTalonSRX\.h$") +# Check that the current directory is part of a Git repository +def inGitRepo(directory): + ret = subprocess.run(["git", "rev-parse"], stderr = subprocess.DEVNULL) + return ret.returncode == 0 -# Handle running in either the root or styleguide directories -configPath = "" -if os.getcwd().rpartition(os.sep)[2] == "styleguide": - configPath = ".." -else: - configPath = "." +def main(): + if not inGitRepo("."): + print("Error: not invoked within a Git repository", file = sys.stderr) + sys.exit(1) -# Recursively create list of files in given directory -files = [os.path.join(dp, f) for dp, dn, fn in - os.walk(os.path.expanduser(configPath)) for f in fn] + # Handle running in either the root or styleguide directories + configPath = "" + if os.getcwd().rpartition(os.sep)[2] == "styleguide": + configPath = ".." + else: + configPath = "." -# Apply regex filters to list -files = [f for f in files if regexInclude.search(f)] -files = [f for f in files if not regexExclude.search(f)] + # Recursively create list of files in given directory + files = [os.path.join(dp, f) for dp, dn, fn in + os.walk(os.path.expanduser(configPath)) for f in fn] -# Set clang-format name for platform -clangExec = "clang-format" -if sys.platform.startswith("win32"): - clangExec += ".exe" + if not files: + print("Error: no files found to format", file = sys.stderr) + sys.exit(1) -if not files: - print("Error: no files found to format", file=sys.stderr) - sys.exit(1) + # Don't format generated files + files = [name for name in files if Task.notGeneratedFile(name)] -for name in files: - # List names of files as they are processed if verbose flag was given - if len(sys.argv) > 1 and sys.argv[1] == "-v": - print("Processing", name,) - call([clangExec, "-i", "-style=file", name]) + clangFormat = ClangFormat() + licenseUpdate = LicenseUpdate() + newline = Newline() + whitespace = Whitespace() + + # Check for verbose flag + isVerbose = len(sys.argv) > 1 and sys.argv[1] == "-v" + + for name in files: + if isVerbose: + print("Processing", name,) + + for task in [clangFormat, licenseUpdate, newline, whitespace]: + if task.fileMatchesExtension(name): + if isVerbose: + print(" with " + type(task).__name__) + task.run(name) + +if __name__ == "__main__": + main() diff --git a/styleguide/licenseupdate.py b/styleguide/licenseupdate.py new file mode 100644 index 0000000000..c92dae7dc4 --- /dev/null +++ b/styleguide/licenseupdate.py @@ -0,0 +1,117 @@ +# This task updates the license comment block at the top of all source files. + +# If there is already a comment block, a year range through the current year is +# created using the first year in the comment. If there is no comment block, a +# new one is added containing just the current year. + +from datetime import date +from functools import partial +import hashlib +import os +from task import Task + +currentYear = str(date.today().year) + +class LicenseUpdate(Task): + def getIncludeExtensions(self): + return ["cpp", "h", "inc", "java"] + + def run(self, name): + with open(name, "r") as file: + modifyCopyright = False + year = "" + + # Get first line of file + line = file.readline() + + # If first line is non-documentation comment + if line[0:3] == "/*\n" or line[0:3] == "/*-": + modifyCopyright = True + + # Get next line + line = file.readline() + + # Search for start of copyright year + pos = line.find("20") + + # Extract it if found. If not, rewrite whole comment + if pos != -1: + year = line[pos:pos + 4] + else: + modifyCopyright = False + + # Retrieve lines until one past end of comment block + inComment = True + inBlock = True + while inBlock: + if not inComment: + pos = line.find("/*", pos) + if pos != -1: + inComment = True + else: + inBlock = False + else: + pos = line.find("*/", pos) + if pos != -1: + inComment = False + + # This assumes no comments are started on the same line + # after another ends + line = file.readline() + pos = 0 + + with open(name + ".tmp", "w") as temp: + # Write first line of comment + temp.write("/*") + for i in range(0, 76): + temp.write("-") + temp.write("*/\n") + + # Write second line of comment + temp.write("/* Copyright (c) FIRST ") + if modifyCopyright and year != currentYear: + temp.write(year) + temp.write("-") + temp.write(currentYear) + temp.write(". All Rights Reserved.") + for i in range(0, 24): + temp.write(" ") + if not modifyCopyright or year == currentYear: + for i in range(0, 5): + temp.write(" ") + temp.write("*/\n") + + # Write rest of lines of comment + temp.write("""\ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*""") + for i in range(0, 76): + temp.write("-") + temp.write("*/\n") + + # If line after comment block isn't empty + if len(line) > 1 and line[0] != " ": + temp.write("\n") + temp.write(line) + + # Copy rest of original file into new one + for line in file: + temp.write(line) + + # Replace old file if it was changed + if self.md5sum(name) != self.md5sum(name + ".tmp"): + os.remove(name) + os.rename(name + ".tmp", name) + else: + os.remove(name + ".tmp") + + # Compute MD5 sum of file + @staticmethod + def md5sum(name): + with open(name, mode = "rb") as file: + digest = hashlib.md5() + for buf in iter(partial(file.read, 128), b""): + digest.update(buf) + return digest.hexdigest() diff --git a/styleguide/newline.py b/styleguide/newline.py new file mode 100644 index 0000000000..f9224c5c62 --- /dev/null +++ b/styleguide/newline.py @@ -0,0 +1,35 @@ +# This task ensures that all source files have exactly one EOF newline. + +import os +from task import Task + +class Newline(Task): + def run(self, name): + newlines = 0 + + # Remove all but one EOF newline, or append one if necessary + eol = os.linesep + if name.endswith("bat"): + eol = "\r\n" + with open(name, "r+", newline = eol) as file: + # Get file size + file.seek(0, os.SEEK_END) + size = file.tell() + + # Seek to last character in file + file.seek(size - 1) + + # While last character is a newline + while file.read(1) == "\n": + newlines = newlines + 1 + + # Seek to character before newline + file.seek(size - 1 - len(eol) * newlines) + + if newlines < 1: + # Append newline to end of file + file.seek(size) + file.write("\n") + elif newlines > 1: + # Truncate all but one newline + file.truncate(size - len(eol) * (newlines - 1)) diff --git a/styleguide/styleguide.xsl b/styleguide/styleguide.xsl index 0c656bd350..84cb144db0 100644 --- a/styleguide/styleguide.xsl +++ b/styleguide/styleguide.xsl @@ -50,7 +50,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> var bodyElements = GetElementsByName(bodyName); var linkElement = GetElementsByName('link-' + buttonName)[0]; if (bodyElements.length != 1) { - throw Error('ShowHideByName() got the wrong number of bodyElements: ' + + throw Error('ShowHideByName() got the wrong number of bodyElements: ' + bodyElements.length); } else { var bodyElement = bodyElements[0]; @@ -138,10 +138,10 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> var showHideAllValue = showHideAllRegex.exec(window.location.href); if (showHideAllValue != null) { if (showHideAllValue[2] == "y") { - SetHiddenState(document.getElementsByTagName("body")[0].childNodes, + SetHiddenState(document.getElementsByTagName("body")[0].childNodes, "inline", ''); } else { - SetHiddenState(document.getElementsByTagName("body")[0].childNodes, + SetHiddenState(document.getElementsByTagName("body")[0].childNodes, "none", ''); } } @@ -551,8 +551,8 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> @@ -716,7 +716,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> 5) Print line[a:c] (Note that we ignore line[0:a]) 6) Print line[b:c] in an external span (in order to double the block indent in external code). - 7) Print line[c:] with function names processed to produce both + 7) Print line[c:] with function names processed to produce both internal and external names. 8) If there are more lines, recurse. --> @@ -820,7 +820,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> - + @@ -895,7 +895,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions"> diff --git a/styleguide/task.py b/styleguide/task.py new file mode 100644 index 0000000000..2ab4ee2226 --- /dev/null +++ b/styleguide/task.py @@ -0,0 +1,75 @@ +# Provides a task base class for use by format.py + +from abc import * +import os +import re + +sep = os.sep +# If directory separator is backslash, escape it for regexes +if sep == "\\": + sep += "\\" + +# List of folder regexes which should be excluded from modification +folderExclude = \ + [name + sep for name in [ + "\.git", + "\.gradle", + "FRC_FPGA_ChipObject", + "NetworkCommunication", + "__pycache__", + "build", + "ctre", + "frccansae", + "gtest", + "i2clib", + "msgs", + "ni-libraries", + "ni" + sep + "vision", + "spilib", + "wpilibj" + sep + "src" + sep + "athena" + sep + "cpp" + sep + "include", + "wpilibj" + sep + "src" + sep + "athena" + sep + "cpp" + sep + "lib", + "wpilibj" + sep + "src" + sep + "athena" + sep + "cpp" + sep + "nivision", + "visa"]] + +# List of file regexes which should be excluded from modification +fileExclude = [name + "$" for name in [ + "CanTalonSRX\.h", + "NIIMAQdx\.h", + "can_proto\.h", + "nivision\.h", + "\.jar", + "\.patch", + "\.png", + "\.py", + "\.so"]] + +# Regex of exclusions +regexExclude = re.compile("|".join(folderExclude + fileExclude)) + +class Task(object): + __metaclass__ = ABCMeta + + def __init__(self): + self.regexInclude = re.compile("|".join(["\." + ext + "$" for ext in + self.getIncludeExtensions()])) + + # Extensions of files which should be included in processing + def getIncludeExtensions(self): + return [] + + # Perform task on file with given name + @abstractmethod + def run(self, name): + return + + # Returns True if file isn't generated (generated files are skipped) + @staticmethod + def notGeneratedFile(name): + return not regexExclude.search(name) + + # Returns True if file has an extension this task can process + def fileMatchesExtension(self, name): + if self.getIncludeExtensions() != []: + return self.regexInclude.search(name) + else: + return True diff --git a/styleguide/whitespace.py b/styleguide/whitespace.py new file mode 100644 index 0000000000..c110211823 --- /dev/null +++ b/styleguide/whitespace.py @@ -0,0 +1,23 @@ +# This task removes trailing whitespace from all source files. + +import os +from task import Task + +class Whitespace(Task): + def run(self, name): + # Remove trailing whitespace + fileChanged = False + with open(name, "r") as file: + with open(name + ".tmp", "w") as temp: + for line in file: + processedLine = line[0:len(line) - 1].rstrip() + "\n" + if not fileChanged and len(line) != len(processedLine): + fileChanged = True + temp.write(processedLine) + + # Replace old file if it was changed + if fileChanged: + os.remove(name) + os.rename(name + ".tmp", name) + else: + os.remove(name + ".tmp") diff --git a/wpilibc/athena/src/Compressor.cpp b/wpilibc/athena/src/Compressor.cpp index ce8345baea..c7177a1352 100644 --- a/wpilibc/athena/src/Compressor.cpp +++ b/wpilibc/athena/src/Compressor.cpp @@ -1,6 +1,9 @@ -/* - * Compressor.cpp - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ #include "Compressor.h" diff --git a/wpilibc/sim/include/WPILib.h b/wpilibc/sim/include/WPILib.h index 99a76753f2..95d110c404 100644 --- a/wpilibc/sim/include/WPILib.h +++ b/wpilibc/sim/include/WPILib.h @@ -1,9 +1,10 @@ -/* - * WPILIb.h - * - * Created on: May 29, 2014 - * Author: alex - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + #pragma once #define SIMULATION "gazebo" diff --git a/wpilibc/sim/src/simulation/SimContinuousOutput.cpp b/wpilibc/sim/src/simulation/SimContinuousOutput.cpp index 675726f3f7..417ff62aef 100644 --- a/wpilibc/sim/src/simulation/SimContinuousOutput.cpp +++ b/wpilibc/sim/src/simulation/SimContinuousOutput.cpp @@ -1,9 +1,9 @@ -/* - * SimContinuousOutput.cpp - * - * Created on: May 28, 2014 - * Author: alex - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ #include "simulation/SimContinuousOutput.h" #include "simulation/MainNode.h" diff --git a/wpilibc/sim/src/simulation/SimDigitalInput.cpp b/wpilibc/sim/src/simulation/SimDigitalInput.cpp index d8f4f05950..1ed958fcf7 100644 --- a/wpilibc/sim/src/simulation/SimDigitalInput.cpp +++ b/wpilibc/sim/src/simulation/SimDigitalInput.cpp @@ -1,9 +1,9 @@ -/* - * SimDigitalInput.cpp - * - * Created on: May 28, 2014 - * Author: alex - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ #include "simulation/SimDigitalInput.h" #include "simulation/MainNode.h" diff --git a/wpilibc/sim/src/simulation/SimFloatInput.cpp b/wpilibc/sim/src/simulation/SimFloatInput.cpp index 77474f7523..d758ce00c4 100644 --- a/wpilibc/sim/src/simulation/SimFloatInput.cpp +++ b/wpilibc/sim/src/simulation/SimFloatInput.cpp @@ -1,9 +1,9 @@ -/* - * SimFloatInput.cpp - * - * Created on: May 28, 2014 - * Author: alex - */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ #include "simulation/SimFloatInput.h" #include "simulation/MainNode.h" diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java index 89acff3d51..efac88cff0 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogGyro.java @@ -28,14 +28,14 @@ public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowS private static final float kDefaultVoltsPerDegreePerSecond = 0.007f; protected AnalogInput m_analog; private boolean m_channelAllocated = false; - + private int m_gyroHandle = 0; /** * Initialize the gyro. Calibration is handled by calibrate(). */ public void initGyro() { - + if (m_gyroHandle == 0) { m_gyroHandle = AnalogGyroJNI.initializeAnalogGyro(m_analog.m_port); } @@ -107,7 +107,7 @@ public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowS throw new NullPointerException("AnalogInput supplied to Gyro constructor is null"); } initGyro(); - AnalogGyroJNI.setAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond, + AnalogGyroJNI.setAnalogGyroParameters(m_gyroHandle, kDefaultVoltsPerDegreePerSecond, (float)offset, center); reset(); } @@ -173,7 +173,7 @@ public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowS * @param voltsPerDegreePerSecond The sensitivity in Volts/degree/second. */ public void setSensitivity(double voltsPerDegreePerSecond) { - AnalogGyroJNI.setAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle, + AnalogGyroJNI.setAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle, (float)voltsPerDegreePerSecond); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTrigger.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTrigger.java index eac3ca79aa..3523652180 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTrigger.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTrigger.java @@ -72,7 +72,7 @@ public class AnalogTrigger { AnalogJNI.initializeAnalogTrigger(channel.m_port, index.asIntBuffer()); m_index = index.asIntBuffer().get(0); - UsageReporting.report(tResourceType.kResourceType_AnalogTrigger, channel.getChannel()); + UsageReporting.report(tResourceType.kResourceType_AnalogTrigger, channel.getChannel()); } /** diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java index 722786eda4..a1c376642b 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/AnalogTriggerOutput.java @@ -80,7 +80,7 @@ public class AnalogTriggerOutput extends DigitalSource { UsageReporting.report(tResourceType.kResourceType_AnalogTriggerOutput, trigger.getIndex(), outputType.m_value); } - + /** * Frees the resources for this output. */ @@ -88,7 +88,7 @@ public class AnalogTriggerOutput extends DigitalSource { if (m_interrupt != 0) { cancelInterrupts(); } - + } /** @@ -109,12 +109,12 @@ public class AnalogTriggerOutput extends DigitalSource { public int getAnalogTriggerTypeForRouting() { return m_outputType.m_value; } - + @Override public int getChannel() { return m_trigger.m_index; } - + @Override public boolean isAnalogTrigger() { return true; diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java index 38ed9ac869..dd87e1158f 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalInput.java @@ -23,7 +23,7 @@ import edu.wpi.first.wpilibj.tables.ITable; public class DigitalInput extends DigitalSource implements LiveWindowSendable { private int m_channel = 0; private int m_handle = 0; - + /** * Create an instance of a Digital Input class. Creates a digital input given a channel. * @@ -32,13 +32,13 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable { public DigitalInput(int channel) { checkDigitalChannel(channel); m_channel = channel; - + m_handle = DIOJNI.initializeDIOPort(DIOJNI.getPort((byte)channel), true); LiveWindow.addSensor("DigitalInput", channel, this); UsageReporting.report(tResourceType.kResourceType_DigitalInput, channel); } - + /** * Frees the resources for this output. */ @@ -46,7 +46,7 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable { if (m_interrupt != 0) { cancelInterrupts(); } - + DIOJNI.freeDIOPort(m_handle); } @@ -79,7 +79,7 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable { public int getAnalogTriggerTypeForRouting() { return 0; } - + /** * Is this an analog trigger. * @@ -89,7 +89,7 @@ public class DigitalInput extends DigitalSource implements LiveWindowSendable { public boolean isAnalogTrigger() { return false; } - + /** * Get the HAL Port Handle. * diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java index ca774a4a36..959d91e6b3 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalOutput.java @@ -36,7 +36,7 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { public DigitalOutput(int channel) { checkDigitalChannel(channel); m_channel = channel; - + m_handle = DIOJNI.initializeDIOPort(DIOJNI.getPort((byte)channel), false); UsageReporting.report(tResourceType.kResourceType_DigitalOutput, channel); @@ -67,7 +67,7 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { /** * @return The GPIO channel number that this object represents. */ - @Override + @Override public int getChannel() { return m_channel; } @@ -181,7 +181,7 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { public int getAnalogTriggerTypeForRouting() { return 0; } - + /** * Is this an analog trigger. * @@ -191,7 +191,7 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable { public boolean isAnalogTrigger() { return false; } - + /** * Get the HAL Port Handle. * diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalSource.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalSource.java index f4626dec1b..3ba3382130 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalSource.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DigitalSource.java @@ -15,6 +15,6 @@ package edu.wpi.first.wpilibj; */ public abstract class DigitalSource extends InterruptableSensorBase { public abstract boolean isAnalogTrigger(); - + public abstract int getChannel(); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index 06cca2fbb6..46ae634578 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -70,7 +70,7 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { int portHandle = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_forwardChannel); m_forwardHandle = SolenoidJNI.initializeSolenoidPort(portHandle); - + try { portHandle = SolenoidJNI.getPortWithModule((byte) m_moduleNumber, (byte) m_reverseChannel); m_reverseHandle = SolenoidJNI.initializeSolenoidPort(portHandle); @@ -107,7 +107,7 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { public void set(final Value value) { boolean forward = false; boolean reverse = false; - + switch (value) { case kOff: forward = false; @@ -138,7 +138,7 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { public Value get() { boolean valueForward = SolenoidJNI.getSolenoid(m_forwardHandle); boolean valueReverse = SolenoidJNI.getSolenoid(m_reverseHandle); - + if (valueForward) { return Value.kForward; } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java index 6b96a9b6ae..a6f594c3f8 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/DriverStation.java @@ -81,7 +81,7 @@ public class DriverStation implements RobotState.Interface { private HALJoystickPOVs[] m_joystickPOVsCache = new HALJoystickPOVs[kJoystickPorts]; private HALJoystickButtons[] m_joystickButtonsCache = new HALJoystickButtons[kJoystickPorts]; // preallocated byte buffer for button count - private ByteBuffer m_buttonCountBuffer = ByteBuffer.allocateDirect(1); + private ByteBuffer m_buttonCountBuffer = ByteBuffer.allocateDirect(1); private int[] m_joystickIsXbox = new int[kJoystickPorts]; private int[] m_joystickType = new int[kJoystickPorts]; @@ -94,7 +94,7 @@ public class DriverStation implements RobotState.Interface { private final Object m_newControlDataMutex; private final Object m_joystickMutex; private volatile boolean m_threadKeepAlive = true; - + private boolean m_userInDisabled = false; private boolean m_userInAutonomous = false; private boolean m_userInTeleop = false; @@ -129,9 +129,9 @@ public class DriverStation implements RobotState.Interface { m_joystickPOVs[i] = new HALJoystickPOVs(FRCNetworkCommunicationsLibrary.kMaxJoystickPOVs); m_joystickButtonsCache[i] = new HALJoystickButtons(); - m_joystickAxesCache[i] = + m_joystickAxesCache[i] = new HALJoystickAxes(FRCNetworkCommunicationsLibrary.kMaxJoystickAxes); - m_joystickPOVsCache[i] = + m_joystickPOVsCache[i] = new HALJoystickPOVs(FRCNetworkCommunicationsLibrary.kMaxJoystickPOVs); } @@ -216,11 +216,11 @@ public class DriverStation implements RobotState.Interface { protected void getData() { // Get the status of all of the joysticks for (byte stick = 0; stick < kJoystickPorts; stick++) { - m_joystickAxesCache[stick].m_count = - FRCNetworkCommunicationsLibrary.HALGetJoystickAxes(stick, + m_joystickAxesCache[stick].m_count = + FRCNetworkCommunicationsLibrary.HALGetJoystickAxes(stick, m_joystickAxesCache[stick].m_axes); - m_joystickPOVsCache[stick].m_count = - FRCNetworkCommunicationsLibrary.HALGetJoystickPOVs(stick, + m_joystickPOVsCache[stick].m_count = + FRCNetworkCommunicationsLibrary.HALGetJoystickPOVs(stick, m_joystickPOVsCache[stick].m_povs); m_joystickButtonsCache[stick].m_buttons = FRCNetworkCommunicationsLibrary.HALGetJoystickButtons(stick, m_buttonCountBuffer); @@ -295,7 +295,7 @@ public class DriverStation implements RobotState.Interface { if (axis < 0 || axis >= FRCNetworkCommunicationsLibrary.kMaxJoystickAxes) { throw new RuntimeException("Joystick axis is out of range"); } - + boolean error = false; double retVal = 0.0; synchronized (m_joystickMutex) { @@ -306,7 +306,7 @@ public class DriverStation implements RobotState.Interface { } else { retVal = m_joystickAxes[stick].m_axes[axis]; } - } + } if (error) { reportJoystickUnpluggedWarning("Joystick axis " + axis + " on port " + stick + " not available, check if controller is plugged in"); @@ -504,7 +504,7 @@ public class DriverStation implements RobotState.Interface { throw new RuntimeException("Joystick index is out of range, should be 0-5"); } boolean error = false; - String retVal = ""; + String retVal = ""; synchronized (m_joystickMutex) { // TODO: Remove this when calling for descriptor on empty stick no longer // crashes @@ -514,7 +514,7 @@ public class DriverStation implements RobotState.Interface { } else { retVal = FRCNetworkCommunicationsLibrary.HALGetJoystickName((byte) stick); } - } + } if (error) { reportJoystickUnpluggedWarning("Joystick on port " + stick + " not available, check if controller is plugged in"); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java index e93d42a725..be7db61c32 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Encoder.java @@ -33,10 +33,10 @@ import edu.wpi.first.wpilibj.util.AllocationException; public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveWindowSendable { public enum IndexingType { kResetWhileHigh(0), kResetWhileLow(1), kResetOnFallingEdge(2), kResetOnRisingEdge(3); - + @SuppressWarnings("MemberName") public final int value; - + IndexingType(int value) { this.value = value; } @@ -60,9 +60,9 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW private boolean m_allocatedB; private boolean m_allocatedI; private PIDSourceType m_pidSource; - + private int m_encoder; // the HAL encoder object - + /** * Common initialization code for Encoders. This code allocates resources for Encoders and is @@ -73,10 +73,10 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW * @param reverseDirection If true, counts down instead of up (this is all relative) */ private void initEncoder(boolean reverseDirection, final EncodingType type) { - m_encoder = EncoderJNI.initializeEncoder(m_aSource.getPortHandleForRouting(), - m_aSource.getAnalogTriggerTypeForRouting(), m_bSource.getPortHandleForRouting(), + m_encoder = EncoderJNI.initializeEncoder(m_aSource.getPortHandleForRouting(), + m_aSource.getAnalogTriggerTypeForRouting(), m_bSource.getPortHandleForRouting(), m_bSource.getAnalogTriggerTypeForRouting(), reverseDirection, type.value); - + m_pidSource = PIDSourceType.kDisplacement; UsageReporting.report(tResourceType.kResourceType_Encoder, getFPGAIndex(), type.value); @@ -580,7 +580,7 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW * @param type The state that will cause the encoder to reset */ public void setIndexSource(DigitalSource source, IndexingType type) { - EncoderJNI.setEncoderIndexSource(m_encoder, source.getPortHandleForRouting(), + EncoderJNI.setEncoderIndexSource(m_encoder, source.getPortHandleForRouting(), source.getAnalogTriggerTypeForRouting(), type.value); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java index 19b580cfc9..de273468c7 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/InterruptableSensorBase.java @@ -88,7 +88,7 @@ public abstract class InterruptableSensorBase extends SensorBase { assert (m_interrupt != 0); - InterruptJNI.requestInterrupts(m_interrupt, getPortHandleForRouting(), + InterruptJNI.requestInterrupts(m_interrupt, getPortHandleForRouting(), getAnalogTriggerTypeForRouting()); setUpSourceEdge(true, false); InterruptJNI.attachInterruptHandler(m_interrupt, handler.m_function, @@ -109,7 +109,7 @@ public abstract class InterruptableSensorBase extends SensorBase { assert (m_interrupt != 0); - InterruptJNI.requestInterrupts(m_interrupt, getPortHandleForRouting(), + InterruptJNI.requestInterrupts(m_interrupt, getPortHandleForRouting(), getAnalogTriggerTypeForRouting()); setUpSourceEdge(true, false); @@ -123,7 +123,7 @@ public abstract class InterruptableSensorBase extends SensorBase { */ protected void allocateInterrupts(boolean watcher) { m_isSynchronousInterrupt = watcher; - + m_interrupt = InterruptJNI.initializeInterrupts(watcher); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java index 6f329468fa..1b1e602ff9 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Relay.java @@ -110,7 +110,7 @@ public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable } private final int m_channel; - + private int m_forwardHandle = 0; private int m_reverseHandle = 0; private long m_port; @@ -176,10 +176,10 @@ public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable } catch (RuntimeException ex) { // do nothing. Ignore } - + RelayJNI.freeRelayPort(m_forwardHandle); RelayJNI.freeRelayPort(m_reverseHandle); - + m_forwardHandle = 0; m_reverseHandle = 0; } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java index 793d594baf..9f94ce8fc1 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/SensorBase.java @@ -18,7 +18,7 @@ public abstract class SensorBase { // TODO: Refactor /** * Ticks per microsecond. */ - public static final int kSystemClockTicksPerMicrosecond = + public static final int kSystemClockTicksPerMicrosecond = ConstantsJNI.getSystemClockTicksPerMicrosecond(); /** * Number of digital channels per roboRIO. diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java index 8357c80518..02aad4b761 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/Ultrasonic.java @@ -289,7 +289,7 @@ public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSenda // single sensor m_counter.reset(); // reset the counter to zero (invalid data now) // do the ping to start getting a single range - m_pingChannel.pulse(m_pingChannel.getChannel(), (float) kPingTime); + m_pingChannel.pulse(m_pingChannel.getChannel(), (float) kPingTime); } /** diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/AnalogGyroJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/AnalogGyroJNI.java index fe3a771fae..dcf0686f0a 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/AnalogGyroJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/AnalogGyroJNI.java @@ -9,29 +9,29 @@ package edu.wpi.first.wpilibj.hal; public class AnalogGyroJNI extends JNIWrapper { public static native int initializeAnalogGyro(int halAnalogInputHandle); - + public static native void setupAnalogGyro(int handle); - + public static native void freeAnalogGyro(int handle); - - public static native void setAnalogGyroParameters(int handle, - float voltsPerDegreePerSecond, + + public static native void setAnalogGyroParameters(int handle, + float voltsPerDegreePerSecond, float offset, int center); public static native void setAnalogGyroVoltsPerDegreePerSecond(int handle, float voltsPerDegreePerSecond); - + public static native void resetAnalogGyro(int handle); - + public static native void calibrateAnalogGyro(int handle); - + public static native void setAnalogGyroDeadband(int handle, float volts); - + public static native float getAnalogGyroAngle(int handle); - + public static native double getAnalogGyroRate(int handle); - + public static native float getAnalogGyroOffset(int handle); - + public static native int getAnalogGyroCenter(int handle); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CounterJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CounterJNI.java index b3a2549905..e85b7a3fbd 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CounterJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/CounterJNI.java @@ -16,7 +16,7 @@ public class CounterJNI extends JNIWrapper { public static native void setCounterAverageSize(int counterHandle, int size); - public static native void setCounterUpSource(int counterHandle, int digitalSourceHandle, + public static native void setCounterUpSource(int counterHandle, int digitalSourceHandle, int analogTriggerType); public static native void setCounterUpSourceEdge(int counterHandle, boolean risingEdge, @@ -24,7 +24,7 @@ public class CounterJNI extends JNIWrapper { public static native void clearCounterUpSource(int counterHandle); - public static native void setCounterDownSource(int counterHandle, int digitalSourceHandle, + public static native void setCounterDownSource(int counterHandle, int digitalSourceHandle, int analogTriggerType); public static native void setCounterDownSourceEdge(int counterHandle, boolean risingEdge, diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/DIOJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/DIOJNI.java index 4cf0eb64c9..b9d2c31498 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/DIOJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/DIOJNI.java @@ -26,7 +26,7 @@ public class DIOJNI extends JNIWrapper { public static native boolean isAnyPulsing(); public static native short getLoopTiming(); - + public static native int allocateDigitalPWM(); public static native void freeDigitalPWM(int pwmGenerator); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/EncoderJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/EncoderJNI.java index ce271aae11..4cc3e48989 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/EncoderJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/EncoderJNI.java @@ -10,19 +10,19 @@ package edu.wpi.first.wpilibj.hal; import java.nio.IntBuffer; public class EncoderJNI extends JNIWrapper { - - public static native int initializeEncoder(int digitalSourceHandleA, int analogTriggerTypeA, + + public static native int initializeEncoder(int digitalSourceHandleA, int analogTriggerTypeA, int digitalSourceHandleB, int analogTriggerTypeB, boolean reverseDirection, int encodingType); public static native void freeEncoder(int encoderHandle); public static native int getEncoder(int encoderHandle); - + public static native int getEncoderRaw(int encoderHandle); - + public static native int getEncodingScaleFactor(int encoderHandle); - + public static native void resetEncoder(int encoderHandle); public static native double getEncoderPeriod(int encoderHandle); @@ -32,13 +32,13 @@ public class EncoderJNI extends JNIWrapper { public static native boolean getEncoderStopped(int encoderHandle); public static native boolean getEncoderDirection(int encoderHandle); - + public static native double getEncoderDistance(int encoderHandle); - + public static native double getEncoderRate(int encoderHandle); - + public static native void setEncoderMinRate(int encoderHandle, double minRate); - + public static native void setEncoderDistancePerPulse(int encoderHandle, double distancePerPulse); public static native void setEncoderReverseDirection(int encoderHandle, @@ -49,12 +49,12 @@ public class EncoderJNI extends JNIWrapper { public static native int getEncoderSamplesToAverage(int encoderHandle); - public static native void setEncoderIndexSource(int encoderHandle, int digitalSourceHandle, + public static native void setEncoderIndexSource(int encoderHandle, int digitalSourceHandle, int analogTriggerType, int indexingType); - + @SuppressWarnings("AbbreviationAsWordInName") public static native int getEncoderFPGAIndex(int encoderHandle); - + public static native int getEncoderEncodingScale(int encoderHandle); public static native double getEncoderDecodingScaleFactor(int encoderHandle); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java index a542fce3df..06ff3bb70f 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/InterruptJNI.java @@ -9,7 +9,7 @@ package edu.wpi.first.wpilibj.hal; public class InterruptJNI extends JNIWrapper { public static final int HalInvalidHandle = 0; - + public interface InterruptJNIHandlerFunction { void apply(int interruptAssertedMask, Object param); } @@ -29,7 +29,7 @@ public class InterruptJNI extends JNIWrapper { public static native double readInterruptFallingTimestamp(int interruptHandle); - public static native void requestInterrupts(int interruptHandle, int digitalSourceHandle, + public static native void requestInterrupts(int interruptHandle, int digitalSourceHandle, int analogTriggerType); public static native void attachInterruptHandler(int interruptHandle, diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/PortsJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/PortsJNI.java index 457643a535..72a861fc09 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/PortsJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/PortsJNI.java @@ -9,40 +9,40 @@ package edu.wpi.first.wpilibj.hal; public class PortsJNI extends JNIWrapper { public static native int getNumAccumulators(); - + public static native int getNumAnalogTriggers(); - + public static native int getNumAnalogInputs(); - + public static native int getNumAnalogOutputs(); - + public static native int getNumCounters(); - + public static native int getNumDigitalHeaders(); - + public static native int getNumPWMHeaders(); - + public static native int getNumDigitalPins(); - + public static native int getNumPWMPins(); - + public static native int getNumDigitalPWMOutputs(); - + public static native int getNumEncoders(); - + public static native int getNumInterrupts(); - + public static native int getNumRelayPins(); - + public static native int getNumRelayHeaders(); - + public static native int getNumPCMModules(); - + public static native int getNumSolenoidPins(); - + public static native int getNumPDPModules(); - + public static native int getNumPDPChannels(); - + public static native int getNumCanTalons(); } diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/RelayJNI.java b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/RelayJNI.java index bfe17d4139..3b9729455f 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/RelayJNI.java +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/hal/RelayJNI.java @@ -9,11 +9,11 @@ package edu.wpi.first.wpilibj.hal; public class RelayJNI extends DIOJNI { public static native int initializeRelayPort(int halPortHandle, boolean forward); - + public static native void freeRelayPort(int relayPortHandle); - + public static native boolean checkRelayChannel(int pin); - + public static native void setRelay(int relayPortHandle, boolean on); public static native boolean getRelay(int relayPortHandle); diff --git a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/package.html b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/package.html index 7696bf331e..c22bf27a93 100644 --- a/wpilibj/src/athena/java/edu/wpi/first/wpilibj/package.html +++ b/wpilibj/src/athena/java/edu/wpi/first/wpilibj/package.html @@ -11,7 +11,7 @@ station, and a number of other utility functions like timing and field managemen The library is designed to:
  • Deal with all the low level interfacing to these components so you can concentrate on - solving this yearŐs Ňrobot problemÓ. This is a philosophical decision to let you focus + solving this year's "robot problem". This is a philosophical decision to let you focus on the higher-level design of your robot rather than deal with the details of the processor and the operating system.
  • diff --git a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java index e7b5e436fe..b8ed44ef4a 100644 --- a/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java +++ b/wpilibj/src/shared/java/edu/wpi/first/wpilibj/PIDController.java @@ -1,7 +1,8 @@ -/* Copyright (c) FIRST 2008-2012. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ +/* the project. */ /*----------------------------------------------------------------------------*/ package edu.wpi.first.wpilibj; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java index 8e899c67ac..939ff2eb9f 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java @@ -35,7 +35,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testDigitalChannels() { assertEquals(26, SensorBase.kDigitalChannels); } - + /** * kAnalogInputChannels. */ @@ -43,7 +43,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testAnalogInputChannels() { assertEquals(8, SensorBase.kAnalogInputChannels); } - + /** * kAnalogOutputChannels. */ @@ -51,7 +51,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testAnalogOutputChannels() { assertEquals(2, SensorBase.kAnalogOutputChannels); } - + /** * kSolenoidChannels. */ @@ -59,7 +59,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testSolenoidChannels() { assertEquals(8, SensorBase.kSolenoidChannels); } - + /** * kPwmChannels. */ @@ -67,7 +67,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testPwmChannels() { assertEquals(20, SensorBase.kPwmChannels); } - + /** * kRelayChannels. */ @@ -75,7 +75,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testRelayChannels() { assertEquals(8, SensorBase.kRelayChannels); } - + /** * kPDPChannels. */ @@ -83,7 +83,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testPDPChannels() { assertEquals(16, SensorBase.kPDPChannels); } - + /** * kPDPModules. */ @@ -91,7 +91,7 @@ public class ConstantsPortsTest extends AbstractComsSetup { public void testPDPModules() { assertEquals(63, SensorBase.kPDPModules); } - + /** * kPCMModules. */ diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java index a7af2f7cea..6567e3246b 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java @@ -20,8 +20,8 @@ import edu.wpi.first.wpilibj.test.AbstractTestSuite; @RunWith(Suite.class) @SuiteClasses({AnalogCrossConnectTest.class, AnalogPotentiometerTest.class, BuiltInAccelerometerTest.class, CANTalonTest.class, - CircularBufferTest.class, ConstantsPortsTest.class, CounterTest.class, - DigitalGlitchFilterTest.class, DIOCrossConnectTest.class, EncoderTest.class, + CircularBufferTest.class, ConstantsPortsTest.class, CounterTest.class, + DigitalGlitchFilterTest.class, DIOCrossConnectTest.class, EncoderTest.class, FilterNoiseTest.class, FilterOutputTest.class, GyroTest.class, MotorEncoderTest.class, MotorInvertingTest.class, PCMTest.class, PDPTest.class, PIDTest.class, PIDToleranceTest.class, PreferencesTest.class, RelayCrossConnectTest.class, diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/package-info.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/package-info.java index e53a216a13..0f1c9794f3 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/package-info.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/package-info.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + /** * Provides a suite of tests to cover CANJaguar fully in all different control modes and with each * supported positional input. Different setup parameters are provided in each Test class. All test diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FilterOutputFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FilterOutputFixture.java index dbdcdcd847..992ace0c69 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FilterOutputFixture.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FilterOutputFixture.java @@ -129,18 +129,18 @@ public abstract class FilterOutputFixture implements ITestF @SuppressWarnings("ParameterName") public abstract double getData(double t); - + @Override public void setPIDSourceType(PIDSourceType pidSource) { } - + @Override public PIDSourceType getPIDSourceType() { return PIDSourceType.kDisplacement; } - + @Override public double pidGet() { m_count += TestBench.kFilterStep; diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java index 4b0ea006b7..db3d4a0bd8 100644 --- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java +++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java @@ -1,3 +1,10 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + /** * This is the starting point for the integration testing framework. This package should contain * classes that are not explicitly for testing the library but instead provide the framework that diff --git a/wpilibjIntegrationTests/src/main/resources/logging.properties b/wpilibjIntegrationTests/src/main/resources/logging.properties index 8a6ddddb5c..b15c5347aa 100644 --- a/wpilibjIntegrationTests/src/main/resources/logging.properties +++ b/wpilibjIntegrationTests/src/main/resources/logging.properties @@ -1,4 +1,4 @@ -# "handlers" specifies a comma separated list of log Handler +# "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. # By default we only configure a ConsoleHandler, which will only # show messages at the INFO and above levels.