Package edu.wpi.first.wpilibj
Class Solenoid
- java.lang.Object
-
- edu.wpi.first.wpilibj.Solenoid
-
- All Implemented Interfaces:
Sendable
,AutoCloseable
public class Solenoid extends Object implements Sendable, AutoCloseable
Solenoid class for running high voltage Digital Output on a pneumatics module.The Solenoid class is typically used for pneumatic solenoids, but could be used for any device within the current spec of the module.
-
-
Constructor Summary
Constructors Constructor Description Solenoid(int module, PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a specified module and type.Solenoid(PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a default module and specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
get()
Read the current value of the solenoid.int
getChannel()
Get the channel this solenoid is connected to.void
initSendable(SendableBuilder builder)
Initializes thisSendable
object.boolean
isDisabled()
Check if solenoid is DisabledListed.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.void
toggle()
Toggle the value of the solenoid.
-
-
-
Constructor Detail
-
Solenoid
public Solenoid(PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a default module and specified type.- Parameters:
moduleType
- The module type to use.channel
- The channel the solenoid is on.
-
Solenoid
public Solenoid(int module, PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a specified module and type.- Parameters:
module
- The module ID to use.moduleType
- The module type to use.channel
- The channel the solenoid is on.
-
-
Method Detail
-
close
public void close()
- Specified by:
close
in 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.
-
toggle
public void toggle()
Toggle the value of the solenoid.If the solenoid is set to on, it'll be turned off. If the solenoid is set to off, it'll be turned on.
-
getChannel
public int getChannel()
Get the channel this solenoid is connected to.- Returns:
- The channel this solenoid is connected to.
-
isDisabled
public boolean isDisabled()
Check if solenoid is DisabledListed. If a solenoid is shorted, it is added to the Disabled List and disabled until power cycle, or until faults are cleared.- Returns:
- If solenoid is disabled due to short.
-
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.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-
-