Switches compressor to handles (#125)

This commit is contained in:
Thad House
2016-07-02 08:22:44 -07:00
committed by Peter Johnson
parent 0f105a26f7
commit 62c217cd01
9 changed files with 253 additions and 114 deletions

View File

@@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.tables.ITable;
* thereby stopping the compressor from operating.
*/
public class Compressor extends SensorBase implements LiveWindowSendable {
private long m_pcm;
private int m_compressorHandle;
/**
* Constructor.
@@ -34,7 +34,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
public Compressor(int module) {
m_table = null;
m_pcm = CompressorJNI.initializeCompressor((byte) module);
m_compressorHandle = CompressorJNI.initializeCompressor((byte) module);
}
/**
@@ -70,7 +70,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if the compressor is on
*/
public boolean enabled() {
return CompressorJNI.getCompressor(m_pcm);
return CompressorJNI.getCompressor(m_compressorHandle);
}
/**
@@ -79,7 +79,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if the pressure is low by reading the pressure switch that is plugged into the PCM
*/
public boolean getPressureSwitchValue() {
return CompressorJNI.getPressureSwitch(m_pcm);
return CompressorJNI.getPressureSwitch(m_compressorHandle);
}
/**
@@ -88,7 +88,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return current consumed in amps for the compressor motor
*/
public float getCompressorCurrent() {
return CompressorJNI.getCompressorCurrent(m_pcm);
return CompressorJNI.getCompressorCurrent(m_compressorHandle);
}
/**
@@ -98,7 +98,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* operation of the compressor is disabled.
*/
public void setClosedLoopControl(boolean on) {
CompressorJNI.setClosedLoopControl(m_pcm, on);
CompressorJNI.setClosedLoopControl(m_compressorHandle, on);
}
/**
@@ -107,7 +107,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if compressor is operating on closed-loop mode, otherwise return false.
*/
public boolean getClosedLoopControl() {
return CompressorJNI.getClosedLoopControl(m_pcm);
return CompressorJNI.getClosedLoopControl(m_compressorHandle);
}
/**
@@ -117,7 +117,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if PCM is in fault state.
*/
public boolean getCompressorCurrentTooHighFault() {
return CompressorJNI.getCompressorCurrentTooHighFault(m_pcm);
return CompressorJNI.getCompressorCurrentTooHighFault(m_compressorHandle);
}
/**
@@ -127,21 +127,21 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if PCM sticky fault is set.
*/
public boolean getCompressorCurrentTooHighStickyFault() {
return CompressorJNI.getCompressorCurrentTooHighStickyFault(m_pcm);
return CompressorJNI.getCompressorCurrentTooHighStickyFault(m_compressorHandle);
}
/**
* @return true if PCM sticky fault is set : Compressor output appears to be shorted.
*/
public boolean getCompressorShortedStickyFault() {
return CompressorJNI.getCompressorShortedStickyFault(m_pcm);
return CompressorJNI.getCompressorShortedStickyFault(m_compressorHandle);
}
/**
* @return true if PCM is in fault state : Compressor output appears to be shorted.
*/
public boolean getCompressorShortedFault() {
return CompressorJNI.getCompressorShortedFault(m_pcm);
return CompressorJNI.getCompressorShortedFault(m_compressorHandle);
}
/**
@@ -151,7 +151,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if PCM sticky fault is set.
*/
public boolean getCompressorNotConnectedStickyFault() {
return CompressorJNI.getCompressorNotConnectedStickyFault(m_pcm);
return CompressorJNI.getCompressorNotConnectedStickyFault(m_compressorHandle);
}
/**
@@ -161,7 +161,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* @return true if PCM is in fault state.
*/
public boolean getCompressorNotConnectedFault() {
return CompressorJNI.getCompressorNotConnectedFault(m_pcm);
return CompressorJNI.getCompressorNotConnectedFault(m_compressorHandle);
}
/**
@@ -174,7 +174,7 @@ public class Compressor extends SensorBase implements LiveWindowSendable {
* <p>If no sticky faults are set then this call will have no effect.
*/
public void clearAllPCMStickyFaults() {
CompressorJNI.clearAllPCMStickyFaults(m_pcm);
CompressorJNI.clearAllPCMStickyFaults(m_compressorHandle);
}
@Override

View File

@@ -8,31 +8,31 @@
package edu.wpi.first.wpilibj.hal;
public class CompressorJNI extends JNIWrapper {
public static native long initializeCompressor(byte module);
public static native int initializeCompressor(byte module);
public static native boolean checkCompressorModule(byte module);
public static native boolean getCompressor(long pcmPointer);
public static native boolean getCompressor(int compressorHandle);
public static native void setClosedLoopControl(long pcmPointer, boolean value);
public static native void setClosedLoopControl(int compressorHandle, boolean value);
public static native boolean getClosedLoopControl(long pcmPointer);
public static native boolean getClosedLoopControl(int compressorHandle);
public static native boolean getPressureSwitch(long pcmPointer);
public static native boolean getPressureSwitch(int compressorHandle);
public static native float getCompressorCurrent(long pcmPointer);
public static native float getCompressorCurrent(int compressorHandle);
public static native boolean getCompressorCurrentTooHighFault(long pcmPointer);
public static native boolean getCompressorCurrentTooHighFault(int compressorHandle);
public static native boolean getCompressorCurrentTooHighStickyFault(long pcmPointer);
public static native boolean getCompressorCurrentTooHighStickyFault(int compressorHandle);
public static native boolean getCompressorShortedStickyFault(long pcmPointer);
public static native boolean getCompressorShortedStickyFault(int compressorHandle);
public static native boolean getCompressorShortedFault(long pcmPointer);
public static native boolean getCompressorShortedFault(int compressorHandle);
public static native boolean getCompressorNotConnectedStickyFault(long pcmPointer);
public static native boolean getCompressorNotConnectedStickyFault(int compressorHandle);
public static native boolean getCompressorNotConnectedFault(long pcmPointer);
public static native boolean getCompressorNotConnectedFault(int compressorHandle);
public static native void clearAllPCMStickyFaults(long pcmPointer);
public static native void clearAllPCMStickyFaults(int compressorHandle);
}