1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <memory>
#include "frc/simulation/CallbackStore.h"
namespace frc {
class PowerDistribution;
namespace sim {
/**
* Class to control a simulated Power Distribution Panel (PowerDistribution).
*/
class PowerDistributionSim {
public:
/**
* Constructs from a PowerDistribution module number (CAN ID).
*
* @param module module number
*/
explicit PowerDistributionSim(int module = 0);
/**
* Constructs from a PowerDistribution object.
*
* @param pdp PowerDistribution to simulate
*/
explicit PowerDistributionSim(const PowerDistribution& pdp);
/**
* Register a callback to be run when the PowerDistribution is initialized.
*
* @param callback the callback
* @param initialNotify whether to run the callback with the initial state
* @return the CallbackStore object associated with this callback
*/
[[nodiscard]]
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify);
/**
* Check whether the PowerDistribution has been initialized.
*
* @return true if initialized
*/
bool GetInitialized() const;
/**
* Define whether the PowerDistribution has been initialized.
*
* @param initialized whether this object is initialized
*/
void SetInitialized(bool initialized);
/**
* Register a callback to be run whenever the PowerDistribution temperature
* changes.
*
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the CallbackStore object associated with this callback
*/
[[nodiscard]]
std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
NotifyCallback callback, bool initialNotify);
/**
* Check the temperature of the PowerDistribution.
*
* @return the PowerDistribution temperature
*/
double GetTemperature() const;
/**
* Define the PowerDistribution temperature.
*
* @param temperature the new PowerDistribution temperature
*/
void SetTemperature(double temperature);
/**
* Register a callback to be run whenever the PowerDistribution voltage
* changes.
*
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the CallbackStore object associated with this callback
*/
[[nodiscard]]
std::unique_ptr<CallbackStore> RegisterVoltageCallback(
NotifyCallback callback, bool initialNotify);
/**
* Check the PowerDistribution voltage.
*
* @return the PowerDistribution voltage.
*/
double GetVoltage() const;
/**
* Set the PowerDistribution voltage.
*
* @param voltage the new PowerDistribution voltage
*/
void SetVoltage(double voltage);
/**
* Register a callback to be run whenever the current of a specific channel
* changes.
*
* @param channel the channel
* @param callback the callback
* @param initialNotify whether to call the callback with the initial state
* @return the CallbackStore object associated with this callback
*/
[[nodiscard]]
std::unique_ptr<CallbackStore> RegisterCurrentCallback(
int channel, NotifyCallback callback, bool initialNotify);
/**
* Read the current in one of the PowerDistribution channels.
*
* @param channel the channel to check
* @return the current in the given channel
*/
double GetCurrent(int channel) const;
/**
* Change the current in the given channel.
*
* @param channel the channel to edit
* @param current the new current for the channel
*/
void SetCurrent(int channel, double current);
/**
* Read the current of all of the PowerDistribution channels.
*
* @param currents output array; set to the current in each channel. The
* array must be big enough to hold all the PowerDistribution
* channels
* @param length length of output array
*/
void GetAllCurrents(double* currents, int length) const;
/**
* Change the current in all of the PowerDistribution channels.
*
* @param currents array containing the current values for each channel. The
* array must be big enough to hold all the PowerDistribution
* channels
* @param length length of array
*/
void SetAllCurrents(const double* currents, int length);
/**
* Reset all PowerDistribution simulation data.
*/
void ResetData();
private:
int m_index;
};
} // namespace sim
} // namespace frc