Ms > About the MS Assembly > General Principles of Programming using Ms Assembly > Metamodel
Mind the following features on creating a metamodel and working with it:
The object class Metamodel- MetabaseObjectClass.KE_CLASS_MSMETAMODEL.
It is obligatory to specify a parent container because the metamodel can be located only within a container.
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:
Folder. A folder is used to arrange calculation chain structure. The IMsCalculationChainFolder interface.
Model. Smallest calculation unit. This model can be used within the whole modeling container. The IMsCalculationChainModel interface.
Internal model. Smallest calculation unit. This model exists and can be used only within a metamodel. The IMsCalculationChainModel interface.
Metamodel. Existing calculation chain added to metamodel. The IMsCalculationChainMetaModel interface.
Cycle. A controlling construction that organizes multiple calculation of specified chain elements. The IMsCalculationChainIterator interface.
Chain calculation condition. The controlling construction that ensures calculation of determined chain elements only on satisfying a condition. The IMsCalculationChainBranch 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.
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: