Opc.Ua.Server.StandardServer.SetTriggering C# (CSharp) Method

SetTriggering() public method

Invokes the SetTriggering service.
public SetTriggering ( RequestHeader requestHeader, uint subscriptionId, uint triggeringItemId, UInt32Collection linksToAdd, UInt32Collection linksToRemove, StatusCodeCollection &addResults, DiagnosticInfoCollection &addDiagnosticInfos, StatusCodeCollection &removeResults, DiagnosticInfoCollection &removeDiagnosticInfos ) : ResponseHeader
requestHeader RequestHeader The request header.
subscriptionId uint The subscription id.
triggeringItemId uint The id for the MonitoredItem used as the triggering item.
linksToAdd UInt32Collection The list of ids of the items to report that are to be added as triggering links.
linksToRemove UInt32Collection The list of ids of the items to report for the triggering links to be deleted.
addResults StatusCodeCollection The list of StatusCodes for the items to add.
addDiagnosticInfos DiagnosticInfoCollection The list of diagnostic information for the links to add.
removeResults StatusCodeCollection The list of StatusCodes for the items to delete.
removeDiagnosticInfos DiagnosticInfoCollection The list of diagnostic information for the links to delete.
return ResponseHeader
        public override ResponseHeader SetTriggering(
            RequestHeader requestHeader,
            uint subscriptionId,
            uint triggeringItemId,
            UInt32Collection linksToAdd,
            UInt32Collection linksToRemove,
            out StatusCodeCollection addResults,
            out DiagnosticInfoCollection addDiagnosticInfos,
            out StatusCodeCollection removeResults,
            out DiagnosticInfoCollection removeDiagnosticInfos)
        {
            addResults = null;
            addDiagnosticInfos = null;
            removeResults = null;
            removeDiagnosticInfos = null;

            OperationContext context = ValidateRequest(requestHeader, RequestType.SetTriggering);

            try
            {
                if ((linksToAdd == null || linksToAdd.Count == 0) && (linksToRemove == null || linksToRemove.Count == 0))
                {
                    throw new ServiceResultException(StatusCodes.BadNothingToDo);
                }

                ServerInternal.SubscriptionManager.SetTriggering(
                    context,
                    subscriptionId,
                    triggeringItemId,
                    linksToAdd,
                    linksToRemove,
                    out addResults,
                    out addDiagnosticInfos,
                    out removeResults,
                    out removeDiagnosticInfos);

                return CreateResponse(requestHeader, context.StringTable);
            }
            catch (ServiceResultException e)
            {
                lock (ServerInternal.DiagnosticsLock)
                {
                    ServerInternal.ServerDiagnostics.RejectedRequestsCount++;

                    if (IsSecurityError(e.StatusCode))
                    {
                        ServerInternal.ServerDiagnostics.SecurityRejectedRequestsCount++;
                    }
                }

                throw TranslateException(context, e);
            }
            finally
            {
                OnRequestComplete(context);
            }  
        }