Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA Enterprise SCADA Execution Pipeline API Reference

Exit the pipeline early

This scenario guides you through the process of writing code that enables you to exit the Execution Pipeline.

There are two scenarios that cause an early exit from an Execution Pipeline:

  • An uncaught exception occurring within your step.
  • Returning a StepResult with a success parameter of false.

Execution Pipeline steps should internally catch known exceptions and handle them gracefully. The recommended practice for exiting a pipeline execution is to return a StepResult in your IStepContext with a success parameter of false.

When an Execution Pipeline exits early, it will still execute any enabled step that has ExecutionRequired set to true.

Follow the steps in this scenario to gracefully exit the pipeline.

To identify the code associated with each step, see the code comments in the Example code section.

To exit the pipeline early

In this example, the step code is written to a file called MyAnalogStep.cs to create a new Execution Pipeline step called MyAnalogStep within the MyPipeline Execution Pipeline.

  1. Set the ExecutionRequired member of the IStepInterface.

    If set to true, the step will still execute even if the pipeline has been exited early. Only set this to true for steps that are essential even if the rest of the pipeline doesn’t run. For example, detaching or unlocking a record or table used by the pipeline should always occur even if no other pipeline processing occurs.

  1. Initialize return parameters and local stepContext variables.
  2. If you want to exit the pipeline without an exception, set the resultState to false and save a copy of the exception.
  3. Catch exceptions and gracefully perform error handling.
  4. Provide a StepResult to the context with the resultState of success/failure and the resultException (if it exists).
  5. Return the updated step context.

Example code

using System;
using OASySDNA.Common.Logging; 
using OASySDNA.RealTime.ExecutionPipelines.MyPipeline.Context;
namespace OASySDNA.RealTime.ExecutionPipelines.MyPipeline.Steps.Analog
{
    public sealed class MyAnalogStep : IStep
    {
        public String Name { get; } = "MyAnalogStep";
        // Set the ExecutionRequired member of the IStep Interface.
       // If this is set to true, this step will still execute even if the pipeline has been exited early.
       // This should only be set to true for steps that are essential even if the rest of the pipeline doesn’t run.
       // For example, detaching or unlocking a record or table used by the pipeline should always occur
       // even if no other pipeline processing occurs.     
        public Boolean ExecutionRequired { get; } = false;
        public IStepContext Execute(IStepContext stepContext, ICachedSettings cachedSettings)
        {
             // Initialize return parameters and local stepContext variables.
            Exception resultException = null;
            var resultState = true; 
            var context = stepContext;
            try
            {
                if(ShouldContinueRunning() == false)
                {
                  // If you wish to exit the pipeline without an exception, set the resultState to false.
                  resultState = false;
                }
            }
            catch (Exception exp)
            {
                  // Catch exceptions and gracefully perform error handling.
                  // Set the resultState to false and save a copy of the exception.
                resultException = exp;
                resultState = false;
            }
            // Provide a StepResult to the context with the resultState of success/failure and the resultException (if it exists).
            context.StepResults.Add(new StepResult(Name, resultState, resultException));
            // Return the updated step context that contains success/failure of our step.
            return context;
        }
    }
}
TitleResults for “How to create a CRG?”Also Available in