WPILibC++  2019.1.1-beta-2-28-g9903348
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
AnalogTriggerSim.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/AnalogTriggerData.h"
17 
18 namespace frc {
19 namespace sim {
21  public:
22  explicit AnalogTriggerSim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
25  NotifyCallback callback, bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
28  store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32 
33  bool GetInitialized() const {
34  return HALSIM_GetAnalogTriggerInitialized(m_index);
35  }
36 
37  void SetInitialized(bool initialized) {
38  HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
39  }
40 
41  std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
42  NotifyCallback callback, bool initialNotify) {
43  auto store = std::make_unique<CallbackStore>(
44  m_index, -1, callback,
45  &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
46  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
47  m_index, &CallbackStoreThunk, store.get(), initialNotify));
48  return store;
49  }
50 
51  double GetTriggerLowerBound() const {
52  return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
53  }
54 
55  void SetTriggerLowerBound(double triggerLowerBound) {
56  HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
57  }
58 
59  std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
60  NotifyCallback callback, bool initialNotify) {
61  auto store = std::make_unique<CallbackStore>(
62  m_index, -1, callback,
63  &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
64  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
65  m_index, &CallbackStoreThunk, store.get(), initialNotify));
66  return store;
67  }
68 
69  double GetTriggerUpperBound() const {
70  return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
71  }
72 
73  void SetTriggerUpperBound(double triggerUpperBound) {
74  HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
75  }
76 
77  void ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
78 
79  private:
80  int m_index;
81 };
82 } // namespace sim
83 } // namespace frc
84 #endif // __FRC_ROBORIO__
Definition: AnalogTriggerSim.h:20
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18