CalculationType: TsCalculationType;
CalculationType[Context: Prognoz.Platform.Interop.Fore.IForeRuntimeContext]: TsCalculationType;
Context. Method execution context. It is relevant only for Fore.NET.
The property is read-only.
The CalculationType property returns the custom method calculation mode.
If the pointwise calculation is used, that is, CalculationType = TsCalculationType.Pointwise, the custom method is executed for each series observation. If the series calculation is used, that is, CalculationType = TsCalculationType.Series, the method is executed for the entire series.
This example displays a custom calculation method. To execute the example, add links to the Metabase, Ms, Transform system assemblies.
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("Series mode");
If pSeries.CalcPointCount < 25 Then
If pSeries.CalcPointCount < 15 Then
pContext.RaiseError("Number of observations is insufficient. Calculation cannot be executed");
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 cannot be executed");
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 displayed in the message. If the number of observations is less than 25, the warning is displayed. If the number of observations is less than 15, the error is displayed and the method is not calculated.
This example displays a 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, Null) As ITimeSeries;
If pContext.CalculationType[Null] = TsCalculationType.tctSeries Then
pContext.RaiseMessage("Series mode");
If pSeries.CalcPointCount < 25 Then
If pSeries.CalcPointCount < 15 Then
pContext.RaiseError("Number of observations is insufficient. Calculation cannot be executed");
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 cannot be executed");
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 displayed in the message. If the number of observations is less than 25, the warning is displayed. If the number of observations is less than 15, the error is displayed and the method is not calculated.
See also: