GetVariableValues(
Slice: IMsFormulaTransformSlice;
EntryKey: Integer;
ScenarioKeys: Array;
CleanIdentification: Boolean;
Calculation: IMsMethodCalculation;
Coord: IMsFormulaTransformCoord;
FillType: MsFillBoundType;
Transform: IMsFormulaTransform;
Var Dates: Array;
Var FilledDates: Array;
Var FilledCount: Integer;
Var Level: Integer;
Var Result: Array);
GetVariableValues(
Slice: Prognoz.Platform.Interop.Ms.IMsFormulaTransformSlice;
EntryKey: integer;
ScenarioKeys: System.Array;
CleanIdentification: boolean;
Calculation: Prognoz.Platform.Interop.Ms.IMsMethodCalculation;
Coord: Prognoz.Platform.Interop.Ms.IMsFormulaTransformCoord;
FillType: Prognoz.Platform.Interop.Ms.MsFillBoundType;
Transform: Prognoz.Platform.Interop.Ms.MsFormulaTransform;
var Dates: System.Array;
var FilledDates:System.Array;
var FilledCount: integer;
var Level: integer;
var Result: System.Array);
Slice. Variable slice.
EntryKey. V.ariable key.
ScenarioKeys. Array of modeling scenario keys.
CleanIdentification. Indicates whether to clear sample period.
Calculation. Parameters of calculation of the model containing the variable.
Coord. Parameters of the variable coordinate.
FillType. Period of data receiving.
Transform. Parameters of the model containing the variable.
Dates. Array of dates for variable values.
FilledDates. Array of indicators whether variable contains date-specific value.
FilledCount. Number of non-empty variable values.
Level. Calendar frequency of the variable.
Result. Variable values.
The GetVariableValues method returns variable values with dates by specified scenarios.
Available values of the CleanIdentification parameter:
True. Clear sample period.
False. Do not clear sample period.
The method returns execution result in the Dates, FilledDates, FilledCount, Level, Result parameters. Each element of the Dates array corresponds to the elements in the FilledDates and Result arrays.
Executing the example requires that the repository contains a modeling container with the MS identifier, containing a modeling problem with the MODEL_RESETTEST_WEB identifier. This problem must contain an internal metamodel, the calculation chain of which contains at least one model.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainEnts: IMsCalculationChainEntries;
ChainEl: IMsCalculationChainEntry;
i: Integer;
Model: IMsModel;
Transform: IMsFormulaTransform;
Vars: IMsFormulaTransformVariables;
OutputVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
VarKey: Integer;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
ScenKeys: Array Of Integer;
Dates: Array Of DateTime;
FilledDates: Array Of Boolean;
FilledCount: Integer;
Level: Integer;
Result: Array Of Double;
Begin
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MS");
// Get modeling problem
Problem := mb.ItemByIdNamespace("MODEL_RESETTEST_WEB", MsObj.Key).Bind As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Get the first model in the calculation chain
ChainEnts := Meta.CalculationChain;
For i := 0 To ChainEnts.Count - 1 Do
ChainEl := ChainEnts.Item(i);
If ChainEl.Type = MsCalculationChainEntryType.Model Then
Model := (ChainEl As IMsCalculationChainModel).Model;
Break;
End If;
End For;
// Get the input variable of the model
Transform := Model.Transform;
Vars := Transform.Outputs;
OutputVar := Vars.Item(0);
VarKey := OutputVar.Key;
Slice := OutputVar.Slices.Item(0);
// Get the parameters of the method of model calculation
Coord := Transform.CreateCoord(OutputVar);
// Set the parameters of calculation period of the model
Calc := Transform.CreateCalculation;
Calc.Period.IdentificationStartDate := model.Transform.Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := model.Transform.Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := model.Transform.Period.ForecastStartDate;
Calc.Period.ForecastEndDate := model.Transform.Period.ForecastEndDate;
// Create an array of scenario keys and specify the Fact scenario there
ScenKeys := New Integer[1];
ScenKeys[0] := -1;
// Get input variable values
MetaVisual.GetVariableValues(Slice, VarKey, ScenKeys, True, Calc, Coord,
MsFillBoundType.EndForecast, Transform, Dates, FilledDates, FilledCount, Level, Result);
// Output values to console window
For i := 0 To Dates.Length - 1 Do
Debug.Write(Dates[i]);
Debug.Write(" - ");
Debug.WriteLine(Result[i])
End For;
End Sub UserProc;
After executing the example the console window displays input variable values for the first model in the problem calculation chain.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsObj: IMetabaseObjectDescriptor;
Problem: IMsProblem;
Meta: IMsMetaModel;
MetaVisual: IMsMetaModelVisualController;
ChainEnts: IMsCalculationChainEntries;
ChainEl: IMsCalculationChainEntry;
i: Integer;
Model: IMsModel;
Transform: MsFormulaTransform;
Vars: IMsFormulaTransformVariables;
OutputVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
VarKey: uinteger;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
ScenKeys: Array Of integer;
Dates: System.Array;
FilledDates: System.Array;
FilledCount: Integer;
Level: Integer;
Result: System.Array;
Begin
mb := Params.Metabase;
// Get modeling container
MsObj := mb.ItemById["MS"];
// Get modeling problem
Problem := mb.ItemByIdNamespace["MODEL_RESETTEST_WEB", MsObj.Key].Bind() As IMsProblem;
// Get metamodel
Meta := Problem.MetaModel;
MetaVisual := Meta.VisualController;
// Get the first model in the calculation chain
ChainEnts := Meta.CalculationChain;
For i := 0 To ChainEnts.Count - 1 Do
ChainEl := ChainEnts.Item[i];
If ChainEl.Type = MsCalculationChainEntryType.mccetModel Then
Model := (ChainEl As IMsCalculationChainModel).Model;
Break;
End If;
End For;
// Get the input variable of the model
Transform := Model.Transform;
Vars := Transform.Outputs;
OutputVar := Vars.Item[0];
VarKey := OutputVar.Key;
Slice := OutputVar.Slices.Item[0];
// Get the parameters of the method of model calculation
Coord := Transform.CreateCoord(OutputVar);
// Set the parameters of calculation period of the model
Calc := Transform.CreateCalculation();
Calc.Period.IdentificationStartDate := model.Transform.Period.IdentificationStartDate;
Calc.Period.IdentificationEndDate := model.Transform.Period.IdentificationEndDate;
Calc.Period.ForecastStartDate := model.Transform.Period.ForecastStartDate;
Calc.Period.ForecastEndDate := model.Transform.Period.ForecastEndDate;
// Create an array of scenario keys and specify the Fact scenario there
ScenKeys := New Integer[1];
ScenKeys[0] := -1;
// Get input variable values
MetaVisual.GetVariableValues(Slice, VarKey As integer, ScenKeys, False, Calc, Coord,
MsFillBoundType.fbtEndForecast, Transform, Var Dates, Var FilledDates, Var FilledCount, Var Level, Var Result);
// Output values to console window
For i := 0 To Dates.Length - 1 Do
System.Diagnostics.Debug.Write(Dates[i]);
System.Diagnostics.Debug.Write(" - ");
System.Diagnostics.Debug.WriteLine(Result[i])
End For;
End Sub;
See also: