mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpilib] PowerDistribution: Add module type getter (#3948)
This commit is contained in:
@@ -124,6 +124,13 @@ int PowerDistribution::GetModule() const {
|
||||
return m_module;
|
||||
}
|
||||
|
||||
PowerDistribution::ModuleType PowerDistribution::GetType() const {
|
||||
int32_t status = 0;
|
||||
auto type = HAL_GetPowerDistributionType(m_handle, &status);
|
||||
FRC_ReportError(status, "Module {}", m_module);
|
||||
return static_cast<ModuleType>(type);
|
||||
}
|
||||
|
||||
bool PowerDistribution::GetSwitchableChannel() const {
|
||||
int32_t status = 0;
|
||||
bool state = HAL_GetPowerDistributionSwitchableChannel(m_handle, &status);
|
||||
|
||||
@@ -100,6 +100,11 @@ class PowerDistribution : public wpi::Sendable,
|
||||
*/
|
||||
int GetModule() const;
|
||||
|
||||
/**
|
||||
* Gets module type.
|
||||
*/
|
||||
ModuleType GetType() const;
|
||||
|
||||
/**
|
||||
* Gets whether the PDH switchable channel is turned on or off. Returns false
|
||||
* with the CTRE PDP.
|
||||
|
||||
@@ -152,6 +152,20 @@ public class PowerDistribution implements Sendable, AutoCloseable {
|
||||
return m_module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the module type for this power distribution object.
|
||||
*
|
||||
* @return The module type
|
||||
*/
|
||||
public ModuleType getType() {
|
||||
int type = PowerDistributionJNI.getType(m_handle);
|
||||
if (type == PowerDistributionJNI.REV_TYPE) {
|
||||
return ModuleType.kRev;
|
||||
} else {
|
||||
return ModuleType.kCTRE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the PDH switchable channel is turned on or off. Returns false with the CTRE PDP.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user