Пример #1
0
        /// <summary>
        /// Creates a node that represents the configuration database.
        /// </summary>
        private TreeNode CreateConfigDatabaseNode(ConfigDatabase configDatabase)
        {
            TreeNode configDatabaseNode = TreeViewExtensions.CreateNode(AppPhrases.ConfigDatabaseNode, "database.png");

            configDatabaseNode.Tag = new TreeNodeTag(project.ConfigDatabase, ExplorerNodeType.ConfigDatabase);

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

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

            TreeNode cnlTableNode = CreateBaseTableNode(configDatabase.CnlTable);

            cnlTableNode.ContextMenuStrip = contextMenus.CnlTableMenu;
            primaryNode.Nodes.Add(cnlTableNode);
            FillCnlTableNodeInternal(cnlTableNode, configDatabase);

            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.LimTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.ViewTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.RoleTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.RoleRefTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.ObjRightTable));
            primaryNode.Nodes.Add(CreateBaseTableNode(configDatabase.UserTable));
            configDatabaseNode.Nodes.Add(primaryNode);

            // secondary tables in alphabetical order
            TreeNode secondaryNode = TreeViewExtensions.CreateNode(AppPhrases.SecondaryTablesNode, "folder_closed.png");
            SortedList <string, TreeNode> secondaryNodes = new()
            {
                { configDatabase.ArchiveTable.Title, CreateBaseTableNode(configDatabase.ArchiveTable) },
                { configDatabase.CnlStatusTable.Title, CreateBaseTableNode(configDatabase.CnlStatusTable) },
Пример #2
0
 /// <summary>
 /// Creates a new subscription node according to the subscription configuration.
 /// </summary>
 private static TreeNode CreateSubscriptionNode(SubscriptionConfig subscriptionConfig)
 {
     return(TreeViewExtensions.CreateNode(
                GetDisplayName(subscriptionConfig.DisplayName, DriverPhrases.UnnamedSubscription),
                ImageKey.FolderClosed,
                subscriptionConfig));
 }
Пример #3
0
        /// <summary>
        /// Fills the tree view.
        /// </summary>
        private void FillTreeView()
        {
            try
            {
                treeView.BeginUpdate();
                treeView.Nodes.Clear();

                foreach (Device device in configDatabase.DeviceTable.EnumerateItems())
                {
                    string   nodeText   = string.Format(CommonPhrases.EntityCaption, device.DeviceNum, device.Name);
                    TreeNode deviceNode = TreeViewExtensions.CreateNode(nodeText, "device.png");
                    deviceNode.ContextMenuStrip = cmsDevice;
                    deviceNode.Tag = device;
                    deviceNode.Nodes.Add(TreeViewExtensions.CreateNode(CommonPhrases.EmptyData, "empty.png"));
                    treeView.Nodes.Add(deviceNode);
                }

                TreeNode emptyDeviceNode = TreeViewExtensions.CreateNode(AdminPhrases.EmptyDevice, "device.png");
                emptyDeviceNode.ContextMenuStrip = cmsDevice;
                emptyDeviceNode.Tag = new Device {
                    DeviceNum = 0, Name = AdminPhrases.EmptyDevice
                };
                emptyDeviceNode.Nodes.Add(TreeViewExtensions.CreateNode(CommonPhrases.EmptyData, "empty.png"));
                treeView.Nodes.Add(emptyDeviceNode);
            }
            finally
            {
                treeView.EndUpdate();
            }
        }
Пример #4
0
 /// <summary>
 /// Creates a new command node according to the command configuration.
 /// </summary>
 private static TreeNode CreateCommandNode(CommandConfig commandConfig)
 {
     return(TreeViewExtensions.CreateNode(
                GetDisplayName(commandConfig.DisplayName, DriverPhrases.UnnamedCommand),
                ImageKey.Command,
                commandConfig));
 }
Пример #5
0
 /// <summary>
 /// Creates a new monitored item node according to the item configuration.
 /// </summary>
 private static TreeNode CreateItemNode(ItemConfig itemConfig)
 {
     return(TreeViewExtensions.CreateNode(
                GetDisplayName(itemConfig.DisplayName, DriverPhrases.UnnamedItem),
                ImageKey.Variable,
                itemConfig));
 }
Пример #6
0
        /// <summary>
        /// Creates a node that represents the specified contact group.
        /// </summary>
        private static TreeNode CreateContactGroupNode(ContactGroup contactGroup)
        {
            TreeNode contactGroupNode = TreeViewExtensions.CreateNode(contactGroup, ImageKey.FolderClosed);

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

            return(contactGroupNode);
        }
Пример #7
0
        /// <summary>
        /// Creates a tree node that represents communication lines.
        /// </summary>
        private TreeNode CreateLinesNode(CommApp commApp)
        {
            TreeNode linesNode = TreeViewExtensions.CreateNode(ExtensionPhrases.LinesNode, ImageKey.Lines);

            linesNode.ContextMenuStrip = menuControl.LineMenu;
            linesNode.Tag = new CommNodeTag(commApp, commApp.AppConfig, CommNodeType.Lines);

            foreach (LineConfig lineConfig in commApp.AppConfig.Lines)
            {
                linesNode.Nodes.Add(CreateLineNode(commApp, lineConfig));
            }

            return(linesNode);
        }
        /// <summary>
        /// Gets tree nodes to add to the configuration tree.
        /// </summary>
        public override TreeNode[] GetTreeNodes()
        {
            TreeNode optionsNode = TreeViewExtensions.CreateNode(
                DriverPhrases.OptionsNode, ImageKey.Options, DeviceConfig.DeviceOptions);

            itemsNode = TreeViewExtensions.CreateNode(
                DriverPhrases.ItemsNode, ImageKey.FolderClosed, DeviceConfig.Items);

            foreach (ItemConfig item in DeviceConfig.Items)
            {
                itemsNode.Nodes.Add(CreateItemNode(item));
            }

            return(new TreeNode[] { optionsNode, itemsNode });
        }
Пример #9
0
        /// <summary>
        /// Creates a node that represents the specified contact.
        /// </summary>
        private static TreeNode CreateContactNode(Contact contact)
        {
            TreeNode contactNode = TreeViewExtensions.CreateNode(contact, ImageKey.Contact);

            foreach (AddressBookItem contactItem in contact.ContactItems)
            {
                if (contactItem is PhoneNumber phoneNumber)
                {
                    contactNode.Nodes.Add(CreatePhoneNumberNode(phoneNumber));
                }
                else if (contactItem is Email email)
                {
                    contactNode.Nodes.Add(CreateEmailNode(email));
                }
            }

            return(contactNode);
        }
Пример #10
0
        /// <summary>
        /// Fills the device node by channel nodes.
        /// </summary>
        private void FillDeviceNode(TreeNode deviceNode, Device device)
        {
            try
            {
                treeView.BeginUpdate();
                deviceNode.Nodes.Clear();

                foreach (Cnl cnl in configDatabase.CnlTable.SelectItems(
                             new TableFilter("DeviceNum", device.DeviceNum), true))
                {
                    string   nodeText = string.Format(CommonPhrases.EntityCaption, cnl.CnlNum, cnl.Name);
                    TreeNode cnlNode  = TreeViewExtensions.CreateNode(nodeText, "cnl.png");
                    cnlNode.Tag = cnl;
                    deviceNode.Nodes.Add(cnlNode);
                }
            }
            finally
            {
                treeView.EndUpdate();
            }
        }
Пример #11
0
        /// <summary>
        /// Creates a tree node that represents the specified communication line.
        /// </summary>
        public TreeNode CreateLineNode(CommApp commApp, LineConfig lineConfig)
        {
            TreeNode lineNode = TreeViewExtensions.CreateNode(CommUtils.GetLineTitle(lineConfig),
                                                              lineConfig.Active ? ImageKey.Line : ImageKey.LineInactive);

            lineNode.ContextMenuStrip = menuControl.LineMenu;
            lineNode.Tag = new CommNodeTag(commApp, lineConfig, CommNodeType.Line);

            lineNode.Nodes.AddRange(new TreeNode[]
            {
                new TreeNode(ExtensionPhrases.LineOptionsNode)
                {
                    ImageKey         = ImageKey.Options,
                    SelectedImageKey = ImageKey.Options,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.LineOptions)
                    {
                        FormType = typeof(FrmLineConfig),
                        FormArgs = new object[] { adminContext, commApp, lineConfig }
                    }
                },
                new TreeNode(ExtensionPhrases.LineStatsNode)
                {
                    ImageKey         = ImageKey.Stats,
                    SelectedImageKey = ImageKey.Stats,
                    Tag = new CommNodeTag(commApp, null, CommNodeType.LineStats)
                    {
                        FormType = typeof(FrmLineStats),
                        FormArgs = new object[] { adminContext, lineConfig }
                    }
                }
            });

            foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling)
            {
                lineNode.Nodes.Add(CreateDeviceNode(commApp, deviceConfig));
            }

            return(lineNode);
        }
Пример #12
0
        /// <summary>
        /// Fills the device tree.
        /// </summary>
        private void FillDeviceTree()
        {
            try
            {
                tvDevice.BeginUpdate();
                tvDevice.Nodes.Clear();

                subscriptionsNode = TreeViewExtensions.CreateNode(DriverPhrases.SubscriptionsNode, ImageKey.FolderClosed);
                commandsNode      = TreeViewExtensions.CreateNode(DriverPhrases.CommandsNode, ImageKey.FolderClosed);
                int tagNum = 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));
                        itemConfig.Tag = new ItemConfigTag(tagNum);
                        tagNum++;
                    }
                }

                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();
            }
        }
Пример #13
0
        /// <summary>
        /// Gets tree nodes to add to the configuration tree.
        /// </summary>
        public override TreeNode[] GetTreeNodes()
        {
            TreeNode optionsNode = TreeViewExtensions.CreateNode(
                DriverPhrases.OptionsNode, ImageKey.Options, DeviceConfig.DeviceOptions);

            subscriptionsNode = TreeViewExtensions.CreateNode(
                DriverPhrases.SubscriptionsNode, ImageKey.FolderClosed, DeviceConfig.Subscriptions);
            commandsNode = TreeViewExtensions.CreateNode(
                DriverPhrases.CommandsNode, ImageKey.FolderClosed, DeviceConfig.Commands);

            foreach (SubscriptionConfig subscription in DeviceConfig.Subscriptions)
            {
                subscriptionsNode.Nodes.Add(CreateSubscriptionNode(subscription));
            }

            foreach (CommandConfig command in DeviceConfig.Commands)
            {
                commandsNode.Nodes.Add(CreateCommandNode(command));
            }

            return(new TreeNode[] { optionsNode, subscriptionsNode, commandsNode });
        }
Пример #14
0
        /// <summary>
        /// Shows the data model.
        /// </summary>
        public void ShowModel(WirenBoardModel wirenBoardModel)
        {
            ArgumentNullException.ThrowIfNull(wirenBoardModel, nameof(wirenBoardModel));

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

                foreach (DeviceModel deviceModel in wirenBoardModel.Devices)
                {
                    TreeNode deviceNode = TreeViewExtensions.CreateNode(deviceModel.Code, "device.png", deviceModel);
                    treeView.Nodes.Add(deviceNode);

                    foreach (ControlModel controlModel in deviceModel.Controls)
                    {
                        TreeNode controlNode = TreeViewExtensions.CreateNode(controlModel.Code, "elem.png", controlModel);
                        deviceNode.Nodes.Add(controlNode);
                    }

                    if (deviceNode.Nodes.Count > 0)
                    {
                        deviceNode.Checked = true;
                    }
                }

                if (treeView.Nodes.Count > 0)
                {
                    treeView.SelectedNode = treeView.Nodes[0];
                }

                treeView.CollapseAll();
            }
            finally
            {
                treeView.EndUpdate();
            }
        }
Пример #15
0
 /// <summary>
 /// Creates a tree node according to the command configuration.
 /// </summary>
 private static TreeNode CreateCommandNode(CommandConfig command)
 {
     return(TreeViewExtensions.CreateNode(GetCommandNodeText(command), ImageKey.Cmd, command));
 }
Пример #16
0
 /// <summary>
 /// Creates a tree node according to the subscription configuration.
 /// </summary>
 private static TreeNode CreateSubscriptionNode(SubscriptionConfig subscription)
 {
     return(TreeViewExtensions.CreateNode(GetSubscriptionNodeText(subscription), ImageKey.Elem, subscription));
 }
Пример #17
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.NodeId;
                }

                if (fillNodeRequired && nodeId != null && opcSession != null)
                {
                    Browser browser = new(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 = TreeViewExtensions.CreateNode(rd.DisplayName, SelectImageKey(rd.NodeClass));
                        childNode.Tag = new ServerNodeTag(rd, opcSession.NamespaceUris);

                        // allow to expand any node
                        TreeNode emptyNode = TreeViewExtensions.CreateNode(DriverPhrases.EmptyNode, ImageKey.Empty);
                        childNode.Nodes.Add(emptyNode);

                        nodeCollection.Add(childNode);
                    }

                    if (serverNodeTag != null)
                    {
                        serverNodeTag.IsFilled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ScadaUiUtils.ShowError(ex.BuildErrorMessage(DriverPhrases.BrowseServerError));
            }
            finally
            {
                tvServer.EndUpdate();
            }
        }
Пример #18
0
 /// <summary>
 /// Creates a node that represents the specified email.
 /// </summary>
 private static TreeNode CreateEmailNode(Email email)
 {
     return(TreeViewExtensions.CreateNode(email, ImageKey.Email));
 }
Пример #19
0
 /// <summary>
 /// Creates a node that represents the specified phone number.
 /// </summary>
 private static TreeNode CreatePhoneNumberNode(PhoneNumber phoneNumber)
 {
     return(TreeViewExtensions.CreateNode(phoneNumber, ImageKey.Phone));
 }
Пример #20
0
 /// <summary>
 /// Creates a node that represents the specified element.
 /// </summary>
 private static TreeNode CreateElemNode(ElemTag elemTag)
 {
     return(TreeViewExtensions.CreateNode(elemTag, "elem.png"));
 }
 /// <summary>
 /// Creates a tree node according to the item configuration.
 /// </summary>
 private static TreeNode CreateItemNode(ItemConfig item)
 {
     return(TreeViewExtensions.CreateNode(GetItemNodeText(item), ImageKey.Elem, item));
 }