Remove MotorSafetyHelper, create MotorSafety base class instead (#562)

Most of the MotorSafety implementation was moved into the MotorSafety base
class. SafePWM's inheritance of MotorSafety was moved into PWM to
eliminate Java needing a helper class.

In Java, a helper class for Sendable (SendableImpl) was added due to
lack of multiple inheritance.
This commit is contained in:
Tyler Veness
2018-11-22 21:15:26 -08:00
committed by Peter Johnson
parent df347e3d80
commit acb786a791
39 changed files with 710 additions and 1023 deletions

View File

@@ -47,6 +47,8 @@ PWM::PWM(int channel) {
HAL_Report(HALUsageReporting::kResourceType_PWM, channel);
SetName("PWM", channel);
SetSafetyEnabled(false);
}
PWM::~PWM() {
@@ -60,7 +62,7 @@ PWM::~PWM() {
}
PWM::PWM(PWM&& rhs)
: ErrorBase(std::move(rhs)),
: MotorSafety(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)) {
std::swap(m_handle, rhs.m_handle);
@@ -76,6 +78,12 @@ PWM& PWM::operator=(PWM&& rhs) {
return *this;
}
void PWM::StopMotor() { SetDisabled(); }
void PWM::GetDescription(wpi::raw_ostream& desc) const {
desc << "PWM " << GetChannel();
}
void PWM::SetRaw(uint16_t value) {
if (StatusIsFatal()) return;
@@ -114,6 +122,8 @@ void PWM::SetSpeed(double speed) {
int32_t status = 0;
HAL_SetPWMSpeed(m_handle, speed, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
Feed();
}
double PWM::GetSpeed() const {