public void TestDisableStopsInterruptFiring() { InterruptCounter counter = new InterruptCounter(); TestHandlerFunction function = new TestHandlerFunction(counter); GetInterruptable().RequestInterrupts(function.Fired, counter); GetInterruptable().EnableInterrupts(); int fireCount = 50; for (int i = 0; i < fireCount; i++) { SetInterruptLow(); SetInterruptHigh(); while (function.InterruptComplete == 0) { Thread.Yield(); } function.InterruptComplete = 0; } GetInterruptable().DisableInterrupts(); for (int i = 0; i < fireCount; i++) { SetInterruptLow(); SetInterruptHigh(); Thread.Yield(); } Assert.AreEqual(fireCount, counter.GetCount(), "The interrupt did not fire the expected number of times"); }
public void TestSingleInterruptsTriggering() { InterruptCounter counter = new InterruptCounter(); TestHandlerFunction function = new TestHandlerFunction(counter); GetInterruptable().RequestInterrupts(function.Fired, counter); GetInterruptable().EnableInterrupts(); SetInterruptLow(); Delay(0.01); long interruptTriggerTime = (long)Utility.GetFPGATime(); SetInterruptHigh(); while (function.InterruptComplete == 0) { Thread.Yield(); } Assert.AreEqual(1, counter.GetCount(), "The interrupt did not fire the expected number of times"); long range = 10000; string error = "The interrupt did not fire within the expected time period (values in milliseconds)"; Assert.Greater(function.InterruptFireTime, interruptTriggerTime - range, error); Assert.Less(function.InterruptFireTime, interruptTriggerTime + range, error); error = "The ReadRisingTimestamp() did not return the correct value (values in seconds"; Assert.Greater(GetInterruptable().ReadRisingTimestanp(), (interruptTriggerTime - range) / 1e6, error); Assert.Less(GetInterruptable().ReadRisingTimestanp(), (interruptTriggerTime + range) / 1e6, error); }
public void TestSingleInterruptsTriggering() { //TODO: Add Analog Interrupts if (RobotBase.IsSimulation && this is AnalogCrossConnectTest) { Assert.Ignore(); } InterruptCounter counter = new InterruptCounter(); TestHandlerFunction function = new TestHandlerFunction(counter); GetInterruptable().RequestInterrupts(function.fired, counter); GetInterruptable().EnableInterrupts(); SetInterruptLow(); Delay(0.01); long interruptTriggerTime = Utility.GetFPGATime(); SetInterruptHigh(); while (function.interruptComplete == 0) { Delay(0.005); } Assert.AreEqual(1, counter.GetCount(), "The interrupt did not fire the expected number of times"); long range = 10000; string error = "The interrupt did not fire within the expected time period (values in milliseconds)"; Assert.Greater(function.interruptFireTime, (interruptTriggerTime - range), error); Assert.Less(function.interruptFireTime, (interruptTriggerTime + range), error); error = "The ReadRisingTimestamp() did not return the correct value (values in seconds"; Assert.Greater(GetInterruptable().ReadRisingTimestanp(), (interruptTriggerTime - range) / 1e6, error); Assert.Less(GetInterruptable().ReadRisingTimestanp(), (interruptTriggerTime + range) / 1e6, error); }
public void TestDisableStopsInterruptFiring() { //TODO: Add Analog Interrupts if (RobotBase.IsSimulation && this is AnalogCrossConnectTest) { Assert.Ignore(); } InterruptCounter counter = new InterruptCounter(); TestHandlerFunction function = new TestHandlerFunction(counter); GetInterruptable().RequestInterrupts(function.fired, counter); GetInterruptable().EnableInterrupts(); int fireCount = 50; for (int i = 0; i < fireCount; i++) { SetInterruptLow(); SetInterruptHigh(); while (function.interruptComplete == 0) { Delay(0.005); } function.interruptComplete = 0; } GetInterruptable().DisableInterrupts(); for (int i = 0; i < fireCount; i++) { SetInterruptLow(); SetInterruptHigh(); Delay(0.005); } Assert.AreEqual(fireCount, counter.GetCount(), "The interrupt did not fire the expected number of times"); }