Example #1
0
        public void Analog()
        {
            #region Startup
            var  TestTable = new LadderDataTable();
            Node PowerRail = new Node();
            PowerRail.LogicLevel = false;

            PWM pwm = new PWM("1", PowerRail);
            pwm.DataTable = TestTable;
            ADC adc = new ADC("1", PowerRail);
            adc.DataTable = TestTable;
            #endregion Startup

            #region PWM
            pwm.DudyCycle = "255";
            pwm.Execute();
            Assert.IsFalse(pwm.InternalState);

            PowerRail.LogicLevel = true;
            pwm.Execute();
            Assert.IsTrue(pwm.InternalState);

            PowerRail.LogicLevel = false;
            pwm.DudyCycle        = "DudyCycle";
            pwm.DudyCycleValue   = (byte)128;
            pwm.Execute();
            Assert.IsFalse(pwm.InternalState);

            PowerRail.LogicLevel = true;
            pwm.Execute();
            Assert.IsTrue(pwm.InternalState);
            #endregion PWM

            #region ADC
            PowerRail.LogicLevel = false;
            adc.Execute();
            Assert.IsFalse(adc.InternalState);
            adc.InputValue = (short)1023;
            adc.Execute();
            Assert.IsFalse(adc.InternalState);

            PowerRail.LogicLevel = true;
            adc.Execute();
            Assert.IsTrue(adc.InternalState);
            #endregion ADC
        }