Below is the example of using the GetMs operation to open a metamodel. The request contains an instance of opened modeling container and a pattern for opening the metamodel. The response contains the opened metamodel.
{ "GetMs" : { "tMs" : { "id" : "CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB" }, "tArg" : { "pattern" : { "obInst" : "true", "scenarios" : "None", "item" : { "key" : "89990", "problem" : { "metamodel" : { "calculationChain" : "Get", "calcChainPattern" : { "metaModelPattern" : { "calculationChain" : "Get", "calcChainPattern" : { "modelPattern" : { "generatedName" : "true" } } }, "modelPattern" : { "generatedName" : "true" } }, "visualControllerPattern" : { "variableRubricatorKey" : "true", "freeVariables" : "true" } } } } } } } }
{ "GetMsResult" : { "id" : { "id" : "CGKEECJHPGLBFOAENHCHCNMCBALKLKEEEKBNGDKPHJENHLDI!M!S!CHPOBOCJHPGLBFOAEIBNAJLANGNCFIOLENLIGJEOCACFCIOLB" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "http:\/\/v-shp-development.dev.fs.fsight.world\/", "@isShortcut" : "0", "@isLink" : "0", "@ver" : "2", "@hf" : "0", "i" : "MODELSPACE", "n" : "Modeling container", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0", "hasPrv" : "0", "ic" : "0", "isPermanent" : "1", "isTemp" : "0" } }, "dirty" : "0", "item" : { "k" : "89990", "id" : "MODEL", "n" : "MODEL", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : { "k" : "89991", "calculationChain" : { "its" : { "Item" : [ { "k" : "1", "n" : "Output variable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "{"Geometry":{"x":10,"y":10,"width":150,"height":50}}", "chainVariable" : { "slice" : { "k" : "0", "id" : "Output variable|A", "n" : "Output variable|A", "vis" : "1", "variableKey" : "1", "stubKey" : "89992", "selections" : { "its" : { "Item" : { "id" : { "id" : "90004" }, "variant" : "1" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "Output variable|A", "originalName" : "Output variable", "originalShortName" : "Output variable", "useCustomName" : "0" } }, { "k" : "2", "n" : "Input variable", "vis" : "1", "type" : "Variable", "excluded" : "0", "graphMeta" : "{"Geometry":{"x":10,"y":70,"width":150,"height":50}}", "chainVariable" : { "slice" : { "k" : "0", "id" : "Input variable|A", "n" : "Input variable|A", "vis" : "1", "variableKey" : "2", "stubKey" : "89992", "selections" : { "its" : { "Item" : { "id" : { "id" : "90004" }, "variant" : "2" } } }, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "Year" }, "fullName" : "Input variable|A", "originalName" : "Input variable", "originalShortName" : "Input variable", "useCustomName" : "0" } }, { "k" : "3", "id" : "OBJ3", "n" : "Output variable|A[t] = A0 + A1*Input variable|A[t], (From parent)-(From parent)", "vis" : "1", "type" : "Model", "excluded" : "0", "graphMeta" : "", "model" : { "generatedName" : "Output variable|A[t] = A0 + A1*Input variable|A[t]", "readOnly" : "0" } } ] } }, "visualController" : { "variableRubricatorKey" : "89992", "freeVariables" : { "its" : "" }, "userRPath" : "", "isRExist" : "0" }, "suppressEmptyFilter" : { "suppressEmpty" : "0", "suppressEmptyArea" : "SerieBounds" }, "readOnly" : "0", "variableTestUseR" : "0", "calculateIdentOnFact" : "0" }, "useScenarios" : "0", "readOnly" : "0" } } } } }
The GetMsCalcChain function opens metamodel of the specified model. Input parameters:
ms. Opened modeling container instance.
modelKey. Key of the model that contains a metamodel.
After execution the function returns the opened metamodel. Information about the metamodel is displayed to the console window.
public static MsMetaModel GetMsCalcChain(MsId ms, ulong modelKey) { var getMsOp = new GetMs(); // Set operation execution parameters getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { // Set general data getting pattern
pattern = new MsMdPattern() { scenarios = ListOperation.None, item = new MsItemPattern() { // Set open model key key = modelKey, // Set model data getting pattern problem = new MsProblemPattern() { // Set metamodel data getting pattern metamodel = new MsMetaModelPattern()
{ // Set calculation chain data getting pattern calculationChain = ListOperation.Get, calcChainPattern = new MsCalculationChainPattern() { metaModelPattern = new MsMetaModelPattern() { // Set calculation chain data getting pattern calculationChain = ListOperation.Get, calcChainPattern = new MsCalculationChainPattern() { modelPattern = new MsModelPattern() { generatedName = true}
} }, modelPattern = new MsModelPattern(){ generatedName = true} }, // Set data getting pattern for visual model building visualControllerPattern = new MsMetaModelVisualControllerPattern() { variableRubricatorKey = true, freeVariables = true
} } } } } }; // Create proxy object for operation execution var somClient = new SomPortTypeClient(); // Open model GetMsResult getMsResult = somClient.GetMs(getMsOp);
MsMetaModel mModel = getMsResult.meta.item.problemMd.metamodel; // Get calculation chain MsCalculationChainEntries calcChain = mModel.calculationChain; // Output data about chain into console window Console.WriteLine("Calculation chain: "); foreach (MsCalculationChainEntry calcEl in calcChain.its) { switch(calcEl.type) { case MsCalculationChainType.Model:
Console.WriteLine("".PadRight(2) + "model: " + calcEl.model.generatedName); break; case MsCalculationChainType.MetaModel: Console.WriteLine("".PadRight(2) + "metamodel with key: " + calcEl.metaModel.k); break; }; Console.WriteLine("".PadRight(4) + "element is excluded from calculation: " + calcEl.excluded); Console.WriteLine("".PadRight(4) + "parent element key: " + calcEl.parentKey); } return mModel; }
See also: