Below is the example of using the GetMs operation to create a variable based on a time series database series. The request contains an instance of the opened modeling container, the pattern for changing the model, and the time series. The response contains description of the created variable.
{ "Envelope" : { "Body" : { "GetMs" : { "tMs" : { "id" : "S70!M!S!C1"
}, "tArg" : { "pattern" : { "obInst" : "true", "item" : { "key" : "4412", "metaModel" :
{ "tag" : "false", "visualControllerPattern" : "" } } }, "execParams" : { "rubFacts" : {
"it" : { "k" : "10113", "vis" : "true", "atts" : { "its" : { "it" : [
{ "k" : "9", "id" : "COUNTRY", "n" : "Country", "vis" : "true", "value" : "313" } ] } }
} }, "inputRubKey" : "2940", "execSaveProblem" : "true", "execGetVariablesByFactors" : "true" } } } } } }
{ "Envelope" : { "Body" : { "GetMsResult" : { "id" : {
"id" : "S70!M!S!C1" }, "meta" : { "obInst" : { "obDesc" : { "@isShortcut" : "0", "i" : "MODELSPACE",
"n" : "Modeling container", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0", "item" : {
"k" : "4412", "id" : "MODEL_DEL_METAMODEL", "n" : "model_del", "vis" : "1", "type" : "MetaModel", "metaModelMd" : { "k" : "4412", "visualController" : {
"variablesByFactors" : { "its" : { "Item" : { "slice" : { "k" : "0", "id" : "OBJ_TSDB!313",
"n" : "Time series database!d12", "vis" : "1", "variableKey" : "4563", "stubKey" : "2940", "selections" : { "its" : { "Item" : {
"id" : { "id" : "208" }, "variant" : "313" } } }, "aggregator" : "None", "parametrizedDimensions" :
{ "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } } },
"unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "None" }, "variableExists" : "0"
} } } } } } } } } } }
The GetMsRubVar function creates a variable based on the specified time series database series. Input parameters:
ms. Opened modeling container instance.
metaModelKey. Key of the calculation chain, to which the variable is added.
varRub. Time series.
rubKey. Key of the time series database that contains the varRub series.
After execution the function returns the model that contains a new variable. The variable data is displayed in the console window.
public static MsItem GetMsRubVar(MsId ms, ulong metaModelKey, RubFact varRub, ulong rubKey) { var getMsOp = new GetMs(); getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { // Set data change pattern pattern = new MsMdPattern() { item = new MsItemPattern() { key = metaModelKey, metaModel = new MsMetaModelPattern() { tag = false, visualControllerPattern = new MsMetaModelVisualControllerPattern() {} } } }, execParams = new MsMdExecParams() { rubFacts = new RubFact[] { varRub }, inputRubKey = rubKey, execGetVariablesByFactors = true, execSaveProblem = true } }; // Create proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.GetMs(getMsOp); MsMetaModelVisualController metaVC = result.meta.item.metaModelMd.visualController; MsVariablesByFactors vars = metaVC.variablesByFactors; foreach (MsVariableByFactor vbf in vars.its) { Console.WriteLine("Variable added: " + vbf.slice.n); Console.WriteLine(" - variable exists: " + vbf.variableExists); }; return result.meta.item; }
See also: