Show contents 

Ms > About the MS Assembly > General Principles of Programming using Ms Assembly > Metamodel

Metamodel

Mind the following features on creating a metamodel and working with it:

The IMsMetaModel interface is used to work with the model by Fore language. The user can form calculation chain and determine metamodel parameters using properties and methods of this interface.

The IMsCalculationChainEntries interface is used to work with calculation chain. The user can add the following elements to calculation chain using methods of this interface:

The user can determine metamodel parameters that affect the model calculation that are included into the chain. The IMsModelParam interface is used to work with metamodel parameters.

A modeling problem is used to calculate the whole metamodel chain with respect to order of elements, cycles, conditions, and parameters.

Creating a Metamodel

After model creation the user should create a metamodel that contains the Balance of Trade, billion USD model for calculation.

Add links to the Metabase and Ms system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    KMDesc: IMetabaseObjectDescriptor;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Meta: IMsMetaModel;
    Model: IMsModel;
    Root: IMsCalculationChainEntries;
Begin
    MB := MetabaseClass.Active;
    KMDesc := MB.ItemById("MODEL_SPACE");
    // Create a metamodel
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSMETAMODEL;
    CrInfo.Id := "META_MODEL_BALANCE";
    CrInfo.Name := "Metamodel for balance of trade calculation";
    CrInfo.Parent := KMDesc;
    MObj := MB.CreateObject(CrInfo).Edit;
    Meta := MObj As IMsMetaModel;
    // Add the Balance of Trade, billion USD model to calculation chain
    Model := MB.ItemByIdNamespace("BALANCE_MODEL", KMDesc.Key).Bind As IMsModel;
    Root := Meta.CalculationChain;
    Root.AddModel(Model);
    MObj.Save;
    Debug.WriteLine("Metamodel is created '" + MObj.Name + "' with identifier '" + MObj.Id + "'");
End Sub UserProc;

After executing the unit the Metamodel for Balance of Trade Calculation metamodel with the META_MODEL_BALANCE identifier is created, information about it is displayed in the console window.

Then the user creates and calculates the modeling problem.

See also:

General Principles of Programming using Ms Assembly