made it so that AnalogTriggerOutput actually works as an InterruptableSensorBase

Before, it just had empty methods with TODOs on them. These changes have been
tested, and the only thing is that AnalogTriggerOutput::Type::k*Pulse don't seem
to work.

git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4189 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
index 89bf448..beeb788 100644
--- a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
+++ b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.cpp
@@ -41,8 +41,10 @@
 	{
 	case kInWindow:
 		result = m_trigger->m_trigger->readOutput_InHysteresis(m_trigger->m_index, &localStatus);
+		break;
 	case kState:
 		result = m_trigger->m_trigger->readOutput_OverLimit(m_trigger->m_index, &localStatus);
+		break;
 	case kRisingPulse:
 	case kFallingPulse:
 		wpi_setWPIError(AnalogTriggerPulseOutputError);
@@ -75,20 +77,3 @@
 {
 	return true;
 }
-
-/**
- * Request interrupts asynchronously on this analog trigger output.
- * TODO: Hardware supports interrupts on Analog Trigger outputs... WPILib should too
- */
-void AnalogTriggerOutput::RequestInterrupts(tInterruptHandler handler, void *param)
-{
-}
-
-/**
- * Request interrupts synchronously on this analog trigger output.
- * TODO: Hardware supports interrupts on Analog Trigger outputs... WPILib should too
- */
-void AnalogTriggerOutput::RequestInterrupts()
-{
-}
-
diff --git a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
index 53dc88a..61d9ae5 100644
--- a/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
+++ b/aos/externals/WPILib/WPILib/AnalogTriggerOutput.h
@@ -42,6 +42,7 @@
 {
 	friend class AnalogTrigger;
 public:
+  // kRisingPulse and kFallingPulse don't seem to work with RequestInterrupts.
 	typedef enum {kInWindow=0, kState=1, kRisingPulse=2, kFallingPulse=3} Type;
 	
 	virtual ~AnalogTriggerOutput();
@@ -51,8 +52,6 @@
 	virtual UINT32 GetChannelForRouting();
 	virtual UINT32 GetModuleForRouting();
 	virtual bool GetAnalogTriggerForRouting();
-	virtual void RequestInterrupts(tInterruptHandler handler, void *param=NULL); ///< Asynchronus handler version.
-	virtual void RequestInterrupts();		///< Synchronus Wait version.
 protected:
 	AnalogTriggerOutput(AnalogTrigger *trigger, Type outputType);
 
diff --git a/aos/externals/WPILib/WPILib/DigitalInput.cpp b/aos/externals/WPILib/WPILib/DigitalInput.cpp
index 75640b6..4178ce0 100644
--- a/aos/externals/WPILib/WPILib/DigitalInput.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalInput.cpp
@@ -10,9 +10,6 @@
 #include "Resource.h"
 #include "WPIErrors.h"
 
-// TODO: This is not a good place for this...
-Resource *interruptsResource = NULL;
-
 /**
  * Create an instance of a DigitalInput.
  * Creates a digital input given a slot and channel. Common creation routine
@@ -21,7 +18,6 @@
 void DigitalInput::InitDigitalInput(UINT8 moduleNumber, UINT32 channel)
 {
 	char buf[64];
-	Resource::CreateResourceObject(&interruptsResource, tInterrupt::kNumSystems);
 	if (!CheckDigitalModule(moduleNumber))
 	{
 		snprintf(buf, 64, "Digital Module %d", moduleNumber);
@@ -70,12 +66,6 @@
 DigitalInput::~DigitalInput()
 {
 	if (StatusIsFatal()) return;
-	if (m_manager != NULL)
-	{
-		delete m_manager;
-		delete m_interrupt;
-		interruptsResource->Free(m_interruptIndex);
-	}
 	m_module->FreeDIO(m_channel);
 }
 
@@ -122,83 +112,6 @@
 	return false;
 }
 
-/**
- * Request interrupts asynchronously on this digital input.
- * @param handler The address of the interrupt handler function of type tInterruptHandler that
- * will be called whenever there is an interrupt on the digitial input port.
- * Request interrupts in synchronus mode where the user program interrupt handler will be
- * called when an interrupt occurs.
- * The default is interrupt on rising edges only.
- */
-void DigitalInput::RequestInterrupts(tInterruptHandler handler, void *param)
-{
-	if (StatusIsFatal()) return;
-	UINT32 index = interruptsResource->Allocate("Async Interrupt");
-	if (index == ~0ul)
-	{
-		CloneError(interruptsResource);
-		return;
-	}
-	m_interruptIndex = index;
-
-	 // Creates a manager too
-	AllocateInterrupts(false);
-
-	tRioStatusCode localStatus = NiFpga_Status_Success;
-	m_interrupt->writeConfig_WaitForAck(false, &localStatus);
-	m_interrupt->writeConfig_Source_AnalogTrigger(GetAnalogTriggerForRouting(), &localStatus);
-	m_interrupt->writeConfig_Source_Channel(GetChannelForRouting(), &localStatus);
-	m_interrupt->writeConfig_Source_Module(GetModuleForRouting(), &localStatus);
-	SetUpSourceEdge(true, false);
-
-	m_manager->registerHandler(handler, param, &localStatus);
-	wpi_setError(localStatus);
-}
-
-/**
- * Request interrupts synchronously on this digital input.
- * Request interrupts in synchronus mode where the user program will have to explicitly
- * wait for the interrupt to occur.
- * The default is interrupt on rising edges only.
- */
-void DigitalInput::RequestInterrupts()
-{
-	if (StatusIsFatal()) return;
-	UINT32 index = interruptsResource->Allocate("Sync Interrupt");
-	if (index == ~0ul)
-	{
-		CloneError(interruptsResource);
-		return;
-	}
-	m_interruptIndex = index;
-
-	AllocateInterrupts(true);
-
-	tRioStatusCode localStatus = NiFpga_Status_Success;
-	m_interrupt->writeConfig_Source_AnalogTrigger(GetAnalogTriggerForRouting(), &localStatus);
-	m_interrupt->writeConfig_Source_Channel(GetChannelForRouting(), &localStatus);
-	m_interrupt->writeConfig_Source_Module(GetModuleForRouting(), &localStatus);
-	SetUpSourceEdge(true, false);
-	wpi_setError(localStatus);
-}
-
-void DigitalInput::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
-{
-	if (StatusIsFatal()) return;
-	if (m_interrupt == NULL)
-	{
-		wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
-		return;
-	}
-	tRioStatusCode localStatus = NiFpga_Status_Success;
-	if (m_interrupt != NULL)
-	{
-		m_interrupt->writeConfig_RisingEdge(risingEdge, &localStatus);
-		m_interrupt->writeConfig_FallingEdge(fallingEdge, &localStatus);
-	}
-	wpi_setError(localStatus);
-}
-
 void DigitalInput::UpdateTable() {
 	if (m_table != NULL) {
 		m_table->PutBoolean("Value", Get());
diff --git a/aos/externals/WPILib/WPILib/DigitalInput.h b/aos/externals/WPILib/WPILib/DigitalInput.h
index 96f122a..9c87f0d 100644
--- a/aos/externals/WPILib/WPILib/DigitalInput.h
+++ b/aos/externals/WPILib/WPILib/DigitalInput.h
@@ -32,11 +32,6 @@
 	virtual UINT32 GetModuleForRouting();
 	virtual bool GetAnalogTriggerForRouting();
 	
-	// Interruptable Interface
-	virtual void RequestInterrupts(tInterruptHandler handler, void *param=NULL); ///< Asynchronus handler version.
-	virtual void RequestInterrupts();		///< Synchronus Wait version.
-	void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
-
 	void UpdateTable();
 	void StartLiveWindowMode();
 	void StopLiveWindowMode();
diff --git a/aos/externals/WPILib/WPILib/DigitalSource.cpp b/aos/externals/WPILib/WPILib/DigitalSource.cpp
index 40cc75c..3c1e3a8 100644
--- a/aos/externals/WPILib/WPILib/DigitalSource.cpp
+++ b/aos/externals/WPILib/WPILib/DigitalSource.cpp
@@ -5,10 +5,102 @@
 /*----------------------------------------------------------------------------*/
 
 #include "DigitalSource.h"
+#include "Resource.h"
+#include "WPIErrors.h"
+
+Resource *interruptsResource = NULL;
+
+DigitalSource::DigitalSource()
+{
+	Resource::CreateResourceObject(&interruptsResource, tInterrupt::kNumSystems);
+}
 
 /**
  * DigitalSource destructor.
  */
 DigitalSource::~DigitalSource()
 {
+	if (m_manager != NULL)
+	{
+		delete m_manager;
+		delete m_interrupt;
+		interruptsResource->Free(m_interruptIndex);
+	}
+}
+
+/**
+ * Request interrupts asynchronously on this digital input.
+ * @param handler The address of the interrupt handler function of type tInterruptHandler that
+ * will be called whenever there is an interrupt on the digitial input port.
+ * Request interrupts in synchronus mode where the user program interrupt handler will be
+ * called when an interrupt occurs.
+ * The default is interrupt on rising edges only.
+ */
+void DigitalSource::RequestInterrupts(tInterruptHandler handler, void *param)
+{
+	if (StatusIsFatal()) return;
+	UINT32 index = interruptsResource->Allocate("Async Interrupt");
+	if (index == ~0ul)
+	{
+		CloneError(interruptsResource);
+		return;
+	}
+	m_interruptIndex = index;
+
+	 // Creates a manager too
+	AllocateInterrupts(false);
+
+	tRioStatusCode localStatus = NiFpga_Status_Success;
+	m_interrupt->writeConfig_WaitForAck(false, &localStatus);
+	m_interrupt->writeConfig_Source_AnalogTrigger(GetAnalogTriggerForRouting(), &localStatus);
+	m_interrupt->writeConfig_Source_Channel(GetChannelForRouting(), &localStatus);
+	m_interrupt->writeConfig_Source_Module(GetModuleForRouting(), &localStatus);
+	SetUpSourceEdge(true, false);
+
+	m_manager->registerHandler(handler, param, &localStatus);
+	wpi_setError(localStatus);
+}
+
+/**
+ * Request interrupts synchronously on this digital input.
+ * Request interrupts in synchronus mode where the user program will have to explicitly
+ * wait for the interrupt to occur.
+ * The default is interrupt on rising edges only.
+ */
+void DigitalSource::RequestInterrupts()
+{
+	if (StatusIsFatal()) return;
+	UINT32 index = interruptsResource->Allocate("Sync Interrupt");
+	if (index == ~0ul)
+	{
+		CloneError(interruptsResource);
+		return;
+	}
+	m_interruptIndex = index;
+
+	AllocateInterrupts(true);
+
+	tRioStatusCode localStatus = NiFpga_Status_Success;
+	m_interrupt->writeConfig_Source_AnalogTrigger(GetAnalogTriggerForRouting(), &localStatus);
+	m_interrupt->writeConfig_Source_Channel(GetChannelForRouting(), &localStatus);
+	m_interrupt->writeConfig_Source_Module(GetModuleForRouting(), &localStatus);
+	SetUpSourceEdge(true, false);
+	wpi_setError(localStatus);
+}
+
+void DigitalSource::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
+{
+	if (StatusIsFatal()) return;
+	if (m_interrupt == NULL)
+	{
+		wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
+		return;
+	}
+	tRioStatusCode localStatus = NiFpga_Status_Success;
+	if (m_interrupt != NULL)
+	{
+		m_interrupt->writeConfig_RisingEdge(risingEdge, &localStatus);
+		m_interrupt->writeConfig_FallingEdge(fallingEdge, &localStatus);
+	}
+	wpi_setError(localStatus);
 }
diff --git a/aos/externals/WPILib/WPILib/DigitalSource.h b/aos/externals/WPILib/WPILib/DigitalSource.h
index 1c427be..637a65e 100644
--- a/aos/externals/WPILib/WPILib/DigitalSource.h
+++ b/aos/externals/WPILib/WPILib/DigitalSource.h
@@ -19,12 +19,14 @@
 class DigitalSource: public InterruptableSensorBase
 {
 public:
+ DigitalSource();
 	virtual ~DigitalSource();
 	virtual UINT32 GetChannelForRouting() = 0;
 	virtual UINT32 GetModuleForRouting() = 0;
 	virtual bool GetAnalogTriggerForRouting() = 0;
-	virtual void RequestInterrupts(tInterruptHandler handler, void *param) = 0;
-	virtual void RequestInterrupts() = 0;
+	virtual void RequestInterrupts(tInterruptHandler handler, void *param);
+	virtual void RequestInterrupts();
+	void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
 };
 
 #endif
diff --git a/frc971/crio/crio.gyp b/frc971/crio/crio.gyp
index e2cd6ae..b91b32d 100644
--- a/frc971/crio/crio.gyp
+++ b/frc971/crio/crio.gyp
@@ -6,6 +6,9 @@
       'type': 'static_library',
       'sources': [
         '<(AOS)/externals/WPILib/WPILib/LiveWindow/LiveWindow.cpp',
+        '<(AOS)/externals/WPILib/WPILib/AnalogTriggerOutput.cpp',
+        '<(AOS)/externals/WPILib/WPILib/DigitalInput.cpp',
+        '<(AOS)/externals/WPILib/WPILib/DigitalSource.cpp',
       ],
       'dependencies': [
         '<(EXTERNALS):WPILib',