ITsCalculationContext.ParamValues

Fore syntax

ParamValues: ITsModelParamValues;

Fore.NET syntax

ParamValues[Context: Prognoz.Platform.Interop.Fore.IForeRuntimeContext]: Prognoz.Platform.Interop.Transform.ITsModelParamValues;

Description

The ParamValues property returns collection of parameter values available in the custom calculation method

Comments

Parameters are available if they are contained in the calculated model.

Fore example

The example contains a custom calculation method.

Add links to the Dal, Ms, Transform system assemblies.

Function UserFunction(Input: ITimeSeries): Variant;
Var
    pContext: ITsCalculationContext;
    i, k: Integer;
    pParVals: ITsModelParamValues;
    pParVal: ITsModelParamValue;
Begin
    // Get of custom calculation method
    pContext := TsCalculation.Current;
    pParVals := pContext.ParamValues;
    // If numeric parameters are available in the calculation,
    // increase the value of observations for parameter value
    If (pParVals <> NullAnd (pParVals.Count > 0Then
        For i := 0 To pParVals.Count - 1 Do
            pParVal := pParVals.Item(i);
            If (pParVal.DataType = DbDataType.Float) Or (pParVal.DataType = DbDataType.Integer) Then
                For k := Input.StartIndex To Input.EndIndex Do
                    Input.Item(k) := Input.Item(k) + pParVal.Value;
                End For;
            End If;
        End For;
    // If there are no parameters, fill the series with zeros
    Else
        For k := Input.StartIndex To Input.EndIndex Do
            Input.Item(k) := 0;
        End For;
    End If;
    // Return the changed series
    Return Input;
End Function UserFunction;

If there are numeric parameters available in calculation, the method increases the value of observations of input series for parameter value; if there are no parameters,the method fill the series with zeros.

Fore.NET example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Transform;

Public Shared Function UserFunction(Input: ITimeSeries): object;
Var
    TsCalc: TsCalculation;
    pContext: ITsCalculationContext;
    i, k: Integer;
    pParVals: ITsModelParamValues;
    pParVal: ITsModelParamValue;
Begin
    // Get of custom calculation method
    TsCalc := New TsCalculation.Create();
    pContext := TsCalc.Current[Null];
    pParVals := pContext.ParamValues[Null];
    // If numeric parameters are available in the calculation,
    // increase the value of observations for parameter value
    If (pParVals <> NullAnd (pParVals.Count > 0Then
        For i := 0 To pParVals.Count - 1 Do
            pParVal := pParVals.Item[i];
            If (pParVal.DataType = DbDataType.ddtFloat) Or (pParVal.DataType = DbDataType.ddtInteger) Then
                For k := Input.StartIndex To Input.EndIndex Do
                    Input.Item[k] := (Input.Item[k] As double) + (pParVal.Value As double);
                End For;
            End If;
        End For;
    // If there are no parameters, fill the series with zeros  
    Else
        For k := Input.StartIndex To Input.EndIndex Do
            Input.Item[k] := 0;
        End For;
    End If;
    // Return the changed series
    Return Input;
End Function UserFunction;

See also:

ITsCalculationContext