WPILib Reorganization

This is a major restructuring of the WPILib repository to simply build
procedures and remove the remnants of Maven from everything except the
eclipse plugins. Gradle files have been largely simplified or rewritten,
taking advantage of splitting up parts of the build into separate build
files for ease of reading.

The eclipse plugins are now in a separate project, as is ntcore. All
dependencies are resolved via Maven dependencies, with the
Jenkins-maintained WPILib repo. Project structures have also been
simplified: we no longer have separate subprojects inside wpilibc and
wpilibj. Where possible, these changes hav been done with git renames,
to make sure we still have full history for all repositories. Other
unrelated subprojects have also been broken out: OutlineViewer is now a
separate project.

Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
This commit is contained in:
Fredric Silberberg
2015-09-24 20:26:49 -04:00
parent c20d34c2b6
commit 6d854afb0e
1769 changed files with 2278 additions and 333177 deletions

View File

@@ -0,0 +1,137 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.Timer;
/**
* @file FakeCounterSource.java Simulates an encoder for testing purposes
* @author Ryan O'Meara
*/
public class FakeCounterSource {
private Thread m_task;
private int m_count;
private int m_mSec;
private DigitalOutput m_output;
private boolean m_allocated;
/**
* Thread object that allows emulation of an encoder
*/
private class EncoderThread extends Thread {
FakeCounterSource m_encoder;
EncoderThread(FakeCounterSource encode) {
m_encoder = encode;
}
public void run() {
m_encoder.m_output.set(false);
try {
for (int i = 0; i < m_encoder.m_count; i++) {
Thread.sleep(m_encoder.m_mSec);
m_encoder.m_output.set(true);
Thread.sleep(m_encoder.m_mSec);
m_encoder.m_output.set(false);
}
} catch (InterruptedException e) {
}
}
}
/**
* Create a fake encoder on a given port
*$
* @param output the port to output the given signal to
*/
public FakeCounterSource(DigitalOutput output) {
m_output = output;
m_allocated = false;
initEncoder();
}
/**
* Create a fake encoder on a given port
*$
* @param port The port the encoder is supposed to be on
*/
public FakeCounterSource(int port) {
m_output = new DigitalOutput(port);
m_allocated = true;
initEncoder();
}
/**
* Destroy Object with minimum memory leak
*/
public void free() {
m_task = null;
if (m_allocated) {
m_output.free();
m_output = null;
m_allocated = false;
}
}
/**
* Common initailization code
*/
private void initEncoder() {
m_mSec = 1;
m_task = new EncoderThread(this);
m_output.set(false);
}
/**
* Starts the thread execution task
*/
public void start() {
m_task.start();
}
/**
* Waits for the thread to complete
*/
public void complete() {
try {
m_task.join();
} catch (InterruptedException e) {
}
m_task = new EncoderThread(this);
Timer.delay(.01);
}
/**
* Starts and completes a task set - does not return until thred has finished
* its operations
*/
public void execute() {
start();
complete();
}
/**
* Sets the count to run encoder
*$
* @param count The count to emulate to the controller
*/
public void setCount(int count) {
m_count = count;
}
/**
* Specify the rate to send pulses
*$
* @param mSec The rate to send out pulses at
*/
public void setRate(int mSec) {
m_mSec = mSec;
}
}

View File

@@ -0,0 +1,162 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014. 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.Timer;
/**
* @file FakeEncoderSource.java Emulates a quadrature encoder
* @author Ryan O'Meara
*/
public class FakeEncoderSource {
private Thread m_task;
private int m_count;
private int m_mSec;
private boolean m_forward;
private DigitalOutput m_outputA, m_outputB;
private final boolean allocatedOutputs;
/**
* Thread object that allows emulation of a quadrature encoder
*/
private class QuadEncoderThread extends Thread {
FakeEncoderSource m_encoder;
QuadEncoderThread(FakeEncoderSource encode) {
m_encoder = encode;
}
public void run() {
DigitalOutput lead, lag;
m_encoder.m_outputA.set(false);
m_encoder.m_outputB.set(false);
if (m_encoder.isForward()) {
lead = m_encoder.m_outputA;
lag = m_encoder.m_outputB;
} else {
lead = m_encoder.m_outputB;
lag = m_encoder.m_outputA;
}
try {
for (int i = 0; i < m_encoder.m_count; i++) {
lead.set(true);
Thread.sleep(m_encoder.m_mSec);
lag.set(true);
Thread.sleep(m_encoder.m_mSec);
lead.set(false);
Thread.sleep(m_encoder.m_mSec);
lag.set(false);
Thread.sleep(m_encoder.m_mSec);
}
} catch (InterruptedException e) {
}
}
}
public FakeEncoderSource(int portA, int portB) {
m_outputA = new DigitalOutput(portA);
m_outputB = new DigitalOutput(portB);
allocatedOutputs = true;
initQuadEncoder();
}
public FakeEncoderSource(DigitalOutput iA, DigitalOutput iB) {
m_outputA = iA;
m_outputB = iB;
allocatedOutputs = false;
initQuadEncoder();
}
public void free() {
m_task = null;
if (allocatedOutputs) {
m_outputA.free();
m_outputB.free();
}
}
/**
* Common initialization code
*/
private final void initQuadEncoder() {
m_mSec = 1;
m_forward = true;
m_task = new QuadEncoderThread(this);
m_outputA.set(false);
m_outputB.set(false);
}
/**
* Starts the thread
*/
public void start() {
m_task.start();
}
/**
* Waits for thread to end
*/
public void complete() {
try {
m_task.join();
} catch (InterruptedException e) {
}
m_task = new QuadEncoderThread(this);
Timer.delay(.01);
}
/**
* Runs and waits for thread to end before returning
*/
public void execute() {
start();
complete();
}
/**
* Rate of pulses to send
*$
* @param mSec Pulse Rate
*/
public void setRate(int mSec) {
m_mSec = mSec;
}
/**
* Set the number of pulses to simulate
*$
* @param count Pulse count
*/
public void setCount(int count) {
m_count = Math.abs(count);
}
/**
* Set which direction the encoder simulates motion in
*$
* @param isForward Whether to simulate forward motion
*/
public void setForward(boolean isForward) {
m_forward = isForward;
}
/**
* Accesses whether the encoder is simulating forward motion
*$
* @return Whether the simulated motion is in the forward direction
*/
public boolean isForward() {
return m_forward;
}
}

View File

@@ -0,0 +1,84 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008-2014. 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. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.AnalogOutput;
/**
* @author jonathanleitschuh
*
*/
public class FakePotentiometerSource {
private AnalogOutput output;
private boolean m_init_output;
private double potMaxAngle;
private double potMaxVoltage = 5.0;
private final double defaultPotMaxAngle;
public FakePotentiometerSource(AnalogOutput output, double defaultPotMaxAngle) {
this.defaultPotMaxAngle = defaultPotMaxAngle;
potMaxAngle = defaultPotMaxAngle;
this.output = output;
m_init_output = false;
}
public FakePotentiometerSource(int port, double defaultPotMaxAngle) {
this(new AnalogOutput(port), defaultPotMaxAngle);
m_init_output = true;
}
/**
* Sets the maximum voltage output. If not the default is 5.0V
*$
* @param voltage The voltage that indicates that the pot is at the max value.
*/
public void setMaxVoltage(double voltage) {
potMaxVoltage = voltage;
}
public void setRange(double range) {
potMaxAngle = range;
}
public void reset() {
potMaxAngle = defaultPotMaxAngle;
output.setVoltage(0.0);
}
public void setAngle(double angle) {
output.setVoltage((potMaxVoltage / potMaxAngle) * angle);
}
public void setVoltage(double voltage) {
output.setVoltage(voltage);
}
public double getVoltage() {
return output.getVoltage();
}
/**
* Returns the currently set angle
*$
* @return
*/
public double getAngle() {
double voltage = output.getVoltage();
if (voltage == 0) { // Removes divide by zero error
return 0;
}
return voltage * (potMaxAngle / potMaxVoltage);
}
public void free() {
if (m_init_output) {
output.free();
output = null;
m_init_output = false;
}
}
}