Opc.Ua.Server.DiagnosticsNodeManager.UpdateSubscriptionDiagnostics C# (CSharp) Method

UpdateSubscriptionDiagnostics() private method

Updates the subscription diagnostics summary structure.
private UpdateSubscriptionDiagnostics ( SubscriptionDiagnosticsData diagnostics, SubscriptionDiagnosticsDataType subscriptionArray, int index ) : bool
diagnostics SubscriptionDiagnosticsData
subscriptionArray SubscriptionDiagnosticsDataType
index int
return bool
        private bool UpdateSubscriptionDiagnostics(
            SubscriptionDiagnosticsData diagnostics, 
            SubscriptionDiagnosticsDataType[] subscriptionArray, 
            int index)
        {  
            // get the latest snapshot.
            object value = null;
            
            ServiceResult result = diagnostics.UpdateCallback(
                SystemContext, 
                diagnostics.Value.Variable, 
                ref value);

            SubscriptionDiagnosticsDataType newValue = value as SubscriptionDiagnosticsDataType;
            subscriptionArray[index] = newValue;

            // check for changes.
            if (Utils.IsEqual(newValue, diagnostics.Value.Value))
            {
                return false;
            }
            
            diagnostics.Value.Error = null;
            
            // check for bad value.
            if (ServiceResult.IsNotBad(result) && newValue == null)
            {
                result = StatusCodes.BadOutOfService;
            }

            // check for bad result.
            if (ServiceResult.IsBad(result))
            {
                diagnostics.Value.Error = result;
                newValue = null;
            }
            
            // update the value.
            diagnostics.Value.Value = newValue;
            diagnostics.Value.Timestamp = DateTime.UtcNow;

            // notify any monitored items.
            diagnostics.Value.ChangesComplete(SystemContext);

            return true;
        }