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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// 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 "frc/PneumaticsBase.h"
#include "frc/PneumaticsModuleType.h"
#include "frc/simulation/CallbackStore.h"
namespace frc::sim {
class PneumaticsBaseSim {
public:
virtual ~PneumaticsBaseSim() = default;
static std::shared_ptr<PneumaticsBaseSim> GetForType(
int module, PneumaticsModuleType type);
/**
* Check whether the PCM/PH has been initialized.
*
* @return true if initialized
*/
virtual bool GetInitialized() const = 0;
/**
* Define whether the PCM/PH has been initialized.
*
* @param initialized true for initialized
*/
virtual void SetInitialized(bool initialized) = 0;
/**
* Register a callback to be run when the PCM/PH is initialized.
*
* @param callback the callback
* @param initialNotify whether to run the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback.
* Save a reference to this object; it being deconstructed cancels the
* callback.
*/
[[nodiscard]]
virtual std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) = 0;
/**
* Check if the compressor is on.
*
* @return true if the compressor is active
*/
virtual bool GetCompressorOn() const = 0;
/**
* Set whether the compressor is active.
*
* @param compressorOn the new value
*/
virtual void SetCompressorOn(bool compressorOn) = 0;
/**
* Register a callback to be run when the compressor activates.
*
* @param callback the callback
* @param initialNotify whether to run the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback.
* Save a reference to this object; it being deconstructed cancels the
* callback.
*/
[[nodiscard]]
virtual std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
NotifyCallback callback, bool initialNotify) = 0;
/**
* Check the solenoid output on a specific channel.
*
* @param channel the channel to check
* @return the solenoid output
*/
virtual bool GetSolenoidOutput(int channel) const = 0;
/**
* Change the solenoid output on a specific channel.
*
* @param channel the channel to check
* @param solenoidOutput the new solenoid output
*/
virtual void SetSolenoidOutput(int channel, bool solenoidOutput) = 0;
/**
* Register a callback to be run when the solenoid output on a channel
* changes.
*
* @param channel the channel to monitor
* @param callback the callback
* @param initialNotify should the callback be run with the initial value
* @return the {@link CallbackStore} object associated with this callback.
* Save a reference to this object; it being deconstructed cancels the
* callback.
*/
[[nodiscard]]
virtual std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
int channel, NotifyCallback callback, bool initialNotify) = 0;
/**
* Check the value of the pressure switch.
*
* @return the pressure switch value
*/
virtual bool GetPressureSwitch() const = 0;
/**
* Set the value of the pressure switch.
*
* @param pressureSwitch the new value
*/
virtual void SetPressureSwitch(bool pressureSwitch) = 0;
/**
* Register a callback to be run whenever the pressure switch value changes.
*
* @param callback the callback
* @param initialNotify whether the callback should be called with the initial
* value
* @return the {@link CallbackStore} object associated with this callback.
* Save a reference to this object; it being deconstructed cancels the
* callback.
*/
[[nodiscard]]
virtual std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
NotifyCallback callback, bool initialNotify) = 0;
/**
* Read the compressor current.
*
* @return the current of the compressor connected to this module
*/
virtual double GetCompressorCurrent() const = 0;
/**
* Set the compressor current.
*
* @param compressorCurrent the new compressor current
*/
virtual void SetCompressorCurrent(double compressorCurrent) = 0;
/**
* Register a callback to be run whenever the compressor current changes.
*
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the {@link CallbackStore} object associated with this callback.
* Save a reference to this object; it being deconstructed cancels the
* callback.
*/
[[nodiscard]]
virtual std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
NotifyCallback callback, bool initialNotify) = 0;
/**
* Get the current value of all solenoid outputs.
*
* @return the solenoid outputs (1 bit per output)
*/
virtual uint8_t GetAllSolenoidOutputs() const = 0;
/**
* Change all of the solenoid outputs.
*
* @param outputs the new solenoid outputs (1 bit per output)
*/
virtual void SetAllSolenoidOutputs(uint8_t outputs) = 0;
/** Reset all simulation data for this object. */
virtual void ResetData() = 0;
protected:
/// PneumaticsBase index.
const int m_index;
/**
* Constructs a PneumaticsBaseSim with the given index.
*
* @param index The index.
*/
explicit PneumaticsBaseSim(const int index);
/**
* Constructs a PneumaticsBaseSim for the given module.
*
* @param module The module.
*/
explicit PneumaticsBaseSim(const PneumaticsBase& module);
};
} // namespace frc::sim