mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
SolenoidBase functions are now static (#530)
Instance methods were kept around for backwards compat in Java. In C++, the instance methods were changed to match Java. Also some cleanup to the JNI layer to match updated variable types we missed. Closes #416
This commit is contained in:
committed by
Peter Johnson
parent
f32e696fef
commit
e1fc60b8dd
@@ -124,13 +124,13 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getAllSolenoids
|
||||
* Signature: (B)Z
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jbyte JNICALL
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids(
|
||||
JNIEnv *env, jclass, jbyte module) {
|
||||
JNIEnv *env, jclass, jint module) {
|
||||
int32_t status = 0;
|
||||
jbyte val = HAL_GetAllSolenoids(module, &status);
|
||||
jint val = HAL_GetAllSolenoids(module, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -138,11 +138,11 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidBlackList
|
||||
* Signature: (B)I
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList(
|
||||
JNIEnv *env, jclass, jbyte module) {
|
||||
JNIEnv *env, jclass, jint module) {
|
||||
int32_t status = 0;
|
||||
jint val = HAL_GetPCMSolenoidBlackList(module, &status);
|
||||
CheckStatus(env, status);
|
||||
@@ -151,11 +151,11 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidVoltageStickyFault
|
||||
* Signature: (B)Z
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault(
|
||||
JNIEnv *env, jclass, jbyte module) {
|
||||
JNIEnv *env, jclass, jint module) {
|
||||
int32_t status = 0;
|
||||
bool val = HAL_GetPCMSolenoidVoltageStickyFault(module, &status);
|
||||
CheckStatus(env, status);
|
||||
@@ -164,11 +164,11 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: getPCMSolenoidVoltageFault
|
||||
* Signature: (B)Z
|
||||
* Signature: (I)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault(
|
||||
JNIEnv *env, jclass, jbyte module) {
|
||||
JNIEnv *env, jclass, jint module) {
|
||||
int32_t status = 0;
|
||||
bool val = HAL_GetPCMSolenoidVoltageFault(module, &status);
|
||||
CheckStatus(env, status);
|
||||
@@ -177,11 +177,11 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault(
|
||||
/*
|
||||
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
|
||||
* Method: clearAllPCMStickyFaults
|
||||
* Signature: (B)V
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults(
|
||||
JNIEnv *env, jclass, jbyte module) {
|
||||
JNIEnv *env, jclass, jint module) {
|
||||
int32_t status = 0;
|
||||
HAL_ClearAllPCMStickyFaults(module, &status);
|
||||
CheckStatus(env, status);
|
||||
|
||||
@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.hal.SolenoidJNI;
|
||||
*/
|
||||
public abstract class SolenoidBase extends SensorBase {
|
||||
|
||||
protected final byte m_moduleNumber; // The number of the solenoid module being used.
|
||||
protected final int m_moduleNumber; // The number of the solenoid module being used.
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -23,7 +23,17 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
* @param moduleNumber The PCM CAN ID
|
||||
*/
|
||||
public SolenoidBase(final int moduleNumber) {
|
||||
m_moduleNumber = (byte) moduleNumber;
|
||||
m_moduleNumber = moduleNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all 8 solenoids from the specified module as a single byte.
|
||||
*
|
||||
* @param moduleNumber the module number to read
|
||||
* @return The current value of all 8 solenoids on the module.
|
||||
*/
|
||||
public static int getAll(int moduleNumber) {
|
||||
return SolenoidJNI.getAllSolenoids(moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,8 +41,21 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
*
|
||||
* @return The current value of all 8 solenoids on this module.
|
||||
*/
|
||||
public byte getAll() {
|
||||
return SolenoidJNI.getAllSolenoids(m_moduleNumber);
|
||||
public int getAll() {
|
||||
return SolenoidBase.getAll(m_moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads complete solenoid blacklist for all 8 solenoids as a single byte. If a solenoid is
|
||||
* shorted, it is added to the blacklist and disabled until power cycle, or until faults are
|
||||
* cleared.
|
||||
*
|
||||
* @param moduleNumber the module number to read
|
||||
* @return The solenoid blacklist of all 8 solenoids on the module.
|
||||
* @see #clearAllPCMStickyFaults()
|
||||
*/
|
||||
public static int getPCMSolenoidBlackList(int moduleNumber) {
|
||||
return SolenoidJNI.getPCMSolenoidBlackList(moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,8 +66,19 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
* @return The solenoid blacklist of all 8 solenoids on the module.
|
||||
* @see #clearAllPCMStickyFaults()
|
||||
*/
|
||||
public byte getPCMSolenoidBlackList() {
|
||||
return (byte) SolenoidJNI.getPCMSolenoidBlackList(m_moduleNumber);
|
||||
public int getPCMSolenoidBlackList() {
|
||||
return SolenoidBase.getPCMSolenoidBlackList(m_moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, the common highside solenoid voltage rail is too low, most likely a solenoid channel
|
||||
* is shorted.
|
||||
*
|
||||
* @param moduleNumber the module number to read
|
||||
* @return true if PCM sticky fault is set
|
||||
*/
|
||||
public static boolean getPCMSolenoidVoltageStickyFault(int moduleNumber) {
|
||||
return SolenoidJNI.getPCMSolenoidVoltageStickyFault(moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +88,18 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
* @return true if PCM sticky fault is set
|
||||
*/
|
||||
public boolean getPCMSolenoidVoltageStickyFault() {
|
||||
return SolenoidJNI.getPCMSolenoidVoltageStickyFault(m_moduleNumber);
|
||||
return SolenoidBase.getPCMSolenoidVoltageStickyFault(m_moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* The common highside solenoid voltage rail is too low, most likely a solenoid channel is
|
||||
* shorted.
|
||||
*
|
||||
* @param moduleNumber the module number to read
|
||||
* @return true if PCM is in fault state.
|
||||
*/
|
||||
public static boolean getPCMSolenoidVoltageFault(int moduleNumber) {
|
||||
return SolenoidJNI.getPCMSolenoidVoltageFault(moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +109,22 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
* @return true if PCM is in fault state.
|
||||
*/
|
||||
public boolean getPCMSolenoidVoltageFault() {
|
||||
return SolenoidJNI.getPCMSolenoidVoltageFault(m_moduleNumber);
|
||||
return SolenoidBase.getPCMSolenoidVoltageFault(m_moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear ALL sticky faults inside PCM that Compressor is wired to.
|
||||
*
|
||||
* <p>If a sticky fault is set, then it will be persistently cleared. Compressor drive maybe
|
||||
* momentarily disable while flags are being cleared. Care should be taken to not call this too
|
||||
* frequently, otherwise normal compressor functionality may be prevented.
|
||||
*
|
||||
* <p>If no sticky faults are set then this call will have no effect.
|
||||
*
|
||||
* @param moduleNumber the module number to read
|
||||
*/
|
||||
public static void clearAllPCMStickyFaults(int moduleNumber) {
|
||||
SolenoidJNI.clearAllPCMStickyFaults(moduleNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +137,6 @@ public abstract class SolenoidBase extends SensorBase {
|
||||
* <p>If no sticky faults are set then this call will have no effect.
|
||||
*/
|
||||
public void clearAllPCMStickyFaults() {
|
||||
SolenoidJNI.clearAllPCMStickyFaults(m_moduleNumber);
|
||||
SolenoidBase.clearAllPCMStickyFaults(m_moduleNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ public class SolenoidJNI extends JNIWrapper {
|
||||
|
||||
public static native boolean getSolenoid(int portHandle);
|
||||
|
||||
public static native byte getAllSolenoids(byte module);
|
||||
public static native int getAllSolenoids(int module);
|
||||
|
||||
public static native int getPCMSolenoidBlackList(byte module);
|
||||
public static native int getPCMSolenoidBlackList(int module);
|
||||
|
||||
public static native boolean getPCMSolenoidVoltageStickyFault(byte module);
|
||||
public static native boolean getPCMSolenoidVoltageStickyFault(int module);
|
||||
|
||||
public static native boolean getPCMSolenoidVoltageFault(byte module);
|
||||
public static native boolean getPCMSolenoidVoltageFault(int module);
|
||||
|
||||
public static native void clearAllPCMStickyFaults(byte module);
|
||||
public static native void clearAllPCMStickyFaults(int module);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user