WPILibC++  2020.3.2
Solenoid.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <hal/Types.h>
11 
12 #include "frc/SolenoidBase.h"
13 #include "frc/smartdashboard/Sendable.h"
14 #include "frc/smartdashboard/SendableHelper.h"
15 
16 namespace frc {
17 
18 class SendableBuilder;
19 
26 class Solenoid : public SolenoidBase,
27  public Sendable,
28  public SendableHelper<Solenoid> {
29  public:
35  explicit Solenoid(int channel);
36 
43  Solenoid(int moduleNumber, int channel);
44 
45  ~Solenoid() override;
46 
47  Solenoid(Solenoid&&) = default;
48  Solenoid& operator=(Solenoid&&) = default;
49 
55  virtual void Set(bool on);
56 
62  virtual bool Get() const;
63 
74  bool IsBlackListed() const;
75 
86  void SetPulseDuration(double durationSeconds);
87 
94  void StartPulse();
95 
96  void InitSendable(SendableBuilder& builder) override;
97 
98  private:
99  hal::Handle<HAL_SolenoidHandle> m_solenoidHandle;
100  int m_channel; // The channel on the module to control
101 };
102 
103 } // namespace frc
frc::Solenoid::Set
virtual void Set(bool on)
Set the value of a solenoid.
frc::Solenoid::IsBlackListed
bool IsBlackListed() const
Check if solenoid is blacklisted.
frc::Solenoid::Get
virtual bool Get() const
Read the current value of the solenoid.
frc::Solenoid::StartPulse
void StartPulse()
Trigger the PCM to generate a pulse of the duration set in setPulseDuration.
frc::Solenoid
Solenoid class for running high voltage Digital Output (PCM).
Definition: Solenoid.h:26
frc::SolenoidBase
SolenoidBase class is the common base class for the Solenoid and DoubleSolenoid classes.
Definition: SolenoidBase.h:18
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::Solenoid::Solenoid
Solenoid(int channel)
Constructor using the default PCM ID (0).
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23
frc::Solenoid::SetPulseDuration
void SetPulseDuration(double durationSeconds)
Set the pulse duration in the PCM.
frc::Solenoid::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.