Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assigns a default value for the conditionally removable input connector #196

Merged
merged 5 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path of the file to parse>
```
Expand All @@ -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.
Expand All @@ -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

Expand Down
16 changes: 9 additions & 7 deletions lib/evaluateMath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified test/FromModelica/cdl/docx/FromModelica.Block1.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.BlockInputOutput.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.BlockWithBlock1.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.ConditionalBlock.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.CustomPWithLimiter.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.DynamicTextColor.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.EmptyEquation.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.Enable.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.MyController.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.NoClassComment.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.NoWithin-package.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.Parameter1.docx
Binary file not shown.
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.Parameter2.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.Parameter3.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.ParameterWithInfo.docx
Binary file not shown.
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.PointList.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.RemovableInputs.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.SubController.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.TestEvaluation_1.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.TestEvaluation_2.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.TestEvaluation_3.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.TestEvaluation_4.docx
Binary file not shown.
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.WithCDLElementary.docx
Binary file not shown.
Binary file modified test/FromModelica/cdl/docx/FromModelica.package.docx
Binary file not shown.
3 changes: 3 additions & 0 deletions test/FromModelica/cdl/json/FromModelica.ConditionalBlock.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"name": "u",
"comment": "Input connector",
"instantiate": "enaBlo",
"__cdl": {
"default": "0"
},
"placement": {
"transformation": {
"extent": [
Expand Down
6 changes: 6 additions & 0 deletions test/FromModelica/cdl/json/FromModelica.Enable.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
"isFinal": true
},
"instantiate": "use_enthalpy",
"__cdl": {
"default": "0"
},
"placement": {
"transformation": {
"extent": [
Expand Down Expand Up @@ -292,6 +295,9 @@
"isFinal": true
},
"instantiate": "use_enthalpy",
"__cdl": {
"default": "0"
},
"placement": {
"transformation": {
"extent": [
Expand Down
12 changes: 12 additions & 0 deletions test/FromModelica/cdl/json/FromModelica.RemovableInputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"name": "u",
"comment": "Input connector",
"instantiate": "enaBlo",
"__cdl": {
"default": "0"
},
"placement": {
"transformation": {
"extent": [
Expand Down Expand Up @@ -109,6 +112,9 @@
"isFinal": false
},
"instantiate": "enaBlo",
"__cdl": {
"default": "293.15"
},
"placement": {
"transformation": {
"extent": [
Expand Down Expand Up @@ -184,6 +190,9 @@
"name": "uWin",
"comment": "Window opening status",
"instantiate": "have_winSen",
"__cdl": {
"default": "false"
},
"placement": {
"transformation": {
"extent": [
Expand Down Expand Up @@ -216,6 +225,9 @@
"name": "nOcc",
"comment": "Occupancy",
"instantiate": "have_occSen",
"__cdl": {
"default": "0"
},
"placement": {
"transformation": {
"extent": [
Expand Down
Binary file modified test/FromModelica/modelica/docx/FromModelica.docx
Binary file not shown.