WPILibC++  2020.3.2
AnalogOutSim.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/AnalogOutData.h"
15 
16 namespace frc {
17 namespace sim {
18 class AnalogOutSim {
19  public:
20  explicit AnalogOutSim(int index) { m_index = index; }
21 
22  std::unique_ptr<CallbackStore> RegisterVoltageCallback(
23  NotifyCallback callback, bool initialNotify) {
24  auto store = std::make_unique<CallbackStore>(
25  m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
26  store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
27  m_index, &CallbackStoreThunk, store.get(), initialNotify));
28  return store;
29  }
30 
31  double GetVoltage() const { return HALSIM_GetAnalogOutVoltage(m_index); }
32 
33  void SetVoltage(double voltage) {
34  HALSIM_SetAnalogOutVoltage(m_index, voltage);
35  }
36 
37  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
38  NotifyCallback callback, bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
41  store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
42  m_index, &CallbackStoreThunk, store.get(), initialNotify));
43  return store;
44  }
45 
46  bool GetInitialized() const {
47  return HALSIM_GetAnalogOutInitialized(m_index);
48  }
49 
50  void SetInitialized(bool initialized) {
51  HALSIM_SetAnalogOutInitialized(m_index, initialized);
52  }
53 
54  void ResetData() { HALSIM_ResetAnalogOutData(m_index); }
55 
56  private:
57  int m_index;
58 };
59 } // namespace sim
60 } // namespace frc
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::sim::AnalogOutSim
Definition: AnalogOutSim.h:18