WPILibC++ 2023.4.3
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]] std::unique_ptr<CallbackStore> RegisterInitializedCallback(
41 NotifyCallback callback, bool initialNotify) override;
42
43 bool GetInitialized() const override;
44
45 void SetInitialized(bool solenoidInitialized) override;
46
47 [[nodiscard]] std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
48 int channel, NotifyCallback callback, bool initialNotify) override;
49
50 bool GetSolenoidOutput(int channel) const override;
51
52 void SetSolenoidOutput(int channel, bool solenoidOutput) override;
53
54 [[nodiscard]] std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
55 NotifyCallback callback, bool initialNotify) override;
56
57 /**
58 * Check if the compressor is on.
59 *
60 * @return true if the compressor is active
61 */
62 bool GetCompressorOn() const override;
63
64 /**
65 * Set whether the compressor is active.
66 *
67 * @param compressorOn the new value
68 */
69 void SetCompressorOn(bool compressorOn) override;
70
71 /**
72 * Register a callback to be run whenever the closed loop state changes.
73 *
74 * @param callback the callback
75 * @param initialNotify whether the callback should be called with the
76 * initial value
77 * @return the CallbackStore object associated with this callback
78 */
79 [[nodiscard]] std::unique_ptr<CallbackStore>
81 bool initialNotify);
82
83 /**
84 * Check whether the closed loop compressor control is active.
85 *
86 * @return compressor config type
87 */
89
90 /**
91 * Turn on/off the closed loop control of the compressor.
92 *
93 * @param compressorConfigType compressor config type
94 */
95 void SetCompressorConfigType(int compressorConfigType);
96
97 [[nodiscard]] std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
98 NotifyCallback callback, bool initialNotify) override;
99
100 bool GetPressureSwitch() const override;
101
102 void SetPressureSwitch(bool pressureSwitch) override;
103
104 [[nodiscard]] std::unique_ptr<CallbackStore>
106 bool initialNotify) override;
107
108 double GetCompressorCurrent() const override;
109
110 void SetCompressorCurrent(double compressorCurrent) override;
111
113
114 void SetAllSolenoidOutputs(uint8_t outputs) override;
115
116 void ResetData() override;
117};
118} // namespace sim
119} // 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: AprilTagFieldLayout.h:22