Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

read Connectionstate

More
24 May 2021 12:50 #9698 by AdiROC
Replied by AdiROC on topic read Connectionstate
exactly what I was looking for, thank you!

code:
        public void initializeLogServer()
        {
            EasyUAClient _client = new EasyUAClient();
            _client.ServerConditionChanged += ServerConditionChanged;
        }
 
 
 
        private static void ServerConditionChanged(object sender, EasyUAServerConditionChangedEventArgs e)
        {
            Debug.WriteLine(e);
            if(e.Connected == true)
            {
                ValuesController.StateIO = true;
            }
            else
            {
                ValuesController.StateIO = false;
                if(e.ErrorMessage != null)
                {
                    Log.Error(e.ErrorMessage);
                }
            }
        }

Please Log in or Create an account to join the conversation.

More
24 May 2021 11:27 #9697 by support
The following user(s) said Thank You: AdiROC

Please Log in or Create an account to join the conversation.

More
24 May 2021 09:44 #9696 by AdiROC
read Connectionstate was created by AdiROC
Hello

In my Client Application, I need to know if the client is connected at the moment or not.

To achieve this, I wrote this code:
private static void EasyUAClientOnLogEntry(object sender, LogEntryEventArgs logEntryEventArgs)
        {
            Debug.WriteLine(logEntryEventArgs);
 
            switch (logEntryEventArgs.EntryType.ToString())
            {
                case "Information":
                    Log.Information(logEntryEventArgs.Message);
                    break;
                case "Warning":
                    Log.Warning(logEntryEventArgs.Message);
                    break;
                default:
                    Log.Debug(logEntryEventArgs.EntryType + ": " + logEntryEventArgs.Message);
                    break;
            }
 
            if(logEntryEventArgs.Message.Contains("{BadTcpInternalError}") == true)
            {
                Log.Error("OPCUA Client is not connected");
                ValuesController.StateIO = false;
            }
            else if (logEntryEventArgs.Message.Contains("has successfully connected") == true)
            {
                Log.Information("OPCUA Client is connected");
                ValuesController.StateIO = true;
            }
        }

Is there a better way to do this?

Thanks in advance!

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.042 seconds