mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Reduced duplication between formatting scripts with Task base class (#80)
Also added scripts for EOF newline management and for removing trailing whitespace. configure.bat was rewritten to use CRLF line endings. Documentation for the existing scripts was also improved.
This commit is contained in:
committed by
Peter Johnson
parent
ea6876e81f
commit
aafca4ed7f
@@ -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: '^<.*'
|
||||
|
||||
@@ -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%"^
|
||||
..
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class Publisher<T extends Message> implements PublisherRecord {
|
||||
private List<Connection> 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<DriverStation> 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;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.awt.event.ActionListener;
|
||||
|
||||
public class EnableAction implements ActionListener {
|
||||
private DS ds;
|
||||
|
||||
|
||||
public EnableAction(DS ds) {
|
||||
this.ds = ds;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FakeJoystick implements ISimJoystick {
|
||||
public String getName() {
|
||||
return "Empty Joystick";
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class JoystickList extends JList<ISimJoystick> {
|
||||
int index = Integer.parseInt(indexString);
|
||||
JList.DropLocation dl = (JList.DropLocation) support.getDropLocation();
|
||||
int dropTargetIndex = dl.getIndex();
|
||||
|
||||
|
||||
list.moveElement(index, dropTargetIndex);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -18,11 +18,11 @@ import net.java.games.input.ControllerEnvironment;
|
||||
|
||||
public class JoystickProvider {
|
||||
List<ISimJoystick> joysticks;
|
||||
|
||||
|
||||
public JoystickProvider() {
|
||||
scanForJoysticks();
|
||||
}
|
||||
|
||||
|
||||
public List<ISimJoystick> scanForJoysticks() {
|
||||
List<ISimJoystick> 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<ISimJoystick> getJoysticks() {
|
||||
return joysticks;
|
||||
}
|
||||
|
||||
|
||||
public void setJoysticks(List<ISimJoystick> joysticks) {
|
||||
this.joysticks = joysticks;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.gazebosim.transport.SubscriberCallback;
|
||||
public class Main {
|
||||
private static double simTime = 0;
|
||||
private static Subscriber<Float64> sub;
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
Node node = new Node("frc");
|
||||
try {
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
15
styleguide/clangformat.py
Normal file
15
styleguide/clangformat.py
Normal file
@@ -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)
|
||||
@@ -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()
|
||||
|
||||
117
styleguide/licenseupdate.py
Normal file
117
styleguide/licenseupdate.py
Normal file
@@ -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()
|
||||
35
styleguide/newline.py
Normal file
35
styleguide/newline.py
Normal file
@@ -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))
|
||||
@@ -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", '<xsl:value-of select="$hide_button_text"/>');
|
||||
} else {
|
||||
SetHiddenState(document.getElementsByTagName("body")[0].childNodes,
|
||||
SetHiddenState(document.getElementsByTagName("body")[0].childNodes,
|
||||
"none", '<xsl:value-of select="$show_button_text"/>');
|
||||
}
|
||||
}
|
||||
@@ -551,8 +551,8 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions">
|
||||
</xsl:template>
|
||||
|
||||
<!-- Given text, determine the starting position of code.
|
||||
This similar to num_leading_spaces_one_line but treats "Yes:" and "No:"
|
||||
as spaces. Also, if there is no code on the first line, it searches
|
||||
This similar to num_leading_spaces_one_line but treats "Yes:" and "No:"
|
||||
as spaces. Also, if there is no code on the first line, it searches
|
||||
subsequent lines until a non-empty line is found.
|
||||
Used to find the start of code in snippets like:
|
||||
Yes: if(foo):
|
||||
@@ -583,7 +583,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions">
|
||||
<xsl:with-param name="current_count" select="$current_count + 3"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<!-- This is only reached if the first line is entirely whitespace or
|
||||
<!-- This is only reached if the first line is entirely whitespace or
|
||||
contains nothing but "Yes:" or "No:"-->
|
||||
<xsl:when test="starts-with($text, '
')">
|
||||
<xsl:call-template name="code_start_index">
|
||||
@@ -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:<end>] with function names processed to produce both
|
||||
7) Print line[c:<end>] 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">
|
||||
<xsl:with-param name="b" select="$b"/>
|
||||
<xsl:with-param name="previous_indent" select="$b"/>
|
||||
<xsl:with-param name="previous_ends_with_colon" select="0"/>
|
||||
<xsl:with-param name="is_first_line" select="1"/>
|
||||
<xsl:with-param name="is_first_line" select="1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
@@ -895,7 +895,7 @@ xmlns:fn="http://www.w3.org/2005/xpath-functions">
|
||||
<!-- Given a single word of text convert it from CamelCase to
|
||||
lower_with_under.
|
||||
This means replacing each uppercase character with _ followed by the
|
||||
lowercase version except for the first character which is replaced
|
||||
lowercase version except for the first character which is replaced
|
||||
without adding the _.-->
|
||||
<xsl:template name="convert_camel_case_to_lowercase_with_under">
|
||||
<xsl:param name="text"/>
|
||||
|
||||
75
styleguide/task.py
Normal file
75
styleguide/task.py
Normal file
@@ -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
|
||||
23
styleguide/whitespace.py
Normal file
23
styleguide/whitespace.py
Normal file
@@ -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")
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -15,6 +15,6 @@ package edu.wpi.first.wpilibj;
|
||||
*/
|
||||
public abstract class DigitalSource extends InterruptableSensorBase {
|
||||
public abstract boolean isAnalogTrigger();
|
||||
|
||||
|
||||
public abstract int getChannel();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -11,7 +11,7 @@ station, and a number of other utility functions like timing and field managemen
|
||||
The library is designed to:
|
||||
<ul>
|
||||
<li>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.
|
||||
</li>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -129,18 +129,18 @@ public abstract class FilterOutputFixture<T extends PIDSource> 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user