mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
artf4115: Added MotorSafety to Relays
Change-Id: Ia8d9ecfa21bb8102e73d91ec44791bd5141a0b4b
This commit is contained in:
committed by
Fred Silberberg (WPI)
parent
c21c47f546
commit
525f88ae17
@@ -23,7 +23,8 @@ import edu.wpi.first.wpilibj.tables.ITableListener;
|
||||
* allows the two channels (forward and reverse) to be used independently for
|
||||
* something that does not care about voltage polarity (like a solenoid).
|
||||
*/
|
||||
public class Relay extends SensorBase implements LiveWindowSendable {
|
||||
public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable {
|
||||
private MotorSafetyHelper m_safetyHelper;
|
||||
/**
|
||||
* This class represents errors in trying to set relay values contradictory
|
||||
* to the direction to which the relay is set.
|
||||
@@ -119,6 +120,10 @@ public class Relay extends SensorBase implements LiveWindowSendable {
|
||||
private void initRelay() {
|
||||
SensorBase.checkRelayChannel(m_channel);
|
||||
impl = new SimSpeedController("simulator/relay/" + m_channel);
|
||||
|
||||
m_safetyHelper = new MotorSafetyHelper(this);
|
||||
m_safetyHelper.setSafetyEnabled(false);
|
||||
|
||||
LiveWindow.addActuator("Relay", m_channel, this);
|
||||
}
|
||||
|
||||
@@ -246,6 +251,50 @@ public class Relay extends SensorBase implements LiveWindowSendable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channel number.
|
||||
*
|
||||
* @return The channel number.
|
||||
*/
|
||||
public int getChannel() {
|
||||
return m_channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpiration(double timeout) {
|
||||
m_safetyHelper.setExpiration(timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getExpiration() {
|
||||
return m_safetyHelper.getExpiration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return m_safetyHelper.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopMotor() {
|
||||
set(Value.kOff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafetyEnabled() {
|
||||
return m_safetyHelper.isSafetyEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSafetyEnabled(boolean enabled) {
|
||||
m_safetyHelper.setSafetyEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Relay ID " + getChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Relay Direction
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user