WPILibC++  2018.4.1-20180729223220-1149-g7bd3f9f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
PDPSim.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/PDPData.h"
17 
18 namespace frc {
19 namespace sim {
20 class PDPSim {
21  public:
22  explicit PDPSim(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_CancelPDPInitializedCallback);
28  store->SetUid(HALSIM_RegisterPDPInitializedCallback(
29  m_index, &CallbackStoreThunk, store.get(), initialNotify));
30  return store;
31  }
32  bool GetInitialized() { return HALSIM_GetPDPInitialized(m_index); }
33  void SetInitialized(bool initialized) {
34  HALSIM_SetPDPInitialized(m_index, initialized);
35  }
36 
37  std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
38  NotifyCallback callback, bool initialNotify) {
39  auto store = std::make_unique<CallbackStore>(
40  m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
41  store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
42  m_index, &CallbackStoreThunk, store.get(), initialNotify));
43  return store;
44  }
45  double GetTemperature() { return HALSIM_GetPDPTemperature(m_index); }
46  void SetTemperature(double temperature) {
47  HALSIM_SetPDPTemperature(m_index, temperature);
48  }
49 
50  std::unique_ptr<CallbackStore> RegisterVoltageCallback(
51  NotifyCallback callback, bool initialNotify) {
52  auto store = std::make_unique<CallbackStore>(
53  m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
54  store->SetUid(HALSIM_RegisterPDPVoltageCallback(
55  m_index, &CallbackStoreThunk, store.get(), initialNotify));
56  return store;
57  }
58  double GetVoltage() { return HALSIM_GetPDPVoltage(m_index); }
59  void SetVoltage(double voltage) { HALSIM_SetPDPVoltage(m_index, voltage); }
60 
61  std::unique_ptr<CallbackStore> RegisterCurrentCallback(
62  int channel, NotifyCallback callback, bool initialNotify) {
63  auto store = std::make_unique<CallbackStore>(
64  m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
65  store->SetUid(HALSIM_RegisterPDPCurrentCallback(
66  m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
67  return store;
68  }
69  double GetCurrent(int channel) {
70  return HALSIM_GetPDPCurrent(m_index, channel);
71  }
72  void SetCurrent(int channel, double current) {
73  HALSIM_SetPDPCurrent(m_index, channel, current);
74  }
75 
76  void ResetData() { HALSIM_ResetPDPData(m_index); }
77 
78  private:
79  int m_index;
80 };
81 } // namespace sim
82 } // namespace frc
83 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: PDPSim.h:20