Ниже приведен пример использования операции GetMs для открытия метамодели. В запросе передаются: экземпляр открытого контейнера моделирования и шаблон для открытия метамодели. В ответе приходит открытая метамодель.
{
"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" : "Контейнер моделирования",
"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" : "Моделируемая переменная",
"vis" : "1",
"type" : "Variable",
"excluded" : "0",
"graphMeta" : "{"Geometry":{"x":10,"y":10,"width":150,"height":50}}",
"chainVariable" :
{
"slice" :
{
"k" : "0",
"id" : "Моделируемая переменная|A",
"n" : "Моделируемая переменная|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" : "Моделируемая переменная|A",
"originalName" : "Моделируемая переменная",
"originalShortName" : "Моделируемая переменная",
"useCustomName" : "0"
}
},
{
"k" : "2",
"n" : "Входная переменная",
"vis" : "1",
"type" : "Variable",
"excluded" : "0",
"graphMeta" : "{"Geometry":{"x":10,"y":70,"width":150,"height":50}}",
"chainVariable" :
{
"slice" :
{
"k" : "0",
"id" : "Входная переменная|A",
"n" : "Входная переменная|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" : "Входная переменная|A",
"originalName" : "Входная переменная",
"originalShortName" : "Входная переменная",
"useCustomName" : "0"
}
},
{
"k" : "3",
"id" : "OBJ3",
"n" : "Моделируемая переменная|A[t] = A0 + A1*Входная переменная|A[t], (От родителя)-(От родителя)",
"vis" : "1",
"type" : "Model",
"excluded" : "0",
"graphMeta" : "",
"model" :
{
"generatedName" : "Моделируемая переменная|A[t] = A0 + A1*Входная переменная|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"
}
}
}
}
}
public static MsMetaModel GetMsCalcChain(MsId ms, ulong modelKey)
{
var getMsOp = new GetMs();
// Задаем параметры выполнения операции
getMsOp.tMs = ms;
getMsOp.tArg = new GetMsArg()
{ // Задаем общий шаблон извлечения данных
pattern = new MsMdPattern()
{
scenarios = ListOperation.None,
item = new MsItemPattern()
{ // Задаем ключ открываемой модели
key = modelKey,
// Задаем шаблон извлечения данных модели
problem = new MsProblemPattern()
{ // Задаем шаблон извлечения данных метамодели
metamodel = new MsMetaModelPattern()
{ // Задаем шаблон извлечения данных цепочки расчёта
calculationChain = ListOperation.Get,
calcChainPattern = new MsCalculationChainPattern()
{
metaModelPattern = new MsMetaModelPattern()
{ // Задаем шаблон извлечения данных цепочки расчёта
calculationChain = ListOperation.Get,
calcChainPattern = new MsCalculationChainPattern()
{
modelPattern = new MsModelPattern() { generatedName = true}
}
},
modelPattern = new MsModelPattern(){ generatedName = true}
},
// Задаем шаблон извлечения данных для визуального построения метамодели
visualControllerPattern = new MsMetaModelVisualControllerPattern()
{
variableRubricatorKey = true,
freeVariables = true
} } } } } }; // Создаем прокси-объект для выполнения операции var somClient = new SomPortTypeClient(); // Открываем модель GetMsResult getMsResult = somClient.GetMs(getMsOp);
MsMetaModel mModel = getMsResult.meta.item.problemMd.metamodel;
// Получаем цепочку расчёта
MsCalculationChainEntries calcChain = mModel.calculationChain;
// Выводим данные о цепочке в окно консоли
Console.WriteLine("Цепочка расчёта: ");
foreach (MsCalculationChainEntry calcEl in calcChain.its)
{
switch(calcEl.type)
{
case MsCalculationChainType.Model:
Console.WriteLine("".PadRight(2) + "модель: " + calcEl.model.generatedName);
break;
case MsCalculationChainType.MetaModel:
Console.WriteLine("".PadRight(2) + "метамодель с ключом: " + calcEl.metaModel.k);
break;
};
Console.WriteLine("".PadRight(4) + "элемент исключён из расчёта: " + calcEl.excluded);
Console.WriteLine("".PadRight(4) + "ключ родительского элемента: " + calcEl.parentKey);
}
return mModel;
}
См. также: