Class Solenoid
java.lang.Object
org.wpilib.hardware.pneumatic.Solenoid
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
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
ConstructorsConstructorDescriptionSolenoid(CANPort busId, int module, PneumaticsModuleType moduleType, int channel) Constructs a solenoid for a specified module and type.Solenoid(CANPort busId, PneumaticsModuleType moduleType, int channel) Constructs a solenoid for a default module and specified type. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanget()Read the current value of the solenoid.intGet the channel this solenoid is connected to.Gets the telemetry table type.booleanCheck if solenoid is DisabledListed.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.voidset(boolean on) Set the value of a solenoid.voidsetPulseDuration(double duration) Set the pulse duration in the pneumatics module.voidTrigger the pneumatics module to generate a pulse of the duration set in setPulseDuration.voidtoggle()Toggle the value of the solenoid.
-
Constructor Details
-
Solenoid
Constructs a solenoid for a default module and specified type.- Parameters:
busId- The bus IDmoduleType- The module type to use.channel- The channel the solenoid is on.
-
Solenoid
Constructs a solenoid for a specified module and type.- Parameters:
busId- The bus IDmodule- The module ID to use.moduleType- The module type to use.channel- The channel the solenoid is on.
-
-
Method Details
-
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.
-
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 duration) Set the pulse duration in the pneumatics module. This is used in conjunction with the startPulse method to allow the pneumatics module to control the timing of a pulse.On the PCM, the timing can be controlled in 0.01 second increments, with a maximum of 2.55 seconds.
On the PH, the timing can be controlled in 0.001 second increments, with a maximum of 65.534 seconds.
- Parameters:
duration- The duration of the pulse in seconds.- See Also:
-
startPulse
public void startPulse()Trigger the pneumatics module to generate a pulse of the duration set in setPulseDuration.- See Also:
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-