ITsCalculationContext.CalculationType

Fore syntax

CalculationType: TsCalculationType;

Fore.NET syntax

CalculationType[Context: Prognoz.Platform.Interop.Fore.IForeRuntimeContext]: TsCalculationType;

Parameters

Context. The method execution context. Relevant only for Fore.NET.

Description

This property is read-only.

The CalculationType property returns the custom method calculation mode.

Comments

If the pointwise calculation is used, that is, CalculationType = TsCalculationType.Pointwise, then the custom method is performed per series observation. If the series calculation is used, that is, CalculationType = TsCalculationType.Series, then the method is performed for the whole series.

Fore example

This example demonstrates custom calculation method. Add links to the Metabase, Ms, Transform system assemblies to execute the example.

Public Function CalculateSomething: Variant;
Var
    pContext: ITsCalculationContext;
    i: Integer;
    pSeries: ITimeSeries;
Begin
    pContext := TsCalculation.Current;
    pContext.Tag := pContext.ParentObject.Name;
    pSeries := pContext.CreateTimeSeries;
    If pContext.CalculationType = TsCalculationType.Series Then
        pContext.RaiseMessage("Vector mode");
        If pSeries.CalcPointCount < 25 Then
            If pSeries.CalcPointCount < 15 Then
                pContext.RaiseError("Number of observations is insufficient. Calculation can not be performed");
            Else
                pContext.RaiseWarning("Number of observations is small. Unreliable  data may be received");
            End If;
        End If;
        For i := pSeries.StartIndex To pSeries.EndIndex Do
            pSeries.Item(i) := 1 / i;
        End For;
        Return pSeries;
    Else
        If pContext.CalculationDirection = TsCalculationDirection.Forward Then
            pContext.RaiseMessage(Pointwise mode (forward));
        Else
            pContext.RaiseMessage(Pointwise mode (backward));
        End If;
        If pSeries.CalcPointCount < 25 Then
            If pSeries.CalcPointCount < 15 Then
                pContext.RaiseError("Number of observations is insufficient. Calculation can not be performed");
            Else
                pContext.RaiseWarning("Number of observations is small. Unreliable  data may be received");
            End If;
        End If;
        i := pSeries.CurrentIndex;
        pSeries.Item(i) := 1 / i;
        Return pSeries.Item(i);
    End If;
End Function CalculateSomething;

The method calculates values on the basis of observation index. The method works both in series and pointwise modes. The calculation mode is shown in a message. If the number of observations is less than 25, the warning is shown. If the number of observations is less than 15, the error is shown and the method is not calculated.

Fore.NET example

This example demonstrates custom calculation method.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Transform;
Imports Prognoz.Platform.Interop.Dimensions;

Public Shared Function CalculateSomethingNet(): object;
Var
    TsCalc: TsCalculation;
    pContext: ITsCalculationContext;
    i: Integer;
    pSeries: ITimeSeries;
Begin
    TsCalc := New TsCalculation.Create();
    pContext := TsCalc.Current[Null];
    pContext.Tag := pContext.ParentObject.Name;
    pSeries := pContext.CreateTimeSeries(-1 As DimCalendarLevel, NullAs ITimeSeries;
    If pContext.CalculationType[Null] = TsCalculationType.tctSeries Then
        pContext.RaiseMessage("Vector mode");
        If pSeries.CalcPointCount < 25 Then
            If pSeries.CalcPointCount < 15 Then
                pContext.RaiseError("Number of observations is insufficient. Calculation can not be performed");
            Else
                pContext.RaiseWarning("Number of observations is small. Unreliable  data may be received");
            End If;
        End If;
        For i := pSeries.StartIndex To pSeries.EndIndex Do
            pSeries.Item[i] := 1 / i;
        End For;
        Return pSeries;
    Else
        If pContext.CalculationDirection[Null] = TsCalculationDirection.tcdForward Then
            pContext.RaiseMessage(Pointwise mode (forward));
        Else
            pContext.RaiseMessage(Pointwise mode (backward));
        End If;
        If pSeries.CalcPointCount < 25 Then
            If pSeries.CalcPointCount < 15 Then
                pContext.RaiseError("Number of observations is insufficient. Calculation can not be performed");
            Else
                pContext.RaiseWarning("Number of observations is small. Unreliable  data may be received");
            End If;
        End If;
        i := pSeries.CurrentIndex;
        pSeries.Item[i] := 1 / i;
        Return pSeries.Item[i];
    End If;
End Function;

The method calculates values on the basis of observation index. The method works both in series and pointwise modes. The calculation mode is shown in a message. If the number of observations is less than 25, the warning is shown. If the number of observations is less than 15, the error is shown and the method is not calculated.

See also:

ITsCalculationContext