コード例 #1
0
 internal override InterruptableSensorBase GiveInterruptableSensorBase()
 {
     m_interruptTrigger = new AnalogTrigger(s_analogIo.GetInput());
     m_interruptTrigger.SetLimitsVoltage(2.0f, 3.0f);
     m_interruptTriggerOutput = new AnalogTriggerOutput(m_interruptTrigger, AnalogTriggerType.State);
     return(m_interruptTriggerOutput);
 }
コード例 #2
0
        public void TestAnalogTriggerAboveWindow()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());
            trigger.SetLimitsVoltage(2.0f, 3.0f);

            s_analogIo.GetOutput().SetVoltage(4.0f);
            Timer.Delay(DelayTime);

            Assert.IsFalse(trigger.GetInWindow(), "Analog Trigger is in the window (2V, 3V)");
            Assert.IsTrue(trigger.GetTriggerState(), "Analog trigger is not on");

            trigger.Dispose();
        }
コード例 #3
0
        public void TestAnalogTriggerInWindow()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());
            trigger.SetLimitsVoltage(2.0f, 3.0f);

            s_analogIo.GetOutput().SetVoltage(2.5f);
            Timer.Delay(DelayTime);

            Assert.IsTrue(trigger.GetInWindow(), "Analog Trigger is not in the window (2V, 3V)");
            //Not checking for state, because state will be whichever state it was in last.

            trigger.Dispose();
        }
コード例 #4
0
        public void TestAnalogTriggerInWindow()
        {
            AnalogTrigger trigger = new AnalogTrigger(analogIO.GetInput());
            trigger.SetLimitsVoltage(2.0f, 3.0f);

            analogIO.GetOutput().SetVoltage(2.5f);
            Timer.Delay(DelayTime);

            Assert.IsTrue(trigger.InWindow, "Analog Trigger is not in the window (2V, 3V)");
            Assert.IsFalse(trigger.TriggerState, "Analog trigger is on");

            trigger.Dispose();
        }
コード例 #5
0
        public void TestAnalogTriggerAboveWindow()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());

            trigger.SetLimitsVoltage(2.0f, 3.0f);

            s_analogIo.GetOutput().SetVoltage(4.0f);
            Timer.Delay(DelayTime);

            Assert.IsFalse(trigger.GetInWindow(), "Analog Trigger is in the window (2V, 3V)");
            Assert.IsTrue(trigger.GetTriggerState(), "Analog trigger is not on");

            trigger.Dispose();
        }
コード例 #6
0
        public void TestAnalogTriggerInWindow()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());

            trigger.SetLimitsVoltage(2.0f, 3.0f);

            s_analogIo.GetOutput().SetVoltage(2.5f);
            Timer.Delay(DelayTime);

            Assert.IsTrue(trigger.GetInWindow(), "Analog Trigger is not in the window (2V, 3V)");
            //Not checking for state, because state will be whichever state it was in last.

            trigger.Dispose();
        }
コード例 #7
0
        public void TestAnalogTriggerCounter()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());

            trigger.SetLimitsVoltage(2.0f, 3.0f);
            Counter counter = new Counter(trigger);

            for (int i = 0; i < 50; i++)
            {
                s_analogIo.GetOutput().SetVoltage(1.0);
                Timer.Delay(DelayTime);
                s_analogIo.GetOutput().SetVoltage(4.0);
                Timer.Delay(DelayTime);
            }

            Assert.AreEqual(50, counter.Get(), "Analog trigger counter did not count 50 ticks");

            counter.Dispose();
            trigger.Dispose();
        }
コード例 #8
0
        public void TestSetLimitsVoltageInvalid()
        {
            using (AnalogTrigger at = new AnalogTrigger(2))
            {
                Assert.Throws<BoundaryException>(() =>
                {
                    at.SetLimitsVoltage(4.0, 2.0);
                });

            }
        }
コード例 #9
0
 public void TestSetLimitsVoltageValid()
 {
     using (AnalogTrigger at = new AnalogTrigger(2))
     {
         at.SetLimitsVoltage(2.2, 4.4);
         Assert.That(GetData(at.Index).TrigLower, Is.EqualTo(2.2));
         Assert.That(GetData(at.Index).TrigUpper, Is.EqualTo(4.4));
     }
 }
コード例 #10
0
        public void TestAnalogTriggerCounter()
        {
            AnalogTrigger trigger = new AnalogTrigger(s_analogIo.GetInput());
            trigger.SetLimitsVoltage(2.0f, 3.0f);
            Counter counter = new Counter(trigger);

            for (int i = 0; i < 50; i++)
            {
                s_analogIo.GetOutput().SetVoltage(1.0);
                Timer.Delay(DelayTime);
                s_analogIo.GetOutput().SetVoltage(4.0);
                Timer.Delay(DelayTime);
            }

            Assert.AreEqual(50, counter.Get(), "Analog trigger counter did not count 50 ticks");

            counter.Dispose();
            trigger.Dispose();
        }
コード例 #11
0
 internal override InterruptableSensorBase GiveInterruptableSensorBase()
 {
     m_interruptTrigger = new AnalogTrigger(s_analogIo.GetInput());
     m_interruptTrigger.SetLimitsVoltage(2.0f, 3.0f);
     m_interruptTriggerOutput = new AnalogTriggerOutput(m_interruptTrigger, AnalogTriggerType.State);
     return m_interruptTriggerOutput;
 }