Ejemplo n.º 1
0
        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    EventsLV.IsSubscribed = false;
                    EventsLV.ChangeArea(ExpandedNodeId.ToNodeId(ObjectIds.Plaforms, m_session.NamespaceUris), true);

                    TypeDeclaration type = new TypeDeclaration();
                    type.NodeId       = ExpandedNodeId.ToNodeId(ObjectTypeIds.WellTestReportType, m_session.NamespaceUris);
                    type.Declarations = ModelUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

                    EventsLV.ChangeFilter(new FilterDeclaration(type, null), true);
                    m_connectedOnce = true;
                }

                EventsLV.IsSubscribed = Events_EnableSubscriptionMI.Checked;
                EventsLV.ChangeSession(m_session, true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Ejemplo n.º 2
0
        private void Events_ModifyEventFilterMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                if (!new ModifyFilterDlg().ShowDialog(EventsLV.Filter))
                {
                    return;
                }

                EventsLV.ChangeFilter(EventsLV.Filter, true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Ejemplo n.º 3
0
        private void Events_SelectEventTypeMI_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }

                TypeDeclaration type = new SelectTypeDlg().ShowDialog(m_session, Opc.Ua.ObjectTypeIds.BaseEventType, "Select Event Type");

                if (type == null)
                {
                    return;
                }

                EventsLV.ChangeFilter(new FilterDeclaration(type, EventsLV.Filter), true);
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the application after connecting to or disconnecting from the server.
        /// </summary>
        private void Server_ConnectComplete(object sender, EventArgs e)
        {
            try
            {
                m_session = ConnectServerCTRL.Session;

                if (m_session == null)
                {
                    return;
                }

                // set a suitable initial state.
                if (m_session != null && !m_connectedOnce)
                {
                    m_connectedOnce = true;

                    EventsLV.IsSubscribed      = false;
                    EventsLV.DisplayConditions = true;
                    EventsLV.ChangeArea(Opc.Ua.ObjectIds.Server, false);

                    FilterDeclaration filter = new FilterDeclaration();

                    ushort namespaceIndex = (ushort)m_session.NamespaceUris.GetIndex(DsatsDemo.Namespaces.DsatsDemo);

                    filter.EventTypeId = ExpandedNodeId.ToNodeId(DsatsDemo.ObjectTypeIds.LockConditionType, m_session.NamespaceUris);

                    filter.AddSimpleField(String.Empty, BuiltInType.NodeId, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.EventId, BuiltInType.ByteString, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.EventType, BuiltInType.NodeId, false);
                    filter.AddSimpleField(Opc.Ua.BrowseNames.ConditionName, BuiltInType.String, true);

                    filter.AddSimpleField(new QualifiedName[] {
                        new QualifiedName(DsatsDemo.BrowseNames.LockState, namespaceIndex),
                        new QualifiedName(Opc.Ua.BrowseNames.CurrentState)
                    },
                                          BuiltInType.String,
                                          ValueRanks.Scalar,
                                          true);

                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.ClientUserId, namespaceIndex), BuiltInType.String, true);
                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.SubjectName, namespaceIndex), BuiltInType.String, true);
                    filter.AddSimpleField(new QualifiedName(DsatsDemo.BrowseNames.SessionId, namespaceIndex), BuiltInType.NodeId, true);

                    EventsLV.ChangeFilter(filter, true);

                    m_filter = filter;

                    PhaseCB.Items.Clear();

                    BrowseDescription nodeToBrowse = new BrowseDescription();
                    nodeToBrowse.NodeId          = new NodeId(DsatsDemo.Objects.Rig_Phases, namespaceIndex);
                    nodeToBrowse.ReferenceTypeId = Opc.Ua.ReferenceTypeIds.HierarchicalReferences;
                    nodeToBrowse.IncludeSubtypes = true;
                    nodeToBrowse.BrowseDirection = BrowseDirection.Forward;
                    nodeToBrowse.ResultMask      = (uint)BrowseResultMask.All;

                    DataValue value        = m_session.ReadValue(new NodeId(DsatsDemo.Variables.Rig_CurrentPhase, namespaceIndex));
                    NodeId    currentPhase = value.GetValue <NodeId>(null);

                    ReferenceDescriptionCollection references = ClientUtils.Browse(m_session, nodeToBrowse, false);

                    if (references != null)
                    {
                        for (int ii = 0; ii < references.Count; ii++)
                        {
                            PhaseCB.Items.Add(references[ii]);

                            if (currentPhase == references[ii].NodeId)
                            {
                                PhaseCB.SelectedIndex = ii;
                            }
                        }
                    }

                    m_connectedOnce = true;
                }

                EventsLV.IsSubscribed = true;
                EventsLV.ChangeSession(m_session, true);
                EventsLV.ConditionRefresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }