Write a New Step within the Krunch Pipeline Data Stream
- Last UpdatedApr 08, 2026
- 2 minute read
This scenario guides you through the steps required to add a new step code into the Krunch Pipeline Data Stream.
To identify the code associated with each step, see the code comments in the Example code section.
To add a new step into the Krunch Pipeline Data Stream.
In this example, the step code is written to a file called MyNewStep.cs.
- In the created project used to create the step code, open or create the class file.
- Ensure that the following libraries (at a minimum) are referenced at the top of the file:
using System; using OASySDNA.RealTime.ExecutionPipelines.KrunchCommon.Context; using OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Common;
- Ensure that the namespace is appropriate for a KrunchDataStream step and the appropriate RealTime database (RTDB) table.
For example:
-
namespace OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Analog - Name the class to the name of your step, inheriting from IStep.
- Set the Name member of the IStepInterface to the name of your step.
- Set the ExecutionRequired member of the IStep Interface.
- Create the step method with IStepContext and ICachedSettings as parameters, and returning an IStepContext.
- Initialize return parameters and local stepContext variables that access the krunch context parameters.
- Create the code within the step as desired.
- Catch exceptions and gracefully perform error handling.
- Provide a StepResult to the context with the resultState of success/failure and the resultException (if it exists).
- Return the updated step context.
Example code
// In the created project used to create the step code, open, or create the class file.
// Ensure that the following libraries (at a minimum) are referenced at the top of the file.
using System;
using OASySDNA.RealTime.ExecutionPipelines.KrunchCommon.Context;
using OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Common;
// Ensure that the namespace is for a KrunchDataStream step, and the appropriate RealTime table.
namespace OASySDNA.RealTime.ExecutionPipelines.KrunchDataStream.Steps.Analog
{
// Name the class to the name of your step, inheriting from IStep.
public sealed class MyNewStep : IStep
{
// Set the Name member of the IStepInterface to the name of your step.
public String Name { get; } = "MyNewStep";
// 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 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 krunch context parameters.
Exception resultException = null;
var resultState = true;
var context = stepContext as KrunchContext;
var commonParameters = context.CommonParameters as CommonKrunchDataStreamParameters;
var additionalParameters = context.AdditionalParameters;
var setRecord = context.CommonParameters.SetRecord;
try
{
// Create the code within the step as desired.
DoStepCode();
}
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;
}
}
}