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,179 @@
/*----------------------------------------------------------------------------*/
/* 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;
import static org.junit.Assert.*;
import java.util.concurrent.Delayed;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
/**
* @author Kacper Puczydlowski
*
*/
public class PCMTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PCMTest.class.getName());
/*
* The PCM switches the compressor up to 2 seconds after the pressure switch
* changes.
*/
protected static final double kCompressorDelayTime = 2.0;
/* Solenoids should change much more quickly */
protected static final double kSolenoidDelayTime = 1.0;
/*
* The voltage divider on the test bench should bring the compressor output to
* around these values.
*/
protected static final double kCompressorOnVoltage = 5.00;
protected static final double kCompressorOffVoltage = 1.68;
private static Compressor compressor;
private static DigitalOutput fakePressureSwitch;
private static AnalogInput fakeCompressor;
private static DigitalInput fakeSolenoid1, fakeSolenoid2;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
compressor = new Compressor();
fakePressureSwitch = new DigitalOutput(11);
fakeCompressor = new AnalogInput(1);
fakeSolenoid1 = new DigitalInput(12);
fakeSolenoid2 = new DigitalInput(13);
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
compressor.free();
fakePressureSwitch.free();
fakeCompressor.free();
fakeSolenoid1.free();
fakeSolenoid2.free();
}
@Before
public void setUp() throws Exception {}
@Before
public void reset() throws Exception {
compressor.stop();
fakePressureSwitch.set(false);
}
@After
public void tearDown() throws Exception {}
/**
* Test if the compressor turns on and off when the pressure switch is toggled
*/
@Test
public void testPressureSwitch() throws Exception {
double range = 0.1;
reset();
compressor.setClosedLoopControl(true);
// Turn on the compressor
fakePressureSwitch.set(true);
Timer.delay(kCompressorDelayTime);
assertEquals("Compressor did not turn on when the pressure switch turned on.",
kCompressorOnVoltage, fakeCompressor.getVoltage(), range);
// Turn on the compressor
fakePressureSwitch.set(false);
Timer.delay(kCompressorDelayTime);
assertEquals("Compressor did not turn off when the pressure switch turned off.",
kCompressorOffVoltage, fakeCompressor.getVoltage(), range);
}
/**
* Test if the correct solenoids turn on and off when they should
*/
@Test
public void testSolenoid() throws Exception {
reset();
Solenoid solenoid1 = new Solenoid(0);
Solenoid solenoid2 = new Solenoid(1);
solenoid1.set(false);
solenoid2.set(false);
Timer.delay(kSolenoidDelayTime);
assertTrue("Solenoid #1 did not turn on", fakeSolenoid1.get());
assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get());
// Turn Solenoid #1 on, and turn Solenoid #2 off
solenoid1.set(true);
solenoid2.set(false);
Timer.delay(kSolenoidDelayTime);
assertFalse("Solenoid #1 did not turn on", fakeSolenoid1.get());
assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get());
// Turn Solenoid #1 off, and turn Solenoid #2 on
solenoid1.set(false);
solenoid2.set(true);
Timer.delay(kSolenoidDelayTime);
assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get());
assertFalse("Solenoid #2 did not turn on", fakeSolenoid2.get());
// Turn both Solenoids on
solenoid1.set(true);
solenoid2.set(true);
Timer.delay(kSolenoidDelayTime);
assertFalse("Solenoid #1 did not turn on", fakeSolenoid1.get());
assertFalse("Solenoid #2 did not turn on", fakeSolenoid2.get());
solenoid1.free();
solenoid2.free();
}
/**
* Test if the correct solenoids turn on and off when they should when used
* with the DoubleSolenoid class.
*/
@Test
public void doubleSolenoid() {
DoubleSolenoid solenoid = new DoubleSolenoid(0, 1);
solenoid.set(DoubleSolenoid.Value.kOff);
Timer.delay(kSolenoidDelayTime);
assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get());
assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get());
solenoid.set(DoubleSolenoid.Value.kForward);
Timer.delay(kSolenoidDelayTime);
assertFalse("Solenoid #1 did not turn on", fakeSolenoid1.get());
assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get());
solenoid.set(DoubleSolenoid.Value.kReverse);
Timer.delay(kSolenoidDelayTime);
assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get());
assertFalse("Solenoid #2 did not turn on", fakeSolenoid2.get());
solenoid.free();
}
protected Logger getClassLogger() {
return logger;
}
}