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

CDL-Based Sequence Documentation #249

Merged
merged 36 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e98d060
Auto commit all [ci skip]
AntoineGautier Aug 14, 2024
ac294d4
Add parameter expression evaluation
AntoineGautier Aug 15, 2024
684b969
Merge branch 'master' of github.com:lbl-srg/modelica-json into tmp/proto
AntoineGautier Aug 15, 2024
5748bea
Update with prefix, fix enum regex
AntoineGautier Aug 30, 2024
e671926
Add code to fetch documentation
AntoineGautier Aug 30, 2024
32f8e17
Improve expression evaluation
AntoineGautier Sep 6, 2024
47b6b1e
Fix corner cases
AntoineGautier Sep 7, 2024
93d9ac7
Add tests
AntoineGautier Sep 8, 2024
bb687ef
Improve expression evaluation
AntoineGautier Sep 10, 2024
6c41b35
Add displayUnit
AntoineGautier Sep 12, 2024
ac61295
Add unit conversion
AntoineGautier Sep 13, 2024
234a1e4
Add functions to convert img tags
AntoineGautier Sep 17, 2024
6f8ce68
Add href conversion, refactor w/ inplace modif of cheerio objects
AntoineGautier Sep 18, 2024
dfa2d84
Add section numbering
AntoineGautier Sep 19, 2024
66e4325
Add CDL toggle function, add unit tests
AntoineGautier Sep 20, 2024
dd1ef3c
Apply standard --fix, add functionalities
AntoineGautier Sep 25, 2024
579dab3
Fix bugs, update objects, update tests
AntoineGautier Sep 26, 2024
2d56dca
Improve handling of unique doc sections
AntoineGautier Sep 27, 2024
dbf2763
Remove heading attribute, add eslint rules
AntoineGautier Sep 30, 2024
1344588
Check conditional instance across instance tree
AntoineGautier Oct 2, 2024
173b650
Update dependencies and app version
AntoineGautier Oct 2, 2024
8d0169a
Merge branch 'master' of github.com:lbl-srg/modelica-json into issue2…
AntoineGautier Oct 2, 2024
d31a698
Remove .vscode from tracked, organize test dir
AntoineGautier Oct 2, 2024
8a36072
Add argument to app.js
AntoineGautier Oct 2, 2024
98ddc38
Upgrade node version for .toSorted (20 is a LTS version)
AntoineGautier Oct 3, 2024
0e2a732
TMP: limit CI scope
AntoineGautier Oct 3, 2024
526948e
Sort before comparing
AntoineGautier Oct 3, 2024
82acab3
Recreate reference file
AntoineGautier Oct 3, 2024
1304ce4
Recreate reference JSON
AntoineGautier Oct 3, 2024
79fea1c
Fetch element by name before comparing properties
AntoineGautier Oct 3, 2024
1bbda19
Restore full CI
AntoineGautier Oct 3, 2024
2c6eab6
Add option to include tables with parameters and I/O
AntoineGautier Oct 15, 2024
e200aba
Update README
AntoineGautier Oct 17, 2024
88d2803
Update doc, fix issue w/ units for array variables
AntoineGautier Nov 4, 2024
5b0d5ea
Fix standard
AntoineGautier Nov 6, 2024
dfb3a9b
Add tabs and groups, filter out undocumented blocks
AntoineGautier Nov 8, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ modelica-json.log
/cxf
.nyc_output
.DS_Store
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist: focal

language: node_js
node_js:
- "18"
- "20"

env:
- MODELICAPATH="./.tmp/"
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ First, set the MODELICAPATH environment variable by adding the following line to
export MODELICAPATH=${MODELICAPATH}:/usr/local/Modelica/Library/
```

The parser requires Java and node. The java dependency can be installed using:
The parser requires Java and node. The java dependency can be installed using:
```
sudo apt-get install default-jdk default-jre
```
The node version should be >= 18 and you can use [Node Version Manager](https://nodejs.org/en/download/package-manager) to set it up. Following is using 0.39.7 version:
The node version should be >= 18 and you can use [Node Version Manager](https://nodejs.org/en/download/package-manager) to set it up. Following is using 0.39.7 version:
```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
Expand Down Expand Up @@ -60,7 +60,7 @@ make clean-installation

### Windows

- First, make sure that both the `modelica-json` directory and the `Modelica Buildings Library` directory are in the folders that do not require administrator access.
- First, make sure that both the `modelica-json` directory and the `Modelica Buildings Library` directory are in the folders that do not require administrator access.
By saving the directories in driver other than `C:\` would typical avoid the administrator access issue.

- Then, create the `MODELICAPATH` environment variable and set the value as the path of Modelica Buildings Library, like `E:\modelica-buildings` or `E:\modelica-buildings-master`.
Expand Down Expand Up @@ -99,7 +99,9 @@ This parser takes a .mo file in input and has three possible outputs, that can b
- **raw-json** : detailed transcription of a Modelica file in JSON
- **json**: simplified JSON format, easier to read an interpret
- **semantic**: generate semantic model from semantic information included within `annotation` in the Modelica file
- **cxf**: generate CXF representation in `.jsonld` of a CDL sequence complying with ASHRAE S231P
- **cxf**: generate CXF representation in `.jsonld` of a CDL sequence complying with ASHRAE S231P
- **doc**: create the documentation of the sequence of operation in an HTML document
- **doc+**: create the documentation of the sequence of operation and the list of all variables in an HTML document

##### --mode / -m

Expand All @@ -122,12 +124,12 @@ If `-p` flag is specified, the JSON output conforms to prettyprint. The default

##### --elementary

If `--elementary` flag is specified, the CXF (jsonld) files for the elementary blocks are also generated. Else, they are ignored. The default option is `false`.
If `--elementary` flag is specified, the CXF (jsonld) files for the elementary blocks are also generated. Else, they are ignored. The default option is `false`.
`-o`/`--output` should be `cxf`.

##### --cxfCore

If `--cxfCore` flag is specified, generate the CXF-core.jsonld files for all the elementary blocks. The default option is `false`.
If `--cxfCore` flag is specified, generate the CXF-core.jsonld files for all the elementary blocks. The default option is `false`.
`-o`/`--output` should be `cxf`, `-f`/`--file` should be `path/to/CDL` and `--elementary` flag must be used.

## 4. JSON Schemas
Expand All @@ -148,7 +150,7 @@ Graphical viewers are available (please use right click + open in a new tab or r

[CXF-Core.jsonld](CXF-Core.jsonld) contains the CXF representation of all CDL elementary blocks, classes and relationships.

To generate the `CXF-Core.jsonld`, use:
To generate the `CXF-Core.jsonld`, use:

```
node app.js -f <path/to/modelica-buildings>/Buildings/Controls/OBC/CDL -o cxf --elementary --cxfCore
Expand Down
12 changes: 10 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const pa = require('./lib/parser.js')
const ut = require('./lib/util.js')
const se = require('./lib/semanticExtractor.js')
const ce = require('./lib/cxfExtractor.js')
const dc = require('./lib/cdlDoc.js')

const logger = require('winston')
const path = require('path')
Expand All @@ -19,7 +20,7 @@ parser.addArgument(
['-o', '--output'],
{
help: 'Specify output format.',
choices: ['raw-json', 'json', 'modelica', 'semantic', 'cxf'],
choices: ['raw-json', 'json', 'modelica', 'semantic', 'cxf', 'doc', 'doc+'],
defaultValue: 'json'
}
)
Expand Down Expand Up @@ -119,11 +120,12 @@ if (args.output === 'modelica') {
throw new Error('In order to generate CXF-core.jsonld containing all elementary blocks, --elementary flag must be used.')
}
}
let jsons // Array of json representations of all mo files recursively instantiated by the top-level class
const completedJsonGeneration = new Promise(
function (resolve, reject) {
const moFiles = ut.getMoFiles(args.file)
// Parse the json representation for moFiles
pa.getJsons(moFiles, args.mode, args.output, args.directory, args.prettyPrint, args.elementary, args.cxfCore)
jsons = pa.getJsons(moFiles, args.mode, args.output, args.directory, args.prettyPrint, args.elementary, args.cxfCore)
resolve(0)
}
)
Expand All @@ -134,6 +136,12 @@ if (args.output === 'modelica') {
if (args.output === 'cxf' && args.cxfCore && args.elementary) {
ce.getCxfCore(args.file, args.directory, args.prettyPrint)
}
if (args.output === 'doc' || args.output === 'doc+') {
const unitData = JSON.parse(
fs.readFileSync(path.join(__dirname, 'units-si.json'), 'utf8'))
const includeVariables = (args.output === 'doc+')
dc.buildDoc(jsons[0], jsons, unitData, args.directory, includeVariables)
}
})
}

Expand Down
Loading