Below is the example of using the SetMs operation to edit equation parameters. The request contains an instance of opened modeling container, parameters of operation execution, equation settings for theBaxter-King Filter method, and the pattern for getting changed data. After execution the operation returns the model that contains the changed equation.
{
"SetMs" : { "tMs" : { "id" : "S20!M!S!C1" }, "tArg" : { "pattern" : {
"obInst" : "true", "item" : { "key" : "3317", "model" : { "transform" : { "formulas" : "" }
} } }, "meta" : { "item" : { "k" : "3317", "type" : "Model", "modelMd" :
{ "transform" : { "formulas" : { "its" : { "it" : [ {
"k" : "0", "kind" : "BandpassFilter", "method" : { "bandpassFilter" : { "missingData" : "", "width" : "3", "frequencyLow" : "2", "frequencyHigh" : "8",
"outputType" : "CycleSeries" } } } ] } } } } }
}, "metaGet" : { "obInst" : "true", "scenarios" : "Get", "item" : { "key" : "2803", "problem" : {
"metamodel" : { "calculationChain" : "Get", "calcChainPattern" : { "modelPattern" : { "transform" : { "formulaCount" : "true",
"formulas" : { "method" : "" }, "equationsFormula" : { "method" : "" }, "kind" : "true" }
} }, "visualControllerPattern" : { "variableRubricatorKey" : "true", "chainWorkbookKey" : "true", "freeVariables" : "true" } } }
} }, "execParams" : { "execSaveModel" : "true" } } } } } }
{ "SetMsResult" : {
"id" : { "id" : "S20!M!S!C1" }, "meta" : { "obInst" : { "obDesc" : {
"@isShortcut" : "0", "i" : "MODELSPACE", "n" : "Modeling container", "k" : "1581", "c" : "5121", "p" : "1580", "h" : "0" } }, "dirty" : "0",
"scenarios" : { "nodes" : { "it" : { "@isFolder" : "0", "k" : "1628", "id" : "OBJ1628", "n" : "Basic",
"vis" : "1", "scenDesc" : { "@isShortcut" : "0", "i" : "OBJ1628", "n" : "Basic", "k" : "1628", "c" : "5124", "p" : "1627", "h" : "0"
} } } }, "item" : { "k" : "2803", "id" : "TEMP_MODEL", "n" : "TEMP_MODEL", "vis" : "1",
"type" : "Problem", "problemMd" : { "metamodel" : { "k" : "2804", "calculationChain" : { "its" : {
"Item" : { "k" : "3317", "id" : "OBJ3317", "n" : "MyInputVavable[t] = HPFilter(MyInputVavable[t], Degree = 2.000)", "vis" : "1", "type" : "Model", "excluded" : "0", "model" : {
"transform" : { "formulaCount" : "1", "formulas" : { "its" : { "it" : [ {
"k" : "0", "kind" : "BandpassFilter", "method" : { "bandpassFilter" : { "missingData" : { "specifiedVector" : "", "method" : "None",
"methodParameter" : "5", "specifiedValue" : "0" }, "width" : "3", "frequencyLow" : "2.000000", "frequencyHigh" : "8.000000", "outputType" : "CycleSeries", "explained" : { "slice" :
{ "k" : "0", "id" : "261", "n" : "MyInputVavable", "vis" : "1", "variableKey" : "3319", "stubKey" : "2805", "selections" : { "its" :
{ "Item" : { "id" : { "id" : "2818" }, "variant" : "261" } }
}, "aggregator" : "None", "parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0"
} } }, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" },
"level" : "None" }, "lag" : "", "key" : "0", "termToText" : "{MyInputVavable[t]}", "termToInnerText" : "@_3319:0[]", "termInfo" : { "k" : "4294967295", "lag" : "0",
"inversion" : { "type" : "None", "lag" : "PrecidingValue", "previousLag" : "-1", "seasonality" : "None", "dependence" : "Linear", "K" : "3" } },
"unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" } }, "cycleTerm" : {
"k" : "4294967295" }, "nonCyclicalTerm" : { "k" : "4294967295" } }, "inversionInfo" : { "type" : "None",
"lag" : "PrecidingValue", "previousLag" : "-1", "seasonality" : "None", "dependence" : "Linear", "K" : "3" } }, "calendarLevel" : "Year", "outputSliceKey" : "0" }
] } }, "kind" : "Simple" } } } } }, "visualController" :
{ "variableRubricatorKey" : "2805", "chainWorkbookKey" : "2837", "freeVariables" : { "its" : { "Item" : { "k" : "0",
"id" : "262", "n" : "MyOutputVavable", "vis" : "1", "variableKey" : "2840", "stubKey" : "2805", "selections" : { "its" : { "Item" :
{ "id" : { "id" : "2818" }, "variant" : "262" } } }, "aggregator" : "None",
"parametrizedDimensions" : { "its" : { "Item" : { "dimension" : "0", "parameter" : "0" } }
}, "unitInfo" : { "unit" : "4294967295", "measure" : "4294967295", "baseUnit" : "4294967295", "unitsDimensionKey" : "0" }, "level" : "None" }
} } } } } } }
public static MsItem SetMsBpf(MsId ms, ulong modelKey, ulong eqKey) { // vars.its.Length var setMsOp = new SetMs(); // Set operation execution parameters setMsOp.tMs = ms; setMsOp.tArg = new SetMsArg() { // Set data change pattern pattern = new MsMdPattern() { item = new MsItemPattern() { // Specify model key key = modelKey, problem = new MsProblemPattern() { metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Change } } } }, // Set data that must be changed meta = new MsMd() { item = new MsItem() { k = modelKey, type = MsItemType.Problem, problemMd = new MsProblem() { metamodel = new MsMetaModel() { calculationChain = new MsCalculationChainEntries() { its = new MsCalculationChainEntry[] { new MsCalculationChainEntry() { k = eqKey, type = MsCalculationChainType.Model, model = new MsModel() { transform = new MsFormulaTransform() { formulas = new TsFormulas() { its = new TsFormula[] { new TsFormula() { kind = TsFormulaKind.BandpassFilter, method = new TsMethod() { // Set parameters of the Baxter-King Filter method bandpassFilter = new TsBandpassFilterMethod() { // Set missing data treatment method missingData = new StatMissingData(){}, // Set cycle period parameters width = 3, frequencyLow = 2, frequencyHigh = 8, // Set component loaded to output variable outputType = TsBPFOutputType.CycleSeries, // Do not additionally load cycle and non-cyclical components cycleTerm = null, nonCyclicalTerm = null } } } } } } } } } } } } } }, // Set changed data getting pattern metaGet = new MsMdPattern() { scenarios = ListOperation.Get, period = true, item = new MsItemPattern() { key = modelKey, problem = new MsProblemPattern() { details = true, scenarios = ListOperation.Get, useSavedCoefficients = true, metamodel = new MsMetaModelPattern() { calculationChain = ListOperation.Get, calcChainPattern = new MsCalculationChainPattern() { modelPattern = new MsModelPattern() { transform = new MsFormulaTransformPattern() { kind = true, formulaCount = true, formulas = new TsFormulaPattern() { method = new TsMethodPattern() { } }, equationsFormula = new TsFormulaPattern() { method = new TsMethodPattern() { } } } } }, visualControllerPattern = new MsMetaModelVisualControllerPattern() { variableRubricatorKey = true, levelFormat = MsLevelFormat.Short, useSourceName = false, freeVariables = true } } } } } }; // Create a proxy object for operation execution var somClient = new SomPortTypeClient(); // Set operation execution parameters var result = somClient.SetMs(setMsOp); return result.meta.item; }
See also: