WPILibC++  2018.4.1-20180729123227-1139-ga11fcb6
 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  bool GetSolenoidInitialized(int channel) {
34  return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
35  }
36  void SetSolenoidInitialized(int channel, bool solenoidInitialized) {
37  HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
38  }
39 
40  std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
41  int channel, NotifyCallback callback, bool initialNotify) {
42  auto store = std::make_unique<CallbackStore>(
43  m_index, channel, -1, callback,
44  &HALSIM_CancelPCMSolenoidOutputCallback);
45  store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
46  m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
47  return store;
48  }
49  bool GetSolenoidOutput(int channel) {
50  return HALSIM_GetPCMSolenoidOutput(m_index, channel);
51  }
52  void SetSolenoidOutput(int channel, bool solenoidOutput) {
53  HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
54  }
55 
56  std::unique_ptr<CallbackStore> RegisterCompressorInitializedCallback(
57  NotifyCallback callback, bool initialNotify) {
58  auto store = std::make_unique<CallbackStore>(
59  m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
60  store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
61  m_index, &CallbackStoreThunk, store.get(), initialNotify));
62  return store;
63  }
64  bool GetCompressorInitialized() {
65  return HALSIM_GetPCMCompressorInitialized(m_index);
66  }
67  void SetCompressorInitialized(bool compressorInitialized) {
68  HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
69  }
70 
71  std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
72  NotifyCallback callback, bool initialNotify) {
73  auto store = std::make_unique<CallbackStore>(
74  m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
75  store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
76  m_index, &CallbackStoreThunk, store.get(), initialNotify));
77  return store;
78  }
79  bool GetCompressorOn() { return HALSIM_GetPCMCompressorOn(m_index); }
80  void SetCompressorOn(bool compressorOn) {
81  HALSIM_SetPCMCompressorOn(m_index, compressorOn);
82  }
83 
84  std::unique_ptr<CallbackStore> RegisterClosedLoopEnabledCallback(
85  NotifyCallback callback, bool initialNotify) {
86  auto store = std::make_unique<CallbackStore>(
87  m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
88  store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
89  m_index, &CallbackStoreThunk, store.get(), initialNotify));
90  return store;
91  }
92  bool GetClosedLoopEnabled() {
93  return HALSIM_GetPCMClosedLoopEnabled(m_index);
94  }
95  void SetClosedLoopEnabled(bool closedLoopEnabled) {
96  HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
97  }
98 
99  std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
100  NotifyCallback callback, bool initialNotify) {
101  auto store = std::make_unique<CallbackStore>(
102  m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
103  store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
104  m_index, &CallbackStoreThunk, store.get(), initialNotify));
105  return store;
106  }
107  bool GetPressureSwitch() { return HALSIM_GetPCMPressureSwitch(m_index); }
108  void SetPressureSwitch(bool pressureSwitch) {
109  HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
110  }
111 
112  std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
113  NotifyCallback callback, bool initialNotify) {
114  auto store = std::make_unique<CallbackStore>(
115  m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
116  store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
117  m_index, &CallbackStoreThunk, store.get(), initialNotify));
118  return store;
119  }
120  double GetCompressorCurrent() {
121  return HALSIM_GetPCMCompressorCurrent(m_index);
122  }
123  void SetCompressorCurrent(double compressorCurrent) {
124  HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
125  }
126 
127  void ResetData() { HALSIM_ResetPCMData(m_index); }
128 
129  private:
130  int m_index;
131 };
132 } // namespace sim
133 } // namespace frc
134 #endif // __FRC_ROBORIO__
Definition: SPIAccelerometerSim.h:18
Definition: PCMSim.h:20