WPILibC++  2018.4.1-20180729181730-1145-g898076f
 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  bool GetInitialized() { return HALSIM_GetAnalogTriggerInitialized(m_index); }
33  void SetInitialized(bool initialized) {
34  HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
35  }
36 
37  std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
38  NotifyCallback callback, bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback,
41  &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
42  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
43  m_index, &CallbackStoreThunk, store.get(), initialNotify));
44  return store;
45  }
46  double GetTriggerLowerBound() {
47  return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
48  }
49  void SetTriggerLowerBound(double triggerLowerBound) {
50  HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
51  }
52 
53  std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
54  NotifyCallback callback, bool initialNotify) {
55  auto store = std::make_unique<CallbackStore>(
56  m_index, -1, callback,
57  &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
58  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
59  m_index, &CallbackStoreThunk, store.get(), initialNotify));
60  return store;
61  }
62  double GetTriggerUpperBound() {
63  return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
64  }
65  void SetTriggerUpperBound(double triggerUpperBound) {
66  HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
67  }
68 
69  void ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
70 
71  private:
72  int m_index;
73 };
74 } // namespace sim
75 } // namespace frc
76 #endif // __FRC_ROBORIO__
Definition: AnalogTriggerSim.h:20
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18