1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <memory>
#include <hal/Types.h>
#include <units/time.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
#include "frc/PneumaticsBase.h"
#include "frc/PneumaticsModuleType.h"
namespace frc {
/**
* Solenoid class for running high voltage Digital Output on a pneumatics
* module.
*
* The Solenoid class is typically used for pneumatics solenoids, but could be
* used for any device within the current spec of the module.
*/
class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
public:
/**
* Constructs a solenoid for a specified module and type.
*
* @param module The module ID to use.
* @param moduleType The module type to use.
* @param channel The channel the solenoid is on.
*/
Solenoid(int module, PneumaticsModuleType moduleType, int channel);
/**
* Constructs a solenoid for a default module and specified type.
*
* @param moduleType The module type to use.
* @param channel The channel the solenoid is on.
*/
Solenoid(PneumaticsModuleType moduleType, int channel);
~Solenoid() override;
Solenoid(Solenoid&&) = default;
Solenoid& operator=(Solenoid&&) = default;
/**
* Set the value of a solenoid.
*
* @param on Turn the solenoid output off or on.
*/
void Set(bool on);
/**
* Read the current value of the solenoid.
*
* @return The current value of the solenoid.
*/
bool Get() const;
/**
* Toggle the value of the solenoid.
*
* If the solenoid is set to on, it'll be turned off. If the solenoid is set
* to off, it'll be turned on.
*/
void Toggle();
/**
* Get the channel this solenoid is connected to.
*/
int GetChannel() const;
/**
* Check if solenoid is Disabled.
*
* If a solenoid is shorted, it is added to the DisabledList and
* disabled until power cycle, or until faults are cleared.
*
* @see ClearAllPCMStickyFaults()
*
* @return If solenoid is disabled due to short.
*/
bool IsDisabled() const;
/**
* Set the pulse duration in the pneumatics module. This is used in
* conjunction with the startPulse method to allow the pneumatics module to
* control the timing of a pulse.
*
* On the PCM, the timing can be controlled in 0.01 second increments, with a
* maximum of 2.55 seconds. On the PH, the timing can be controlled in 0.001
* second increments, with a maximum of 65.534 seconds.
*
* @param duration The duration of the pulse.
*
* @see startPulse()
*/
void SetPulseDuration(units::second_t duration);
/**
* %Trigger the pneumatics module to generate a pulse of the duration set in
* setPulseDuration.
*
* @see setPulseDuration()
*/
void StartPulse();
void InitSendable(wpi::SendableBuilder& builder) override;
private:
std::shared_ptr<PneumaticsBase> m_module;
int m_mask;
int m_channel;
};
} // namespace frc