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

Use additional parameters

This scenario guides you through the process of using an initialized AdditionalParameter. Since the step is stored as a C# Object, you must explicitly cast the type to the known data type when a custom variable is later used in a dependent step. When updating the value of the custom parameter you must also explicitly cast the value to ensure that the system does not throw an exception if the wrong type is used.

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

To use additional parameters

In this example, the new AdditionalParameter is used within a file called UseCustomParameter.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, and give the class the name of your step.
  3. Set the Name member to the name of the step in the RealTime_PipelineExtensions_KrunchDataStream.json file.
  4. 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).
  5. Create the step method, with IStepContext and ICachedSettings as parameters, and returning an IStepContext.
  6. Retrieve the value of your AddtionalParameter.
  7. Use the AdditionalParameter and update the value within the context if desired.

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;
namespace OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Analog
{
    // Set the class to implement the IStep interface.
    // Name the class after the name of your step.
    public sealed class UseCustomParameter : IStep
    {
        // Set the Name member to the name of the step in the RealTime_PipelineExtensions_KrunchDataStream.json file.
        public String Name { get; } = "UseCustomParameter";
        // Set the ExecutionRequired member of the IStep Interface.
        public Boolean ExecutionRequired { get; } = false;
        // Create the step method, which takes an IStepContext and ICachedSettings as parameters, and
        // returns a resulting IStepContext.
        /// <param name="stepContext">Context for krunching that contains information passed between steps.</param>
        /// <param name="cachedSettings">Cached configurations from RealTime 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;
            var setRecord = context.CommonParameters.SetRecord;
            try
            {
                // Retrieve the value of your AddtionalParameter.
                var customParameter = (Double)additionalParameters.Get("CustomParameter");
                // Use the AdditionalParameter and update the value within the context if desired.
                if (customParameter > 0)
                {
                    additionalParameters.Update("CustomParameter", (Double)(customParameter));
                }
            }
            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