Optimize Solenoid Gets. Fixes artf4730.

Implement GetAllSolenoids in the HAL so that SolenoidBase doesn't have to
read each solenoid individually.

Change-Id: I85559565949f7a7119ead410187235636a63f0ed
This commit is contained in:
Joe Ross
2015-11-15 10:46:18 -08:00
committed by Brad Miller (WPI)
parent 84ca2ab0f5
commit 906fe65e39
8 changed files with 53 additions and 10 deletions

View File

@@ -99,6 +99,20 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoi
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getAllSolenoids
* Signature: (J)Z
*/
JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getAllSolenoids
(JNIEnv *env, jclass, jlong solenoid_port)
{
int32_t status = 0;
jbyte val = getAllSolenoids((void*)solenoid_port, &status);
CheckStatus(env, status);
return val;
}
/*
* Class: edu_wpi_first_wpilibj_hal_SolenoidJNI
* Method: getPCMSolenoidBlackList

View File

@@ -65,11 +65,7 @@ public abstract class SolenoidBase extends SensorBase {
* @return The current value of all 8 solenoids on this module.
*/
public byte getAll() {
byte value = 0;
for (int i = 0; i < SensorBase.kSolenoidChannels; i++) {
value |= (SolenoidJNI.getSolenoid(m_ports[i]) ? 1 : 0) << i;
}
return value;
return SolenoidJNI.getAllSolenoids(m_ports[0]);
}
/**

View File

@@ -11,6 +11,8 @@ public class SolenoidJNI extends JNIWrapper {
public static native boolean getSolenoid(long port);
public static native byte getAllSolenoids(long port);
public static native int getPCMSolenoidBlackList(long pcm_pointer);
public static native boolean getPCMSolenoidVoltageStickyFault(long pcm_pointer);