Exemplo n.º 1
0
 public static void Handle(NodeHandler handler, TiaPortal tia)
 {
     foreach (Project p in tia.Projects)
     {
         handleProject(handler, p);
     }
 }
Exemplo n.º 2
0
 public SelectHMI(TiaPortal portal)
 {
     tiaPortal = portal;
     InitializeComponent();
     VisibleChanged += updateList;
     itemTree.MouseDoubleClick += treeDoubleClick;
 }
Exemplo n.º 3
0
 public BrowseDialog(TiaPortal portal)
 {
     InitializeComponent();
     AutoExpandMaxChildren = -1;
     builder = new TIATree.TreeNodeBuilder(portal);
     VisibleChanged += updateList;
     blockTree.MouseDoubleClick += treeDoubleClick;
 }
Exemplo n.º 4
0
 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     tiaPortal.Dispose();
     tiaPortal = null;
     folder_dialog = null;
     data_block_dialog = null;
     browse_dialog = null;
     connectToolStripMenuItem.Enabled = true;
     disconnectToolStripMenuItem.Enabled = false;
 }
Exemplo n.º 5
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (select_dialog == null)
            {
                select_dialog = new PortalSelect();
            }
            if (select_dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TiaPortalProcess proc = select_dialog.selectedProcess();
                if (proc != null)
                {
                    WaitConnect wait = new WaitConnect();
                    wait.Show();
                    Application.DoEvents();
                    try
                    {
                        tiaPortal = proc.Attach();
                        connectToolStripMenuItem.Enabled = false;
                        disconnectToolStripMenuItem.Enabled = true;
                    }
                    catch (EngineeringException ex)
                    {
                        MessageBox.Show("Failed to connect to TIAPortal: " + ex.Message);
                    }
                    wait.Hide();
                    wait.Dispose();

                }
            }
        }
Exemplo n.º 6
0
 public TreeNodeBuilder(TiaPortal tia)
 {
     TIA = tia;
 }
        internal void LoadViaOpennessDlls()
        {
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    if (tiaPortal != null)
                    {
                        tiaPortal.Dispose();
                        tiaPortal = null;
                    }
                    tiaPortal = new TiaPortal(TiaPortalMode.WithoutUserInterface);
                    tiapProject = tiaPortal.Projects.Open(ProjectFile);
                }
                catch (Siemens.Engineering.EngineeringSecurityException ex)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    if (i == 9)
                        throw;
                }
                if (tiapProject != null)
                    break;
            }


            var main = new TIAOpennessProjectFolder(this) { Name = "Main" };
            ProjectStructure = main;
            
            //var frm = new sliver.Windows.Forms.StateBrowserForm();
            //frm.ObjectToBrowse = tiapProject;
            //frm.Show();

            foreach (var d in tiapProject.Devices)
            {
                Console.WriteLine(d.Subtype);                
                if (d.Subtype.EndsWith(".Device") && !d.Subtype.StartsWith("GSD.") && !d.Subtype.StartsWith("ET200eco.")) //d.Subtype.StartsWith("S7300") || d.Subtype.StartsWith("S7400") || d.Subtype.StartsWith("S71200") || d.Subtype.StartsWith("S71500"))
                {
                    

                    var controller = d.DeviceItems.OfType<ControllerTarget>().FirstOrDefault();
                    if (controller == null)
                    {
                        var fld = new TIAOpennessProjectFolder(this)
                        {
                            Name = d.Name,
                            TiaPortalItem = d,
                            Comment = d.Comment != null ? d.Comment.GetText(CultureInfo.CurrentCulture) : null
                        };
                        main.SubItems.Add(fld);

                        LoadSubDevicesViaOpennessDlls(fld, d);
                    }
                    else
                    {
                        var fld = new TIAOpennessControllerFolder(this)
                        {
                            Name = d.Name,
                            TiaPortalItem = d,
                            Comment = d.Comment != null ? d.Comment.GetText(CultureInfo.CurrentCulture) : null
                        };
                        main.SubItems.Add(fld);

                        LoadControlerFolderViaOpennessDlls(fld, controller);
                    }
                }
            }
        }