GetVariableData(Slice: IMsFormulaTransformSlice;
EntryKey: Integer;
Calculation: IMsMethodCalculation;
Coord: IMsFormulaTransformCoord;
FillType: MsFillBoundType;
Var IdentificationStartDate: DateTime;
Var ForecastEndDate: DateTime;
[Transform: IMsFormulaTransform = Null;]
[UseInversion: Boolean = False]): Array;
Slice. Variable slice.
EntryKey. V.ariable key.
Calculation. Parameters of calculation of the model containing the variable.
Coord. Parameters of the variable coordinate.
FillType. Period of data receiving.
IdentificationStartDate. Returns calculation start date.
ForecastEndDate. Returns calculation end date.
Transform. Parameters of the model containing the variable.
UseInversion. Determines whether to apply the transformation to the data of the variable.
The GetVariableData method returns the data of the variable by the specified parameters.
The FillType parameter determines a period of getting data in the following way: start of getting data always matches with the sample period, end of getting data is set by the MsFillBoundType enumeration.
The UseInversion parameter is relevant if some transformation is set for the variable. Available values of the parameter:
True. The GetVariableData method returns the data of the variable, for which the transformation is applied.
False. The GetVariableData method returns source data of the variable.
Executing the example requires that the repository includes a modeling container with the MODEL_SPACE identifier including a modeling problem with the WEB_PROBLEM identifier. This problem must contain an internal metamodel, the calculation chain of which contains at least one model.
Add links to the Metabase and Ms system assemblies.
Sub GetData;
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;
StartDate, EndDate: DateTime;
Data: Array Of Double;
Begin
mb := MetabaseClass.Active;
// Get modeling container
MsObj := mb.ItemById("MODEL_SPACE");
// Get modeling problem
Problem := mb.ItemByIdNamespace("WEB_PROBLEM", 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;
// Get data of the variable
Data := MetaVisual.GetVariableData(Slice, VarKey, Calc, Coord,
MsFillBoundType.EndIdentify, StartDate, EndDate, Transform, False);
Debug.WriteLine("Calculation start: " + StartDate.ToString);
Debug.WriteLine("Calculation end: " + EndDate.ToString);
For i := 0 To Data.Length - 1 Do
Debug.WriteLine(Data[i]);
End For;
End Sub GetData;
After executing the example the console window displays the data of the input variable for the sample period and start/end date of calculation for the first model in the calculation chain.
See also: