WPILibC++ 2023.4.3
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:
29
30 /**
31 * Constructs a double solenoid for a specified module of a specific module
32 * type.
33 *
34 * @param module The module of the solenoid module to use.
35 * @param moduleType The module type to use.
36 * @param forwardChannel The forward channel on the module to control.
37 * @param reverseChannel The reverse channel on the module to control.
38 */
39 DoubleSolenoid(int module, PneumaticsModuleType moduleType,
40 int forwardChannel, int reverseChannel);
41
42 /**
43 * Constructs a double solenoid for a default module of a specific module
44 * type.
45 *
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(PneumaticsModuleType moduleType, int forwardChannel,
51 int reverseChannel);
52
53 ~DoubleSolenoid() override;
54
57
58 /**
59 * Set the value of a solenoid.
60 *
61 * @param value The value to set (Off, Forward or Reverse)
62 */
63 virtual void Set(Value value);
64
65 /**
66 * Read the current value of the solenoid.
67 *
68 * @return The current value of the solenoid.
69 */
70 virtual Value Get() const;
71
72 /**
73 * Toggle the value of the solenoid.
74 *
75 * If the solenoid is set to forward, it'll be set to reverse. If the solenoid
76 * is set to reverse, it'll be set to forward. If the solenoid is set to off,
77 * nothing happens.
78 */
79 void Toggle();
80
81 /**
82 * Get the forward channel.
83 *
84 * @return the forward channel.
85 */
86 int GetFwdChannel() const;
87
88 /**
89 * Get the reverse channel.
90 *
91 * @return the reverse channel.
92 */
93 int GetRevChannel() const;
94
95 /**
96 * Check if the forward solenoid is Disabled.
97 *
98 * If a solenoid is shorted, it is added to the DisabledList and disabled
99 * until power cycle, or until faults are cleared.
100 *
101 * @see ClearAllPCMStickyFaults()
102 * @return If solenoid is disabled due to short.
103 */
105
106 /**
107 * Check if the reverse 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 ClearAllPCMStickyFaults()
113 * @return If solenoid is disabled due to short.
114 */
116
117 void InitSendable(wpi::SendableBuilder& builder) override;
118
119 private:
120 std::shared_ptr<PneumaticsBase> m_module;
121 int m_forwardChannel; // The forward channel on the module to control.
122 int m_reverseChannel; // The reverse channel on the module to control.
123 int m_forwardMask; // The mask for the forward channel.
124 int m_reverseMask; // The mask for the reverse channel.
125 int m_mask;
126};
127
128} // 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.
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.
virtual Value Get() const
Read the current value of the 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
Definition: DoubleSolenoid.h:28
@ kOff
Definition: DoubleSolenoid.h:28
@ kReverse
Definition: DoubleSolenoid.h:28
@ kForward
Definition: DoubleSolenoid.h:28
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
virtual void Set(Value value)
Set the value of a solenoid.
int GetRevChannel() const
Get the reverse channel.
DoubleSolenoid & operator=(DoubleSolenoid &&)=default
Definition: core.h:1240
Definition: SendableBuilder.h:18
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Interface for Sendable objects.
Definition: Sendable.h:16
Definition: AprilTagFieldLayout.h:22
PneumaticsModuleType
Definition: PneumaticsModuleType.h:8