WPILibC++ 2023.4.3-108-ge5452e3
REVPHSim.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
12
13namespace frc {
14
15class Compressor;
16
17namespace sim {
18
19/**
20 * Class to control a simulated Pneumatic Control Module (PCM).
21 */
23 public:
24 /**
25 * Constructs with the default PCM module number (CAN ID).
26 */
28
29 /**
30 * Constructs from a PCM module number (CAN ID).
31 *
32 * @param module module number
33 */
34 explicit REVPHSim(int module);
35
36 explicit REVPHSim(const PneumaticsBase& pneumatics);
37
38 ~REVPHSim() override = default;
39
40 [[nodiscard]]
41 std::unique_ptr<CallbackStore> RegisterInitializedCallback(
42 NotifyCallback callback, bool initialNotify) override;
43
44 bool GetInitialized() const override;
45
46 void SetInitialized(bool solenoidInitialized) override;
47
48 [[nodiscard]]
49 std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
50 int channel, NotifyCallback callback, bool initialNotify) override;
51
52 bool GetSolenoidOutput(int channel) const override;
53
54 void SetSolenoidOutput(int channel, bool solenoidOutput) override;
55
56 [[nodiscard]]
57 std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
58 NotifyCallback callback, bool initialNotify) override;
59
60 /**
61 * Check if the compressor is on.
62 *
63 * @return true if the compressor is active
64 */
65 bool GetCompressorOn() const override;
66
67 /**
68 * Set whether the compressor is active.
69 *
70 * @param compressorOn the new value
71 */
72 void SetCompressorOn(bool compressorOn) override;
73
74 /**
75 * Register a callback to be run whenever the closed loop state changes.
76 *
77 * @param callback the callback
78 * @param initialNotify whether the callback should be called with the
79 * initial value
80 * @return the CallbackStore object associated with this callback
81 */
82 [[nodiscard]]
83 std::unique_ptr<CallbackStore> RegisterCompressorConfigTypeCallback(
84 NotifyCallback callback, bool initialNotify);
85
86 /**
87 * Check whether the closed loop compressor control is active.
88 *
89 * @return compressor config type
90 */
92
93 /**
94 * Turn on/off the closed loop control of the compressor.
95 *
96 * @param compressorConfigType compressor config type
97 */
98 void SetCompressorConfigType(int compressorConfigType);
99
100 [[nodiscard]]
101 std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
102 NotifyCallback callback, bool initialNotify) override;
103
104 bool GetPressureSwitch() const override;
105
106 void SetPressureSwitch(bool pressureSwitch) override;
107
108 [[nodiscard]]
109 std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
110 NotifyCallback callback, bool initialNotify) override;
111
112 double GetCompressorCurrent() const override;
113
114 void SetCompressorCurrent(double compressorCurrent) override;
115
117
118 void SetAllSolenoidOutputs(uint8_t outputs) override;
119
120 void ResetData() override;
121};
122} // namespace sim
123} // namespace frc
Definition: PneumaticsBase.h:21
Definition: PneumaticsBaseSim.h:15
Class to control a simulated Pneumatic Control Module (PCM).
Definition: REVPHSim.h:22
void SetCompressorConfigType(int compressorConfigType)
Turn on/off the closed loop control of the compressor.
void SetCompressorCurrent(double compressorCurrent) override
Set the compressor current.
REVPHSim(const PneumaticsBase &pneumatics)
std::unique_ptr< CallbackStore > RegisterPressureSwitchCallback(NotifyCallback callback, bool initialNotify) override
Register a callback to be run whenever the pressure switch value changes.
int GetCompressorConfigType() const
Check whether the closed loop compressor control is active.
REVPHSim(int module)
Constructs from a PCM module number (CAN ID).
bool GetSolenoidOutput(int channel) const override
Check the solenoid output on a specific channel.
std::unique_ptr< CallbackStore > RegisterInitializedCallback(NotifyCallback callback, bool initialNotify) override
Register a callback to be run when the PCM/PH is initialized.
void ResetData() override
Reset all simulation data for this object.
~REVPHSim() override=default
std::unique_ptr< CallbackStore > RegisterCompressorOnCallback(NotifyCallback callback, bool initialNotify) override
Register a callback to be run when the compressor activates.
double GetCompressorCurrent() const override
Read the compressor current.
std::unique_ptr< CallbackStore > RegisterCompressorConfigTypeCallback(NotifyCallback callback, bool initialNotify)
Register a callback to be run whenever the closed loop state changes.
REVPHSim()
Constructs with the default PCM module number (CAN ID).
void SetInitialized(bool solenoidInitialized) override
Define whether the PCM/PH has been initialized.
void SetAllSolenoidOutputs(uint8_t outputs) override
Change all of the solenoid outputs.
std::unique_ptr< CallbackStore > RegisterSolenoidOutputCallback(int channel, NotifyCallback callback, bool initialNotify) override
Register a callback to be run when the solenoid output on a channel changes.
void SetCompressorOn(bool compressorOn) override
Set whether the compressor is active.
bool GetCompressorOn() const override
Check if the compressor is on.
void SetSolenoidOutput(int channel, bool solenoidOutput) override
Change the solenoid output on a specific channel.
std::unique_ptr< CallbackStore > RegisterCompressorCurrentCallback(NotifyCallback callback, bool initialNotify) override
Register a callback to be run whenever the compressor current changes.
uint8_t GetAllSolenoidOutputs() const override
Get the current value of all solenoid outputs.
bool GetInitialized() const override
Check whether the PCM/PH has been initialized.
void SetPressureSwitch(bool pressureSwitch) override
Set the value of the pressure switch.
bool GetPressureSwitch() const override
Check the value of the pressure switch.
::uint8_t uint8_t
Definition: Meta.h:52
std::function< void(std::string_view, const HAL_Value *)> NotifyCallback
Definition: CallbackStore.h:14
Definition: AprilTagPoseEstimator.h:15