Ниже приведен пример использования операции GetMs для получения данных уравнения. В запросе передаются: экземпляр открытого контейнера моделирования и шаблон для извлечения данных. В ответе приходит рабочая книга, содержащая данные уравнения.
{ "GetMs" : {
"tMs" : { "id" : "S59!M!S!C1" }, "tArg" : { "pattern" : { "obInst" : "true", "item" :
{ "key" : "2803", "problem" : { "metamodel" : { "visualControllerPattern" : { "variableWorkbook" : {
"pattern" : { "obInst" : "true", "cellsTable" : { "headers" : "true", "slots" : { "elementName" : "true" },
"cells" : "true", "emptyCells" : "false", "getCellDate" : "true" } } } } } } }
}, "execParams" : { "k" : "4667", "execFillWithModel" : "true" } } } } } }
{ "GetMsResult" : { "id" :
{ "id" : "S59!M!S!C1" }, "meta" : { "obInst" : { "obDesc" : { "@isShortcut" : "0",
"i" : "MODELSPACE", "n" : "Контейнер моделирования", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0", "item" :
{ "k" : "2803", "id" : "TEMP_MODEL", "n" : "TEMP_MODEL", "vis" : "1", "type" : "Problem", "problemMd" : { "metamodel" : {
"k" : "2804", "visualController" : { "variableWorkbook" : { "id" : { "id" : "S59!M!S!W3" }, "meta" :
{ "obInst" : { "obDesc" : { "@isShortcut" : "0", "i" : "VARIABLESWB_2804", "n" : "VariablesWorkBook", "k" : "2835", "c" : "2827",
"p" : "2804", "h" : "0" } }, "dirty" : "1", "windowsPosition" : "Vertical", "hasPivot" : "0", "hasLaner" : "1", "series" : {
"@count" : "3", "its" : "" }, "cellsTable" : { "@rowCount" : "3", "@columnCount" : "21", "columns" : { "dims" :
{ "it" : { "k" : "0", "id" : "calendar" } }, "slots" : { "s" :
[ { "@date" : "2000-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2000", "n" : "2000A1" }
} }, { "@date" : "2001-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2001", "n" : "2001A1"
} } }, { "@date" : "2002-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2002",
"n" : "2002A1" } } }, { "@date" : "2003-01-01", "els" : { "e" : {
"k" : "YEARS:1.1.2003", "n" : "2003A1" } } }, { "@date" : "2004-01-01", "els" : { "e" :
{ "k" : "YEARS:1.1.2004", "n" : "2004A1" } } }, { "@date" : "2005-01-01", "els" : {
"e" : { "k" : "YEARS:1.1.2005", "n" : "2005A1" } } }, { "@date" : "2006-01-01", "els" :
{ "e" : { "k" : "YEARS:1.1.2006", "n" : "2006A1" } } }, { "@date" : "2007-01-01",
"els" : { "e" : { "k" : "YEARS:1.1.2007", "n" : "2007A1" } } }, {
"@date" : "2008-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2008", "n" : "2008A1" } } },
{ "@date" : "2009-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2009", "n" : "2009A1" } }
}, { "@date" : "2010-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2010", "n" : "2010A1" }
} }, { "@date" : "2011-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2011", "n" : "2011A1"
} } }, { "@date" : "2012-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2012",
"n" : "2012A1" } } }, { "@date" : "2013-01-01", "els" : { "e" : {
"k" : "YEARS:1.1.2013", "n" : "2013A1" } } }, { "@date" : "2014-01-01", "els" : { "e" :
{ "k" : "YEARS:1.1.2014", "n" : "2014A1" } } }, { "@date" : "2015-01-01", "els" : {
"e" : { "k" : "YEARS:1.1.2015", "n" : "2015A1" } } }, { "@date" : "2016-01-01", "els" :
{ "e" : { "k" : "YEARS:1.1.2016", "n" : "2016A1" } } }, { "@date" : "2017-01-01",
"els" : { "e" : { "k" : "YEARS:1.1.2017", "n" : "2017A1" } } }, {
"@date" : "2018-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2018", "n" : "2018A1" } } },
{ "@date" : "2019-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2019", "n" : "2019A1" } }
}, { "@date" : "2020-01-01", "els" : { "e" : { "k" : "YEARS:1.1.2020", "n" : "2020A1" }
} } ] } }, "rows" : { "dims" : { "it" :
{ "k" : "0", "id" : "series" } }, "slots" : { "s" : [ {
"els" : { "e" : { "k" : "MyInputVavable", "n" : "MyInputVavable" } } }, {
"els" : { "e" : { "k" : "MyOutputVavable", "n" : "MyOutputVavable" } } }, {
"els" : { "e" : { "k" : "MyInputVavable", "n" : "MyInputVavable" } } } ]
} }, "cells" : { "c" : [ { "@v" : "3.000000", "@dt" : "3", "@row" : "0",
"@column" : "0", "@date" : "2000-01-01" }, { "@v" : "6.200000", "@dt" : "3", "@row" : "0", "@column" : "1", "@date" : "2001-01-01" },
{ "@v" : "7.100000", "@dt" : "3", "@row" : "0", "@column" : "2", "@date" : "2002-01-01" }, { "@v" : "5.800000", "@dt" : "3",
"@row" : "0", "@column" : "3", "@date" : "2003-01-01" }, { "@v" : "2.800000", "@dt" : "3", "@row" : "0", "@column" : "4", "@date" : "2004-01-01"
}, { "@v" : "3.700000", "@dt" : "3", "@row" : "0", "@column" : "5", "@date" : "2005-01-01" }, { "@v" : "4.454652",
"@dt" : "3", "@row" : "0", "@column" : "6", "@date" : "2006-01-01" }, { "@v" : "3.200000", "@dt" : "3", "@row" : "0", "@column" : "7",
"@date" : "2007-01-01" }, { "@v" : "3.600000", "@dt" : "3", "@row" : "0", "@column" : "8", "@date" : "2008-01-01" }, {
"@v" : "8.000000", "@dt" : "3", "@row" : "0", "@column" : "9", "@date" : "2009-01-01" }, { "@v" : "7.000000", "@dt" : "3", "@row" : "0",
"@column" : "10", "@date" : "2010-01-01" }, { "@v" : "1.000000", "@dt" : "3", "@row" : "1", "@column" : "0", "@date" : "2000-01-01" },
{ "@v" : "-1.700000", "@dt" : "3", "@row" : "1", "@column" : "1", "@date" : "2001-01-01" }, { "@v" : "7.200000", "@dt" : "3",
"@row" : "1", "@column" : "2", "@date" : "2002-01-01" }, { "@v" : "-1.000000", "@dt" : "3", "@row" : "1", "@column" : "3", "@date" : "2003-01-01"
}, { "@v" : "5.000000", "@dt" : "3", "@row" : "1", "@column" : "4", "@date" : "2004-01-01" }, { "@v" : "0.200000",
"@dt" : "3", "@row" : "1", "@column" : "5", "@date" : "2005-01-01" }, { "@v" : "6.600000", "@dt" : "3", "@row" : "1", "@column" : "6",
"@date" : "2006-01-01" }, { "@v" : "-0.500000", "@dt" : "3", "@row" : "1", "@column" : "7", "@date" : "2007-01-01" }, {
"@v" : "3.200000", "@dt" : "3", "@row" : "1", "@column" : "8", "@date" : "2008-01-01" }, { "@v" : "2.000000", "@dt" : "3", "@row" : "1",
"@column" : "9", "@date" : "2009-01-01" }, { "@v" : "3.000000", "@dt" : "3", "@row" : "1", "@column" : "10", "@date" : "2010-01-01" },
{ "@v" : "3.000000", "@dt" : "3", "@row" : "2", "@column" : "0", "@date" : "2000-01-01" }, { "@v" : "6.200000", "@dt" : "3",
"@row" : "2", "@column" : "1", "@date" : "2001-01-01" }, { "@v" : "7.100000", "@dt" : "3", "@row" : "2", "@column" : "2", "@date" : "2002-01-01"
}, { "@v" : "5.800000", "@dt" : "3", "@row" : "2", "@column" : "3", "@date" : "2003-01-01" }, { "@v" : "2.800000",
"@dt" : "3", "@row" : "2", "@column" : "4", "@date" : "2004-01-01" }, { "@v" : "3.700000", "@dt" : "3", "@row" : "2", "@column" : "5",
"@date" : "2005-01-01" }, { "@v" : "4.454652", "@dt" : "3", "@row" : "2", "@column" : "6", "@date" : "2006-01-01" }, {
"@v" : "6.448962", "@dt" : "3", "@row" : "2", "@column" : "7", "@date" : "2007-01-01" }, { "@v" : "4.749104", "@dt" : "3", "@row" : "2",
"@column" : "8", "@date" : "2008-01-01" }, { "@v" : "4.215213", "@dt" : "3", "@row" : "2", "@column" : "9", "@date" : "2009-01-01" },
{ "@v" : "4.909267", "@dt" : "3", "@row" : "2", "@column" : "10", "@date" : "2010-01-01" } ] } }
} } } } } } }
public static GetWbkMdResult GetMsEqData(MsId ms, ulong modelKey, ulong eqKey) { var getMsOp = new GetMs(); getMsOp.tMs = ms; getMsOp.tArg = new GetMsArg() { // Задаем шаблон получения данных pattern = new MsMdPattern() { item = new MsItemPattern() { // Указываем ключ модели key = modelKey, problem = new MsProblemPattern()
{ metamodel = new MsMetaModelPattern() { // Задаём шаблон для визуального построения метамодели visualControllerPattern = new MsMetaModelVisualControllerPattern() { // Задаём шаблон извлечения внутренней рабочей книги variableWorkbook = new GetWbkMdArg() { pattern = new WbkMdPattern() { cellsTable = new WbkCellsTablePattern()
{ headers = true, cells = true, emptyCells = false, slots = new PvtSlotPattern() {elementName = true } } } } } }
} } },// Задаём параметры выполнения операции execParams = new MsMdExecParams() { // Указываем ключ уравнения k = eqKey, execFillWithModel = true } }; // Создаем прокси-объект для выполнения операции
var somClient = new SomPortTypeClient(); // Получаем данные уравнения GetMsResult getMsResult = somClient.GetMs(getMsOp); // Выводим данные уравнения MsMetaModelVisualController metaVC = getMsResult.meta.item.problemMd.metamodel.visualController; WbkCellsTable table = metaVC.variableWorkbook.meta.cellsTable; int ar = table.cells.Length; Console.WriteLine("Дата - Значение"); ulong row = 0; ulong rowAft = 2; int nowRow = 0; for (int i = 0; i <= (ar="" -="" 1);="" i++)="" {="" if="" (row="" !="rowAft)" console.writeline("");="" console.writeline(((table.rows.slots.getvalue(nowrow)="" as="" pvtslot).els.getvalue(0)="" pvtslotel).n);="" rowaft="row;" nowrow++;="" }="" console.write((table.cells.getvalue(i)="" pvttablecell).date="" +="" "="" ");="" console.writeline((table.cells.getvalue(i)="" pvttablecell).v);="" row="(table.cells.GetValue(i)" pvttablecell).row;="" };="" return="" metavc.variableworkbook;="" }
См. также: