WPILibC++  2019.1.1-beta-2-39-gff58c51
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
AnalogGyroSim.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/AnalogGyroData.h"
17 
18 namespace frc {
19 namespace sim {
21  public:
22  explicit AnalogGyroSim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
25  bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
28  store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32 
33  double GetAngle() const { return HALSIM_GetAnalogGyroAngle(m_index); }
34 
35  void SetAngle(double angle) { HALSIM_SetAnalogGyroAngle(m_index, angle); }
36 
37  std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
38  bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
41  store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
42  m_index, &CallbackStoreThunk, store.get(), initialNotify));
43  return store;
44  }
45 
46  double GetRate() const { return HALSIM_GetAnalogGyroRate(m_index); }
47 
48  void SetRate(double rate) { HALSIM_SetAnalogGyroRate(m_index, rate); }
49 
50  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
51  NotifyCallback callback, bool initialNotify) {
52  auto store = std::make_unique<CallbackStore>(
53  m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
54  store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
55  m_index, &CallbackStoreThunk, store.get(), initialNotify));
56  return store;
57  }
58 
59  bool GetInitialized() const {
60  return HALSIM_GetAnalogGyroInitialized(m_index);
61  }
62 
63  void SetInitialized(bool initialized) {
64  HALSIM_SetAnalogGyroInitialized(m_index, initialized);
65  }
66 
67  void ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
68 
69  private:
70  int m_index;
71 };
72 } // namespace sim
73 } // namespace frc
74 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: AnalogGyroSim.h:20