WPILibC++  2018.4.1-20180729181730-1145-g898076f
 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  double GetAngle() { return HALSIM_GetAnalogGyroAngle(m_index); }
33  void SetAngle(double angle) { HALSIM_SetAnalogGyroAngle(m_index, angle); }
34 
35  std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
36  bool initialNotify) {
37  auto store = std::make_unique<CallbackStore>(
38  m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
39  store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
40  m_index, &CallbackStoreThunk, store.get(), initialNotify));
41  return store;
42  }
43  double GetRate() { return HALSIM_GetAnalogGyroRate(m_index); }
44  void SetRate(double rate) { HALSIM_SetAnalogGyroRate(m_index, rate); }
45 
46  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
47  NotifyCallback callback, bool initialNotify) {
48  auto store = std::make_unique<CallbackStore>(
49  m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
50  store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
51  m_index, &CallbackStoreThunk, store.get(), initialNotify));
52  return store;
53  }
54  bool GetInitialized() { return HALSIM_GetAnalogGyroInitialized(m_index); }
55  void SetInitialized(bool initialized) {
56  HALSIM_SetAnalogGyroInitialized(m_index, initialized);
57  }
58 
59  void ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
60 
61  private:
62  int m_index;
63 };
64 } // namespace sim
65 } // namespace frc
66 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: AnalogGyroSim.h:20