diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java index bad97aa41e..4d24a4cae9 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/PowerDistributionPanel.java @@ -59,4 +59,53 @@ public class PowerDistributionPanel extends SensorBase { return current; } + + /** + * @return The current of all the channels + */ + public double getTotalCurrent(){ + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + double current = PDPJNI.getPDPTotalCurrent(status.asIntBuffer()); + + return current; + } + + /** + * @return the total power + */ + public double getTotalPower(){ + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + double power = PDPJNI.getPDPTotalPower(status.asIntBuffer()); + + return power; + + } + + public double getTotalEnergy(){ + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + double energy = PDPJNI.getPDPTotalEnergy(status.asIntBuffer()); + + return energy; + } + + public void resetTotalEnergy(){ + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + PDPJNI.resetPDPTotalEnergy(status.asIntBuffer()); + } + + public void clearStickyFaults(){ + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + PDPJNI.clearPDPStickyFaults(status.asIntBuffer()); + } + } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/PDPJNI.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/PDPJNI.java index c11d99e786..525ba68840 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/PDPJNI.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/PDPJNI.java @@ -7,4 +7,9 @@ public class PDPJNI extends JNIWrapper { public static native double getPDPTemperature(IntBuffer status); public static native double getPDPVoltage(IntBuffer status); public static native double getPDPChannelCurrent(byte channel, IntBuffer status); -} + public static native double getPDPTotalCurrent(IntBuffer status); + public static native double getPDPTotalPower(IntBuffer status); + public static native double getPDPTotalEnergy(IntBuffer status); + public static native void resetPDPTotalEnergy(IntBuffer status); + public static native void clearPDPStickyFaults(IntBuffer status); +} \ No newline at end of file diff --git a/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp b/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp index a35fa0ce3f..8e2096eb64 100644 --- a/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/PDPJNI.cpp @@ -40,3 +40,68 @@ JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPChannelCur return getPDPChannelCurrent(channel, status_ptr); } +/* + * Class: edu_wpi_first_wpilibj_hal_PDPJNI + * Method: getPDPTotalCurrent + * Signature: (BLjava/nio/IntBuffer;)D + */ +JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalCurrent + (JNIEnv *env, jclass, jobject status) +{ + jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + + return getPDPTotalCurrent(status_ptr); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_PDPJNI + * Method: getPDPTotalPower + * Signature: (BLjava/nio/IntBuffer;)D + */ +JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalPower + (JNIEnv *env, jclass, jobject status) +{ + jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + + return getPDPTotalPower(status_ptr); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_PDPJNI + * Method: resetPDPTotalEnergy + * Signature: (BLjava/nio/IntBuffer;)D + */ +JNIEXPORT jdouble JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_getPDPTotalEnergy + (JNIEnv *env, jclass, jobject status) +{ + jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + + return getPDPTotalEnergy(status_ptr); +} + + +/* + * Class: edu_wpi_first_wpilibj_hal_PDPJNI + * Method: resetPDPTotalEnergy + * Signature: (BLjava/nio/IntBuffer;)D + */ +JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_resetPDPTotalEnergy + (JNIEnv *env, jclass, jobject status) +{ + jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + + resetPDPTotalEnergy(status_ptr); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_PDPJNI + * Method: clearStickyFaults + * Signature: (BLjava/nio/IntBuffer;)D + */ +JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_PDPJNI_clearPDPStickyFaults + (JNIEnv *env, jclass, jobject status) +{ + jint *status_ptr = (jint *)env->GetDirectBufferAddress(status); + + clearPDPStickyFaults(status_ptr); +} \ No newline at end of file