mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
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:
committed by
Brad Miller (WPI)
parent
84ca2ab0f5
commit
906fe65e39
@@ -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
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user