Update headers and .sos to v15 image + most API changes

Java still does not work

Change-Id: I172ac401a07b6703909068f82b7b6cc67e6075c0
This commit is contained in:
Thomas Clark
2014-10-05 17:17:59 -04:00
parent 6089722c4f
commit 7e9f183cf9
87 changed files with 2812 additions and 2667 deletions

View File

@@ -88,11 +88,6 @@ public class Counter extends SensorBase implements CounterBase,
UsageReporting.report(tResourceType.kResourceType_Counter, m_index,
mode.value);
status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
CounterJNI.startCounter(m_counter, status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
}
/**
@@ -325,7 +320,7 @@ public class Counter extends SensorBase implements CounterBase,
if(source == null){
throw new NullPointerException("The Digital Source given was null");
}
if (m_downSource != null && m_allocatedDownSource) {
m_downSource.free();
m_allocatedDownSource = false;
@@ -358,7 +353,7 @@ public class Counter extends SensorBase implements CounterBase,
if (triggerType == null){
throw new NullPointerException("Analog Trigger Type given was null");
}
setDownSource(analogTrigger.createOutput(triggerType));
m_allocatedDownSource = true;
}

View File

@@ -107,14 +107,6 @@ public class Encoder extends SensorBase implements CounterBase, PIDSource, LiveW
UsageReporting.report(tResourceType.kResourceType_Encoder,
m_index, m_encodingType.value);
LiveWindow.addSensor("Encoder", m_aSource.getChannelForRouting(), this);
if (m_counter == null) {
ByteBuffer status = ByteBuffer.allocateDirect(4);
// set the byte order
status.order(ByteOrder.LITTLE_ENDIAN);
EncoderJNI.startEncoder(m_encoder, status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
}
}
/**

View File

@@ -19,7 +19,7 @@ import edu.wpi.first.wpilibj.util.CheckedAllocationException;
* Base for sensors to be used with interrupts
*/
public abstract class InterruptableSensorBase extends SensorBase {
/**
/**
* This is done to store the JVM variable in the InterruptJNI
* This is done because the HAL must have access to the JVM variable
* in order to attach the newly spawned thread when an interrupt is fired.
@@ -35,12 +35,12 @@ public abstract class InterruptableSensorBase extends SensorBase {
* The interrupt resource
*/
protected ByteBuffer m_interrupt = null;
/**
* Flags if the interrupt being allocated is synchronous
*/
protected boolean m_isSynchronousInterrupt = false;
/**
* The index of the interrupt
*/
@@ -56,7 +56,7 @@ public abstract class InterruptableSensorBase extends SensorBase {
public InterruptableSensorBase() {
m_interrupt = null;
}
/**
* @return
*/
@@ -71,7 +71,7 @@ public abstract class InterruptableSensorBase extends SensorBase {
* @return
*/
abstract byte getModuleForRouting();
/**
* Request interrupts asynchronously on this digital input.
*
@@ -80,16 +80,16 @@ public abstract class InterruptableSensorBase extends SensorBase {
* {@link InterruptHandlerFunction#interruptFired(int, Object)} that
* will be called whenever there is an interrupt on this device.
* Request interrupts in synchronus mode where the user program
* interrupt handler will be called when an interrupt occurs. The
* interrupt handler will be called when an interrupt occurs. The
* default is interrupt on rising edges only.
*/
public void requestInterrupts(InterruptHandlerFunction<?> handler) {
if(m_interrupt != null){
throw new AllocationException("The interrupt has already been allocated");
}
allocateInterrupts(false);
assert (m_interrupt != null);
ByteBuffer status = ByteBuffer.allocateDirect(4);
@@ -114,7 +114,7 @@ public abstract class InterruptableSensorBase extends SensorBase {
if(m_interrupt != null){
throw new AllocationException("The interrupt has already been allocated");
}
allocateInterrupts(true);
assert (m_interrupt != null);
@@ -132,7 +132,7 @@ public abstract class InterruptableSensorBase extends SensorBase {
/**
* Allocate the interrupt
*
*
* @param watcher true if the interrupt should be in synchronous mode where the user
* program will have to explicitly wait for the interrupt to occur.
*/
@@ -170,20 +170,33 @@ public abstract class InterruptableSensorBase extends SensorBase {
/**
* In synchronous mode, wait for the defined interrupt to occur.
*
*
* @param timeout
* Timeout in seconds
* @param ignorePrevious
* If true, ignore interrupts that happened before
* waitForInterrupt was called.
*/
public void waitForInterrupt(double timeout) {
public void waitForInterrupt(double timeout, boolean ignorePrevious) {
if (m_interrupt == null) {
throw new IllegalStateException("The interrupt is not allocated.");
}
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
InterruptJNI.waitForInterrupt(m_interrupt, (float) timeout, status.asIntBuffer());
InterruptJNI.waitForInterrupt(m_interrupt, (float) timeout, ignorePrevious, status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
}
/**
* In synchronous mode, wait for the defined interrupt to occur.
*
* @param timeout
* Timeout in seconds
*/
public void waitForInterrupt(double timeout) {
waitForInterrupt(timeout, true);
}
/**
* Enable interrupts to occur on this input. Interrupts are disabled when
* the RequestInterrupt call is made. This gives time to do the setup of the
@@ -219,22 +232,41 @@ public abstract class InterruptableSensorBase extends SensorBase {
}
/**
* Return the timestamp for the interrupt that occurred most recently. This
* is in the same time domain as getClock().
*
* Return the timestamp for the rising interrupt that occurred most
* recently. This is in the same time domain as getClock().
* The rising-edge interrupt should be enabled with
* {@link #setUpSourceEdge}
* @return Timestamp in seconds since boot.
*/
public double readInterruptTimestamp() {
public double readRisingTimestamp() {
if (m_interrupt == null) {
throw new IllegalStateException("The interrupt is not allocated.");
}
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
double timestamp = InterruptJNI.readInterruptTimestamp(m_interrupt, status.asIntBuffer());
double timestamp = InterruptJNI.readRisingTimestamp(m_interrupt, status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return timestamp;
}
/**
* Return the timestamp for the falling interrupt that occurred most
* recently. This is in the same time domain as getClock().
* The falling-edge interrupt should be enabled with
* {@link #setUpSourceEdge}
* @return Timestamp in seconds since boot.
*/
public double readFallingTimestamp() {
if (m_interrupt == null) {
throw new IllegalStateException("The interrupt is not allocated.");
}
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
double timestamp = InterruptJNI.readFallingTimestamp(m_interrupt, status.asIntBuffer());
HALUtil.checkStatus(status.asIntBuffer());
return timestamp;
}
/**
* Set which edge to trigger interrupts on
*

View File

@@ -19,8 +19,6 @@ public class CounterJNI extends JNIWrapper {
public static native void setCounterPulseLengthMode(ByteBuffer counter_pointer, double threshold, IntBuffer status);
public static native int getCounterSamplesToAverage(ByteBuffer counter_pointer, IntBuffer status);
public static native void setCounterSamplesToAverage(ByteBuffer counter_pointer, int samplesToAverage, IntBuffer status);
public static native void startCounter(ByteBuffer counter_pointer, IntBuffer status);
public static native void stopCounter(ByteBuffer counter_pointer, IntBuffer status);
public static native void resetCounter(ByteBuffer counter_pointer, IntBuffer status);
public static native int getCounter(ByteBuffer counter_pointer, IntBuffer status);
public static native double getCounterPeriod(ByteBuffer counter_pointer, IntBuffer status);

View File

@@ -6,8 +6,6 @@ import java.nio.ByteBuffer;
public class EncoderJNI extends JNIWrapper {
public static native ByteBuffer initializeEncoder(byte port_a_module, int port_a_pin, byte port_a_analog_trigger, byte port_b_module, int port_b_pin, byte port_b_analog_trigger, byte reverseDirection, IntBuffer index, IntBuffer status);
public static native void freeEncoder(ByteBuffer encoder_pointer, IntBuffer status);
public static native void startEncoder(ByteBuffer encoder_pointer, IntBuffer status);
public static native void stopEncoder(ByteBuffer encoder_pointer, IntBuffer status);
public static native void resetEncoder(ByteBuffer encoder_pointer, IntBuffer status);
public static native int getEncoder(ByteBuffer encoder_pointer, IntBuffer status);
public static native double getEncoderPeriod(ByteBuffer encoder_pointer, IntBuffer status);

View File

@@ -10,10 +10,11 @@ public class InterruptJNI extends JNIWrapper {
public static native void initializeInterruptJVM(IntBuffer status);
public static native ByteBuffer initializeInterrupts(int interruptIndex, byte watcher, IntBuffer status);
public static native void cleanInterrupts(ByteBuffer interrupt_pointer, IntBuffer status);
public static native void waitForInterrupt(ByteBuffer interrupt_pointer, double timeout, IntBuffer status);
public static native int waitForInterrupt(ByteBuffer interrupt_pointer, double timeout, boolean ignorePrevious, IntBuffer status);
public static native void enableInterrupts(ByteBuffer interrupt_pointer, IntBuffer status);
public static native void disableInterrupts(ByteBuffer interrupt_pointer, IntBuffer status);
public static native double readInterruptTimestamp(ByteBuffer interrupt_pointer, IntBuffer status);
public static native double readRisingTimestamp(ByteBuffer interrupt_pointer, IntBuffer status);
public static native double readFallingTimestamp(ByteBuffer interrupt_pointer, IntBuffer status);
public static native void requestInterrupts(ByteBuffer interrupt_pointer, byte routing_module, int routing_pin, byte routing_analog_trigger, IntBuffer status);
public static native void attachInterruptHandler(ByteBuffer interrupt_pointer, InterruptJNIHandlerFunction handler, Object param, IntBuffer status);
public static native void setInterruptUpSourceEdge(ByteBuffer interrupt_pointer, byte risingEdge, byte fallingEdge, IntBuffer status);