WPILibC++  2020.3.2
AnalogTriggerSim.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018-2019 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 #include <memory>
11 #include <utility>
12 
13 #include "CallbackStore.h"
14 #include "mockdata/AnalogTriggerData.h"
15 
16 namespace frc {
17 namespace sim {
19  public:
20  explicit AnalogTriggerSim(int index) { m_index = index; }
21 
22  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
23  NotifyCallback callback, bool initialNotify) {
24  auto store = std::make_unique<CallbackStore>(
25  m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
26  store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
27  m_index, &CallbackStoreThunk, store.get(), initialNotify));
28  return store;
29  }
30 
31  bool GetInitialized() const {
32  return HALSIM_GetAnalogTriggerInitialized(m_index);
33  }
34 
35  void SetInitialized(bool initialized) {
36  HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
37  }
38 
39  std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
40  NotifyCallback callback, bool initialNotify) {
41  auto store = std::make_unique<CallbackStore>(
42  m_index, -1, callback,
43  &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
44  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
45  m_index, &CallbackStoreThunk, store.get(), initialNotify));
46  return store;
47  }
48 
49  double GetTriggerLowerBound() const {
50  return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
51  }
52 
53  void SetTriggerLowerBound(double triggerLowerBound) {
54  HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
55  }
56 
57  std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
58  NotifyCallback callback, bool initialNotify) {
59  auto store = std::make_unique<CallbackStore>(
60  m_index, -1, callback,
61  &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
62  store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
63  m_index, &CallbackStoreThunk, store.get(), initialNotify));
64  return store;
65  }
66 
67  double GetTriggerUpperBound() const {
68  return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
69  }
70 
71  void SetTriggerUpperBound(double triggerUpperBound) {
72  HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
73  }
74 
75  void ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
76 
77  private:
78  int m_index;
79 };
80 } // namespace sim
81 } // namespace frc
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::sim::AnalogTriggerSim
Definition: AnalogTriggerSim.h:18