Exemplo n.º 1
0
        private void NodeIdBTN_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                NodeId nodeId = new SelectNodeDlg().ShowDialog(
                    m_session,
                    Opc.Ua.ObjectIds.ObjectsFolder,
                    "Select Variable",
                    Opc.Ua.ReferenceTypeIds.Organizes,
                    Opc.Ua.ReferenceTypeIds.Aggregates);

                if (nodeId == null)
                {
                    return;
                }

                if (nodeId != m_nodeId)
                {
                    ChangeNode(nodeId);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void EventAreaBTN_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                NodeId areaId = new SelectNodeDlg().ShowDialog(m_session, Opc.Ua.ObjectIds.Server, "Select Event Area", Opc.Ua.ReferenceTypeIds.HasEventSource);

                if (areaId == null)
                {
                    return;
                }

                m_areaId         = areaId;
                EventAreaTB.Text = m_session.NodeCache.GetDisplayText(m_areaId);
                ResultsLV.ChangeArea(areaId, false);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Exemplo n.º 3
0
        private void Events_SelectEventAreaMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                NodeId areaId = new SelectNodeDlg().ShowDialog(m_session, Opc.Ua.ObjectIds.Server, "Select Event Area", Opc.Ua.ReferenceTypeIds.HasEventSource);

                if (areaId == null)
                {
                    return;
                }

                EventsLV.ChangeArea(areaId, true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
        private void SelectNodeMI_Click(object sender, EventArgs e)
        {
            try
            {
                ReferenceDescription reference = new SelectNodeDlg().ShowDialog(m_browser, ObjectTypes.BaseEventType);

                if (reference != null)
                {
                    Node node = m_session.NodeCache.Find(reference.NodeId) as Node;

                    if (node == null)
                    {
                        return;
                    }
                                        
                    ContentFilterElement element = null;

                    // build the relative path.
                    QualifiedNameCollection browsePath = new QualifiedNameCollection();
                    NodeId typeId = m_session.NodeCache.BuildBrowsePath(node, browsePath);

                    switch (node.NodeClass)
                    {
                        case NodeClass.Variable:
                        {
                            IVariable variable = node as IVariable;

                            if (variable == null)
                            {
                                break;
                            }

                            // create attribute operand.
                            SimpleAttributeOperand attribute = new SimpleAttributeOperand(
                                m_session.FilterContext, 
                                typeId,
                                browsePath);

                            // create default value.
                            object value = GuiUtils.GetDefaultValue(variable.DataType, variable.ValueRank);

                            // create attribute filter.
                            element = m_filter.Push(FilterOperator.Equals, attribute, value);
                            break;
                        }

                        case NodeClass.Object:
                        {
                            // create attribute operand.
                            SimpleAttributeOperand attribute = new SimpleAttributeOperand(
                                m_session.FilterContext, 
                                typeId,
                                browsePath);

                            attribute.AttributeId = Attributes.NodeId;

                            // create attribute filter.
                            element = m_filter.Push(FilterOperator.IsNull, attribute);
                            break;
                        }

                        case NodeClass.ObjectType:
                        {
                            element = m_filter.Push(FilterOperator.OfType, node.NodeId);
                            break;
                        }

                        default:
                        {
                            throw new ArgumentException("Selected an invalid node.");
                        }
                    }

                    // add element.
                    if (element != null)
                    {
                        AddItem(element);
                        AdjustColumns();
                    }
                }
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Exemplo n.º 5
0
        private void BrowseBTN_Click(object sender, EventArgs e)
        {
            try
            {
                Browser browser = new Browser(m_browser.Session);

                browser.BrowseDirection = BrowseDirection.Forward;
                browser.NodeClassMask   = (int)NodeClass.View | (int)NodeClass.Object;
                browser.ReferenceTypeId = ReferenceTypeIds.Organizes;
                browser.IncludeSubtypes = true;

                ReferenceDescription reference = new SelectNodeDlg().ShowDialog(browser, Objects.ViewsFolder);

                if (reference != null)
                {
                    if (reference.NodeClass != NodeClass.View)
                    {
				        MessageBox.Show("Please select a valid view node id.", this.Text);
                        return;
                    }

                    ViewIdTB.Text = Utils.Format("{0}", reference.NodeId);
                }
            }
            catch (Exception exception)
            {
				GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception);
            }
        }
Exemplo n.º 6
0
        private void NodeIdBTN_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                NodeId nodeId = new SelectNodeDlg().ShowDialog(
                    m_session,
                    Opc.Ua.ObjectIds.ObjectsFolder,
                    "Select Variable",
                    Opc.Ua.ReferenceTypeIds.Organizes,
                    Opc.Ua.ReferenceTypeIds.Aggregates);

                if (nodeId == null)
                {
                    return;
                }

                if (nodeId != m_nodeId)
                {
                    ChangeNode(nodeId);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private async void BrowseBTN_Click(object sender, EventArgs e)
        {
            try
            {
                Browser browser = new Browser(m_browser.Session);

                browser.BrowseDirection = BrowseDirection.Forward;
                browser.NodeClassMask = (int)NodeClass.View | (int)NodeClass.Object;
                browser.ReferenceTypeId = ReferenceTypeIds.Organizes;
                browser.IncludeSubtypes = true;

                ReferenceDescription reference = new SelectNodeDlg().ShowDialog(browser, Objects.ViewsFolder);

                if (reference != null)
                {
                    if (reference.NodeClass != NodeClass.View)
                    {
                        MessageDlg dialog = new MessageDlg("Please select a valid view node id.");
                        await dialog.ShowAsync();
                        return;
                    }

                    ViewIdTB.Text = Utils.Format("{0}", reference.NodeId);
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(String.Empty, GuiUtils.CallerName(), exception);
            }
        }