Example #1
0
        private void DisconnectCallback(Session session, ServerConnectionStatusUpdateEventArgs args)
        {
            Logger.Info($"NotConnectedHandler called for {session} with status {session.ConnectionStatus.ToString()}.");

            if (session.ConnectionStatus != ServerConnectionStatus.Disconnected)
            {
                return;
            }

            Logger.Info($"The connection {session} is disconnected.");
            MonitoringStarted = false;
            StartConnectionEstablishment();
        }
Example #2
0
        private void ReconnectCallback(Session session, ServerConnectionStatusUpdateEventArgs args)
        {
            Logger.Info($"PostConnectionHandler called for {session} with status {session.ConnectionStatus.ToString()}.");

            if (session.ConnectionStatus != ServerConnectionStatus.Connected)
            {
                return;
            }

            Logger.Info($"Connection {session} to ServerConsole established.");

            StartMonitoringImpl();
        }
Example #3
0
        private static void Session_ConnectionStatusUpdate(Session sender, ServerConnectionStatusUpdateEventArgs e)
        {
            switch (e.Status)
            {
            case ServerConnectionStatus.Connected:
            case ServerConnectionStatus.Connecting:
            case ServerConnectionStatus.SessionAutomaticallyRecreated:
            case ServerConnectionStatus.ConnectionErrorClientReconnect:

                break;

            case ServerConnectionStatus.LicenseExpired:
                break;

            default:
                break;
            }
            Console.WriteLine(sender.ConnectionStatus);
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        private void Session_ServerConnectionStatusUpdate(Session sender, ServerConnectionStatusUpdateEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new ServerConnectionStatusUpdateEventHandler(Session_ServerConnectionStatusUpdate), sender, e);
                return;
            }

            // check that the current session matches the session that raised the event.
            if (!Object.ReferenceEquals(m_Session, sender))
            {
                return;
            }

            lock (this)
            {
                bool bClearControls = false;

                switch (e.Status)
                {
                case ServerConnectionStatus.Disconnected:
                    m_bConnected = false;
                    // Update Button
                    ConnectDisconnectBTN.Text = "Connect";
                    // Update ToolStripMenu
                    connectToolStripMenuItem.Enabled    = true;
                    disconnectToolStripMenuItem.Enabled = false;
                    // Set enabled state for combobox
                    UrlCB.Enabled = true;
                    // Update status label.
                    toolStripStatusLabel.Text  = "Disconnected";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    // clear controls
                    bClearControls = true;
                    break;

                case ServerConnectionStatus.Connected:
                    m_bConnected = true;
                    // Update Button
                    ConnectDisconnectBTN.Text = "Disconnect";
                    // Update ToolStripMenu
                    connectToolStripMenuItem.Enabled    = false;
                    disconnectToolStripMenuItem.Enabled = true;
                    // Set enabled state for combobox
                    UrlCB.Enabled = false;

                    // Aggregate the UserControls.
                    _browseControlses.Session      = m_Session;
                    attributeListControl.Session   = m_Session;
                    monitoredItems_Control.Session = m_Session;

                    // Update status label.
                    toolStripStatusLabel.Text  = "Connected to " + m_Session.EndpointDescription.EndpointUrl;
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.success;

                    // Browse first level.
                    _browseControlses.Browse(null);
                    break;

                case ServerConnectionStatus.ConnectionWarningWatchdogTimeout:
                    // Update status label.
                    toolStripStatusLabel.Text  = "Watchdog timed out";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    break;

                case ServerConnectionStatus.ConnectionErrorClientReconnect:
                    // Update status label.
                    toolStripStatusLabel.Text  = "Trying to reconnect";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    break;

                case ServerConnectionStatus.ServerShutdownInProgress:
                    // Update status label.
                    toolStripStatusLabel.Text  = "Server is shutting down";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    break;

                case ServerConnectionStatus.ServerShutdown:
                    // Update status label.
                    toolStripStatusLabel.Text  = "Server has shut down";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    break;

                case ServerConnectionStatus.SessionAutomaticallyRecreated:
                    // Update status label.
                    toolStripStatusLabel.Text  = "A new Session was created";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.success;
                    // clear controls
                    bClearControls = true;
                    break;

                case ServerConnectionStatus.Connecting:
                    // Update status label.
                    toolStripStatusLabel.Text  = "Trying to connect to " + ((m_Session.EndpointDescription != null) ? m_Session.EndpointDescription.EndpointUrl : "<unknown>");
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    break;

                case ServerConnectionStatus.LicenseExpired:
                    // Update status label.
                    toolStripStatusLabel.Text  = "The license has expired.";
                    toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.warning;
                    // disable GUI
                    serverToolStripMenuItem.Enabled       = false;
                    subscriptionToolStripMenuItem.Enabled = false;
                    ConnectDisconnectBTN.Enabled          = false;
                    UrlCB.Enabled  = false;
                    bClearControls = true;
                    break;
                }

                if (bClearControls)
                {
                    // Cleanup attribute list.
                    this.attributeListControl.AttributeList.Items.Clear();

                    // Cleanup treeview.
                    _browseControlses.BrowseTree.BeginUpdate();
                    _browseControlses.BrowseTree.Nodes.Clear();
                    _browseControlses.BrowseTree.EndUpdate();

                    // Aggregate the UserControls.
                    _browseControlses.Session    = null;
                    attributeListControl.Session = null;

                    monitoredItems_Control.Clear();
                }
            }
        }
Example #5
0
    /// <summary>
    /// receive updates about session state.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    ///
    private void Session_ServerConnectionStatusUpdate(Session sender, ServerConnectionStatusUpdateEventArgs e)
    {
        // Previously, this was : "InvokeRequired". But I don't see the best way to replace it in WPF : there is a problem with disconnection
        // The actual way with dispatch is the good way
        if (!Dispatcher.CheckAccess()) // CheckAccess returns true if you're on the dispatcher thread
        {
            Dispatcher.BeginInvoke(new ServerConnectionStatusUpdateEventHandler(Session_ServerConnectionStatusUpdate), sender, e);
            return;
        }

        //// check that the current session matches the session that raised the event.
        //if (!Object.ReferenceEquals(m_OPCUA_client.Session, sender))
        //{
        //    return;
        //}

        lock (this)
        {
            bool allowEditing = true;

            switch (e.Status)
            {
            case ServerConnectionStatus.Disconnected:
                // update status label
                allowEditing = false;
                lbl_ConnectionState.Content = "Disconnected";
                // update buttons
                StopButtonBT(bt_connect_play);
                StopButtonBT(bt_statusConnection);



                //TODO
                //btnMonitor.Text = "Monitor";
                break;

            case ServerConnectionStatus.Connected:
                // update status label
                allowEditing = true;
                lbl_ConnectionState.Content = "Connected";
                // update buttons
                ActiveButtonBT(bt_connect_play);
                ActiveButtonBT(bt_statusConnection);



                break;

            case ServerConnectionStatus.ConnectionWarningWatchdogTimeout:
                // update status label
                lbl_ConnectionState.Content = "ConnectionWarningWatchdogTimeout";
                break;

            case ServerConnectionStatus.ConnectionErrorClientReconnect:
                // update status label
                lbl_ConnectionState.Content = "ConnectionErrorClientReconnect";
                break;

            case ServerConnectionStatus.ServerShutdownInProgress:
                // update status label
                lbl_ConnectionState.Content = "ServerShutdownInProgress";
                break;

            case ServerConnectionStatus.ServerShutdown:
                // update status label
                lbl_ConnectionState.Content = "ServerShutdown";
                break;

            case ServerConnectionStatus.SessionAutomaticallyRecreated:
                // update status label
                lbl_ConnectionState.Content = "SessionAutomaticallyRecreated";
                break;

            case ServerConnectionStatus.Connecting:
                // update status label
                lbl_ConnectionState.Content = "Connecting";
                break;

            case ServerConnectionStatus.LicenseExpired:
                // update status label
                lbl_ConnectionState.Content = "LicenseExpired";
                break;
            }

            // Toggle Textboxes
            txb_ServerURL.IsEnabled = !m_OPCUA_client.IsConnected;


            // Toggle action buttons
            btn_Read.IsEnabled = allowEditing;


            //TODO
            //btnReadAsync.Enabled = allowEditing;
            //btnMonitor.Enabled = allowEditing;
            //btnWrite.Enabled = allowEditing;
            //btnWriteAsync.Enabled = allowEditing;
        }
    }
Example #6
0
 //TODO skal fjernes herfra og ned (read metoder)
 private void StatusUpdateHandler(Session s, ServerConnectionStatusUpdateEventArgs e)
 {
     Console.WriteLine("succ");
 }
Example #7
0
 /// <summary>
 /// Triggers if the connection status of the current session has changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="serverConnectionStatusUpdateEventArgs"></param>
 private void SessionOnConnectionStatusUpdate(Session sender,
                                              ServerConnectionStatusUpdateEventArgs serverConnectionStatusUpdateEventArgs)
 {
     Logger.Trace($"Connection status has changed to {sender.ConnectionStatus}");
 }