mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Use new CAN API for PDP (#1081)
This commit is contained in:
committed by
Peter Johnson
parent
f6e4df6a18
commit
056e68f2ae
@@ -14,8 +14,8 @@ import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
|
||||
* Class for getting voltage, current, temperature, power and energy from the Power Distribution
|
||||
* Panel over CAN.
|
||||
*/
|
||||
public class PowerDistributionPanel extends SendableBase {
|
||||
private final int m_module;
|
||||
public class PowerDistributionPanel extends SendableBase {
|
||||
private final int m_handle;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -23,9 +23,8 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @param module The CAN ID of the PDP
|
||||
*/
|
||||
public PowerDistributionPanel(int module) {
|
||||
m_module = module;
|
||||
SensorUtil.checkPDPModule(module);
|
||||
PDPJNI.initializePDP(module);
|
||||
m_handle = PDPJNI.initializePDP(module);
|
||||
setName("PowerDistributionPanel", module);
|
||||
}
|
||||
|
||||
@@ -42,7 +41,7 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return The voltage of the PDP in volts
|
||||
*/
|
||||
public double getVoltage() {
|
||||
return PDPJNI.getPDPVoltage(m_module);
|
||||
return PDPJNI.getPDPVoltage(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +50,7 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return The temperature of the PDP in degrees Celsius
|
||||
*/
|
||||
public double getTemperature() {
|
||||
return PDPJNI.getPDPTemperature(m_module);
|
||||
return PDPJNI.getPDPTemperature(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +59,7 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return The current of one of the PDP channels (channels 0-15) in Amperes
|
||||
*/
|
||||
public double getCurrent(int channel) {
|
||||
double current = PDPJNI.getPDPChannelCurrent((byte) channel, m_module);
|
||||
double current = PDPJNI.getPDPChannelCurrent((byte) channel, m_handle);
|
||||
|
||||
SensorUtil.checkPDPChannel(channel);
|
||||
|
||||
@@ -73,7 +72,7 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return The current of all the channels in Amperes
|
||||
*/
|
||||
public double getTotalCurrent() {
|
||||
return PDPJNI.getPDPTotalCurrent(m_module);
|
||||
return PDPJNI.getPDPTotalCurrent(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +81,7 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return the total power in Watts
|
||||
*/
|
||||
public double getTotalPower() {
|
||||
return PDPJNI.getPDPTotalPower(m_module);
|
||||
return PDPJNI.getPDPTotalPower(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,21 +90,21 @@ public class PowerDistributionPanel extends SendableBase {
|
||||
* @return the total energy in Joules
|
||||
*/
|
||||
public double getTotalEnergy() {
|
||||
return PDPJNI.getPDPTotalEnergy(m_module);
|
||||
return PDPJNI.getPDPTotalEnergy(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the total energy to 0.
|
||||
*/
|
||||
public void resetTotalEnergy() {
|
||||
PDPJNI.resetPDPTotalEnergy(m_module);
|
||||
PDPJNI.resetPDPTotalEnergy(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all PDP sticky faults.
|
||||
*/
|
||||
public void clearStickyFaults() {
|
||||
PDPJNI.clearPDPStickyFaults(m_module);
|
||||
PDPJNI.clearPDPStickyFaults(m_handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user