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.
{ "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" } } } } } }
{ "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"
} } } } } } }
public static MsItem GetMsRubVar(MsId ms, uint metaModelKey, RubFact varRub, uint rubKey)
{
var getMsOp = new GetMs()
{
tMs = ms,
tArg = new GetMsArg()
{
pattern = new MsMdPattern()
{
item = new MsItemPattern()
{
key = metaModelKey,
metaModel = new MsMetaModelPattern()
{
tag = false,
visualControllerPattern = new MsMetaModelVisualControllerPattern() { }
}
}
},
execParams = new MsMdExecParams()
{
execGetVariablesByFactors = new MsMdExecGetVariablesByFactors()
{
rubFacts = new RubFact[] { varRub },
inputRubKey = rubKey
}
}
}
};
// Create a proxy object for operation execution
var somClient = new SomPortTypeClient();
// Add a variable from time series database
var result = somClient.GetMs(getMsOp);
var metaVC = result.meta.item.metaModelMd.visualController;
var vars = metaVC.variablesByFactors;
foreach (MsVariableByFactor vbf in vars.its)
{
Console.WriteLine("Variable is added: " + vbf.chainEntry.n);
Console.WriteLine(" - variable exists: " + vbf.variableExists);
};
return result.meta.item;
}
See also: