mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
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:
@@ -0,0 +1,104 @@
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import edu.wpi.first.wpilibj.can.CANMessageNotFoundException;
|
||||
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class PDPTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(PCMTest.class.getName());
|
||||
|
||||
private static PowerDistributionPanel pdp;
|
||||
private static MotorEncoderFixture<?> me;
|
||||
private final double expectedStoppedCurrentDraw;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
pdp = new PowerDistributionPanel();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
pdp.free();
|
||||
pdp = null;
|
||||
me.teardown();
|
||||
me = null;
|
||||
}
|
||||
|
||||
|
||||
public PDPTest(MotorEncoderFixture<?> mef, Double expectedCurrentDraw) {
|
||||
logger.fine("Constructor with: " + mef.getType());
|
||||
if (me != null && !me.equals(mef))
|
||||
me.teardown();
|
||||
me = mef;
|
||||
me.setup();
|
||||
|
||||
this.expectedStoppedCurrentDraw = expectedCurrentDraw;
|
||||
}
|
||||
|
||||
@Parameters(name = "{index}: {0}, Expected Stopped Current Draw: {1}")
|
||||
public static Collection<Object[]> generateData() {
|
||||
// logger.fine("Loading the MotorList");
|
||||
return Arrays.asList(new Object[][] {
|
||||
{TestBench.getInstance().getTalonPair(), new Double(0.0)},
|
||||
{TestBench.getInstance().getVictorPair(), new Double(0.0)},
|
||||
{TestBench.getInstance().getJaguarPair(), new Double(0.0)}});
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
me.reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if the current changes when the motor is driven using a talon
|
||||
*/
|
||||
@Test
|
||||
public void CheckStoppedCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
Timer.delay(0.25);
|
||||
|
||||
/* The Current should be 0 */
|
||||
assertEquals("The low current was not within the expected range.", expectedStoppedCurrentDraw,
|
||||
pdp.getCurrent(me.getPDPChannel()), 0.001);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the current changes when the motor is driven using a talon
|
||||
*/
|
||||
@Test
|
||||
public void CheckRunningCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
|
||||
/* Set the motor to full forward */
|
||||
me.getMotor().set(1.0);
|
||||
Timer.delay(0.25);
|
||||
|
||||
/* The current should now be greater than the low current */
|
||||
assertThat("The driven current is not greater than the resting current.",
|
||||
pdp.getCurrent(me.getPDPChannel()), is(greaterThan(expectedStoppedCurrentDraw)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Logger getClassLogger() {
|
||||
return logger;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user