Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            cFunctionGroups func = new cFunctionGroups();
            List <PlcBlock> list = new List <PlcBlock>();
            //list = getAllBlocks(software.BlockGroup, list);

            List <PlcType> list2 = new List <PlcType>();
            //list2 = getAllDataTypes(software.TypeGroup, list2);

            List <string> list3 = new List <string>();

            list3 = func.GetAllBlocksNames(software.BlockGroup, list3);
        }
Example #2
0
        private void IterateThroughDevices(Project project)
        {
            // no project is open
            if (project == null)
            {
                return;
            }

            // shop a form to indicate work
            frmReadStructure read = new frmReadStructure();

            read.Show();

            Application.DoEvents();

            //Console.WriteLine(String.Format("Iterate through {0} device(s)", project.Devices.Count));
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            treeView1.Nodes.Clear();

            // search through devices
            foreach (Device device in project.Devices)
            {
                if (device.TypeIdentifier != null)
                {
                    // we search only for PLCs
                    if (device.TypeIdentifier == "System:Device.S71500")
                    {
                        //Console.WriteLine(String.Format("Found {0}", device.Name));
                        listBox1.Items.Add(device.Name);

                        // let's get the CPU
                        foreach (DeviceItem item in device.DeviceItems)
                        {
                            if (item.Classification.ToString() == "CPU")
                            {
                                //Console.WriteLine(String.Format("Found {0}", item.Name));
                                listBox2.Items.Add(item.Name);

                                // get the software container
                                SoftwareContainer softwareContainer = ((IEngineeringServiceProvider)item).GetService <SoftwareContainer>();
                                if (softwareContainer != null)
                                {
                                    software = softwareContainer.Software as PlcSoftware;
                                    //Console.WriteLine("Found : " + software.Name);

                                    // start update treeview
                                    treeView1.BeginUpdate();

                                    // add root node
                                    TreeNode root = new TreeNode(software.Name);
                                    root.Tag = software.BlockGroup;
                                    treeView1.Nodes.Add(root);

                                    cFunctionGroups func = new cFunctionGroups();
                                    func.AddPlcBlocks(software.BlockGroup, root);
                                    //AddPlcBlocks(software.BlockGroup, root);

                                    // add data types
                                    TreeNode dataTypes = new TreeNode("Data types");
                                    dataTypes.Tag = software.TypeGroup;
                                    treeView1.Nodes.Add(dataTypes);

                                    func.AddPlcTypes(software.TypeGroup, dataTypes);
                                    //AddPlcTypes(software.TypeGroup, dataTypes);
                                    dataTypes.Expand();

                                    // end update
                                    treeView1.EndUpdate();

                                    root.Expand();
                                }
                            }
                        }
                    }
                }
            }

            // close form
            read.Close();
            read.Dispose();
        }