Ejemplo n.º 1
0
        public Switch(FlightControlSystem fcs, XmlElement element)
            : base(fcs, element)
        {
            string     value;
            TestSwitch current_test;

            Bind(element); // Bind() this component here in case it is used in its own
                           // definition for a sample-and-hold
            XmlElement test_element = element.FindElement("default");

            if (test_element != null)
            {
                current_test = new TestSwitch();
                value        = test_element.GetAttribute("value");
                current_test.SetTestValue(value, name, propertyManager);
                current_test.Default = true;
                double tmp;
                if (delay > 0 && double.TryParse(value, out tmp))
                {                              // If there is a delay, initialize the
                    for (int i = 0; i < delay - 1; i++)
                    {                          // delay buffer to the default value
                        output_array[i] = tmp; // for the switch if that value is a number.
                    }
                }
                tests.Add(current_test);
            }

            var nodeList = element.GetElementsByTagName("test");

            foreach (var elem in nodeList)
            {
                if (elem is XmlElement)
                {
                    test_element           = elem as XmlElement;
                    current_test           = new TestSwitch();
                    current_test.condition = new Condition(test_element, propertyManager);
                    value = test_element.GetAttribute("value");
                    current_test.SetTestValue(value, name, propertyManager);
                    tests.Add(current_test);
                }
            }

            Debug(0);
        }