WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
DoubleSolenoid.hpp
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 "wpi/hal/Types.h"
14
15namespace wpi {
16
17/**
18 * DoubleSolenoid class for running 2 channels of high voltage Digital Output
19 * on a pneumatics module.
20 *
21 * The DoubleSolenoid class is typically used for pneumatics solenoids that
22 * have two positions controlled by two separate channels.
23 */
25 public wpi::util::SendableHelper<DoubleSolenoid> {
26 public:
27 /**
28 * Possible values for a DoubleSolenoid.
29 */
30 enum Value {
31 /// Off position.
33 /// Forward position.
35 /// Reverse position.
37 };
38
39 /**
40 * Constructs a double solenoid for a specified module of a specific module
41 * type.
42 *
43 * @param busId The bus ID.
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 busId, 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 busId The bus ID.
57 * @param moduleType The module type to use.
58 * @param forwardChannel The forward channel on the module to control.
59 * @param reverseChannel The reverse channel on the module to control.
60 */
61 DoubleSolenoid(int busId, PneumaticsModuleType moduleType, int forwardChannel,
62 int reverseChannel);
63
64 ~DoubleSolenoid() override;
65
68
69 /**
70 * Set the value of a solenoid.
71 *
72 * @param value The value to set (Off, Forward or Reverse)
73 */
74 void Set(Value value);
75
76 /**
77 * Read the current value of the solenoid.
78 *
79 * @return The current value of the solenoid.
80 */
81 Value Get() const;
82
83 /**
84 * Toggle the value of the solenoid.
85 *
86 * If the solenoid is set to forward, it'll be set to reverse. If the solenoid
87 * is set to reverse, it'll be set to forward. If the solenoid is set to off,
88 * nothing happens.
89 */
90 void Toggle();
91
92 /**
93 * Get the forward channel.
94 *
95 * @return the forward channel.
96 */
97 int GetFwdChannel() const;
98
99 /**
100 * Get the reverse channel.
101 *
102 * @return the reverse channel.
103 */
104 int GetRevChannel() const;
105
106 /**
107 * Check if the forward solenoid is Disabled.
108 *
109 * If a solenoid is shorted, it is added to the DisabledList and disabled
110 * until power cycle, or until faults are cleared.
111 *
112 * @see ClearAllStickyFaults()
113 * @return If solenoid is disabled due to short.
114 */
116
117 /**
118 * Check if the reverse solenoid is Disabled.
119 *
120 * If a solenoid is shorted, it is added to the DisabledList and disabled
121 * until power cycle, or until faults are cleared.
122 *
123 * @see ClearAllStickyFaults()
124 * @return If solenoid is disabled due to short.
125 */
127
129
130 private:
131 std::shared_ptr<PneumaticsBase> m_module;
132 int m_forwardChannel; // The forward channel on the module to control.
133 int m_reverseChannel; // The reverse channel on the module to control.
134 int m_forwardMask; // The mask for the forward channel.
135 int m_reverseMask; // The mask for the reverse channel.
136 int m_mask;
137};
138
139} // namespace wpi
bool IsRevSolenoidDisabled() const
Check if the reverse solenoid is Disabled.
Value Get() const
Read the current value of the solenoid.
int GetFwdChannel() const
Get the forward channel.
void Set(Value value)
Set the value of a solenoid.
void Toggle()
Toggle the value of the solenoid.
Value
Possible values for a DoubleSolenoid.
Definition DoubleSolenoid.hpp:30
@ kOff
Off position.
Definition DoubleSolenoid.hpp:32
@ kReverse
Reverse position.
Definition DoubleSolenoid.hpp:36
@ kForward
Forward position.
Definition DoubleSolenoid.hpp:34
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
DoubleSolenoid(DoubleSolenoid &&)=default
bool IsFwdSolenoidDisabled() const
Check if the forward solenoid is Disabled.
DoubleSolenoid(int busId, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a default module of a specific module type.
DoubleSolenoid(int busId, int module, PneumaticsModuleType moduleType, int forwardChannel, int reverseChannel)
Constructs a double solenoid for a specified module of a specific module type.
int GetRevChannel() const
Get the reverse channel.
DoubleSolenoid & operator=(DoubleSolenoid &&)=default
~DoubleSolenoid() override
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.hpp:21
Interface for Sendable objects.
Definition Sendable.hpp:16
Definition CvSource.hpp:15
PneumaticsModuleType
Pneumatics module type.
Definition PneumaticsModuleType.hpp:11