WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
Solenoid.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"
12#include "wpi/units/time.hpp"
15
16namespace wpi {
17
18/**
19 * Solenoid class for running high voltage Digital Output on a pneumatics
20 * module.
21 *
22 * The Solenoid class is typically used for pneumatics solenoids, but could be
23 * used for any device within the current spec of the module.
24 */
26 public wpi::util::SendableHelper<Solenoid> {
27 public:
28 /**
29 * Constructs a solenoid for a specified module and type.
30 *
31 * @param busId The bus ID.
32 * @param module The module ID to use.
33 * @param moduleType The module type to use.
34 * @param channel The channel the solenoid is on.
35 */
36 Solenoid(int busId, int module, PneumaticsModuleType moduleType, int channel);
37
38 /**
39 * Constructs a solenoid for a default module and specified type.
40 *
41 * @param busId The bus ID.
42 * @param moduleType The module type to use.
43 * @param channel The channel the solenoid is on.
44 */
45 Solenoid(int busId, PneumaticsModuleType moduleType, int channel);
46
47 ~Solenoid() override;
48
49 Solenoid(Solenoid&&) = default;
51
52 /**
53 * Set the value of a solenoid.
54 *
55 * @param on Turn the solenoid output off or on.
56 */
57 void Set(bool on);
58
59 /**
60 * Read the current value of the solenoid.
61 *
62 * @return The current value of the solenoid.
63 */
64 bool Get() const;
65
66 /**
67 * Toggle the value of the solenoid.
68 *
69 * If the solenoid is set to on, it'll be turned off. If the solenoid is set
70 * to off, it'll be turned on.
71 */
72 void Toggle();
73
74 /**
75 * Get the channel this solenoid is connected to.
76 */
77 int GetChannel() const;
78
79 /**
80 * Check if solenoid is Disabled.
81 *
82 * If a solenoid is shorted, it is added to the DisabledList and
83 * disabled until power cycle, or until faults are cleared.
84 *
85 * @see ClearAllPCMStickyFaults()
86 *
87 * @return If solenoid is disabled due to short.
88 */
89 bool IsDisabled() const;
90
91 /**
92 * Set the pulse duration in the pneumatics module. This is used in
93 * conjunction with the startPulse method to allow the pneumatics module to
94 * control the timing of a pulse.
95 *
96 * On the PCM, the timing can be controlled in 0.01 second increments, with a
97 * maximum of 2.55 seconds. On the PH, the timing can be controlled in 0.001
98 * second increments, with a maximum of 65.534 seconds.
99 *
100 * @param duration The duration of the pulse.
101 *
102 * @see startPulse()
103 */
104 void SetPulseDuration(wpi::units::second_t duration);
105
106 /**
107 * %Trigger the pneumatics module to generate a pulse of the duration set in
108 * setPulseDuration.
109 *
110 * @see setPulseDuration()
111 */
113
115
116 private:
117 std::shared_ptr<PneumaticsBase> m_module;
118 int m_mask;
119 int m_channel;
120};
121
122} // namespace wpi
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or glfw and nanopb were modified for use in Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based on(or derived from) the Work and for which the editorial revisions
Solenoid(int busId, PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a default module and specified type.
bool Get() const
Read the current value of the solenoid.
~Solenoid() override
void SetPulseDuration(wpi::units::second_t duration)
Set the pulse duration in the pneumatics module.
Solenoid & operator=(Solenoid &&)=default
void InitSendable(wpi::util::SendableBuilder &builder) override
Initializes this Sendable object.
void Set(bool on)
Set the value of a solenoid.
void StartPulse()
Trigger the pneumatics module to generate a pulse of the duration set in setPulseDuration.
bool IsDisabled() const
Check if solenoid is Disabled.
void Toggle()
Toggle the value of the solenoid.
Solenoid(Solenoid &&)=default
Solenoid(int busId, int module, PneumaticsModuleType moduleType, int channel)
Constructs a solenoid for a specified module and type.
int GetChannel() const
Get the channel this solenoid is connected to.
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