mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[sim] Implement PD total current and power (#4830)
This commit is contained in:
@@ -147,11 +147,23 @@ void HAL_GetPowerDistributionAllChannelCurrents(
|
||||
}
|
||||
double HAL_GetPowerDistributionTotalCurrent(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
return 0.0;
|
||||
auto module = hal::can::GetCANModuleFromHandle(handle, status);
|
||||
if (*status != 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double total = 0.0;
|
||||
auto& data = SimPowerDistributionData[module];
|
||||
for (int i = 0; i < kNumPDSimChannels; i++) {
|
||||
total += data.current[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
double HAL_GetPowerDistributionTotalPower(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
return 0.0;
|
||||
double voltage = HAL_GetPowerDistributionVoltage(handle, status);
|
||||
double current = HAL_GetPowerDistributionTotalCurrent(handle, status);
|
||||
return voltage * current;
|
||||
}
|
||||
double HAL_GetPowerDistributionTotalEnergy(HAL_PowerDistributionHandle handle,
|
||||
int32_t* status) {
|
||||
|
||||
Reference in New Issue
Block a user