Пример #1
0
        public DiagnosticCtrl()
        {
            //
            // contextMenuStrip1
            //
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.detailsToolStripMenuItem
            });
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(153, 48);
            //
            // detailsToolStripMenuItem
            //
            this.detailsToolStripMenuItem.Name   = "detailsToolStripMenuItem";
            this.detailsToolStripMenuItem.Size   = new System.Drawing.Size(152, 22);
            this.detailsToolStripMenuItem.Text   = "Details";
            this.detailsToolStripMenuItem.Click += new System.EventHandler(this.DetailsToolStripMenuItem_Click);

            InitializeComponent();
            SetColumns(m_ColumnNames);

            m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);

            ItemsLV.Sorting          = SortOrder.None;
            ItemsLV.View             = View.Details;
            ItemsLV.HideSelection    = false;
            ItemsLV.MultiSelect      = false;
            ItemsLV.HeaderStyle      = ColumnHeaderStyle.Nonclickable;
            ItemsLV.FullRowSelect    = true;
            ItemsLV.Width            = 200;
            ItemsLV.ContextMenuStrip = contextMenuStrip1;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuditEventForm"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="subscription">The subscription.</param>
        public AuditEventForm(Session session, Subscription subscription)
        {
            InitializeComponent();

            m_session = session;
            m_subscription = subscription;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary<NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.AuditUpdateMethodEventType };

            // find the fields of interest.
            m_filter.SelectClauses = m_filter.ConstructSelectClauses(m_session, ObjectTypeIds.AuditUpdateMethodEventType);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.
            m_monitoredItem = m_filter.CreateMonitoredItem(m_session);

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuditEventForm"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="subscription">The subscription.</param>
        public AuditEventForm(Session session, Subscription subscription)
        {
            InitializeComponent();

            m_session      = session;
            m_subscription = subscription;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary <NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId   = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.AuditUpdateMethodEventType };

            // find the fields of interest.
            m_filter.SelectClauses = m_filter.ConstructSelectClauses(m_session, ObjectTypeIds.AuditUpdateMethodEventType);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.
            m_monitoredItem = m_filter.CreateMonitoredItem(m_session);

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
Пример #4
0
        public MonitoredItemDlg()
        {
            InitializeComponent();

            m_SubscriptionStateChanged  = new SubscriptionStateChangedEventHandler(Subscription_StateChanged);
            m_MonitoredItemNotification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
            m_PublishStatusChanged      = new EventHandler(Subscription_PublishStatusChanged);
        }
Пример #5
0
        public MonitoredItemDlg()
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            m_SubscriptionStateChanged = new SubscriptionStateChangedEventHandler(Subscription_StateChanged);
            m_MonitoredItemNotification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
            m_PublishStatusChanged = new EventHandler(Subscription_PublishStatusChanged);
        }
Пример #6
0
        public ClientPage(
            ServiceMessageContext context,
            ApplicationInstance application,
            ClientPage masterPage,
            ApplicationConfiguration configuration)
        {
            InitializeComponent();

            if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }

            m_masterPage  = masterPage;
            m_context     = context;
            m_application = application;
            m_server      = application.Server as Opc.Ua.Server.StandardServer;

            if (m_masterPage == null)
            {
                m_pages = new List <ClientPage>();
            }

            m_configuration = configuration;

            SessionsCTRL.Configuration    = configuration;
            SessionsCTRL.MessageContext   = context;
            SessionsCTRL.AddressSpaceCtrl = BrowseCTRL;
            SessionsCTRL.NodeSelected    += SessionCtrl_NodeSelected;

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            m_endpoints.DiscoveryUrls = configuration.ClientConfiguration.WellKnownDiscoveryUrls;

            // hook up endpoint selector
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);
            EndpointSelectorCTRL.ConnectEndpoint  += EndpointSelectorCTRL_ConnectEndpoint;
            EndpointSelectorCTRL.EndpointsChanged += EndpointSelectorCTRL_OnChange;

            BrowseCTRL.SessionTreeCtrl = SessionsCTRL;
            BrowseCTRL.NodeSelected   += BrowseCTRL_NodeSelected;

            // exception dialog
            GuiUtils.ExceptionMessageDlg += ExceptionMessageDlg;

            ServerUrlTB.Text = "None";

            m_publishers = AmqpConnectionCollection.Load(configuration);

            foreach (var publisher in m_publishers)
            {
                Task t = publisher.OpenAsync();
            }

            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
Пример #7
0
        /// <summary>
        /// Creates a form which uses the specified client configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        public MainForm(ApplicationConfiguration configuration)
        {
            InitializeComponent();
            var appSettings = System.Configuration.ConfigurationManager.AppSettings;

            Boolean.TryParse(appSettings["ColumnAutoAdjust"], out this.ColumnAutoAdjust);
            ServerURL = appSettings["ServerURL"];
            Int32.TryParse(appSettings["MaximumItems"], out MaximumItems);
            if (MaximumItems < MIN_ITEMS)
            {
                MaximumItems = MIN_ITEMS;
            }

            this.Icon = ClientUtils.GetAppIcon();

            ConnectServerCTRL.Configuration = m_configuration = configuration;
            if (ServerURL.Length > 0)
            {
                ConnectServerCTRL.ServerUrl = ServerURL;
            }
            else
            {
                ConnectServerCTRL.ServerUrl = "opc.tcp://localhost:62544/Quickstarts/AlarmConditionServer";
            }

            this.Text = m_configuration.ApplicationName;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary <NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId   = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.ConditionType };

            // declare callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // initialize controls.
            Conditions_Severity_AllMI.Checked = true;
            Conditions_Severity_AllMI.Tag     = EventSeverity.Min;
            Conditions_Severity_LowMI.Tag     = EventSeverity.Low;
            Conditions_Severity_MediumMI.Tag  = EventSeverity.Medium;
            Conditions_Severity_HighMI.Tag    = EventSeverity.High;

            Condition_Type_AllMI.Checked            = true;
            Condition_Type_DialogsMI.Checked        = false;
            Condition_Type_AlarmsMI.Checked         = false;
            Condition_Type_LimitAlarmsMI.Checked    = false;
            Condition_Type_DiscreteAlarmsMI.Checked = false;
        }
Пример #8
0
        public GroupLog()
        {
            LogFileSettings = new LogFileConf();

            UpdatePeriod = 1000;
            LogRate      = 5000;
            LogFileSettings.AppendDate            = true;
            LogFileSettings.AppendTime            = true;
            LogFileSettings.CreationAfterDuration = false;
            LogFileSettings.CADDuration           = 120;
            m_MonitoredItem_Notification          = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
Пример #9
0
 private void Initialize(Uri sessionEndpointUri)
 {
     State            = MonitoredItemState.Unmonitored;
     DisplayName      = string.Empty;
     AttributeId      = Attributes.Value;
     MonitoringMode   = MonitoringMode.Reporting;
     SamplingInterval = OpcSamplingRateMillisec;
     QueueSize        = 0;
     DiscardOldest    = true;
     Notification     = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
     EndpointUri      = sessionEndpointUri;
 }
Пример #10
0
        /// <summary>
        /// Creates a form which uses the specified client configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        public MainForm(ApplicationConfiguration configuration)
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            ConnectServerCTRL.Configuration = m_configuration = configuration;
            ConnectServerCTRL.ServerUrl = "opc.tcp://localhost:62547/Quickstarts/DataAccessServer";
            this.Text = m_configuration.ApplicationName;

            // create the callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
Пример #11
0
        /// <summary>
        /// Creates a form which uses the specified client configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        public MainForm(ApplicationConfiguration configuration)
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            ConnectServerCTRL.Configuration = m_configuration = configuration;
            ConnectServerCTRL.ServerUrl     = "opc.tcp://localhost:62548/Quickstarts/DataAccessServer";
            this.Text = m_configuration.ApplicationName;

            // create the callback.
            m_monitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
        public void AddMonitoredItem(TagChannelOpcUaClient client, string nodeId, int samplingInterval,
                                     MonitoredItemNotificationEventHandler eventHandler)
        {
            var monitoredItem = new MonitoredItem
            {
                StartNodeId      = nodeId,
                SamplingInterval = samplingInterval
            };

            _monitoredItems.Add(monitoredItem);
            monitoredItem.Notification += eventHandler;
            client.NewValueToChannel   += OnNewValueToChannel;
        }
Пример #13
0
        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            // create the default subscription.
            m_subscription = new Subscription();

            m_subscription.DisplayName                = null;
            m_subscription.PublishingInterval         = 1000;
            m_subscription.KeepAliveCount             = 10;
            m_subscription.LifetimeCount              = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled          = true;
            m_subscription.TimestampsToReturn         = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary <NodeId, NodeId>();

            NodeId knownEventId = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);

            m_knownEventTypes = new Dictionary <NodeId, Type>();
            m_knownEventTypes.Add(knownEventId, typeof(SystemCycleStatusEventState));

            TypeDeclaration type = new TypeDeclaration();

            type.NodeId       = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);
            type.Declarations = ClientUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

            // the filter to use.
            m_filter = new FilterDeclaration(type, null);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.
            m_monitoredItem                  = new MonitoredItem();
            m_monitoredItem.StartNodeId      = Opc.Ua.ObjectIds.Server;
            m_monitoredItem.AttributeId      = Attributes.EventNotifier;
            m_monitoredItem.SamplingInterval = 0;
            m_monitoredItem.QueueSize        = 1000;
            m_monitoredItem.DiscardOldest    = true;
            m_monitoredItem.Filter           = m_filter.GetFilter();

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
        public static bool CreateMonitoredItem(NodeId nodeId, Session session, MonitoredItemNotificationEventHandler handler)
        {
            if (session != null)
            {
                // access the default subscription, add it to the session and only create it if successful
                Subscription subscription = session.DefaultSubscription;
                if (session.AddSubscription(subscription))
                {
                    subscription.Create();
                }

                // add the new monitored item.
                MonitoredItem monitoredItem = new MonitoredItem(subscription.DefaultItem);
                if (monitoredItem != null)
                {
                    // Set monitored item attributes
                    // StartNodeId = NodeId to be monitored
                    // AttributeId = which attribute of the node to monitor (in this case the value)
                    // MonitoringMode = When sampling is enabled, the Server samples the item.
                    // In addition, each sample is evaluated to determine if
                    // a Notification should be generated. If so, the
                    // Notification is queued. If reporting is enabled,
                    // the queue is made available to the Subscription for transfer
                    monitoredItem.StartNodeId      = nodeId;
                    monitoredItem.AttributeId      = Attributes.Value;
                    monitoredItem.DisplayName      = nodeId.Identifier.ToString();
                    monitoredItem.MonitoringMode   = MonitoringMode.Reporting;
                    monitoredItem.SamplingInterval = 0;
                    monitoredItem.QueueSize        = 0;
                    monitoredItem.DiscardOldest    = true;

                    monitoredItem.Notification += handler;
                    subscription.AddItem(monitoredItem);
                    subscription.ApplyChanges();

                    return(true);
                }
                else
                {
                    Trace("Error: Could not create monitored item!");
                }
            }
            else
            {
                Trace("Argument error: Session is null!");
            }

            return(false);
        }
 /// <summary>
 /// Init instance variables.
 /// </summary>
 private void Init(string sessionEndpointUrl, int?samplingInterval, string displayName)
 {
     State          = OpcMonitoredItemState.Unmonitored;
     AttributeId    = Attributes.Value;
     MonitoringMode = MonitoringMode.Reporting;
     QueueSize      = 0;
     DiscardOldest  = true;
     Notification   = new MonitoredItemNotificationEventHandler(MonitoredItemNotificationEventHandler);
     EndpointUrl    = sessionEndpointUrl;
     DisplayName    = displayName;
     DisplayNameFromConfiguration = string.IsNullOrEmpty(displayName) ? false : true;
     RequestedSamplingInterval    = samplingInterval == null ? OpcSamplingInterval : (int)samplingInterval;
     RequestedSamplingIntervalFromConfiguration = samplingInterval != null ? true : false;
     SamplingInterval = RequestedSamplingInterval;
 }
Пример #16
0
        public MainForm()
        {
            InitializeComponent();

            m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);

            SetListViewColumnHeaderDefaults(ServerListView);

            m_configuration = ApplicationConfiguration.Load("Opc.Ua.Client", ApplicationType.Client);

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);

            Disconnect();
        }
Пример #17
0
    public SessionCtrl()
    {
      InitializeComponent();

      // You need an image list for the indent feature of the list control to work
      listView1.SmallImageList = new GuiUtils().ImageList;

			SetColumns();

      listView1.Sorting = SortOrder.None;
      listView1.View = View.Details;
      listView1.HideSelection = false;
      listView1.MultiSelect = false;
      listView1.HeaderStyle = ColumnHeaderStyle.Nonclickable;
      listView1.FullRowSelect = true;
      listView1.Width = 200;

      m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);
    }
Пример #18
0
        public SessionCtrl()
        {
            InitializeComponent();

            // You need an image list for the indent feature of the list control to work
            listView1.SmallImageList = new GuiUtils().ImageList;

            SetColumns();

            listView1.Sorting       = SortOrder.None;
            listView1.View          = View.Details;
            listView1.HideSelection = false;
            listView1.MultiSelect   = false;
            listView1.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
            listView1.FullRowSelect = true;
            listView1.Width         = 200;

            m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);
        }
Пример #19
0
        /// <summary>
        /// Creates a form which uses the specified client configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        public MainForm(ApplicationConfiguration configuration)
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            ConnectServerCTRL.Configuration = m_configuration = configuration;
            ConnectServerCTRL.ServerUrl     = "opc.tcp://localhost:62544/Quickstarts/AlarmConditionServer";
            this.Text = m_configuration.ApplicationName;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary <NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId   = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.ConditionType };

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // initialize controls.
            Conditions_Severity_AllMI.Checked = true;
            Conditions_Severity_AllMI.Tag     = EventSeverity.Min;
            Conditions_Severity_LowMI.Tag     = EventSeverity.Low;
            Conditions_Severity_MediumMI.Tag  = EventSeverity.Medium;
            Conditions_Severity_HighMI.Tag    = EventSeverity.High;

            Condition_Type_AllMI.Checked            = true;
            Condition_Type_DialogsMI.Checked        = false;
            Condition_Type_AlarmsMI.Checked         = false;
            Condition_Type_LimitAlarmsMI.Checked    = false;
            Condition_Type_DiscreteAlarmsMI.Checked = false;
        }
        /// <summary>
        /// Create monitored item
        /// </summary>
        /// <param name="opcUaNodeId"></param>
        /// <param name="notification"></param>
        /// <param name="namespaceIndex"></param>
        /// <returns></returns>
        public MonitoredItem CreateOpcUaMonitoredItem(string opcUaNodeId,
                                                      MonitoredItemNotificationEventHandler notification,
                                                      ushort namespaceIndex = 2)
        {
            if (string.IsNullOrWhiteSpace(opcUaNodeId))
            {
                throw new ArgumentNullException(nameof(opcUaNodeId));
            }
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification));
            }

            var monitoredItem = new MonitoredItem()
            {
                NodeClass   = NodeClass.Variable,
                StartNodeId = new NodeId(value: opcUaNodeId, namespaceIndex: namespaceIndex),
            };

            // add notifications for monitored items
            monitoredItem.Notification += notification;

            return(monitoredItem);
        }
Пример #21
0
        /// <summary>
        /// Creates a form which uses the specified client configuration.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        public MainForm(ApplicationConfiguration configuration)
        {
            InitializeComponent();
            this.Icon = ClientUtils.GetAppIcon();

            ConnectServerCTRL.Configuration = m_configuration = configuration;
            ConnectServerCTRL.ServerUrl = "opc.tcp://localhost:62544/Quickstarts/AlarmConditionServer";
            this.Text = m_configuration.ApplicationName;

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary<NodeId, NodeId>();

            // the filter to use.
            m_filter = new FilterDefinition();

            m_filter.AreaId = ObjectIds.Server;
            m_filter.Severity = EventSeverity.Min;
            m_filter.IgnoreSuppressedOrShelved = true;
            m_filter.EventTypes = new NodeId[] { ObjectTypeIds.ConditionType };

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // initialize controls.
            Conditions_Severity_AllMI.Checked = true;
            Conditions_Severity_AllMI.Tag = EventSeverity.Min;
            Conditions_Severity_LowMI.Tag = EventSeverity.Low;
            Conditions_Severity_MediumMI.Tag = EventSeverity.Medium;
            Conditions_Severity_HighMI.Tag = EventSeverity.High;

            Condition_Type_AllMI.Checked = true;
            Condition_Type_DialogsMI.Checked = false;
            Condition_Type_AlarmsMI.Checked = false;
            Condition_Type_LimitAlarmsMI.Checked = false;
            Condition_Type_DiscreteAlarmsMI.Checked = false;
        }
        public ClientPage(
           ServiceMessageContext context,
           ApplicationInstance application,
           ClientPage masterPage,
           ApplicationConfiguration configuration)
        {
            InitializeComponent();

            if (!configuration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                configuration.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
            }
        
            m_masterPage = masterPage;
            m_context = context;
            m_application = application;
            m_server = application.Server as Opc.Ua.Server.StandardServer;

            if (m_masterPage == null)
            {
                m_pages = new List<ClientPage>();
            }

            m_configuration = configuration;
            
            SessionsCTRL.Configuration = configuration;
            SessionsCTRL.MessageContext = context;
            SessionsCTRL.AddressSpaceCtrl = BrowseCTRL;
            SessionsCTRL.NodeSelected += SessionCtrl_NodeSelected;

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            m_endpoints.DiscoveryUrls = configuration.ClientConfiguration.WellKnownDiscoveryUrls;
            
            // hook up endpoint selector
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);
            EndpointSelectorCTRL.ConnectEndpoint += EndpointSelectorCTRL_ConnectEndpoint;
            EndpointSelectorCTRL.EndpointsChanged += EndpointSelectorCTRL_OnChange;

            BrowseCTRL.SessionTreeCtrl = SessionsCTRL;
            BrowseCTRL.NodeSelected += BrowseCTRL_NodeSelected;

            // exception dialog
            GuiUtils.ExceptionMessageDlg += ExceptionMessageDlg;

            ServerUrlTB.Text = "None";

            m_publishers = AmqpConnectionCollection.Load(configuration);

            foreach (var publisher in m_publishers)
            {
                Task t = publisher.OpenAsync();
            }

            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);
        }
Пример #23
0
        public static void Main(string[] args)
        {
            ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
            ApplicationInstance application = new ApplicationInstance();

            application.ApplicationName   = "UA AMQP Publisher";
            application.ApplicationType   = ApplicationType.ClientAndServer;
            application.ConfigSectionName = "Opc.Ua.Publisher";

            try
            {
                // load the application configuration.
                Task <ApplicationConfiguration> task = application.LoadApplicationConfiguration(false);
                task.Wait();
                m_configuration = task.Result;

                // check the application certificate.
                Task <bool> task2 = application.CheckApplicationInstanceCertificate(false, 0);
                task2.Wait();
                bool certOK = task2.Result;
                if (!certOK)
                {
                    throw new Exception("Application instance certificate invalid!");
                }

                // start the server.
                Task task3 = application.Start(new SampleServer());
                task3.Wait();

                // get list of cached endpoints.
                m_endpoints = m_configuration.LoadCachedEndpoints(true);
                m_endpoints.DiscoveryUrls = m_configuration.ClientConfiguration.WellKnownDiscoveryUrls;

                // start publishers.
                m_publishers = AmqpConnectionCollection.Load(m_configuration);
                foreach (AmqpConnection publisher in m_publishers)
                {
                    Task t = publisher.OpenAsync();
                }

                m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

                // connect to a server.
                EndpointConnect();

                // publish preconfigured nodes
                PublishedNodesCollection nodes = PublishedNodesCollection.Load(m_configuration);
                foreach (NodeId node in nodes)
                {
                    CreateMonitoredItem(node);
                }

                Console.WriteLine("Publisher started. Press any key to exit...");
                Console.ReadKey(true);

                if (m_publishers != null)
                {
                    foreach (var publisher in m_publishers)
                    {
                        publisher.Close();
                    }
                }

                if (m_session != null)
                {
                    m_session.Close();
                }
            }
            catch (ServiceResultException ex)
            {
                Utils.Trace("ServiceResultException:" + ex.Message);
                Console.WriteLine("Exception: {0}", ex.Message);
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey(true);
            }
        }
Пример #24
0
        /// <summary>
        /// Creates the subscription.
        /// </summary>
        private void CreateSubscription()
        {
            // create the default subscription.
            m_subscription = new Subscription();

            m_subscription.DisplayName = null;
            m_subscription.PublishingInterval = 1000;
            m_subscription.KeepAliveCount = 10;
            m_subscription.LifetimeCount = 100;
            m_subscription.MaxNotificationsPerPublish = 1000;
            m_subscription.PublishingEnabled = true;
            m_subscription.TimestampsToReturn = TimestampsToReturn.Both;

            m_session.AddSubscription(m_subscription);
            m_subscription.Create();

            // a table used to track event types.
            m_eventTypeMappings = new Dictionary<NodeId, NodeId>();

            NodeId knownEventId = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);

            m_knownEventTypes = new Dictionary<NodeId, Type>();
            m_knownEventTypes.Add(knownEventId, typeof(SystemCycleStatusEventState));
            
            TypeDeclaration type = new TypeDeclaration();
            type.NodeId = ExpandedNodeId.ToNodeId(ObjectTypeIds.SystemCycleStatusEventType, m_session.NamespaceUris);
            type.Declarations = ClientUtils.CollectInstanceDeclarationsForType(m_session, type.NodeId);

            // the filter to use.
            m_filter = new FilterDeclaration(type, null);

            // declate callback.
            m_MonitoredItem_Notification = new MonitoredItemNotificationEventHandler(MonitoredItem_Notification);

            // create a monitored item based on the current filter settings.            
            m_monitoredItem = new MonitoredItem();
            m_monitoredItem.StartNodeId = Opc.Ua.ObjectIds.Server;
            m_monitoredItem.AttributeId = Attributes.EventNotifier;
            m_monitoredItem.SamplingInterval = 0;
            m_monitoredItem.QueueSize = 1000;
            m_monitoredItem.DiscardOldest = true;
            m_monitoredItem.Filter = m_filter.GetFilter();

            // set up callback for notifications.
            m_monitoredItem.Notification += m_MonitoredItem_Notification;

            m_subscription.AddItem(m_monitoredItem);
            m_subscription.ApplyChanges();
        }
Пример #25
0
    public DiagnosticCtrl()
    {
      // 
      // contextMenuStrip1
      // 
      this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.detailsToolStripMenuItem});
      this.contextMenuStrip1.Name = "contextMenuStrip1";
      this.contextMenuStrip1.Size = new System.Drawing.Size(153, 48);
      // 
      // detailsToolStripMenuItem
      // 
      this.detailsToolStripMenuItem.Name = "detailsToolStripMenuItem";
      this.detailsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
      this.detailsToolStripMenuItem.Text = "Details";
      this.detailsToolStripMenuItem.Click += new System.EventHandler(this.DetailsToolStripMenuItem_Click);

      InitializeComponent();
      SetColumns(m_ColumnNames);

      m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);

      ItemsLV.Sorting = SortOrder.None;
      ItemsLV.View = View.Details;
      ItemsLV.HideSelection = false;
      ItemsLV.MultiSelect = false;
      ItemsLV.HeaderStyle = ColumnHeaderStyle.Nonclickable;
      ItemsLV.FullRowSelect = true;
      ItemsLV.Width = 200;
      ItemsLV.ContextMenuStrip = contextMenuStrip1;

    }
Пример #26
0
        public MainForm()
        {
            InitializeComponent();

            m_ItemNotification = new MonitoredItemNotificationEventHandler(ItemNotification);

            SetListViewColumnHeaderDefaults(ServerListView);

            m_configuration = ApplicationConfiguration.Load("Opc.Ua.Client", ApplicationType.Client);

            // get list of cached endpoints.
            m_endpoints = m_configuration.LoadCachedEndpoints(true);
            EndpointSelectorCTRL.Initialize(m_endpoints, m_configuration);

            Disconnect();
        }