Add new CTRE classes and update PDP tests

Change-Id: I489091c5b8b0f1f9890e5104bf01e40ae53cf6ce
This commit is contained in:
Thomas Clark
2014-08-18 10:32:26 -04:00
parent c82a94b268
commit 687bc44ae5
4 changed files with 69 additions and 79 deletions

View File

@@ -25,10 +25,6 @@ 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());
/* The current returned when the motor is not being driven */
protected static final double kLowCurrent = 1.52;
protected static final double kCurrentTolerance = 0.1;
private static PowerDistributionPanel pdp;
private static MotorEncoderFixture<?> me;
@@ -37,21 +33,21 @@ public class PDPTest extends AbstractComsSetup {
public static void setUpBeforeClass() throws Exception {
pdp = new PowerDistributionPanel();
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
pdp.free();
me.teardown();
}
public PDPTest(MotorEncoderFixture<?> mef){
logger.fine("Constructor with: " + mef.getType());
if(me != null && !me.equals(mef)) me.teardown();
me = mef;
me.setup();
}
@Parameters(name= "{index}: {0}")
public static Collection<MotorEncoderFixture<?>[]> generateData(){
//logger.fine("Loading the MotorList");
@@ -66,19 +62,21 @@ public class PDPTest extends AbstractComsSetup {
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{
/* The Current should be kLowCurrent */
Timer.delay(0.25);
/* The Current should be 0 */
assertEquals("The low current was not within the expected range.",
kLowCurrent, pdp.getCurrent(me.getPDPChannel()), kCurrentTolerance);
0.0, pdp.getCurrent(me.getPDPChannel()), 0.001);
}
/**
* Test if the current changes when the motor is driven using a talon
*/
@@ -87,10 +85,11 @@ public class PDPTest extends AbstractComsSetup {
/* Set the motor to full forward */
me.getMotor().set(1.0);
Timer.delay(0.02);
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(kLowCurrent)));
pdp.getCurrent(me.getPDPChannel()), is(greaterThan(0.0)));
}
@Override