IMsMetaModelVisualController.GetVariableData

Fore Syntax

GetVariableData(Slice: IMsFormulaTransformSlice;
                EntryKey: Integer;
                Calculation: IMsMethodCalculation;
                Coord: IMsFormulaTransformCoord;
                FillType: MsFillBoundType;
                Var IdentificationStartDate: DateTime;
                Var ForecastEndDate: DateTime;
                [Transform: IMsFormulaTransform = Null;]
                [UseInversion: Boolean = False]): Array;

Fore.NET Syntax

GetVariableData(Slice: Prognoz.Platform.Interop.Ms.IMsFormulaTransformSlice;
                EntryKey: integer;
                Calculation: Prognoz.Platform.Interop.Ms.IMsMethodCalculation;
                Coord: Prognoz.Platform.Interop.Ms.IMsFormulaTransformCoord;
                FillType: Prognoz.Platform.Interop.Ms.MsFillBoundType;
                Var IdentificationStartDate: System.DateTime;
                Var ForecastEndDate: System.DateTime;
                Transform: MsFormulaTransform;
                UseInversion: Boolean): Syatem.Array;

Parameters

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.

Description

The GetVariableData method returns the data of the variable by the specified parameters.

Comments

The FillType determines the period of receiving data in the following way: start of receiving data always matches with the sample period, end of data receiving is set by the MsFillBoundType enumeration.

The UseInversion parameter is relevant if some transformation is set for the variable. Available values of the parameter:

Fore Example

Executing the example requires a modeling container with the MODEL_SPACE identifier containing a modeling problem with the WEB_PROBLEM identifier in the repository. 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 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.Period.IdentificationStartDate;
    Calc.Period.IdentificationEndDate := model.Period.IdentificationEndDate;
    Calc.Period.ForecastStartDate := model.Period.ForecastStartDate;
    Calc.Period.ForecastEndDate := model.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;

Example execution result: the data of the input variable for the sample period and start/end date of calculation for the first model in the calculation chain will be displayed in the console window.

Fore.NET Example

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;
    StartDate, EndDate: System.DateTime;
    Data: System.Array;
Begin
    mb := Params.Metabase;
    // 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.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.Period.IdentificationStartDate;
    Calc.Period.IdentificationEndDate := model.Period.IdentificationEndDate;
    Calc.Period.ForecastStartDate := model.Period.ForecastStartDate;
    Calc.Period.ForecastEndDate := model.Period.ForecastEndDate;
    // Get data of the variable
    Data := MetaVisual.GetVariableData(Slice, VarKey As integer, Calc, Coord,
        MsFillBoundType.fbtEndIdentify, Var StartDate, Var EndDate, Transform, False);
    System.Diagnostics.Debug.WriteLine("Calculation start: " + StartDate.ToString());
    System.Diagnostics.Debug.WriteLine("Calculation end: " + EndDate.ToString());
    For i := 0 To Data.Length - 1 Do
        System.Diagnostics.Debug.WriteLine(Data[i]);
    End For;
End Sub;

See also:

IMsMetaModelVisualController