Exemplo n.º 1
0
        /// <summary>
        /// Fills the channel table nodes.
        /// </summary>
        private void FillCnlTableNodes(TreeNode inCnlTableNode, TreeNode ctrlCnlTableNode, ConfigBase configBase)
        {
            foreach (KP kp in configBase.KPTable.EnumerateItems())
            {
                string nodeText = string.Format(AppPhrases.TableByDeviceNode, kp.KPNum, kp.Name);

                TreeNode inCnlsByDeviceNode = TreeViewUtils.CreateNode(nodeText, "table.png");
                inCnlsByDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu;
                inCnlsByDeviceNode.Tag = CreateBaseTableTag(configBase.InCnlTable, CreateFilterByDevice(kp));
                inCnlTableNode.Nodes.Add(inCnlsByDeviceNode);

                TreeNode ctrlCnlsByDeviceNode = TreeViewUtils.CreateNode(nodeText, "table.png");
                ctrlCnlsByDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu;
                ctrlCnlsByDeviceNode.Tag = CreateBaseTableTag(configBase.CtrlCnlTable, CreateFilterByDevice(kp));
                ctrlCnlTableNode.Nodes.Add(ctrlCnlsByDeviceNode);
            }

            TreeNode inCnlsEmptyDeviceNode = TreeViewUtils.CreateNode(AppPhrases.EmptyDeviceNode, "table.png");

            inCnlsEmptyDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu;
            inCnlsEmptyDeviceNode.Tag = CreateBaseTableTag(configBase.InCnlTable, CreateFilterByDevice(null));
            inCnlTableNode.Nodes.Add(inCnlsEmptyDeviceNode);

            TreeNode ctrlCnlsEmptyDeviceNode = TreeViewUtils.CreateNode(AppPhrases.EmptyDeviceNode, "table.png");

            ctrlCnlsEmptyDeviceNode.ContextMenuStrip = contextMenus.CnlTableMenu;
            ctrlCnlsEmptyDeviceNode.Tag = CreateBaseTableTag(configBase.CtrlCnlTable, CreateFilterByDevice(null));
            ctrlCnlTableNode.Nodes.Add(ctrlCnlsEmptyDeviceNode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates tree nodes according to the project structure.
        /// </summary>
        public void CreateNodes(ScadaProject project)
        {
            this.project   = project ?? throw new ArgumentNullException("project");
            ProjectNode    = null;
            BaseNode       = null;
            BaseTableNodes = new Dictionary <string, TreeNode>();
            InterfaceNode  = null;
            InstancesNode  = null;

            try
            {
                treeView.BeginUpdate();
                treeView.Nodes.Clear();

                ProjectNode = TreeViewUtils.CreateNode(project.Name, "project.png", true);
                ProjectNode.ContextMenuStrip = contextMenus.ProjectMenu;
                ProjectNode.Tag = new TreeNodeTag
                {
                    RelatedObject = project,
                    NodeType      = AppNodeType.Project
                };
                treeView.Nodes.Add(ProjectNode);

                BaseNode = CreateBaseNode(project.ConfigBase);
                ProjectNode.Nodes.Add(BaseNode);

                InterfaceNode = TreeViewUtils.CreateNode(AppPhrases.InterfaceNode, "ui.png");
                InterfaceNode.ContextMenuStrip = contextMenus.DirectoryMenu;
                InterfaceNode.Tag = new TreeNodeTag
                {
                    RelatedObject = project.Interface,
                    NodeType      = AppNodeType.Interface
                };
                ProjectNode.Nodes.Add(InterfaceNode);

                TreeNode emptyNode = TreeViewUtils.CreateNode(AppPhrases.EmptyNode, "empty.png");
                InterfaceNode.Nodes.Add(emptyNode);

                InstancesNode = TreeViewUtils.CreateNode(AppPhrases.InstancesNode, "instances.png");
                InstancesNode.ContextMenuStrip = contextMenus.InstanceMenu;
                InstancesNode.Tag = new TreeNodeTag
                {
                    RelatedObject = project.Instances,
                    NodeType      = AppNodeType.Instances
                };
                ProjectNode.Nodes.Add(InstancesNode);

                foreach (Instance instance in project.Instances)
                {
                    InstancesNode.Nodes.Add(CreateInstanceNode(instance));
                }

                ProjectNode.Expand();
                InstancesNode.Expand();
            }
            finally
            {
                treeView.EndUpdate();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a node that represents the table of the configuration database.
        /// </summary>
        private TreeNode CreateBaseTableNode(IBaseTable baseTable)
        {
            TreeNode baseTableNode = TreeViewUtils.CreateNode(baseTable.Title, "table.png");

            baseTableNode.Tag = CreateBaseTableTag(baseTable);
            BaseTableNodes.Add(baseTable.Name, baseTableNode);
            return(baseTableNode);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new command node according to the command configuration.
        /// </summary>
        private TreeNode CreateCommandNode(CommandConfig commandConfig)
        {
            TreeNode commandNode = TreeViewUtils.CreateNode(
                GetDisplayName(commandConfig.DisplayName, KpPhrases.EmptyCommand),
                "command.png");

            commandNode.Tag = commandConfig;
            return(commandNode);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new monitored item node according to the item configuration.
        /// </summary>
        private TreeNode CreateItemNode(ItemConfig itemConfig)
        {
            TreeNode itemNode = TreeViewUtils.CreateNode(
                GetDisplayName(itemConfig.DisplayName, KpPhrases.EmptyItem),
                "variable.png");

            itemNode.Tag = itemConfig;
            return(itemNode);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new subscription node according to the subscription configuration.
        /// </summary>
        private TreeNode CreateSubscriptionNode(SubscriptionConfig subscriptionConfig)
        {
            TreeNode subscriptionNode = TreeViewUtils.CreateNode(
                GetDisplayName(subscriptionConfig.DisplayName, KpPhrases.EmptySubscription),
                FolderClosedImageKey);

            subscriptionNode.Tag = subscriptionConfig;
            return(subscriptionNode);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a node that represents the specified directory.
        /// </summary>
        private TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
        {
            TreeNode directoryNode = TreeViewUtils.CreateNode(directoryInfo.Name, "folder_closed.png");

            directoryNode.ContextMenuStrip = contextMenus.DirectoryMenu;
            directoryNode.Tag = new TreeNodeTag {
                RelatedObject = new FileItem(directoryInfo),
                NodeType      = AppNodeType.Directory
            };
            return(directoryNode);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a node that represents the specified file.
        /// </summary>
        private TreeNode CreateFileNode(FileInfo fileInfo)
        {
            TreeNode fileNode = TreeViewUtils.CreateNode(fileInfo.Name, "file.png");

            fileNode.ContextMenuStrip = contextMenus.FileItemMenu;
            fileNode.Tag = new TreeNodeTag {
                RelatedObject = new FileItem(fileInfo),
                NodeType      = AppNodeType.File
            };
            return(fileNode);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Browses the server node.
        /// </summary>
        private void BrowseServerNode(TreeNode treeNode)
        {
            try
            {
                tvServer.BeginUpdate();
                bool fillNode = false;
                TreeNodeCollection nodeCollection = null;
                NodeId             nodeId         = null;

                if (treeNode == null)
                {
                    fillNode       = true;
                    nodeCollection = tvServer.Nodes;
                    nodeId         = ObjectIds.ObjectsFolder;
                }
                else if (treeNode.Tag is ServerNodeTag serverNodeTag)
                {
                    fillNode       = !serverNodeTag.IsFilled;
                    nodeCollection = treeNode.Nodes;
                    nodeId         = serverNodeTag.OpcNodeId;
                }

                if (fillNode && nodeId != null && opcSession != null)
                {
                    opcSession.Browse(null, null, nodeId,
                                      0, BrowseDirection.Forward, ReferenceTypeIds.HierarchicalReferences, true,
                                      (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method,
                                      out byte[] continuationPoint, out ReferenceDescriptionCollection references);
                    nodeCollection.Clear();

                    foreach (ReferenceDescription rd in references)
                    {
                        TreeNode childNode = TreeViewUtils.CreateNode(rd.DisplayName, SelectImageKey(rd.NodeClass));
                        childNode.Tag = new ServerNodeTag(rd, opcSession.NamespaceUris);

                        if (rd.NodeClass.HasFlag(NodeClass.Object))
                        {
                            TreeNode emptyNode = TreeViewUtils.CreateNode(KpPhrases.EmptyNode, "empty.png");
                            childNode.Nodes.Add(emptyNode);
                        }

                        nodeCollection.Add(childNode);
                    }
                }
            }
            catch (Exception ex)
            {
                ScadaUiUtils.ShowError(KpPhrases.BrowseServerError + ":" + Environment.NewLine + ex.Message);
            }
            finally
            {
                tvServer.EndUpdate();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a node that represents the table of the configuration database.
        /// </summary>
        private TreeNode CreateBaseTableNode <T>(BaseTable <T> baseTable)
        {
            TreeNode baseTableNode = TreeViewUtils.CreateNode(baseTable.Title, "table.png");

            baseTableNode.Tag = new TreeNodeTag {
                FormType      = typeof(FrmBaseTableGeneric <T>),
                FormArgs      = new object[] { appData, project, baseTable },
                RelatedObject = baseTable,
                NodeType      = AppNodeType.BaseTable
            };
            return(baseTableNode);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Создать узел дерева для группы переменных
        /// </summary>
        private TreeNode CreateGroupNode(Config.VarGroup group)
        {
            string   imageKey  = group.Variables.Count > 0 ? "folder_open.png" : "folder_closed.png";
            TreeNode groupNode = TreeViewUtils.CreateNode(group, imageKey, true);

            foreach (Config.Variable variable in group.Variables)
            {
                groupNode.Nodes.Add(CreateVariableNode(variable));
            }

            return(groupNode);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Создать узел дерева для группы контактов
        /// </summary>
        private TreeNode CreateContactGroupNode(AddressBook.ContactGroup contactGroup)
        {
            string   imageKey         = contactGroup.Contacts.Count > 0 ? "folder_open.png" : "folder_closed.png";
            TreeNode contactGroupNode = TreeViewUtils.CreateNode(contactGroup, imageKey, true);

            foreach (AddressBook.Contact contact in contactGroup.Contacts)
            {
                contactGroupNode.Nodes.Add(CreateContactNode(contact));
            }

            return(contactGroupNode);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Creates a node that represents the instance.
        /// </summary>
        public TreeNode CreateInstanceNode(Instance instance)
        {
            TreeNode instanceNode = TreeViewUtils.CreateNode(instance.Name, "instance.png");

            instanceNode.ContextMenuStrip = contextMenus.InstanceMenu;
            instanceNode.Tag = new TreeNodeTag {
                RelatedObject = new LiveInstance(instance),
                NodeType      = AppNodeType.Instance
            };

            TreeNode emptyNode = TreeViewUtils.CreateNode(AppPhrases.EmptyNode, "empty.png");

            instanceNode.Nodes.Add(emptyNode);

            return(instanceNode);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates a node that represents the configuration database.
        /// </summary>
        private TreeNode CreateBaseNode(ConfigBase configBase)
        {
            TreeNode baseNode = TreeViewUtils.CreateNode(AppPhrases.BaseNode, "database.png");

            baseNode.Tag = new TreeNodeTag
            {
                RelatedObject = project.ConfigBase,
                NodeType      = AppNodeType.Base
            };

            TreeNode sysTableNode = TreeViewUtils.CreateNode(AppPhrases.SysTableNode, "folder_closed.png");

            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.ObjTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.CommLineTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.KPTable));

            TreeNode inCnlTableNode   = CreateBaseTableNode(configBase.InCnlTable);
            TreeNode ctrlCnlTableNode = CreateBaseTableNode(configBase.CtrlCnlTable);

            inCnlTableNode.ContextMenuStrip   = contextMenus.CnlTableMenu;
            ctrlCnlTableNode.ContextMenuStrip = contextMenus.CnlTableMenu;
            sysTableNode.Nodes.Add(inCnlTableNode);
            sysTableNode.Nodes.Add(ctrlCnlTableNode);
            FillCnlTableNodes(inCnlTableNode, ctrlCnlTableNode, configBase);

            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.RoleTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.RoleRefTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.UserTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.InterfaceTable));
            sysTableNode.Nodes.Add(CreateBaseTableNode(configBase.RightTable));
            baseNode.Nodes.Add(sysTableNode);

            TreeNode dictTableNode = TreeViewUtils.CreateNode(AppPhrases.DictTableNode, "folder_closed.png");

            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.CnlTypeTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.CmdTypeTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.EvTypeTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.KPTypeTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.ParamTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.UnitTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.CmdValTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.FormatTable));
            dictTableNode.Nodes.Add(CreateBaseTableNode(configBase.FormulaTable));
            baseNode.Nodes.Add(dictTableNode);

            return(baseNode);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Adds a branch to the tree.
        /// </summary>
        private void AddBranch(ExportTargetConfig exportTargetConfig, bool insertNewTarget)
        {
            TreeNode targetNode = CreateTargetNode(exportTargetConfig);

            targetNode.Text = exportTargetConfig.GeneralOptions.Name;

            if (!insertNewTarget)
            {
                tvTargets.Nodes.Add(targetNode);
            }
            else
            {
                tvTargets.Insert(null, targetNode, config.ExportTargets, exportTargetConfig);
            }

            TreeNode connectionNode = TreeViewUtils.CreateNode(exportTargetConfig.ConnectionOptions,
                                                               ChooseImageKey(exportTargetConfig.ConnectionOptions));

            connectionNode.Text = LibPhrases.ConnectionOptionsNode;
            targetNode.Nodes.Add(connectionNode);

            TreeNode triggerGroupNode = TreeViewUtils.CreateNode(exportTargetConfig.Triggers,
                                                                 ChooseImageKey(exportTargetConfig.Triggers));

            triggerGroupNode.Text = LibPhrases.TriggerGrNode;
            targetNode.Nodes.Add(triggerGroupNode);

            foreach (TriggerOptions triggerOptions in exportTargetConfig.Triggers)
            {
                TreeNode triggerNode = TreeViewUtils.CreateNode(triggerOptions,
                                                                ChooseImageKey(triggerOptions));
                triggerNode.Text = triggerOptions.Name;
                triggerGroupNode.Nodes.Add(triggerNode);
            }

            TreeNode arcUploadNode = TreeViewUtils.CreateNode(exportTargetConfig.ArcUploadOptions,
                                                              ChooseImageKey(exportTargetConfig.ArcUploadOptions));

            arcUploadNode.Text = LibPhrases.ArcUploadOptionsNode;
            targetNode.Nodes.Add(arcUploadNode);

            if (insertNewTarget)
            {
                tvTargets.SelectedNode.Expand();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Создать узел дерева для контакта
        /// </summary>
        private TreeNode CreateContactNode(AddressBook.Contact contact)
        {
            TreeNode contactNode = TreeViewUtils.CreateNode(contact, "contact.png", true);

            foreach (AddressBook.ContactRecord contactRecord in contact.ContactRecords)
            {
                if (contactRecord is AddressBook.PhoneNumber)
                {
                    contactNode.Nodes.Add(CreatePhoneNumberNode(contactRecord));
                }
                else if (contactRecord is AddressBook.Email)
                {
                    contactNode.Nodes.Add(CreateEmailNode(contactRecord));
                }
            }

            return(contactNode);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Fills the device tree.
        /// </summary>
        private void FillDeviceTree()
        {
            try
            {
                tvDevice.BeginUpdate();
                tvDevice.Nodes.Clear();

                subscriptionsNode = TreeViewUtils.CreateNode(KpPhrases.SubscriptionsNode, FolderClosedImageKey);
                commandsNode      = TreeViewUtils.CreateNode(KpPhrases.CommandsNode, FolderClosedImageKey);
                int signal = 1;

                foreach (SubscriptionConfig subscriptionConfig in deviceConfig.Subscriptions)
                {
                    TreeNode subscriptionNode = CreateSubscriptionNode(subscriptionConfig);
                    subscriptionsNode.Nodes.Add(subscriptionNode);

                    foreach (ItemConfig itemConfig in subscriptionConfig.Items)
                    {
                        subscriptionNode.Nodes.Add(CreateItemNode(itemConfig));

                        ItemConfigTag tag = new ItemConfigTag(signal, itemConfig.IsArray, itemConfig.ArrayLen);
                        signal        += tag.Length;
                        itemConfig.Tag = tag;
                    }
                }

                foreach (CommandConfig commandConfig in deviceConfig.Commands)
                {
                    commandsNode.Nodes.Add(CreateCommandNode(commandConfig));
                }

                tvDevice.Nodes.Add(subscriptionsNode);
                tvDevice.Nodes.Add(commandsNode);
                subscriptionsNode.Expand();
                commandsNode.Expand();
            }
            finally
            {
                tvDevice.EndUpdate();
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Fills the device node by channel nodes.
        /// </summary>
        private void FillDeviceNode(TreeNode deviceNode, KP kp)
        {
            try
            {
                tvCnl.BeginUpdate();
                deviceNode.Nodes.Clear();
                TableFilter tableFilter = new TableFilter("KPNum", kp.KPNum);

                if (cbCnlKind.SelectedIndex == 0)
                {
                    foreach (InCnl inCnl in baseTables.InCnlTable.SelectItems(tableFilter, true))
                    {
                        string   nodeText  = string.Format("[{0}] {1}", inCnl.CnlNum, inCnl.Name);
                        TreeNode inCnlNode = TreeViewUtils.CreateNode(nodeText, "in_cnl.png");
                        inCnlNode.Tag = inCnl;
                        deviceNode.Nodes.Add(inCnlNode);
                    }
                }
                else
                {
                    foreach (CtrlCnl ctrlCnl in baseTables.CtrlCnlTable.SelectItems(tableFilter, true))
                    {
                        string   nodeText    = string.Format("[{0}] {1}", ctrlCnl.CtrlCnlNum, ctrlCnl.Name);
                        TreeNode ctrlCnlNode = TreeViewUtils.CreateNode(nodeText, "out_cnl.png");
                        ctrlCnlNode.Tag = ctrlCnl;
                        deviceNode.Nodes.Add(ctrlCnlNode);
                    }
                }
            }
            catch (Exception ex)
            {
                ProcError(ex, TablePhrases.FillCnlTreeError);
            }
            finally
            {
                tvCnl.EndUpdate();
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Fills the channel tree view.
        /// </summary>
        private void FillCnlTree()
        {
            try
            {
                tvCnl.BeginUpdate();
                tvCnl.Nodes.Clear();

                if (baseTables != null)
                {
                    foreach (KP kp in baseTables.KPTable.EnumerateItems())
                    {
                        string   nodeText   = string.Format("[{0}] {1}", kp.KPNum, kp.Name);
                        TreeNode deviceNode = TreeViewUtils.CreateNode(nodeText, "device.png");
                        deviceNode.ContextMenuStrip = cmsDevice;
                        deviceNode.Tag = kp;
                        deviceNode.Nodes.Add(TreeViewUtils.CreateNode("Empty", "empty.png"));
                        tvCnl.Nodes.Add(deviceNode);
                    }

                    TreeNode emptyDeviceNode = TreeViewUtils.CreateNode(TablePhrases.EmptyDeviceNode, "device.png");
                    emptyDeviceNode.ContextMenuStrip = cmsDevice;
                    emptyDeviceNode.Tag = new KP()
                    {
                        KPNum = 0, Name = TablePhrases.EmptyDeviceNode
                    };
                    emptyDeviceNode.Nodes.Add(TreeViewUtils.CreateNode("Empty", "empty.png"));
                    tvCnl.Nodes.Add(emptyDeviceNode);
                }
            }
            catch (Exception ex)
            {
                ProcError(ex, TablePhrases.FillCnlTreeError);
            }
            finally
            {
                tvCnl.EndUpdate();
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Creates a node that represents the configuration database.
        /// </summary>
        private TreeNode CreateBaseNode(ConfigBase configBase)
        {
            TreeNode baseNode = TreeViewUtils.CreateNode(AppPhrases.BaseNode, "database.png");

            baseNode.Tag = new TreeNodeTag(project.ConfigBase, AppNodeType.Base);

            // primary tables sorted in the order they are configured
            TreeNode primaryNode = TreeViewUtils.CreateNode(AppPhrases.PrimaryTablesNode, "folder_closed.png");

            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.ObjTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.CommLineTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.DeviceTable));

            TreeNode inCnlTableNode  = CreateBaseTableNode(configBase.InCnlTable);
            TreeNode outCnlTableNode = CreateBaseTableNode(configBase.OutCnlTable);

            inCnlTableNode.ContextMenuStrip  = contextMenus.CnlTableMenu;
            outCnlTableNode.ContextMenuStrip = contextMenus.CnlTableMenu;
            primaryNode.Nodes.Add(inCnlTableNode);
            primaryNode.Nodes.Add(outCnlTableNode);
            FillCnlTableNodes(inCnlTableNode, outCnlTableNode, configBase);

            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.LimTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.ViewTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.RoleTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.RoleRefTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.ObjRightTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configBase.UserTable));
            baseNode.Nodes.Add(primaryNode);

            // secondary tables in alphabetical order
            TreeNode secondaryNode = TreeViewUtils.CreateNode(AppPhrases.SecondaryTablesNode, "folder_closed.png");
            SortedList <string, TreeNode> secondaryNodes = new()
            {
                { configBase.ArchiveTable.Title, CreateBaseTableNode(configBase.ArchiveTable) },
                { configBase.CnlStatusTable.Title, CreateBaseTableNode(configBase.CnlStatusTable) },
Exemplo n.º 21
0
 /// <summary>
 /// Создать узел дерева для переменной
 /// </summary>
 private TreeNode CreateVariableNode(Config.Variable variable)
 {
     return(TreeViewUtils.CreateNode(variable, "variable.png"));
 }
Exemplo n.º 22
0
        /// <summary>
        /// Browses the server node.
        /// </summary>
        private void BrowseServerNode(TreeNode treeNode)
        {
            try
            {
                tvServer.BeginUpdate();
                bool fillNodeRequired             = false;
                TreeNodeCollection nodeCollection = null;
                ServerNodeTag      serverNodeTag  = null;
                NodeId             nodeId         = null;

                if (treeNode == null)
                {
                    fillNodeRequired = true;
                    nodeCollection   = tvServer.Nodes;
                    serverNodeTag    = null;
                    nodeId           = ObjectIds.ObjectsFolder;
                }
                else if (treeNode.Tag is ServerNodeTag nodeTag)
                {
                    fillNodeRequired = !nodeTag.IsFilled;
                    nodeCollection   = treeNode.Nodes;
                    serverNodeTag    = nodeTag;
                    nodeId           = nodeTag.OpcNodeId;
                }

                if (fillNodeRequired && nodeId != null && opcSession != null)
                {
                    Browser browser = new Browser(opcSession)
                    {
                        BrowseDirection = BrowseDirection.Forward,
                        NodeClassMask   = (int)NodeClass.Variable | (int)NodeClass.Object | (int)NodeClass.Method,
                        ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences
                    };

                    ReferenceDescriptionCollection browseResults = browser.Browse(nodeId);
                    nodeCollection.Clear();

                    foreach (ReferenceDescription rd in browseResults)
                    {
                        TreeNode childNode = TreeViewUtils.CreateNode(rd.DisplayName, SelectImageKey(rd.NodeClass));
                        childNode.Tag = new ServerNodeTag(rd, opcSession.NamespaceUris);

                        // allow to expand any node
                        TreeNode emptyNode = TreeViewUtils.CreateNode(KpPhrases.EmptyNode, "empty.png");
                        childNode.Nodes.Add(emptyNode);

                        nodeCollection.Add(childNode);
                    }

                    if (serverNodeTag != null)
                    {
                        serverNodeTag.IsFilled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ScadaUiUtils.ShowError(KpPhrases.BrowseServerError + ":" + Environment.NewLine + ex.Message);
            }
            finally
            {
                tvServer.EndUpdate();
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Создать узел дерева для адреса электронной почты
 /// </summary>
 private TreeNode CreateEmailNode(AddressBook.ContactRecord email)
 {
     return(TreeViewUtils.CreateNode(email, "email.png"));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Создать узел дерева для телефонного номера
 /// </summary>
 private TreeNode CreatePhoneNumberNode(AddressBook.ContactRecord phoneNumber)
 {
     return(TreeViewUtils.CreateNode(phoneNumber, "phone.png"));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Creates a tree node corresponding to the target.
 /// </summary>
 private TreeNode CreateTargetNode(ExportTargetConfig exportTargetConfig)
 {
     return(TreeViewUtils.CreateNode(exportTargetConfig, ChooseImageKey(exportTargetConfig)));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Creates a tree node corresponding to the trigger.
 /// </summary>
 private TreeNode CreateTriggerNode(TriggerOptions triggerOptions)
 {
     return(TreeViewUtils.CreateNode(triggerOptions, ChooseImageKey(triggerOptions)));
 }
Exemplo n.º 27
0
        /// <summary>
        /// Fills the instance node, creating child nodes.
        /// </summary>
        public void FillInstanceNode(TreeNode instanceNode)
        {
            LiveInstance liveInstance = (LiveInstance)((TreeNodeTag)instanceNode.Tag).RelatedObject;
            Instance     instance     = liveInstance.Instance;

            try
            {
                treeView.BeginUpdate();
                instanceNode.Nodes.Clear();

                // create Server nodes
                if (instance.ServerApp.Enabled)
                {
                    TreeNode serverNode = TreeViewUtils.CreateNode(AppPhrases.ServerNode, "server.png");
                    serverNode.ContextMenuStrip = contextMenus.ServerMenu;
                    serverNode.Tag = new TreeNodeTag
                    {
                        RelatedObject = instance.ServerApp,
                        NodeType      = AppNodeType.ServerApp
                    };
                    serverNode.Nodes.AddRange(serverShell.GetTreeNodes(
                                                  instance.ServerApp.Settings, liveInstance.ServerEnvironment));
                    instanceNode.Nodes.Add(serverNode);
                }

                // create Communicator nodes
                if (instance.CommApp.Enabled)
                {
                    TreeNode commNode = TreeViewUtils.CreateNode(AppPhrases.CommNode, "comm.png");
                    commNode.ContextMenuStrip = contextMenus.CommMenu;
                    commNode.Tag = new TreeNodeTag
                    {
                        RelatedObject = instance.CommApp,
                        NodeType      = AppNodeType.CommApp
                    };
                    commNode.Nodes.AddRange(commShell.GetTreeNodes(
                                                instance.CommApp.Settings, liveInstance.CommEnvironment));

                    SetContextMenus(commNode);
                    instanceNode.Nodes.Add(commNode);
                }

                // create Webstation nodes
                if (instance.WebApp.Enabled)
                {
                    TreeNode webNode = TreeViewUtils.CreateNode(AppPhrases.WebNode, "chrome.png");
                    webNode.ContextMenuStrip = contextMenus.DirectoryMenu;
                    webNode.Tag = new TreeNodeTag
                    {
                        RelatedObject = instance.WebApp,
                        NodeType      = AppNodeType.WebApp
                    };
                    instanceNode.Nodes.Add(webNode);

                    TreeNode emptyNode = TreeViewUtils.CreateNode(AppPhrases.EmptyNode, "empty.png");
                    webNode.Nodes.Add(emptyNode);
                }
            }
            finally
            {
                treeView.EndUpdate();
            }
        }