WPILibC++  2019.1.1-beta-3-1-g0c3b488
 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 
33  bool GetInitialized() const { return HALSIM_GetPDPInitialized(m_index); }
34 
35  void SetInitialized(bool initialized) {
36  HALSIM_SetPDPInitialized(m_index, initialized);
37  }
38 
39  std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
40  NotifyCallback callback, bool initialNotify) {
41  auto store = std::make_unique<CallbackStore>(
42  m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
43  store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
44  m_index, &CallbackStoreThunk, store.get(), initialNotify));
45  return store;
46  }
47 
48  double GetTemperature() const { return HALSIM_GetPDPTemperature(m_index); }
49 
50  void SetTemperature(double temperature) {
51  HALSIM_SetPDPTemperature(m_index, temperature);
52  }
53 
54  std::unique_ptr<CallbackStore> RegisterVoltageCallback(
55  NotifyCallback callback, bool initialNotify) {
56  auto store = std::make_unique<CallbackStore>(
57  m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
58  store->SetUid(HALSIM_RegisterPDPVoltageCallback(
59  m_index, &CallbackStoreThunk, store.get(), initialNotify));
60  return store;
61  }
62 
63  double GetVoltage() const { return HALSIM_GetPDPVoltage(m_index); }
64 
65  void SetVoltage(double voltage) { HALSIM_SetPDPVoltage(m_index, voltage); }
66 
67  std::unique_ptr<CallbackStore> RegisterCurrentCallback(
68  int channel, NotifyCallback callback, bool initialNotify) {
69  auto store = std::make_unique<CallbackStore>(
70  m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
71  store->SetUid(HALSIM_RegisterPDPCurrentCallback(
72  m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
73  return store;
74  }
75 
76  double GetCurrent(int channel) const {
77  return HALSIM_GetPDPCurrent(m_index, channel);
78  }
79 
80  void SetCurrent(int channel, double current) {
81  HALSIM_SetPDPCurrent(m_index, channel, current);
82  }
83 
84  void ResetData() { HALSIM_ResetPDPData(m_index); }
85 
86  private:
87  int m_index;
88 };
89 } // namespace sim
90 } // namespace frc
91 #endif // __FRC_ROBORIO__
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
Definition: PDPSim.h:20