WPILibC++ 2025.3.1
Loading...
Searching...
No Matches
DoubleSolenoid.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <memory>
8
9#include <hal/Types.h>
12
13#include "frc/PneumaticsBase.h"
15
16namespace frc {
17
18/**
19 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
20 * on a pneumatics module.
21 *
22 * The DoubleSolenoid class is typically used for pneumatics solenoids that
23 * have two positions controlled by two separate channels.
24 */
26 public wpi::SendableHelper<DoubleSolenoid> {
27 public:
28 /**
29 * Possible values for a DoubleSolenoid.
30 */
31 enum Value {
32 /// Off position.
34 /// Forward position.
36 /// Reverse position.
38 };
39
40 /**
41 * Constructs a double solenoid for a specified module of a specific module
42 * type.
43 *
44 * @param module The module of the solenoid module to use.
45 * @param moduleType The module type to use.
46 * @param forwardChannel The forward channel on the module to control.
47 * @param reverseChannel The reverse channel on the module to control.
48 */
49 DoubleSolenoid(int module, PneumaticsModuleType moduleType,
50 int forwardChannel, int reverseChannel);
51
52 /**
53 * Constructs a double solenoid for a default module of a specific module
54 * type.
55 *
56 * @param moduleType The module type to use.
57 * @param forwardChannel The forward channel on the module to control.
58 * @param reverseChannel The reverse channel on the module to control.
59 */
60 DoubleSolenoid(PneumaticsModuleType moduleType, int forwardChannel,
61 int reverseChannel);
62
63 ~DoubleSolenoid() override;
64
67
68 /**
69 * Set the value of a solenoid.
70 *
71 * @param value The value to set (Off, Forward or Reverse)
72 */
73 void Set(Value value);
74
75 /**
76 * Read the current value of the solenoid.
77 *
78 * @return The current value of the solenoid.
79 */
80 Value Get() const;
81
82 /**
83 * Toggle the value of the solenoid.
84 *
85 * If the solenoid is set to forward, it'll be set to reverse. If the solenoid
86 * is set to reverse, it'll be set to forward. If the solenoid is set to off,
87 * nothing happens.
88 */
89 void Toggle();
90
91 /**
92 * Get the forward channel.
93 *
94 * @return the forward channel.
95 */
96 int GetFwdChannel() const;
97
98 /**
99 * Get the reverse channel.
100 *
101 * @return the reverse channel.
102 */
103 int GetRevChannel() const;
104
105 /**
106 * Check if the forward solenoid is Disabled.
107 *
108 * If a solenoid is shorted, it is added to the DisabledList and disabled
109 * until power cycle, or until faults are cleared.
110 *
111 * @see ClearAllStickyFaults()
112 * @return If solenoid is disabled due to short.
113 */
115
116 /**
117 * Check if the reverse solenoid is Disabled.
118 *
119 * If a solenoid is shorted, it is added to the DisabledList and disabled
120 * until power cycle, or until faults are cleared.
121 *
122 * @see ClearAllStickyFaults()
123 * @return If solenoid is disabled due to short.
124 */
126
127 void InitSendable(wpi::SendableBuilder& builder) override;
128
129 private:
130 std::shared_ptr<PneumaticsBase> m_module;
131 int m_forwardChannel; // The forward channel on the module to control.
132 int m_reverseChannel; // The reverse channel on the module to control.
133 int m_forwardMask; // The mask for the forward channel.
134 int m_reverseMask; // The mask for the reverse channel.
135 int m_mask;
136};
137
138} // namespace frc
DoubleSolenoid class for running 2 channels of high voltage Digital Output on a pneumatics module.
Definition DoubleSolenoid.h:26
bool IsFwdSolenoidDisabled() const
Check if the forward solenoid is Disabled.
Value Get() const
Read the current value of the solenoid.
DoubleSolenoid(PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a default module of a specific module type.
bool IsRevSolenoidDisabled() const
Check if the reverse solenoid is Disabled.
DoubleSolenoid(DoubleSolenoid &&)=default
void Toggle()
Toggle the value of the solenoid.
void Set(Value value)
Set the value of a solenoid.
int GetFwdChannel() const
Get the forward channel.
DoubleSolenoid(int module, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a specified module of a specific module type.
~DoubleSolenoid() override
Value
Possible values for a DoubleSolenoid.
Definition DoubleSolenoid.h:31
@ kOff
Off position.
Definition DoubleSolenoid.h:33
@ kReverse
Reverse position.
Definition DoubleSolenoid.h:37
@ kForward
Forward position.
Definition DoubleSolenoid.h:35
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
int GetRevChannel() const
Get the reverse channel.
DoubleSolenoid & operator=(DoubleSolenoid &&)=default
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.h:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.h:21
Interface for Sendable objects.
Definition Sendable.h:16
Definition CAN.h:11
PneumaticsModuleType
Pneumatics module type.
Definition PneumaticsModuleType.h:11