Package edu.wpi.first.wpilibj
Class Solenoid
- java.lang.Object
-
- edu.wpi.first.wpilibj.SolenoidBase
-
- edu.wpi.first.wpilibj.Solenoid
-
- All Implemented Interfaces:
Sendable,AutoCloseable
public class Solenoid extends SolenoidBase implements Sendable, AutoCloseable
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 voidclose()booleanget()Read the current value of the solenoid.voidinitSendable(SendableBuilder builder)Initializes thisSendableobject.booleanisBlackListed()Check if solenoid is blacklisted.voidset(boolean on)Set the value of a solenoid.voidsetPulseDuration(double durationSeconds)Set the pulse duration in the PCM.voidstartPulse()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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.wpilibj.Sendable
addChild, getName, getSubsystem, setName, 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:
closein interfaceAutoCloseable
-
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:SendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- sendable builder
-
-