Package edu.wpi.first.wpilibj
Class SafePWM
- java.lang.Object
-
- edu.wpi.first.wpilibj.SendableBase
-
- edu.wpi.first.wpilibj.PWM
-
- edu.wpi.first.wpilibj.SafePWM
-
- All Implemented Interfaces:
MotorSafety
,Sendable
,AutoCloseable
- Direct Known Subclasses:
PWMSpeedController
public class SafePWM extends PWM implements MotorSafety
Manages a PWM object.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.PWM
PWM.PeriodMultiplier
-
-
Field Summary
-
Fields inherited from interface edu.wpi.first.wpilibj.MotorSafety
DEFAULT_SAFETY_EXPIRATION
-
-
Constructor Summary
Constructors Constructor Description SafePWM(int channel)
Constructor for a SafePWM object taking a channel number.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
disable()
void
feed()
Feed the MotorSafety timer.void
Feed()
Deprecated.Usefeed()
instead.String
getDescription()
double
getExpiration()
Return the expiration time for the PWM object.boolean
isAlive()
Check if the PWM object is currently alive or stopped due to a timeout.boolean
isSafetyEnabled()
Check if motor safety is enabled for this object.void
setExpiration(double timeout)
Set the expiration time for the PWM object.void
setSafetyEnabled(boolean enabled)
void
stopMotor()
Stop the motor associated with this PWM object.-
Methods inherited from class edu.wpi.first.wpilibj.PWM
close, enableDeadbandElimination, getChannel, getPosition, getRaw, getRawBounds, getSpeed, initSendable, setBounds, setDisabled, setPeriodMultiplier, setPosition, setRaw, setSpeed, setZeroLatch
-
Methods inherited from class edu.wpi.first.wpilibj.SendableBase
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
-
-
-
-
Method Detail
-
setExpiration
public void setExpiration(double timeout)
Set the expiration time for the PWM object.- Specified by:
setExpiration
in interfaceMotorSafety
- Parameters:
timeout
- The timeout (in seconds) for this motor object
-
getExpiration
public double getExpiration()
Return the expiration time for the PWM object.- Specified by:
getExpiration
in interfaceMotorSafety
- Returns:
- The expiration time value.
-
isAlive
public boolean isAlive()
Check if the PWM object is currently alive or stopped due to a timeout.- Specified by:
isAlive
in interfaceMotorSafety
- Returns:
- a bool value that is true if the motor has NOT timed out and should still be running.
-
stopMotor
public void stopMotor()
Stop the motor associated with this PWM object. This is called by the MotorSafetyHelper object when it has a timeout for this PWM and needs to stop it from running.- Specified by:
stopMotor
in interfaceMotorSafety
-
isSafetyEnabled
public boolean isSafetyEnabled()
Check if motor safety is enabled for this object.- Specified by:
isSafetyEnabled
in interfaceMotorSafety
- Returns:
- True if motor safety is enforced for this object
-
Feed
@Deprecated public void Feed()
Deprecated.Usefeed()
instead.Feed the MotorSafety timer. This method is called by the subclass motor whenever it updates its speed, thereby resetting the timeout value.
-
feed
public void feed()
Feed the MotorSafety timer. This method is called by the subclass motor whenever it updates its speed, thereby resetting the timeout value.
-
setSafetyEnabled
public void setSafetyEnabled(boolean enabled)
- Specified by:
setSafetyEnabled
in interfaceMotorSafety
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfaceMotorSafety
-
disable
public void disable()
-
-