WPILibC++ 2027.0.0-alpha-2
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 busId The bus ID.
45 * @param module The module of the solenoid module to use.
46 * @param moduleType The module type to use.
47 * @param forwardChannel The forward channel on the module to control.
48 * @param reverseChannel The reverse channel on the module to control.
49 */
50 DoubleSolenoid(int busId, int module, PneumaticsModuleType moduleType,
51 int forwardChannel, int reverseChannel);
52
53 /**
54 * Constructs a double solenoid for a default module of a specific module
55 * type.
56 *
57 * @param busId The bus ID.
58 * @param moduleType The module type to use.
59 * @param forwardChannel The forward channel on the module to control.
60 * @param reverseChannel The reverse channel on the module to control.
61 */
62 DoubleSolenoid(int busId, PneumaticsModuleType moduleType, int forwardChannel,
63 int reverseChannel);
64
65 ~DoubleSolenoid() override;
66
69
70 /**
71 * Set the value of a solenoid.
72 *
73 * @param value The value to set (Off, Forward or Reverse)
74 */
75 void Set(Value value);
76
77 /**
78 * Read the current value of the solenoid.
79 *
80 * @return The current value of the solenoid.
81 */
82 Value Get() const;
83
84 /**
85 * Toggle the value of the solenoid.
86 *
87 * If the solenoid is set to forward, it'll be set to reverse. If the solenoid
88 * is set to reverse, it'll be set to forward. If the solenoid is set to off,
89 * nothing happens.
90 */
91 void Toggle();
92
93 /**
94 * Get the forward channel.
95 *
96 * @return the forward channel.
97 */
98 int GetFwdChannel() const;
99
100 /**
101 * Get the reverse channel.
102 *
103 * @return the reverse channel.
104 */
105 int GetRevChannel() const;
106
107 /**
108 * Check if the forward solenoid is Disabled.
109 *
110 * If a solenoid is shorted, it is added to the DisabledList and disabled
111 * until power cycle, or until faults are cleared.
112 *
113 * @see ClearAllStickyFaults()
114 * @return If solenoid is disabled due to short.
115 */
117
118 /**
119 * Check if the reverse solenoid is Disabled.
120 *
121 * If a solenoid is shorted, it is added to the DisabledList and disabled
122 * until power cycle, or until faults are cleared.
123 *
124 * @see ClearAllStickyFaults()
125 * @return If solenoid is disabled due to short.
126 */
128
129 void InitSendable(wpi::SendableBuilder& builder) override;
130
131 private:
132 std::shared_ptr<PneumaticsBase> m_module;
133 int m_forwardChannel; // The forward channel on the module to control.
134 int m_reverseChannel; // The reverse channel on the module to control.
135 int m_forwardMask; // The mask for the forward channel.
136 int m_reverseMask; // The mask for the reverse channel.
137 int m_mask;
138};
139
140} // 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.
bool IsRevSolenoidDisabled() const
Check if the reverse solenoid is Disabled.
DoubleSolenoid(DoubleSolenoid &&)=default
void Toggle()
Toggle the value of the solenoid.
DoubleSolenoid(int busId, int module, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a specified module of a specific module type.
void Set(Value value)
Set the value of a solenoid.
int GetFwdChannel() const
Get the forward channel.
~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
DoubleSolenoid(int busId, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a default module of a specific module type.
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 SystemServer.h:9
PneumaticsModuleType
Pneumatics module type.
Definition PneumaticsModuleType.h:11