WPILibC++  2018.4.1-20180923204725-1195-g5c6b78e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
PCMSim.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #ifndef __FRC_ROBORIO__
11 
12 #include <memory>
13 #include <utility>
14 
15 #include "CallbackStore.h"
16 #include "mockdata/PCMData.h"
17 
18 namespace frc {
19 namespace sim {
20 class PCMSim {
21  public:
22  explicit PCMSim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterSolenoidInitializedCallback(
25  int channel, NotifyCallback callback, bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, channel, -1, callback,
28  &HALSIM_CancelPCMSolenoidInitializedCallback);
29  store->SetUid(HALSIM_RegisterPCMSolenoidInitializedCallback(
30  m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
31  return store;
32  }
33 
34  bool GetSolenoidInitialized(int channel) const {
35  return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
36  }
37 
38  void SetSolenoidInitialized(int channel, bool solenoidInitialized) {
39  HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
40  }
41 
42  std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
43  int channel, NotifyCallback callback, bool initialNotify) {
44  auto store = std::make_unique<CallbackStore>(
45  m_index, channel, -1, callback,
46  &HALSIM_CancelPCMSolenoidOutputCallback);
47  store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
48  m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
49  return store;
50  }
51 
52  bool GetSolenoidOutput(int channel) const {
53  return HALSIM_GetPCMSolenoidOutput(m_index, channel);
54  }
55 
56  void SetSolenoidOutput(int channel, bool solenoidOutput) {
57  HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
58  }
59 
60  std::unique_ptr<CallbackStore> RegisterCompressorInitializedCallback(
61  NotifyCallback callback, bool initialNotify) {
62  auto store = std::make_unique<CallbackStore>(
63  m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
64  store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
65  m_index, &CallbackStoreThunk, store.get(), initialNotify));
66  return store;
67  }
68 
69  bool GetCompressorInitialized() const {
70  return HALSIM_GetPCMCompressorInitialized(m_index);
71  }
72 
73  void SetCompressorInitialized(bool compressorInitialized) {
74  HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
75  }
76 
77  std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
78  NotifyCallback callback, bool initialNotify) {
79  auto store = std::make_unique<CallbackStore>(
80  m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
81  store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
82  m_index, &CallbackStoreThunk, store.get(), initialNotify));
83  return store;
84  }
85 
86  bool GetCompressorOn() const { return HALSIM_GetPCMCompressorOn(m_index); }
87 
88  void SetCompressorOn(bool compressorOn) {
89  HALSIM_SetPCMCompressorOn(m_index, compressorOn);
90  }
91 
92  std::unique_ptr<CallbackStore> RegisterClosedLoopEnabledCallback(
93  NotifyCallback callback, bool initialNotify) {
94  auto store = std::make_unique<CallbackStore>(
95  m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
96  store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
97  m_index, &CallbackStoreThunk, store.get(), initialNotify));
98  return store;
99  }
100 
101  bool GetClosedLoopEnabled() const {
102  return HALSIM_GetPCMClosedLoopEnabled(m_index);
103  }
104 
105  void SetClosedLoopEnabled(bool closedLoopEnabled) {
106  HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
107  }
108 
109  std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
110  NotifyCallback callback, bool initialNotify) {
111  auto store = std::make_unique<CallbackStore>(
112  m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
113  store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
114  m_index, &CallbackStoreThunk, store.get(), initialNotify));
115  return store;
116  }
117 
118  bool GetPressureSwitch() const {
119  return HALSIM_GetPCMPressureSwitch(m_index);
120  }
121 
122  void SetPressureSwitch(bool pressureSwitch) {
123  HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
124  }
125 
126  std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
127  NotifyCallback callback, bool initialNotify) {
128  auto store = std::make_unique<CallbackStore>(
129  m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
130  store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
131  m_index, &CallbackStoreThunk, store.get(), initialNotify));
132  return store;
133  }
134 
135  double GetCompressorCurrent() const {
136  return HALSIM_GetPCMCompressorCurrent(m_index);
137  }
138 
139  void SetCompressorCurrent(double compressorCurrent) {
140  HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
141  }
142 
143  void ResetData() { HALSIM_ResetPCMData(m_index); }
144 
145  private:
146  int m_index;
147 };
148 } // namespace sim
149 } // namespace frc
150 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: PCMSim.h:20