ParamValues: ITsModelParamValues;
ParamValues[Context: Prognoz.Platform.Interop.Fore.IForeRuntimeContext]: Prognoz.Platform.Interop.Transform.ITsModelParamValues;
The ParamValues property returns the collection of parameter values available in the custom calculation method.
Parameters are available if they are contained in the calculated model.
The example displays 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 custom calculation method context
pContext := TsCalculation.Current;
pParVals := pContext.ParamValues;
// If numeric parameters are available in calculation,
// increase value of observations for parameter value
If (pParVals <> Null) And (pParVals.Count > 0) Then
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 series with zeros
Else
For k := Input.StartIndex To Input.EndIndex Do
Input.Item(k) := 0;
End For;
End If;
// Return 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 fills the series with zeros.
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 custom calculation method context
TsCalc := New TsCalculation.Create();
pContext := TsCalc.Current[Null];
pParVals := pContext.ParamValues[Null];
// If numeric parameters are available in calculation,
// increase value of observations for parameter value
If (pParVals <> Null) And (pParVals.Count > 0) Then
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 changed series
Return Input;
End Function UserFunction;
See also: