The following types are mentioned here: OpcClient.
The state of the connection between the Client and Server is crucial for the communication between the two participants. Monitoring the status of the current session/connection can provide information whether a request can be successfully send. The following events are used to monitor the Client:
OpcClient.Connected and OpcClient.Connecting
The events mentioned are only triggered by the manual call of OpcClient.Connect () and not after a connection break if the connection to the Server was automatically re-established.
OpcClient.Disconnected and OpcClient.Disconnecting
The following types are mentioned here: OpcClient.
The configuration of the OpcClient class decides on the actions that take place as soon as the connection to the Server is lost. Regardless of the cause of the connection loss, the following events are critical:
OpcClient.StateChanged
OpcClient.BreakDetected
OpcClient.Reconnecting and OpcClient.Reconnected
The events described are triggered based on a KeepAlive logic. A watchdog in the OPC Foundation stack used checks the status of the Server cyclically (every 5 seconds) and detects the loss of a connection after 5 seconds at the latest. If the loss of a connection is determined, the events described take action depending on the configuration of the OpcClient. The KeepAlive interval used can be changed via the KeepAlive property of the OpcClient class.
The following types are mentioned here: OpcClient, OpcSubscription, OpcMonitoredItem and OpcNotification.
Notifications are always received by the Client following an active subscription. The processing chain of a notification begins with the handler of the associated MonitoredItem. From there, the notification is forwarded to the responsible subscription and finally to the Client of the subscription. The notifications that can be treated here provide the information received from the Server about a data change or an alarm or event that has occurred on the Server.
OpcClient.NotificationReceived
The following types are mentioned here: OpcClient, OpcSimpleAttributeOperand, OpcFilter, OpcFilterOperand and OpcAlarmCondition.
The following example subscribes to all events that are currently active but have not yet been confirmed:
var isActive = new OpcSimpleAttributeOperand( OpcEventTypes.AlarmCondition, "ActiveState", "Id"); var isAcked = new OpcSimpleAttributeOperand( OpcEventTypes.AcknowledgeableCondition, "AckedState", "Id"); var filter = OpcFilter.Using(client) .FromEvents(OpcEventTypes.AlarmCondition) .Where(OpcFilterOperand.OfType(OpcEventTypes.AlarmCondition) & isAcked == false & isActive == true) .Select(); var subscription = client.SubscribeEvent("ns=2;s=Machine", filter, (sender, e) => { if (e.Event is OpcAlarmCondition alarm) { Console.WriteLine( "{0}: {1}, IsActive = {2}, IsAcked = {3} ({4})", alarm.GetType().Name, alarm.Message, alarm.IsActive, alarm.IsAcked, alarm.Severity); } });
Under UWP (Universal Windows Platform), applications are strictly regulated, such as when developing a mobile application. The following “capabilities” must be set in the project so that the UWP app can act as a Client application via OPC UA:
The required application certificate cannot be automatically created by the OPC UA .NET SDK under UWP. Wherefore an application certificate must be created manually outside of the UWP application. This certificate can then be delivered as part of the assets
of the application and loaded from it. An example of how a UWP project could be set up can be found here: OPC UA .NET Samples - UWP Client
The following types are mentioned here: OpcServer and OpcNodeManager.
By default, all nodes are in the user-defined namespace with the number (= NamespaceIndex) two. The namespace with number one is described by the underlying stack of the OPC Foundation as “core namespace” and as “application namespace”. So that nodes within the namespace with the index one can be managed, the user-defined OpcNodeManager must use the value of the OpcServer.ApplicationUri property as NamespaceUri.
The following types are mentioned here: OpcServer, OpcAccessControlEntry and OpcSession.
To disable subsequent user access attempts as long a user controlled through an access control entry (ACE) is connected, all available endpoints needs to be blocked for the user as long as a session is active for him. How this can work can bee seen here:
server.SessionActivated += (sender, e) => { var identityEntry = GetUserEntry(server.Security, e.Session); if (identityEntry != null) identityEntry.Disable(OpcEndpointIdentity.GetCurrent()); }; server.SessionClosing += (sender, e) => { var identityEntry = GetUserEntry(server.Security, e.Session); if (identityEntry != null) identityEntry.Enable(OpcEndpointIdentity.GetCurrent()); }; private static OpcAccessControlEntry GetUserEntry( OpcServerSecurity security, OpcSession session) { var identity = session.UsedIdentity; // In case of anonymous. if (identity == null) return null; return (from userEntry in security.UserNameAcl.Entries let userPrincipal = userEntry.Principal let userIdentity = (OpcUserIdentity)userPrincipal.Identity where userIdentity.DisplayName == identity.DisplayName select userEntry).FirstOrDefault(); }