Пример #1
0
 public simINDevices(XMLConfiguration configuration, RS232Configuration interf, simINDevice [] devices)
 {
     _configuration  = configuration;
     _interface      = interf;
     _devices        = devices;
     interf.Receiver = this;
 }
        public AddEditEncoderDialog(XMLConfiguration configuration, Encoder encoder)
        {
            _configuration = configuration;
            _encoder       = encoder;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            comboBox3.Items.Add("Pełny kod Gray'a");
            comboBox3.Items.Add("1/2 kodu Gray'a");
            comboBox3.Items.Add("1/4 kodu Gray'a");
            comboBox3.SelectedIndex = 0;

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            // wczytanie listy urządzeń
            for (int i = 0; i < _configuration.KeysDevices.Length; i++)
            {
                comboBox1.Items.Add(new KD()
                {
                    Device = _configuration.KeysDevices[i]
                });
            }

            if (_encoder != null)
            {
                Text = "Edytuj enkoder";

                textBox1.Text = _encoder.Description;
                for (int i = 0; i < comboBox1.Items.Count; i++)
                {
                    if (((KD)comboBox1.Items[i]).Device == _encoder.KeysDevice)
                    {
                        comboBox1.SelectedIndex = i;
                        break;
                    }
                }

                for (int i = 0; i < comboBox2.Items.Count; i++)
                {
                    if (((EI)comboBox2.Items[i]).Index == _encoder.Index)
                    {
                        comboBox2.SelectedIndex = i;
                        break;
                    }
                }

                checkBox1.Checked = _encoder.DetectFast;

                comboBox3.SelectedIndex = (int)_encoder.Type;
            }
            else
            {
                Text = "Dodaj enkoder";
            }
        }
        public void Close(XMLConfiguration conf)
        {
            if (_rs232 != null && _rs232.IsOpen)
            {
                if (_rs232.IsOpen)
                {
                    // uinicjalizacja wszystkich urządzeń na tym interfejsie
                    if (conf != null)
                    {
                        foreach (LEDDevice dev in conf.LEDDevices)
                        {
                            if (dev.Interface == this)
                            {
                                dev.Uninitialize();
                            }
                        }

                        foreach (LEDDisplayDevice dev in conf.LEDDisplayDevices)
                        {
                            if (dev.Interface == this)
                            {
                                dev.Uninitialize();
                            }
                        }

                        foreach (LCDDevice dev in conf.LCDDevices)
                        {
                            if (dev.Interface == this)
                            {
                                dev.Uninitialize();
                            }
                        }

                        foreach (KeysDevice dev in conf.KeysDevices)
                        {
                            if (dev.Interface == this)
                            {
                                dev.Uninitialize();
                            }
                        }
                    }



                    _rs232.Close();
                }
                _rs232.Dispose();
                _rs232 = null;
            }
        }
Пример #4
0
        public AddEditKeyDevice(XMLConfiguration configuration, int keysDeviceIndex, RS232Configuration interf)
        {
            _configuration   = configuration;
            _keysDeviceIndex = keysDeviceIndex;
            _interf          = interf;

            InitializeComponent();

            if (keysDeviceIndex < 0)
            {
                // dodanie nowego
                Text = "Dodaj nowe wejścia cyfrowe";
                comboBox1.SelectedIndex = 0;
                ComboBox1SelectedIndexChanged(null, null);
            }
            else
            {
                // edycja istniejącego
                Text = "Edycja wejść cyfrowych";
                KeysDevice keysd = (KeysDevice)configuration.KeysDevices[keysDeviceIndex];
                textBox2.Text        = keysd.Description;
                checkBox1.Checked    = keysd.HardwareIndexes;
                numericUpDown2.Value = keysd.Delay;
                List <Key> keys = new List <Key>();
                for (int i = 0; i < configuration.Keys.Length; i++)
                {
                    Key key = configuration.Keys[i];
                    if (key.KeysDevice == keysd)
                    {
                        keys.Add(key);
                    }
                }
                keys.Sort(delegate(Key left, Key right)
                {
                    return(left.Index.CompareTo(right.Index));
                });
                for (int j = 0; j < keys.Count; j++)
                {
                    dataGridView1.Rows.Add((j).ToString(), keys[j].ID, keys[j].Description);
                }
                comboBox1.SelectedItem = dataGridView1.Rows.Count.ToString();
                ComboBox1SelectedIndexChanged(null, null);
                _loading             = true;
                numericUpDown1.Value = keysd.DeviceId;
                _loading             = false;
            }
        }
Пример #5
0
        public AddEditLEDDevice(XMLConfiguration configuration, int ledDeviceIndex, RS232Configuration interf)
        {
            InitializeComponent();

            _configuration  = configuration;
            _ledDeviceIndex = ledDeviceIndex;
            _interf         = interf;

            if (ledDeviceIndex < 0)
            {
                // dodanie nowego
                Text = "Dodaj nowe diody LED";
                NumericUpDown2ValueChanged(null, null);
            }
            else
            {
                // edycja istniejącego
                Text = "Edycja diod LED";
                LEDDevice ledd = (LEDDevice)configuration.LEDDevices[ledDeviceIndex];
                textBox2.Text = ledd.Description;
                List <LED> leds = new List <LED>();
                for (int i = 0; i < configuration.LEDs.Length; i++)
                {
                    LED led = configuration.LEDs[i];
                    if (led.LEDDevice == configuration.LEDDevices[ledDeviceIndex])
                    {
                        leds.Add(led);
                    }
                }
                leds.Sort(delegate(LED left, LED right)
                {
                    return(left.Index.CompareTo(right.Index));
                });
                for (int j = 0; j < leds.Count; j++)
                {
                    dataGridView1.Rows.Add((j + 1).ToString(), leds[j].ID, leds[j].Description);
                }
                if (dataGridView1.Rows.Count < numericUpDown2.Value)
                {
                    NumericUpDown2ValueChanged(null, null);
                }
                numericUpDown2.Value = dataGridView1.Rows.Count;
                _loading             = true;
                numericUpDown1.Value = ledd.DeviceId;
                _loading             = false;
            }
        }
        public AddEditLCDDevice(XMLConfiguration configuration, int lcdDeviceIndex, RS232Configuration interf)
        {
            InitializeComponent();

            _configuration  = configuration;
            _lcdDeviceIndex = lcdDeviceIndex;
            _interf         = interf;

            dataGridView1.Columns[3].CellTemplate = new NumericCell1_4();
            dataGridView1.Columns[4].CellTemplate = new NumericCell1_40();

            if (lcdDeviceIndex < 0)
            {
                // dodanie nowego
                Text = "Dodaj nowe wyświetlacze";
                NumericUpDown2ValueChanged(null, null);
            }
            else
            {
                // edycja istniejącego
                Text = "Edycja wyświetlaczy";
                LCDDevice lcdd = (LCDDevice)configuration.LCDDevices[lcdDeviceIndex];
                textBox2.Text = lcdd.Description;
                List <RS232LCD> lcds = new List <RS232LCD>();
                for (int i = 0; i < configuration.LCDs.Length; i++)
                {
                    RS232LCD lcd = (RS232LCD)configuration.LCDs[i];
                    if (lcd.LCDDevice == configuration.LCDDevices[lcdDeviceIndex])
                    {
                        lcds.Add(lcd);
                    }
                }
                lcds.Sort(delegate(RS232LCD left, RS232LCD right)
                {
                    return(left.Index.CompareTo(right.Index));
                });
                for (int j = 0; j < lcds.Count; j++)
                {
                    dataGridView1.Rows.Add((j + 1).ToString(), lcds[j].ID, lcds[j].Description, lcds[j].Rows, lcds[j].Columns);
                }
                numericUpDown2.Value = dataGridView1.Rows.Count;
                _loading             = true;
                numericUpDown1.Value = lcdd.DeviceId;
                _loading             = false;
            }
        }
Пример #7
0
        public AddEditLCDArea(XMLConfiguration configuration, int areIndex)
        {
            InitializeComponent();
            _configuration = configuration;
            _areaIndex     = areIndex;

            foreach (Enum s in Enum.GetValues(typeof(Align)))
            {
                comboBox1.Items.Add(HomeSimCockpitX.LCD.Utils.AlignToString((Align)s));
            }

            foreach (Enum s in Enum.GetValues(typeof(Trim)))
            {
                comboBox2.Items.Add(HomeSimCockpitX.LCD.Utils.TrimToString((Trim)s));
            }

            foreach (Enum s in Enum.GetValues(typeof(Append)))
            {
                comboBox3.Items.Add(HomeSimCockpitX.LCD.Utils.AppendToString((Append)s));
            }

            Array.Sort(_configuration.LCDs);
            foreach (LCD lcd in _configuration.LCDs)
            {
                comboBox4.Items.Add(lcd);
            }

            if (areIndex < 0)
            {
                // dodanie nowego
                Text = "Dodaj nowy obszar";
            }
            else
            {
                // edycja istniejącego
                LCDArea area = configuration.Areas[areIndex];
                Text                   = "Edycja obszaru '" + area.ID + "'";
                textBox1.Text          = area.ID;
                textBox2.Text          = area.Description;
                comboBox1.SelectedItem = Utils.AlignToString(area.Align);
                comboBox2.SelectedItem = Utils.TrimToString(area.Trim);
                comboBox3.SelectedItem = Utils.AppendToString(area.Append);
                textBox3.Text          = area.AppendString;
                ShowCharacters();
            }
        }
Пример #8
0
        public bool Configuration(System.Windows.Forms.IWin32Window parent)
        {
            if (_working)
            {
                MessageBox.Show(parent, "Konfiguracja jest niedostępna w trakcie działania skryptu korzystającego z tego modułu.", "Uwaga", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            ConfigurationDialog cd = new ConfigurationDialog(XMLConfiguration.Load(), _log, this);

            if (cd.ShowDialog(parent) == System.Windows.Forms.DialogResult.OK)
            {
                cd.Configuration.Save();
                _configuration = cd.Configuration;
                LoadVariables();
                return(true);
            }
            return(false);
        }
Пример #9
0
        public AddEditInterfaceDialog(XMLConfiguration configuration, RS232Configuration interf)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            comboBox1.Items.AddRange(SerialPort.GetPortNames());

            comboBox2.Items.AddRange(new object[] { 2400, 4800, 9600, 14400, 19200, 28800, 38400, 56000, 57600, 115200, 128000, 256000 });
            comboBox2.SelectedItem = 57600;

            comboBox3.Items.AddRange(new object[] { 5, 6, 7, 8 });
            comboBox3.SelectedItem = 8;

            comboBox4.Items.AddRange(Enum.GetNames(typeof(Handshake)));
            comboBox4.SelectedItem = Handshake.None.ToString();

            comboBox5.Items.AddRange(Enum.GetNames(typeof(Parity)));
            comboBox5.SelectedItem = Parity.None.ToString();

            comboBox6.Items.AddRange(Enum.GetNames(typeof(StopBits)));
            comboBox6.SelectedItem = StopBits.Two.ToString();

            Interface     = interf;
            Configuration = configuration;

            if (Interface == null)
            {
                Text         = "Dodaj nowy interfejs";
                button1.Text = "Dodaj";
            }
            else
            {
                comboBox1.Text         = Interface.PortName;
                comboBox2.SelectedItem = Interface.BaudRate;
                comboBox3.SelectedItem = Interface.DataBits;
                comboBox4.SelectedItem = Interface.HandShake.ToString();
                comboBox5.SelectedItem = Interface.Parity.ToString();
                comboBox6.SelectedItem = Interface.StopBits.ToString();
                Text         = "Edytuj interfejs";
                button1.Text = "Zapisz";
            }
        }
Пример #10
0
        public AddEditLEDGroupDialog(XMLConfiguration configuration, LEDGroup ledGroup)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            _configuration = configuration;
            LEDGroup       = ledGroup;

            foreach (LED led in _configuration.LEDs)
            {
                checkedListBox1.Items.Add(new Output()
                {
                    Led = led
                });
            }

            if (ledGroup == null)
            {
                Text = "Dodaj nową grupę diod LED";
            }
            else
            {
                Text = "Edytuj grupę diod LED";

                textBox2.Text = ledGroup.ID;
                textBox1.Text = ledGroup.Description;

                foreach (LED dos in ledGroup.LEDs)
                {
                    for (int i = 0; i < checkedListBox1.Items.Count; i++)
                    {
                        if (dos == ((Output)checkedListBox1.Items[i]).Led)
                        {
                            checkedListBox1.SetItemChecked(i, true);
                            break;
                        }
                    }
                }
            }
        }
Пример #11
0
 public static XMLConfiguration Reload()
 {
     __instance = null;
     return(Load());
 }
Пример #12
0
        private void LoadConfiguration()
        {
            _configuration = XMLConfiguration.Load();

            LoadVariables();
        }
Пример #13
0
        public TestDialog(XMLConfiguration configuration, HomeSimCockpitSDK.ILog log, HomeSimCockpitSDK.IModule module)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            _configuration = configuration;

            // pokazanie urządzeń
            foreach (RS232Configuration d in _configuration.Interfaces)
            {
                ListViewItem item = new ListViewItem(d.PortName);
                item.SubItems.Add("");
                item.Tag = d;
                listView1.Items.Add(item);
            }

            // pokazanie wyświetlaczy
            for (int i = 0; i < _configuration.LCDs.Length; i++)
            {
                int r = dataGridView5.Rows.Add(_configuration.LCDs[i].ID, _configuration.LCDs[i].Description, "On", "Clear", "Off");
                dataGridView5.Rows[r].Tag = _configuration.LCDs[i];
            }

            // pokazanie obszarów tekstowych
            for (int i = 0; i < _configuration.Areas.Length; i++)
            {
                int r = dataGridView1.Rows.Add(_configuration.Areas[i].ID, _configuration.Areas[i].Description, "");
                dataGridView1.Rows[r].Tag = _configuration.Areas[i];
            }

            // pokazanie diod LED
            for (int i = 0; i < _configuration.LEDs.Length; i++)
            {
                int r = dataGridView2.Rows.Add(_configuration.LEDs[i].ID, _configuration.LEDs[i].Description, false);
                dataGridView2.Rows[r].Tag = _configuration.LEDs[i];
            }

            // pokazanie grup diod LED
            for (int i = 0; i < _configuration.LEDGroups.Length; i++)
            {
                int r = dataGridView2.Rows.Add(_configuration.LEDGroups[i].ID, _configuration.LEDGroups[i].Description, false);
                dataGridView2.Rows[r].Tag = _configuration.LEDGroups[i];
            }

            // pokazanie wyświetlaczy LED
            for (int i = 0; i < _configuration.LEDDisplays.Length; i++)
            {
                int r = dataGridView3.Rows.Add(_configuration.LEDDisplays[i].ID, _configuration.LEDDisplays[i].Description, "");
                dataGridView3.Rows[r].Tag = _configuration.LEDDisplays[i];
            }

            // pokazanie grup wyświetlaczy LED
            for (int i = 0; i < _configuration.LEDDisplayGroups.Length; i++)
            {
                int r = dataGridView3.Rows.Add(_configuration.LEDDisplayGroups[i].ID, _configuration.LEDDisplayGroups[i].Description, "");
                dataGridView3.Rows[r].Tag = _configuration.LEDDisplayGroups[i];
            }

            // pokazanie wejść cyfrowych
            for (int i = 0; i < _configuration.Keys.Length; i++)
            {
                int r = inputsGrid.Rows.Add(_configuration.Keys[i].ID, _configuration.Keys[i].Description, "False");
                inputsGrid.Rows[r].Tag = _configuration.Keys[i];
            }

            // pokazanie silników krokowych
            for (int i = 0; i < _configuration.StepperDevices.Length; i++)
            {
                if (_configuration.StepperDevices[i].Motor1 != null)
                {
                    int r = dataGridView4.Rows.Add(_configuration.StepperDevices[i].Motor1.Id, _configuration.StepperDevices[i].Motor1.Description, _configuration.StepperDevices[i].Motor1.CurrentPosition);
                    dataGridView4.Rows[r].Tag = _configuration.StepperDevices[i].Motor1;
                }

                if (_configuration.StepperDevices[i].Motor2 != null)
                {
                    int r = dataGridView4.Rows.Add(_configuration.StepperDevices[i].Motor2.Id, _configuration.StepperDevices[i].Motor2.Description, _configuration.StepperDevices[i].Motor2.CurrentPosition);
                    dataGridView4.Rows[r].Tag = _configuration.StepperDevices[i].Motor2;
                }
            }

            // pokazanie serwomechanizmów
            for (int i = 0; i < _configuration.ServoDevices.Length; i++)
            {
                for (int j = 0; j < _configuration.ServoDevices[i].Servos.Length; j++)
                {
                    int r = gridServos.Rows.Add(_configuration.ServoDevices[i].Servos[j].Id, _configuration.ServoDevices[i].Servos[j].Description, _configuration.ServoDevices[i].Servos[j].Min, _configuration.ServoDevices[i].Servos[j].InitialPosition, _configuration.ServoDevices[i].Servos[j].Max);
                    gridServos.Rows[r].Tag = _configuration.ServoDevices[i].Servos[j];
                }
            }

            timer1.Enabled = dataGridView4.Rows.Count > 0;

            // pokazanie dodatkowych zmiennych
            IOutputVariable [] addins = _configuration.GetAddinsVariable();
            if (addins != null && addins.Length > 0)
            {
                Array.Sort <IOutputVariable>(addins, delegate(IOutputVariable left, IOutputVariable right)
                {
                    int result = left.ID.CompareTo(right.ID);
                    if (result == 0)
                    {
                        result = left.Description.CompareTo(right.Description);
                    }
                    return(result);
                });
            }
            for (int i = 0; i < addins.Length; i++)
            {
                int r = addinsGrid.Rows.Add(addins[i].ID, addins[i].Description, "");
                addinsGrid.Rows[r].Tag = addins[i];
            }

            Working = false;
            _log    = log;
            _module = module;
        }
Пример #14
0
 private XMLConfiguration LoadConfiguration()
 {
     return(XMLConfiguration.Load());
 }
Пример #15
0
        public ConfigurationDialog(XMLConfiguration xmlConfiguration, HomeSimCockpitSDK.ILog log, HomeSimCockpitSDK.IModule module)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            Configuration = xmlConfiguration;

            _root = treeView1.Nodes[0];


            // pokazanie interfejsów i urządzeń
            Array.Sort <RS232Configuration>(xmlConfiguration.Interfaces);
            Array.Sort <LEDDevice>(xmlConfiguration.LEDDevices);
            Array.Sort <LCDDevice>(xmlConfiguration.LCDDevices);
            Array.Sort <LEDDisplayDevice>(xmlConfiguration.LEDDisplayDevices);
            Array.Sort <KeysDevice>(xmlConfiguration.KeysDevices);
            Array.Sort <Steppers.StepperDevice>(xmlConfiguration.StepperDevices);
            Array.Sort <Servos.ServoDevice>(xmlConfiguration.ServoDevices);

            for (int i = 0; i < xmlConfiguration.Interfaces.Length; i++)
            {
                InterfaceTreeNode node = new InterfaceTreeNode(xmlConfiguration.Interfaces[i]);
                _root.Nodes.Add(node);

                // dodanie wszystkich LCDDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.LCDDevices.Length; j++)
                {
                    if (xmlConfiguration.LCDDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.LCDDevices[j].Name2);
                        n.Tag = xmlConfiguration.LCDDevices[j];
                        node.Nodes.Add(n);
                    }
                }

                // dodanie wszystkich LEDDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.LEDDevices.Length; j++)
                {
                    if (xmlConfiguration.LEDDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.LEDDevices[j].Name2);
                        n.Tag = xmlConfiguration.LEDDevices[j];
                        node.Nodes.Add(n);
                    }
                }

                // dodanie wszystkich LEDDisplayDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.LEDDisplayDevices.Length; j++)
                {
                    if (xmlConfiguration.LEDDisplayDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.LEDDisplayDevices[j].Name2);
                        n.Tag = xmlConfiguration.LEDDisplayDevices[j];
                        node.Nodes.Add(n);
                    }
                }

                // dodanie wszystkich StepperDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.StepperDevices.Length; j++)
                {
                    if (xmlConfiguration.StepperDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.StepperDevices[j].Name2);
                        n.Tag = xmlConfiguration.StepperDevices[j];
                        node.Nodes.Add(n);
                    }
                }

                // dodanie wszystkich ServoDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.ServoDevices.Length; j++)
                {
                    if (xmlConfiguration.ServoDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.ServoDevices[j].Name2);
                        n.Tag = xmlConfiguration.ServoDevices[j];
                        node.Nodes.Add(n);
                    }
                }

                // dodanie wszystkich KeysDevice podpiętych do tego interfejsu
                for (int j = 0; j < xmlConfiguration.KeysDevices.Length; j++)
                {
                    if (xmlConfiguration.KeysDevices[j].Interface == xmlConfiguration.Interfaces[i])
                    {
                        TreeNode n = new TreeNode(xmlConfiguration.KeysDevices[j].Name2);
                        n.Tag = xmlConfiguration.KeysDevices[j];
                        node.Nodes.Add(n);
                    }
                }
            }

            treeView1.ExpandAll();
            treeView1.SelectedNode = _root;

            ShowVariables();
            _log    = log;
            _module = module;
        }
Пример #16
0
        public static XMLConfiguration Load()
        {
            if (__instance != null)
            {
                return(__instance);
            }

            if (!File.Exists(ConfigurationFilePath))
            {
                throw new FileNotFoundException(ConfigurationFilePath);
            }
            XMLConfiguration c   = new XMLConfiguration();
            XmlDocument      xml = new XmlDocument();

            xml.Load(ConfigurationFilePath);

            // wczytanie interfejsów
            List <RS232Configuration> interfaces = new List <RS232Configuration>();
            XmlNodeList nodes = xml.SelectNodes("/configuration/interfaces/interface");

            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    RS232Configuration interf = RS232Configuration.Load(node);
                    interfaces.Add(interf);
                }
            }
            c.Interfaces = interfaces.ToArray();

            // wczytanie urządzeń z LCD
            List <LCDDevice> lcdDevices = new List <LCDDevice>();

            nodes = xml.SelectNodes("/configuration/lcdDevices/lcdDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LCDDevice lcdDevice = LCDDevice.Load(node, interfaces);
                    if (lcdDevice != null)
                    {
                        lcdDevices.Add(lcdDevice);
                    }
                }
            }
            c.LCDDevices = lcdDevices.ToArray();

            // wczytanie LCD
            List <RS232LCD> lcds = new List <RS232LCD>();

            nodes = xml.SelectNodes("/configuration/lcds/lcd");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    RS232LCD lcd = RS232LCD.Load(lcdDevices, node);
                    if (lcd != null)
                    {
                        lcds.Add(lcd);
                    }
                }
            }
            c.LCDs = lcds.ToArray();

            // wczytanie obszarów LCD
            List <LCDArea> areas = new List <LCDArea>();

            nodes = xml.SelectNodes("/configuration/lcdAreas/area");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LCDArea area = new LCDArea(node, new LCDSet(lcds));
                    areas.Add(area);
                }
            }
            c.Areas = areas.ToArray();

            // wczytanie urządzeń z LED
            List <LEDDevice> ledDevices = new List <LEDDevice>();

            nodes = xml.SelectNodes("/configuration/ledDevices/ledDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LEDDevice ledDevice = LEDDevice.Load(node, interfaces);
                    if (ledDevice != null)
                    {
                        ledDevices.Add(ledDevice);
                    }
                }
            }
            c.LEDDevices = ledDevices.ToArray();

            // wczytanie LED
            List <LED> leds = new List <LED>();

            nodes = xml.SelectNodes("/configuration/leds/led");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LED led = LED.Load(node, ledDevices);
                    if (led != null)
                    {
                        leds.Add(led);
                    }
                }
            }
            c.LEDs = leds.ToArray();

            // wczytanie obszarów LED
            List <LEDGroup> ledGroups = new List <LEDGroup>();

            nodes = xml.SelectNodes("/configuration/leds/leds");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LEDGroup ledGroup = LEDGroup.Load(node, leds);
                    if (ledGroup != null)
                    {
                        ledGroups.Add(ledGroup);
                    }
                }
            }
            c.LEDGroups = ledGroups.ToArray();

            // wczytanie urządzeń z 7-LED
            List <LEDDisplayDevice> ledDisplayDevices = new List <LEDDisplayDevice>();

            nodes = xml.SelectNodes("/configuration/ledDisplayDevices/ledDisplayDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LEDDisplayDevice ledDisplayDevice = LEDDisplayDevice.Load(node, interfaces);
                    if (ledDisplayDevice != null)
                    {
                        ledDisplayDevices.Add(ledDisplayDevice);
                    }
                }
            }
            c.LEDDisplayDevices = ledDisplayDevices.ToArray();

            // wczytanie 7-LED
            List <LEDDisplay> ledDisplays = new List <LEDDisplay>();

            nodes = xml.SelectNodes("/configuration/ledDisplays/ledDisplay");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LEDDisplay ledDisplay = LEDDisplay.Load(node, ledDisplayDevices);
                    if (ledDisplay != null)
                    {
                        ledDisplays.Add(ledDisplay);
                    }
                }
            }
            c.LEDDisplays = ledDisplays.ToArray();

            // wczytanie obszarów 7-LED
            List <LEDDisplayGroup> ledDisplayGroups = new List <LEDDisplayGroup>();

            nodes = xml.SelectNodes("/configuration/ledDisplays/ledDisplays");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    LEDDisplayGroup ledDisplayGroup = LEDDisplayGroup.Load(node, ledDisplays);
                    if (ledDisplayGroup != null)
                    {
                        ledDisplayGroups.Add(ledDisplayGroup);
                    }
                }
            }
            c.LEDDisplayGroups = ledDisplayGroups.ToArray();

            // wczytanie słownika dla wyświetlaczy 7-segmentowych
            XmlNode dictionaryNode = xml.SelectSingleNode("/configuration/ledDisplaysDictionary");

            c.LEDDisplaysDictionary = LEDDisplaysDictionary.Load(dictionaryNode);

            // wczytanie urządzeń Keys
            List <KeysDevice> keysDevices = new List <KeysDevice>();

            nodes = xml.SelectNodes("/configuration/keysDevices/keysDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    KeysDevice keysDevice = KeysDevice.Load(node, interfaces);
                    if (keysDevice != null)
                    {
                        keysDevices.Add(keysDevice);
                    }
                }
            }
            c.KeysDevices = keysDevices.ToArray();

            // wczytanie keys
            List <Key> keys = new List <Key>();

            nodes = xml.SelectNodes("/configuration/keys/key");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    Key key = Key.Load(node, keysDevices);
                    if (key != null)
                    {
                        keys.Add(key);
                    }
                }
            }
            c.Keys = keys.ToArray();

            // wczytanie encoders
            List <Encoder> encoders = new List <Encoder>();

            nodes = xml.SelectNodes("/configuration/encoders/encoder");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    Encoder encoder = Encoder.Load(node, keysDevices);
                    if (encoder != null)
                    {
                        encoders.Add(encoder);

                        // przypisanie enkoderów do wejść (wykrywanie szybkiego kręcenia)
                        foreach (Key key in c.Keys)
                        {
                            if (key.KeysDevice == encoder.KeysDevice)
                            {
                                if (key.Index == encoder.LeftIndex || key.Index == encoder.RightIndex)
                                {
                                    key.Encoder = encoder;
                                }
                            }
                        }
                    }
                }
            }
            c.Encoders = encoders.ToArray();

            // wczytanie stepper motors
            List <StepperDevice> stepperDevices = new List <StepperDevice>();

            nodes = xml.SelectNodes("/configuration/stepperDevices/stepperDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    StepperDevice stepperDevice = StepperDevice.Load(node, interfaces);
                    if (stepperDevice != null)
                    {
                        stepperDevices.Add(stepperDevice);
                    }
                }
            }
            c.StepperDevices = stepperDevices.ToArray();

            // wczytanie servo devices
            List <ServoDevice> servoDevices = new List <ServoDevice>();

            nodes = xml.SelectNodes("/configuration/servoDevices/servoDevice");
            if (nodes != null && nodes.Count > 0)
            {
                foreach (XmlNode node in nodes)
                {
                    ServoDevice servoDevice = ServoDevice.Load(node, interfaces);
                    if (servoDevice != null)
                    {
                        servoDevices.Add(servoDevice);
                    }
                }
            }
            c.ServoDevices = servoDevices.ToArray();


            __instance = c;

            return(__instance);
        }
        public AddEdit7LEDDisplayGroupDialog(XMLConfiguration configuration, LEDDisplayGroup led7DisplayOutputSet)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            _configuration       = configuration;
            LED7DisplayOutputSet = led7DisplayOutputSet;

            comboBox1.Items.Add(Align.Left);
            comboBox1.Items.Add(Align.Center);
            comboBox1.Items.Add(Align.Right);
            comboBox1.SelectedItem = Align.Left;
            comboBox2.Items.Add(Trim.Left);
            comboBox2.Items.Add(Trim.Right);
            comboBox2.SelectedItem = Trim.Right;
            comboBox3.Items.Add(Append.None);
            comboBox3.Items.Add(Append.Left);
            comboBox3.Items.Add(Append.Right);
            comboBox3.SelectedItem = Append.None;

            foreach (LEDDisplay dos in _configuration.LEDDisplays)
            {
                //if (!(dos is LED7DisplayOutputSet))
                {
                    listBox1.Items.Add(new Output()
                    {
                        DO = dos
                    });
                }
            }

            if (LED7DisplayOutputSet == null)
            {
                Text = "Dodaj nową grupę wyświetlaczy 7-LED";
            }
            else
            {
                Text = "Edytuj grupę wyświetlaczy 7-LED";
                Array.Sort(LED7DisplayOutputSet.LEDDisplaysInGroup);
                for (int i = 0; i < LED7DisplayOutputSet.LEDDisplays.Length; i++)
                {
                    for (int j = 0; j < listBox1.Items.Count; j++)
                    {
                        if (LED7DisplayOutputSet.LEDDisplays[i] == ((Output)listBox1.Items[j]).DO)
                        {
                            Output o = (Output)listBox1.Items[j];
                            listBox1.Items.Remove(o);
                            listBox2.Items.Add(o);
                            break;
                        }
                    }
                }
                textBox2.Text          = LED7DisplayOutputSet.ID;
                textBox1.Text          = LED7DisplayOutputSet.Description;
                comboBox1.SelectedItem = LED7DisplayOutputSet.Align;
                comboBox2.SelectedItem = LED7DisplayOutputSet.Trim;
                comboBox3.SelectedItem = LED7DisplayOutputSet.Append;
                textBox3.Text          = LED7DisplayOutputSet.AppendString;
            }
        }