Exemplo n.º 1
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("DigitalInputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte            number = byte.Parse(reader.GetAttribute("Number"));
                    EosDigitalInput input  = new EosDigitalInput(this, number);
                    input.Name = reader.ReadElementString("DigitalInput");
                    _digitalInputs.Add(input);
                    _inputs.Add(input);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            DigitalInputCount = (byte)DigitalInputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AnalogInputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte           number = byte.Parse(reader.GetAttribute("Number"));
                    EosAnalogInput input  = new EosAnalogInput(this, number);
                    input.Name = reader.ReadElementString("AnalogInput");
                    _analogInputs.Add(input);
                    _inputs.Add(input);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            AnalogInputCount = (byte)AnalogInputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("LEDOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte         number = byte.Parse(reader.GetAttribute("Number"));
                    EosLedOutput output = new EosLedOutput(this, number);
                    output.Name = reader.ReadElementString("LEDOutput");
                    _ledOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            LedOutputCount = (byte)LedOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("TextOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte          number = byte.Parse(reader.GetAttribute("Number"));
                    EosTextOutput output = new EosTextOutput(this, number);
                    output.Name = reader.ReadElementString("TextOutput");
                    _textOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            TextOutputCount = (byte)_textOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("ServoOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte     number = byte.Parse(reader.GetAttribute("Number"));
                    EosServo output = new EosServo(this, number);
                    output.Name = reader.GetAttribute("Name");
                    // TODO: Deprectated fix for bad element name... remove after 1.6
                    if (reader.Name.Equals("ServerOutput"))
                    {
                        reader.ReadStartElement("ServerOutput");
                    }
                    else
                    {
                        reader.ReadStartElement("ServoOutput");
                    }
                    output.Calibration.Read(reader);
                    reader.ReadEndElement();
                    _servoOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            ServoOutputCount = (byte)ServoOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("StepperOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte       number = byte.Parse(reader.GetAttribute("Number"));
                    EosStepper output = new EosStepper(this, number);
                    output.Name = reader.GetAttribute("Name");
                    reader.ReadStartElement("StepperOutput");
                    output.Calibration.Read(reader);
                    reader.ReadEndElement();
                    _stepperOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            StepperOutputCount = (byte)StepperOutputs.Count;

            if (reader.Name.Equals("CoilOutputs"))
            {
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement("CoilOutputs");
                    while (reader.NodeType != XmlNodeType.EndElement)
                    {
                        byte          number = byte.Parse(reader.GetAttribute("Number"));
                        EosCoilOutput output = new EosCoilOutput(this, number);
                        output.Name = reader.GetAttribute("Name");
                        reader.ReadStartElement("CoilOutput");
                        output.Calibration.Read(reader);
                        reader.ReadEndElement();
                        _coilOutputs.Add(output);
                        _outputs.Add(output);
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.Read();
                }
            }
            CoilOutputCount = (byte)CoilOutputs.Count;
        }
Exemplo n.º 2
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("DigitalInputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosDigitalInput input = new EosDigitalInput(this, number);
                    input.Name = reader.ReadElementString("DigitalInput");
                    _digitalInputs.Add(input);
                    _inputs.Add(input);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            DigitalInputCount = (byte)DigitalInputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AnalogInputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosAnalogInput input = new EosAnalogInput(this, number);
                    input.Name = reader.ReadElementString("AnalogInput");
                    _analogInputs.Add(input);
                    _inputs.Add(input);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            AnalogInputCount = (byte)AnalogInputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("LEDOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosLedOutput output = new EosLedOutput(this, number);
                    output.Name = reader.ReadElementString("LEDOutput");
                    _ledOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            LedOutputCount = (byte)LedOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("TextOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosTextOutput output = new EosTextOutput(this, number);
                    output.Name = reader.ReadElementString("TextOutput");
                    _textOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            TextOutputCount = (byte)_textOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("ServoOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosServo output = new EosServo(this, number);
                    output.Name = reader.GetAttribute("Name");
                    // TODO: Deprectated fix for bad element name... remove after 1.6
                    if (reader.Name.Equals("ServerOutput"))
                    {
                        reader.ReadStartElement("ServerOutput");
                    }
                    else
                    {
                        reader.ReadStartElement("ServoOutput");
                    }                    
                    output.Calibration.Read(reader);
                    reader.ReadEndElement();
                    _servoOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            ServoOutputCount = (byte)ServoOutputs.Count;

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("StepperOutputs");
                while (reader.NodeType != XmlNodeType.EndElement)
                {
                    byte number = byte.Parse(reader.GetAttribute("Number"));
                    EosStepper output = new EosStepper(this, number);
                    output.Name = reader.GetAttribute("Name");
                    reader.ReadStartElement("StepperOutput");
                    output.Calibration.Read(reader);
                    reader.ReadEndElement();
                    _stepperOutputs.Add(output);
                    _outputs.Add(output);
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            StepperOutputCount = (byte)StepperOutputs.Count;

            if (reader.Name.Equals("CoilOutputs"))
            {
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement("CoilOutputs");
                    while (reader.NodeType != XmlNodeType.EndElement)
                    {
                        byte number = byte.Parse(reader.GetAttribute("Number"));
                        EosCoilOutput output = new EosCoilOutput(this, number);
                        output.Name = reader.GetAttribute("Name");
                        reader.ReadStartElement("CoilOutput");
                        output.Calibration.Read(reader);
                        reader.ReadEndElement();
                        _coilOutputs.Add(output);
                        _outputs.Add(output);
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.Read();
                }
            }
            CoilOutputCount = (byte)CoilOutputs.Count;
        }