WPILibC++  2019.1.1-beta-2-1-g9bc998f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
RelaySim.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/RelayData.h"
17 
18 namespace frc {
19 namespace sim {
20 class RelaySim {
21  public:
22  explicit RelaySim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterInitializedForwardCallback(
25  NotifyCallback callback, bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback);
28  store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32 
33  bool GetInitializedForward() const {
34  return HALSIM_GetRelayInitializedForward(m_index);
35  }
36 
37  void SetInitializedForward(bool initializedForward) {
38  HALSIM_SetRelayInitializedForward(m_index, initializedForward);
39  }
40 
41  std::unique_ptr<CallbackStore> RegisterInitializedReverseCallback(
42  NotifyCallback callback, bool initialNotify) {
43  auto store = std::make_unique<CallbackStore>(
44  m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback);
45  store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback(
46  m_index, &CallbackStoreThunk, store.get(), initialNotify));
47  return store;
48  }
49 
50  bool GetInitializedReverse() const {
51  return HALSIM_GetRelayInitializedReverse(m_index);
52  }
53 
54  void SetInitializedReverse(bool initializedReverse) {
55  HALSIM_SetRelayInitializedReverse(m_index, initializedReverse);
56  }
57 
58  std::unique_ptr<CallbackStore> RegisterForwardCallback(
59  NotifyCallback callback, bool initialNotify) {
60  auto store = std::make_unique<CallbackStore>(
61  m_index, -1, callback, &HALSIM_CancelRelayForwardCallback);
62  store->SetUid(HALSIM_RegisterRelayForwardCallback(
63  m_index, &CallbackStoreThunk, store.get(), initialNotify));
64  return store;
65  }
66 
67  bool GetForward() const { return HALSIM_GetRelayForward(m_index); }
68 
69  void SetForward(bool forward) { HALSIM_SetRelayForward(m_index, forward); }
70 
71  std::unique_ptr<CallbackStore> RegisterReverseCallback(
72  NotifyCallback callback, bool initialNotify) {
73  auto store = std::make_unique<CallbackStore>(
74  m_index, -1, callback, &HALSIM_CancelRelayReverseCallback);
75  store->SetUid(HALSIM_RegisterRelayReverseCallback(
76  m_index, &CallbackStoreThunk, store.get(), initialNotify));
77  return store;
78  }
79 
80  bool GetReverse() const { return HALSIM_GetRelayReverse(m_index); }
81 
82  void SetReverse(bool reverse) { HALSIM_SetRelayReverse(m_index, reverse); }
83 
84  void ResetData() { HALSIM_ResetRelayData(m_index); }
85 
86  private:
87  int m_index;
88 };
89 } // namespace sim
90 } // namespace frc
91 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: RelaySim.h:20