WPILibC++ 2024.3.1
frc::Solenoid Class Reference

Solenoid class for running high voltage Digital Output on a pneumatics module. More...

#include <frc/Solenoid.h>

Inheritance diagram for frc::Solenoid:
wpi::Sendable wpi::SendableHelper< Solenoid >

Public Member Functions

 Solenoid (int module, PneumaticsModuleType moduleType, int channel)
 Constructs a solenoid for a specified module and type. More...
 
 Solenoid (PneumaticsModuleType moduleType, int channel)
 Constructs a solenoid for a default module and specified type. More...
 
 ~Solenoid () override
 
 Solenoid (Solenoid &&)=default
 
Solenoidoperator= (Solenoid &&)=default
 
virtual void Set (bool on)
 Set the value of a solenoid. More...
 
virtual bool Get () const
 Read the current value of the solenoid. More...
 
void Toggle ()
 Toggle the value of the solenoid. More...
 
int GetChannel () const
 Get the channel this solenoid is connected to. More...
 
bool IsDisabled () const
 Check if solenoid is Disabled. More...
 
void SetPulseDuration (units::second_t duration)
 Set the pulse duration in the pneumatics module. More...
 
void StartPulse ()
 Trigger the pneumatics module to generate a pulse of the duration set in setPulseDuration. More...
 
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< Solenoid >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::SendableHelper< Solenoid >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

Solenoid class for running high voltage Digital Output on a pneumatics module.

The Solenoid class is typically used for pneumatics solenoids, but could be used for any device within the current spec of the module.

Constructor & Destructor Documentation

◆ Solenoid() [1/3]

frc::Solenoid::Solenoid ( int  module,
PneumaticsModuleType  moduleType,
int  channel 
)

Constructs a solenoid for a specified module and type.

Parameters
moduleThe module ID to use.
moduleTypeThe module type to use.
channelThe channel the solenoid is on.

◆ Solenoid() [2/3]

frc::Solenoid::Solenoid ( PneumaticsModuleType  moduleType,
int  channel 
)

Constructs a solenoid for a default module and specified type.

Parameters
moduleTypeThe module type to use.
channelThe channel the solenoid is on.

◆ ~Solenoid()

frc::Solenoid::~Solenoid ( )
override

◆ Solenoid() [3/3]

frc::Solenoid::Solenoid ( Solenoid &&  )
default

Member Function Documentation

◆ Get()

virtual bool frc::Solenoid::Get ( ) const
virtual

Read the current value of the solenoid.

Returns
The current value of the solenoid.

◆ GetChannel()

int frc::Solenoid::GetChannel ( ) const

Get the channel this solenoid is connected to.

◆ InitSendable()

void frc::Solenoid::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ IsDisabled()

bool frc::Solenoid::IsDisabled ( ) const

Check if solenoid is Disabled.

If a solenoid is shorted, it is added to the DisabledList and disabled until power cycle, or until faults are cleared.

See also
ClearAllPCMStickyFaults()
Returns
If solenoid is disabled due to short.

◆ operator=()

Solenoid & frc::Solenoid::operator= ( Solenoid &&  )
default

◆ Set()

virtual void frc::Solenoid::Set ( bool  on)
virtual

Set the value of a solenoid.

Parameters
onTurn the solenoid output off or on.

◆ SetPulseDuration()

void frc::Solenoid::SetPulseDuration ( units::second_t  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
durationThe duration of the pulse.
See also
startPulse()

◆ StartPulse()

void frc::Solenoid::StartPulse ( )

Trigger the pneumatics module to generate a pulse of the duration set in setPulseDuration.

See also
setPulseDuration()

◆ Toggle()

void frc::Solenoid::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.


The documentation for this class was generated from the following file: