2014-06-19 14:56:06 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
|
2014-06-19 14:56:06 -04:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-09-25 16:50:13 -07:00
|
|
|
#include "PowerDistributionPanel.h" // NOLINT(build/include_order)
|
2016-05-25 22:38:11 -07:00
|
|
|
|
|
|
|
|
#include "Jaguar.h"
|
|
|
|
|
#include "Talon.h"
|
|
|
|
|
#include "TestBench.h"
|
|
|
|
|
#include "Timer.h"
|
|
|
|
|
#include "Victor.h"
|
2016-09-05 13:55:31 -07:00
|
|
|
#include "gtest/gtest.h"
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2014-08-18 10:32:26 -04:00
|
|
|
static const double kMotorTime = 0.25;
|
2014-06-19 14:56:06 -04:00
|
|
|
|
|
|
|
|
class PowerDistributionPanelTest : public testing::Test {
|
2015-06-25 15:07:55 -04:00
|
|
|
protected:
|
2016-05-20 17:30:37 -07:00
|
|
|
PowerDistributionPanel* m_pdp;
|
|
|
|
|
Talon* m_talon;
|
|
|
|
|
Victor* m_victor;
|
|
|
|
|
Jaguar* m_jaguar;
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2016-07-10 17:47:44 -07:00
|
|
|
void SetUp() override {
|
2015-06-25 15:07:55 -04:00
|
|
|
m_pdp = new PowerDistributionPanel();
|
|
|
|
|
m_talon = new Talon(TestBench::kTalonChannel);
|
|
|
|
|
m_victor = new Victor(TestBench::kVictorChannel);
|
|
|
|
|
m_jaguar = new Jaguar(TestBench::kJaguarChannel);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 17:47:44 -07:00
|
|
|
void TearDown() override {
|
2015-06-25 15:07:55 -04:00
|
|
|
delete m_pdp;
|
|
|
|
|
delete m_talon;
|
|
|
|
|
delete m_victor;
|
|
|
|
|
delete m_jaguar;
|
|
|
|
|
}
|
2014-06-19 14:56:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test if the current changes when the motor is driven using a talon
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
TEST_F(PowerDistributionPanelTest, CheckCurrentTalon) {
|
|
|
|
|
Wait(kMotorTime);
|
2014-06-19 14:56:06 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/* The Current should be 0 */
|
|
|
|
|
EXPECT_FLOAT_EQ(0, m_pdp->GetCurrent(TestBench::kTalonPDPChannel))
|
|
|
|
|
<< "The Talon current was non-zero";
|
2014-06-19 14:56:06 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/* Set the motor to full forward */
|
|
|
|
|
m_talon->Set(1.0);
|
|
|
|
|
Wait(kMotorTime);
|
2014-06-19 14:56:06 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/* The current should now be positive */
|
|
|
|
|
ASSERT_GT(m_pdp->GetCurrent(TestBench::kTalonPDPChannel), 0)
|
|
|
|
|
<< "The Talon current was not positive";
|
2014-06-19 14:56:06 -04:00
|
|
|
}
|