Пример #1
0
        public void TestDigitalPWMOverAllocate()
        {
            List<DigitalOutput> counters = new List<DigitalOutput>();
            for (int i = 0; i < 6; i++)
            {
                DigitalOutput output = new DigitalOutput(i);
                counters.Add(output);
                output.EnablePWM(0.5);
                Assert.That(SimData.DigitalPWM[output.PwmGeneratorChannel].Initialized, Is.True);
            }

            DigitalOutput counter = new DigitalOutput(NumCounters); ;
            Assert.DoesNotThrow(() =>
            {
                counter.EnablePWM(0.5);
                Assert.That(counter.PwmGeneratorChannel, Is.EqualTo(~0));
            });
            counter?.Dispose();

            foreach (var c in counters)
            {
                c?.Dispose();
                if (c == null) return;
                Assert.That(SimData.DigitalPWM[c.PwmGeneratorChannel].Initialized, Is.False);
            }

        }