WPILibC++  2018.4.1-20180927001728-1207-gd5d744a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
AnalogOutSim.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/AnalogOutData.h"
17 
18 namespace frc {
19 namespace sim {
20 class AnalogOutSim {
21  public:
22  explicit AnalogOutSim(int index) { m_index = index; }
23 
24  std::unique_ptr<CallbackStore> RegisterVoltageCallback(
25  NotifyCallback callback, bool initialNotify) {
26  auto store = std::make_unique<CallbackStore>(
27  m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
28  store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32 
33  double GetVoltage() const { return HALSIM_GetAnalogOutVoltage(m_index); }
34 
35  void SetVoltage(double voltage) {
36  HALSIM_SetAnalogOutVoltage(m_index, voltage);
37  }
38 
39  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
40  NotifyCallback callback, bool initialNotify) {
41  auto store = std::make_unique<CallbackStore>(
42  m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
43  store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
44  m_index, &CallbackStoreThunk, store.get(), initialNotify));
45  return store;
46  }
47 
48  bool GetInitialized() const {
49  return HALSIM_GetAnalogOutInitialized(m_index);
50  }
51 
52  void SetInitialized(bool initialized) {
53  HALSIM_SetAnalogOutInitialized(m_index, initialized);
54  }
55 
56  void ResetData() { HALSIM_ResetAnalogOutData(m_index); }
57 
58  private:
59  int m_index;
60 };
61 } // namespace sim
62 } // namespace frc
63 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: AnalogOutSim.h:20