Package edu.wpi.first.wpilibj
Class Solenoid
- java.lang.Object
-
- edu.wpi.first.wpilibj.SendableBase
-
- edu.wpi.first.wpilibj.SolenoidBase
-
- edu.wpi.first.wpilibj.Solenoid
-
- All Implemented Interfaces:
Sendable
,AutoCloseable
public class Solenoid extends SolenoidBase
Solenoid class for running high voltage Digital Output on the PCM.The Solenoid class is typically used for pneumatic solenoids, but could be used for any device within the current spec of the PCM.
-
-
Field Summary
-
Fields inherited from class edu.wpi.first.wpilibj.SolenoidBase
m_moduleNumber
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
get()
Read the current value of the solenoid.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.boolean
isBlackListed()
Check if solenoid is blacklisted.void
set(boolean on)
Set the value of a solenoid.void
setPulseDuration(double durationSeconds)
Set the pulse duration in the PCM.void
startPulse()
Trigger the PCM to generate a pulse of the duration set in setPulseDuration.-
Methods inherited from class edu.wpi.first.wpilibj.SolenoidBase
clearAllPCMStickyFaults, clearAllPCMStickyFaults, getAll, getAll, getPCMSolenoidBlackList, getPCMSolenoidBlackList, getPCMSolenoidVoltageFault, getPCMSolenoidVoltageFault, getPCMSolenoidVoltageStickyFault, getPCMSolenoidVoltageStickyFault
-
Methods inherited from class edu.wpi.first.wpilibj.SendableBase
addChild, free, getName, getSubsystem, setName, setName, setName, setSubsystem
-
-
-
-
Constructor Detail
-
Solenoid
public Solenoid(int channel)
Constructor using the default PCM ID (defaults to 0).- Parameters:
channel
- The channel on the PCM to control (0..7).
-
Solenoid
public Solenoid(int moduleNumber, int channel)
Constructor.- Parameters:
moduleNumber
- The CAN ID of the PCM the solenoid is attached to.channel
- The channel on the PCM to control (0..7).
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Overrides:
close
in classSendableBase
-
set
public void set(boolean on)
Set the value of a solenoid.- Parameters:
on
- True will turn the solenoid output on. False will turn the solenoid output off.
-
get
public boolean get()
Read the current value of the solenoid.- Returns:
- True if the solenoid output is on or false if the solenoid output is off.
-
isBlackListed
public boolean isBlackListed()
Check if solenoid is blacklisted. If a solenoid is shorted, it is added to the blacklist and disabled until power cycle, or until faults are cleared.- Returns:
- If solenoid is disabled due to short.
- See Also:
SolenoidBase.clearAllPCMStickyFaults()
-
setPulseDuration
public void setPulseDuration(double durationSeconds)
Set the pulse duration in the PCM. This is used in conjunction with the startPulse method to allow the PCM to control the timing of a pulse. The timing can be controlled in 0.01 second increments.- Parameters:
durationSeconds
- The duration of the pulse, from 0.01 to 2.55 seconds.- See Also:
startPulse()
-
startPulse
public void startPulse()
Trigger the PCM to generate a pulse of the duration set in setPulseDuration.- See Also:
setPulseDuration(double)
-
initSendable
public void initSendable(SendableBuilder builder)
Description copied from interface:Sendable
Initializes thisSendable
object.- Parameters:
builder
- sendable builder
-
-