diff --git a/README.md b/README.md index 08459a91..cfc341f3 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Now the `\modelica-json` directory should have a new folder `html` and in the fo ## 3. How to use the parser -The parser can be run with the app.js file as follows: +The parser can be run with the `app.js` file as follows: ``` node app.js -f ``` @@ -86,17 +86,17 @@ The only required input is the path of the file or package to be parsed. ##### --output / -o -This parser takes a .mo file in input and has three possible outputs, that can be specified with the argument -o : +This parser takes a `.mo` file in input and has three possible outputs, that can be specified with the argument `-o` : - **raw-json** : detailed transcription of a Modelica file in JSON - **json**: simplified JSON format, easier to read and interpret - **html** (default): transcription from json with links for documentation - **docx** : transcription of the HTML documentation to an editable format -- **svg** : SVG diagram of the control sequence model in cdl model +- **svg** : SVG diagram of the control sequence model in `cdl` model ##### --mode / -m -We offer two different modes of translation that can be chosen with the argument -m : +We offer two different modes of translation that can be chosen with the argument `-m` : - **modelica** : Parses a Modelica package (must be a directory) - **cdl** (default) : Parses a CDL file. @@ -111,11 +111,11 @@ Specify the output directory. The default option is the current directory. ##### --evaluatePropagatedParameters / -p -Evaluate the propagated parameters. It would be needed for exporting CDL sequences to product lines. `false` is the default. +In `cdl` parsing mode, evaluate the propagated parameters. It would be needed for exporting CDL sequences to product lines. `false` is the default. ##### --evaluateExpressions / -e -Evaluate the mathematical expressions used in parameter assignment and class instantiation. It would be needed for exporting CDL sequences to product lines. `false` is the default. +In `cdl` parsing mode, evaluate the mathematical expressions used in parameter assignment and class instantiation. It would be needed for exporting CDL sequences to product lines. `false` is the default. ##### --strict diff --git a/lib/evaluateMath.js b/lib/evaluateMath.js index 55c8cd88..c67785aa 100644 --- a/lib/evaluateMath.js +++ b/lib/evaluateMath.js @@ -530,13 +530,15 @@ function findNewExpression (valType, valExp, allPar) { // replace the modelica constant with their value newValue = modelicaConstants(tmpStr) } else { - for (var j = 0; j < allPar.length; j++) { - var tmpPar = allPar[j] - if (tmpStr === tmpPar.name) { - // check if the used parameter itself is specified by expression - var type = tmpPar.type ? tmpPar.type : tmpPar.className - noSubExpression = checkType(type, tmpPar.value) - newValue = tmpPar.value + if (allPar !== null) { + for (var j = 0; j < allPar.length; j++) { + var tmpPar = allPar[j] + if (tmpStr === tmpPar.name) { + // check if the used parameter itself is specified by expression + var type = tmpPar.type ? tmpPar.type : tmpPar.className + noSubExpression = checkType(type, tmpPar.value) + newValue = tmpPar.value + } } } } diff --git a/lib/jsonquery.js b/lib/jsonquery.js index eab9d477..a09eb0f4 100644 --- a/lib/jsonquery.js +++ b/lib/jsonquery.js @@ -1039,7 +1039,7 @@ function getComponentsOfClass (model, parseMode, className, prefix) { function setCDLdefaultValue (parseMode, condition, annotation, type, declarations, currentClass) { // If it is not in CDL mode, or it is not removable input connector, or there is vendor annotation to specify the default value, // then do not need to specify the default value in this process - if (parseMode !== 'cdl' || !condition.enable || (annotation.__cdl && annotation.__cdl.default) || type.includes('Output')) { + if (parseMode !== 'cdl' || !condition.instantiate || (annotation.__cdl && annotation.__cdl.default) || type.includes('Output')) { return Object.assign({'__cdl': null}) } // Removable Real input diff --git a/test/FromModelica/cdl/docx/FromModelica.Block1.docx b/test/FromModelica/cdl/docx/FromModelica.Block1.docx index 10e957af..0365343e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Block1.docx and b/test/FromModelica/cdl/docx/FromModelica.Block1.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.BlockInputOutput.docx b/test/FromModelica/cdl/docx/FromModelica.BlockInputOutput.docx index f1bdf4bd..4d526e1b 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.BlockInputOutput.docx and b/test/FromModelica/cdl/docx/FromModelica.BlockInputOutput.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.BlockWithBlock1.docx b/test/FromModelica/cdl/docx/FromModelica.BlockWithBlock1.docx index 3fc48e2e..2b958bb6 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.BlockWithBlock1.docx and b/test/FromModelica/cdl/docx/FromModelica.BlockWithBlock1.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.ConditionalBlock.docx b/test/FromModelica/cdl/docx/FromModelica.ConditionalBlock.docx index a8b7d9ed..b564f719 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.ConditionalBlock.docx and b/test/FromModelica/cdl/docx/FromModelica.ConditionalBlock.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.CustomPWithLimiter.docx b/test/FromModelica/cdl/docx/FromModelica.CustomPWithLimiter.docx index 91e021d9..46aaa95c 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.CustomPWithLimiter.docx and b/test/FromModelica/cdl/docx/FromModelica.CustomPWithLimiter.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.DynamicTextColor.docx b/test/FromModelica/cdl/docx/FromModelica.DynamicTextColor.docx index a80670f4..029d5ee0 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.DynamicTextColor.docx and b/test/FromModelica/cdl/docx/FromModelica.DynamicTextColor.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.EmptyEquation.docx b/test/FromModelica/cdl/docx/FromModelica.EmptyEquation.docx index 8dec03b7..d4b7cc29 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.EmptyEquation.docx and b/test/FromModelica/cdl/docx/FromModelica.EmptyEquation.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.Enable.docx b/test/FromModelica/cdl/docx/FromModelica.Enable.docx index d68b10b8..4241a1c7 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Enable.docx and b/test/FromModelica/cdl/docx/FromModelica.Enable.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithComponent.docx b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithComponent.docx index b2122973..c44d0a88 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithComponent.docx and b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithComponent.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithEquation.docx b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithEquation.docx index fa3dc13c..f344baac 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithEquation.docx and b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithEquation.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithParameter.docx b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithParameter.docx index 1c03f2eb..d168a80e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithParameter.docx and b/test/FromModelica/cdl/docx/FromModelica.MisplacedInfoWithParameter.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.MyController.docx b/test/FromModelica/cdl/docx/FromModelica.MyController.docx index 2c25044d..59adccc6 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.MyController.docx and b/test/FromModelica/cdl/docx/FromModelica.MyController.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.NoClassComment.docx b/test/FromModelica/cdl/docx/FromModelica.NoClassComment.docx index 77707d9e..a774e4c8 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.NoClassComment.docx and b/test/FromModelica/cdl/docx/FromModelica.NoClassComment.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.NoWithin-package.docx b/test/FromModelica/cdl/docx/FromModelica.NoWithin-package.docx index af807e56..0e5572b6 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.NoWithin-package.docx and b/test/FromModelica/cdl/docx/FromModelica.NoWithin-package.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.Parameter1.docx b/test/FromModelica/cdl/docx/FromModelica.Parameter1.docx index 656cc6f9..4314e070 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Parameter1.docx and b/test/FromModelica/cdl/docx/FromModelica.Parameter1.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.Parameter1WithVendorAnnotation.docx b/test/FromModelica/cdl/docx/FromModelica.Parameter1WithVendorAnnotation.docx index 34934a67..af9dbab0 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Parameter1WithVendorAnnotation.docx and b/test/FromModelica/cdl/docx/FromModelica.Parameter1WithVendorAnnotation.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.Parameter2.docx b/test/FromModelica/cdl/docx/FromModelica.Parameter2.docx index f2d56deb..c966c59c 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Parameter2.docx and b/test/FromModelica/cdl/docx/FromModelica.Parameter2.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.Parameter3.docx b/test/FromModelica/cdl/docx/FromModelica.Parameter3.docx index 49511a43..79ed136f 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.Parameter3.docx and b/test/FromModelica/cdl/docx/FromModelica.Parameter3.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.ParameterWithAttributes.docx b/test/FromModelica/cdl/docx/FromModelica.ParameterWithAttributes.docx index d3c18860..11be4215 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.ParameterWithAttributes.docx and b/test/FromModelica/cdl/docx/FromModelica.ParameterWithAttributes.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.ParameterWithDefaultName.docx b/test/FromModelica/cdl/docx/FromModelica.ParameterWithDefaultName.docx index ce6ce8b7..bdd9a40e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.ParameterWithDefaultName.docx and b/test/FromModelica/cdl/docx/FromModelica.ParameterWithDefaultName.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.ParameterWithInfo.docx b/test/FromModelica/cdl/docx/FromModelica.ParameterWithInfo.docx index e96b73fb..04b3011b 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.ParameterWithInfo.docx and b/test/FromModelica/cdl/docx/FromModelica.ParameterWithInfo.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.ParameterWithVendorAnnotationInInfo.docx b/test/FromModelica/cdl/docx/FromModelica.ParameterWithVendorAnnotationInInfo.docx index c17692e2..4f4c165e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.ParameterWithVendorAnnotationInInfo.docx and b/test/FromModelica/cdl/docx/FromModelica.ParameterWithVendorAnnotationInInfo.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.PointList.docx b/test/FromModelica/cdl/docx/FromModelica.PointList.docx index 7f90b023..b8d2b2d2 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.PointList.docx and b/test/FromModelica/cdl/docx/FromModelica.PointList.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.RemovableInputs.docx b/test/FromModelica/cdl/docx/FromModelica.RemovableInputs.docx index 0afd2d62..5998587d 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.RemovableInputs.docx and b/test/FromModelica/cdl/docx/FromModelica.RemovableInputs.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.SubController.docx b/test/FromModelica/cdl/docx/FromModelica.SubController.docx index 43f1b388..18099b8b 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.SubController.docx and b/test/FromModelica/cdl/docx/FromModelica.SubController.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_1.docx b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_1.docx index 067e37bd..475ca566 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_1.docx and b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_1.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_2.docx b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_2.docx index f89948fc..8b7ac23e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_2.docx and b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_2.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_3.docx b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_3.docx index 35deb5cc..e0a1d748 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_3.docx and b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_3.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_4.docx b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_4.docx index e1124d71..1f5ef910 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_4.docx and b/test/FromModelica/cdl/docx/FromModelica.TestEvaluation_4.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.VariableModification.docx b/test/FromModelica/cdl/docx/FromModelica.VariableModification.docx index 6bd784ed..7efe904e 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.VariableModification.docx and b/test/FromModelica/cdl/docx/FromModelica.VariableModification.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.WithCDLElementary.docx b/test/FromModelica/cdl/docx/FromModelica.WithCDLElementary.docx index 892b22ab..2e46d3a8 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.WithCDLElementary.docx and b/test/FromModelica/cdl/docx/FromModelica.WithCDLElementary.docx differ diff --git a/test/FromModelica/cdl/docx/FromModelica.package.docx b/test/FromModelica/cdl/docx/FromModelica.package.docx index 114ab21c..d1086c51 100644 Binary files a/test/FromModelica/cdl/docx/FromModelica.package.docx and b/test/FromModelica/cdl/docx/FromModelica.package.docx differ diff --git a/test/FromModelica/cdl/json/FromModelica.ConditionalBlock.json b/test/FromModelica/cdl/json/FromModelica.ConditionalBlock.json index a8a72577..a6a7edd6 100644 --- a/test/FromModelica/cdl/json/FromModelica.ConditionalBlock.json +++ b/test/FromModelica/cdl/json/FromModelica.ConditionalBlock.json @@ -47,6 +47,9 @@ "name": "u", "comment": "Input connector", "instantiate": "enaBlo", + "__cdl": { + "default": "0" + }, "placement": { "transformation": { "extent": [ diff --git a/test/FromModelica/cdl/json/FromModelica.Enable.json b/test/FromModelica/cdl/json/FromModelica.Enable.json index be4988b3..d85efa09 100644 --- a/test/FromModelica/cdl/json/FromModelica.Enable.json +++ b/test/FromModelica/cdl/json/FromModelica.Enable.json @@ -209,6 +209,9 @@ "isFinal": true }, "instantiate": "use_enthalpy", + "__cdl": { + "default": "0" + }, "placement": { "transformation": { "extent": [ @@ -292,6 +295,9 @@ "isFinal": true }, "instantiate": "use_enthalpy", + "__cdl": { + "default": "0" + }, "placement": { "transformation": { "extent": [ diff --git a/test/FromModelica/cdl/json/FromModelica.RemovableInputs.json b/test/FromModelica/cdl/json/FromModelica.RemovableInputs.json index 925b23cf..cb020a0f 100644 --- a/test/FromModelica/cdl/json/FromModelica.RemovableInputs.json +++ b/test/FromModelica/cdl/json/FromModelica.RemovableInputs.json @@ -69,6 +69,9 @@ "name": "u", "comment": "Input connector", "instantiate": "enaBlo", + "__cdl": { + "default": "0" + }, "placement": { "transformation": { "extent": [ @@ -109,6 +112,9 @@ "isFinal": false }, "instantiate": "enaBlo", + "__cdl": { + "default": "293.15" + }, "placement": { "transformation": { "extent": [ @@ -184,6 +190,9 @@ "name": "uWin", "comment": "Window opening status", "instantiate": "have_winSen", + "__cdl": { + "default": "false" + }, "placement": { "transformation": { "extent": [ @@ -216,6 +225,9 @@ "name": "nOcc", "comment": "Occupancy", "instantiate": "have_occSen", + "__cdl": { + "default": "0" + }, "placement": { "transformation": { "extent": [ diff --git a/test/FromModelica/modelica/docx/FromModelica.docx b/test/FromModelica/modelica/docx/FromModelica.docx index f0ade809..e1c111b9 100644 Binary files a/test/FromModelica/modelica/docx/FromModelica.docx and b/test/FromModelica/modelica/docx/FromModelica.docx differ