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:
Tyler Veness
2016-07-10 08:33:27 -07:00
committed by Peter Johnson
parent ea6876e81f
commit aafca4ed7f
57 changed files with 588 additions and 423 deletions

View File

@@ -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) {

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}

View File

@@ -12,7 +12,7 @@ import java.awt.event.ActionListener;
public class EnableAction implements ActionListener {
private DS ds;
public EnableAction(DS ds) {
this.ds = ds;
}

View File

@@ -15,7 +15,7 @@ public class FakeJoystick implements ISimJoystick {
public String getName() {
return "Empty Joystick";
}
public String toString() {
return getName();
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -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()));

View File

@@ -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();

View File

@@ -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