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

Initialize additional parameters

This scenario guides you through the process of initializing new AdditionalParameters for later use in other steps. The default values for AdditionalParameters are initialized during the InitializeAnalogParameters step. If you want to share a new custom variable between multiple steps, the best practice is to first initialize the variable in a new custom step based on InitializeAnalogParameters that comes after the original InitializeAnalogParameters step in the pipeline.

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

To initialize additional parameters

In this example, the initialization code for the new AdditionalParameter is written to a file called InitializeAnalogParametersCustom.cs.

  1. In the created project used to implement custom steps for the Krunch Pipeline, open or create the class file.
  2. Set the class to implement the IStep interface.
  3. Give the class the name of your step.
  4. Set the Name member to the name of the step in the RealTime_PipelineExtensions_KrunchDataStream.json file.
  5. Set the ExecutionRequired member of the IStep Interface (For more information, refer to "IStep Interface Members" in the Execution Pipeline Application Programming Interface [API] Reference documentation).
  6. Create the step method, with IStepContext and ICachedSettings as parameters, and returning an IStepContext.
  7. Initialize return parameters and local stepContext variables that access the AdditonalParameters.
  8. Add your new additionalParameter to the context and initialize.
    AVEVA recommends explicitly casting the type so it's known for use in a later step.

Example step

// In the created project used to implement custom steps for the Krunch Pipeline, open or create the class file.
using System;
using OASySDNA.RealTime.ExecutionPipelines.KrunchCommon.Context;
using OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Context;
namespace OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Analog
{
    // Set the class to implement the IStep interface.
    // Give the class the name of your step.
    public sealed class InitializeAnalogParametersCustom : IStep
    {
        // Set the Name member to the name of the step in the RealTime_PipelineExtensions_KrunchDataStream.json file.
        public String Name { get; } = "InitializeAnalogParametersCustom";
        // Set the ExecutionRequired member of the IStep Interface.
        public Boolean ExecutionRequired { get; } = false;
        // Create the step method, with IStepContext and ICachedSettings as parameters, and
        // returning an IStepContext.

        /// <param name="stepContext">Context for krunching that contains information passed between steps.</param>
        /// <param name="cachedSettings">Cached configurations from RealTime database (RTDB) JSON files.</param>
        /// <returns>The stepContext that has been updated by the step.</returns>
        public IStepContext Execute(IStepContext stepContext, ICachedSettings cachedSettings)
        {
           // Initialize return parameters and local stepContext variables that access the AdditionalParameters.
            Exception resultException = null;
            var resultState = true;
            var context = stepContext as KrunchContext;
            var additionalParameters = context.AdditionalParameters;
            try
            {
                // Add your new additionalParameter to the context and initialize.
                // AVEVA recommends explicitly casting the the type so it's known for use in a later step.
                additionalParameters.Add("CustomDoubleParameter", (Double)setRecord.ReadField<Double>("customDouble"));
            }
            catch (Exception exp)
            {
                resultException = exp;
                resultState = false;
            }
            context.StepResults.Add(new StepResult(Name, resultState, resultException));
            return context;
        }
    }
}
TitleResults for “How to create a CRG?”Also Available in