[hal,wpilib] Change Power Distribution usage reporting to Instances (#7465)

LabVIEW doesn't appear to report PDP. This should reduce the number of
Unknowns in the parsed UsageReporting.
This commit is contained in:
sciencewhiz
2024-11-30 20:32:21 -08:00
committed by GitHub
parent c387a7ecae
commit 9807d60566
6 changed files with 42 additions and 4 deletions

View File

@@ -75,3 +75,6 @@ kLoggingFramework_Epilogue = 2
kLoggingFramework_Monologue = 3
kLoggingFramework_AdvantageKit = 4
kLoggingFramework_DogLog = 5
kPDP_CTRE = 1
kPDP_REV = 2
kPDP_Unknown = 3

View File

@@ -421,6 +421,12 @@ public final class FRCNetComm {
public static final int kLoggingFramework_AdvantageKit = 4;
/** kLoggingFramework_DogLog = 5. */
public static final int kLoggingFramework_DogLog = 5;
/** kPDP_CTRE = 1. */
public static final int kPDP_CTRE = 1;
/** kPDP_REV = 2. */
public static final int kPDP_REV = 2;
/** kPDP_Unknown = 3. */
public static final int kPDP_Unknown = 3;
}
/** Utility class. */

View File

@@ -249,6 +249,9 @@ namespace HALUsageReporting {
kLoggingFramework_Monologue = 3,
kLoggingFramework_AdvantageKit = 4,
kLoggingFramework_DogLog = 5,
kPDP_CTRE = 1,
kPDP_REV = 2,
kPDP_Unknown = 3,
};
}
#endif

View File

@@ -222,6 +222,9 @@ typedef enum
kLoggingFramework_Monologue = 3,
kLoggingFramework_AdvantageKit = 4,
kLoggingFramework_DogLog = 5,
kPDP_CTRE = 1,
kPDP_REV = 2,
kPDP_Unknown = 3,
} tInstances;
/**

View File

@@ -39,7 +39,14 @@ PowerDistribution::PowerDistribution() {
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
FRC_ReportError(status, "Module {}", m_module);
HAL_Report(HALUsageReporting::kResourceType_PDP, m_module + 1);
if (HAL_GetPowerDistributionType(m_handle, &status) ==
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_CTRE);
} else {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
}
wpi::SendableRegistry::AddLW(this, "PowerDistribution", m_module);
}
@@ -54,7 +61,13 @@ PowerDistribution::PowerDistribution(int module, ModuleType moduleType) {
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
FRC_ReportError(status, "Module {}", module);
HAL_Report(HALUsageReporting::kResourceType_PDP, m_module + 1);
if (moduleType == ModuleType::kCTRE) {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_CTRE);
} else {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
}
wpi::SendableRegistry::AddLW(this, "PowerDistribution", m_module);
}

View File

@@ -4,6 +4,7 @@
package edu.wpi.first.wpilibj;
import edu.wpi.first.hal.FRCNetComm.tInstances;
import edu.wpi.first.hal.FRCNetComm.tResourceType;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.PowerDistributionFaults;
@@ -51,7 +52,11 @@ public class PowerDistribution implements Sendable, AutoCloseable {
m_handle = PowerDistributionJNI.initialize(module, moduleType.value);
m_module = PowerDistributionJNI.getModuleNumber(m_handle);
HAL.report(tResourceType.kResourceType_PDP, m_module + 1);
if (moduleType == ModuleType.kCTRE) {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_CTRE);
} else {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
}
SendableRegistry.addLW(this, "PowerDistribution", m_module);
}
@@ -65,7 +70,12 @@ public class PowerDistribution implements Sendable, AutoCloseable {
m_handle = PowerDistributionJNI.initialize(kDefaultModule, PowerDistributionJNI.AUTOMATIC_TYPE);
m_module = PowerDistributionJNI.getModuleNumber(m_handle);
HAL.report(tResourceType.kResourceType_PDP, m_module + 1);
if (PowerDistributionJNI.getType(m_handle) == PowerDistributionJNI.CTRE_TYPE) {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_CTRE);
} else {
HAL.report(tResourceType.kResourceType_PDP, tInstances.kPDP_REV);
}
SendableRegistry.addLW(this, "PowerDistribution", m_module);
}