-
Notifications
You must be signed in to change notification settings - Fork 14
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
Update code generation section to add CXF #157
Open
anandkp92
wants to merge
1
commit into
master
Choose a base branch
from
issue156_generate_cxf
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,19 +104,25 @@ Translation of a Control Sequence using a JSON Intermediate Format | |
|
||
Control companies that choose to not use C-code generation or the FMI standard to | ||
execute CDL-compliant control sequences can develop translators from | ||
CDL to their native language. To aid in this process, a CDL to JSON translator | ||
can be used. Such a translator is currently being developed at | ||
https://github.com/lbl-srg/modelica-json. | ||
This translator parses CDL-compliant control sequences to a JSON format. | ||
The parser generates the following output formats: | ||
|
||
1. A JSON representation of the control sequence, | ||
2. a simplified version of this JSON representation, and | ||
3. an html-formated documentation of the control sequence. | ||
CDL to their native language. To aid in this process, an intermediate | ||
Control eXchange Format (CXF) can be used. CXF is a JSON-LD representation | ||
of a CDL sequence, serialized in JSON. `Modelica-json <https://github.com/lbl-srg/modelica-json>`_ | ||
is a reference implementation of such a CDL to CXF translator. | ||
This translator first parses CDL-compliant control sequences to a abstract | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Write "an abstract" |
||
syntax tree in JSON format and then generates a CXF representation from it. | ||
The ``modelica-json`` tool can also parse Modelica code and it | ||
can generate the following output formats: | ||
|
||
1. A JSON representation of the control sequence (CDL) or the Modelica | ||
file(``raw-json``), | ||
2. A simplified version of this JSON representation (``json``), | ||
3. A semantic model from the control sequnce or the Modelica file | ||
(``semantic``) and | ||
4. A CXF representation of the control sequence (``cxf``). | ||
|
||
To translate CDL-compliant control sequences to the language that is used | ||
by the target building automation system, the simplified JSON representation | ||
is most suited. | ||
by the target building automation system, the Control eXchange Format (CXF) | ||
representation is most suited. | ||
|
||
As an illustrative example, consider the composite control block shown in | ||
:numref:`fig_custom_control_block` and reproduced in | ||
|
@@ -142,17 +148,16 @@ Executing the command | |
|
||
.. code-block:: bash | ||
|
||
node modelica-json/app.js -f CustomPWithLimiter.mo -o json-simplified | ||
node modelica-json/app.js -f CustomPWithLimiter.mo -o cxf | ||
|
||
will produce a file called ``CustomPWithLimiter-simplified.json`` that | ||
will produce a file called ``CustomPWithLimiter.jsonld`` that | ||
looks as follows: | ||
|
||
.. literalinclude:: img/codeGeneration/CustomPWithLimiter/CustomPWithLimiter-simplified.json | ||
.. literalinclude:: img/codeGeneration/CustomPWithLimiter/CustomPWithLimiter.jsonld | ||
:language: json | ||
:linenos: | ||
|
||
Note that the graphical annotations are not shown. | ||
The JSON representation can then be parsed and converted to another block-diagram | ||
The representation can then be parsed and converted to another block-diagram | ||
language. | ||
Note that ``CDL.Reals.MultiplyByParameter`` is an elementary CDL block | ||
(see :numref:`sec_ele_blo`). | ||
|
96 changes: 0 additions & 96 deletions
96
...ification/source/img/codeGeneration/CustomPWithLimiter/CustomPWithLimiter-simplified.json
This file was deleted.
Oops, something went wrong.
130 changes: 130 additions & 0 deletions
130
specification/source/img/codeGeneration/CustomPWithLimiter/CustomPWithLimiter.jsonld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
{ | ||
"@context": { | ||
"S231P": "https://data.ashrae.org/S231P#" | ||
}, | ||
"@graph": [ | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter", | ||
"@type": "S231P:Block", | ||
"S231P:containsBlock": [ | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue" | ||
} | ||
], | ||
"S231P:hasInput": [ | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.e" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.yMax" | ||
} | ||
], | ||
"S231P:hasOutput": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.y" | ||
}, | ||
"S231P:hasParameter": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.k" | ||
}, | ||
"S231P:label": "CustomPWithLimiter" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.e", | ||
"@type": "S231P:RealInput", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Control error", | ||
"S231P:graphics": "{\"Placement\":{\"transformation\":{\"extent\":[{\"x\":-140,\"y\":-60},{\"x\":-100,\"y\":-20}]}}}", | ||
"S231P:isConnectedTo": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.u" | ||
}, | ||
"S231P:label": "e" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain", | ||
"@type": "https://data.ashrae.org/S231P#Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Constant gain", | ||
"S231P:graphics": "{\"Placement\":{\"transformation\":{\"extent\":[{\"x\":-60,\"y\":-50},{\"x\":-40,\"y\":-30}]}}}", | ||
"S231P:hasInstance": [ | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.k" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.u" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.y" | ||
} | ||
], | ||
"S231P:label": "gain" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.k", | ||
"S231P:isFinal": true, | ||
"S231P:value": "k" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.gain.y", | ||
"S231P:isConnectedTo": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.u2" | ||
} | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.k", | ||
"@type": "S231P:Parameter", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Constant gain", | ||
"S231P:isOfDataType": { | ||
"@id": "S231P:Real" | ||
}, | ||
"S231P:label": "k", | ||
"S231P:value": 2 | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue", | ||
"@type": "https://data.ashrae.org/S231P#Buildings.Controls.OBC.CDL.Reals.Min", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Outputs the minimum of its inputs", | ||
"S231P:graphics": "{\"Placement\":{\"transformation\":{\"extent\":[{\"x\":20,\"y\":-10},{\"x\":40,\"y\":10}]}}}", | ||
"S231P:hasInstance": [ | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.u1" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.u2" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.y" | ||
} | ||
], | ||
"S231P:label": "minValue" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.y", | ||
"S231P:isConnectedTo": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.y" | ||
} | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.y", | ||
"@type": "S231P:RealOutput", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Control signal", | ||
"S231P:graphics": "{\"Placement\":{\"transformation\":{\"extent\":[{\"x\":100,\"y\":-10},{\"x\":120,\"y\":10}]}}}", | ||
"S231P:label": "y" | ||
}, | ||
{ | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.yMax", | ||
"@type": "S231P:RealInput", | ||
"S231P:accessSpecifier": "public", | ||
"S231P:description": "Maximum value of output signal", | ||
"S231P:graphics": "{\"Placement\":{\"transformation\":{\"extent\":[{\"x\":-140,\"y\":20},{\"x\":-100,\"y\":60}]}}}", | ||
"S231P:isConnectedTo": { | ||
"@id": "http://example.org#FromModelica.CustomPWithLimiter.minValue.u1" | ||
}, | ||
"S231P:label": "yMax" | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translator is not a "reference implementation" as the translator is not part of the standard. Just write it is a translator.