mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Implement user API for roboRIO power methods (fixes artf3728 and artf3537)
Change-Id: I7501a83dcdd81d45b298e044379ea4ac3670c742
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2012. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import edu.wpi.first.wpilibj.hal.HALUtil;
|
||||
import edu.wpi.first.wpilibj.hal.PowerJNI;
|
||||
|
||||
public class ControllerPower
|
||||
{
|
||||
public static double getInputVoltage()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getVinVoltage(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getInputCurrent()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getVinCurrent(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getVoltage3V3()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserVoltage3V3(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getCurrent3V3()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserCurrent3V3(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static boolean getEnabled3V3()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
boolean retVal = PowerJNI.getUserActive3V3(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static int getFaultCount3V3()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int retVal = PowerJNI.getUserCurrentFaults3V3(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getVoltage5V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserVoltage5V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getCurrent5V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserCurrent5V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static boolean getEnabled5V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
boolean retVal = PowerJNI.getUserActive5V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static int getFaultCount5V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int retVal = PowerJNI.getUserCurrentFaults5V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getVoltage6V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserVoltage6V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static double getCurrent6V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
double retVal = PowerJNI.getUserCurrent6V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static boolean getEnabled6V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
boolean retVal = PowerJNI.getUserActive6V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static int getFaultCount6V()
|
||||
{
|
||||
ByteBuffer status = ByteBuffer.allocateDirect(4);
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int retVal = PowerJNI.getUserCurrentFaults6V(status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,14 @@ public class PowerJNI extends JNIWrapper {
|
||||
public static native float getVinCurrent(IntBuffer status);
|
||||
public static native float getUserVoltage6V(IntBuffer status);
|
||||
public static native float getUserCurrent6V(IntBuffer status);
|
||||
public static native boolean getUserActive6V(IntBuffer status);
|
||||
public static native int getUserCurrentFaults6V(IntBuffer status);
|
||||
public static native float getUserVoltage5V(IntBuffer status);
|
||||
public static native float getUserCurrent5V(IntBuffer status);
|
||||
public static native boolean getUserActive5V(IntBuffer status);
|
||||
public static native int getUserCurrentFaults5V(IntBuffer status);
|
||||
public static native float getUserVoltage3V3(IntBuffer status);
|
||||
public static native float getUserCurrent3V3(IntBuffer status);
|
||||
public static native boolean getUserActive3V3(IntBuffer status);
|
||||
public static native int getUserCurrentFaults3V3(IntBuffer status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user