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

Completing unit tests for Json2Mo translation #227

Open
wants to merge 18 commits into
base: issue175_json2mo
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ modelica-json.log
/outputs
/objects
.DS_Store
.nyc_output
3 changes: 2 additions & 1 deletion InstallOnWindows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
:: versions of JRE, add the higher version JRE path to the top of your "Path" environment

:: Download and install Node.js: https://nodejs.org/en/download/
:: Add nodejs folder to your "Path" environment

:: set MODELICAPATH

Expand All @@ -19,7 +20,7 @@
::*******************************************************************
:: Download maven
echo ----------- Downloading Apache Maven -----------
set MVNLink=https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip
set MVNLink=https://archive.apache.org/dist/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip
set MVNZip=%CD%\apache_maven.zip
bitsadmin /transfer "Downloading MVN" %MVNLink% %MVNZip%

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ make clean-installation

- Install [Java SE Development Kit (64-bit version)](https://www.oracle.com/java/technologies/javase-downloads.html), [Java Runtime Environment (64-bit version)](https://java.com/en/download/manual.jsp) and [Node.js](https://nodejs.org/en/download/).

- Add `path\to\your\nodejs` to the `Path` environment.

- In batch file `InstallOnWindows.bat`, update `JAVA_HOME` path in line `set JAVA_HOME=path\to\your\jdk`.

- Finally, to install dependencies and compile the Java files, run `InstallOnWindows.bat`.
Expand Down Expand Up @@ -91,12 +93,18 @@ The only required input is the path of the file or package to be parsed.

This parser can take a .mo file in input and produce three possible outputs, that can be specified with the argument -o :

<<<<<<< HEAD
- **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
=======
- **raw-json** : intermediate JSON output, aligning closely with the Modelica syntax
- **json**: simplified JSON format, to be used by all applications
- **semantic**: generate a semantic model from the Modelica model, if annotations containing semantic information are present in the Modelica model

This parser can also take a .json file as an input and if it aligns with the simplified JSON output format, a corresponding Modelica or CDL model can be generated using the followed argument in the output format (-o):
- **modelica**: Generate a Modelica/CDL file (.mo) from a JSON file that conforms to the simplified JSON schema.
>>>>>>> ae0dee5722f82ce552a298c4e11fb05b1d90f5d9

##### --mode / -m

Expand All @@ -113,6 +121,11 @@ Logging level. The choices are `error`, `warn`, `info` (default), `verbose`, `de

Specify the output directory. The default option is the current directory.

##### --prettyPrint / -p

Boolean flag to specify if prettyprint the JSON output. The default option is `false`.


## 4. JSON Schemas

The JSON representation of Modelica and CDL models must be compliant with the corresponding JSON Schema. This is applicable for the JSON output, not for the raw-json one.
Expand Down
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ if (args.output === 'json') {
} else {
schema = path.join(`${__dirname}`, 'schema-modelica.json')
}
<<<<<<< HEAD
const jsonDir = (args.directory === 'current') ? process.cwd() : args.directory
let jsonFiles = ut.findFilesInDir(path.join(jsonDir, 'json'), '.json')
=======
console.log('parsing mode: ', schema)
// let jsonFiles = ut.findFilesInDir(path.join(args.directory, 'json'), '.json')
>>>>>>> ae0dee5722f82ce552a298c4e11fb05b1d90f5d9
// exclude CDL folder and possibly Modelica folder
// const pathSep = path.sep
// const cdlPath = path.join(pathSep, 'CDL', pathSep)
Expand Down
3 changes: 2 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const Ajv = require('ajv')
* element. Elements are separated by ':'
*/
function getMODELICAPATH () {
const spe = process.platform.includes('win') ? ';' : ':'
return (process.env.MODELICAPATH)
? (process.cwd() + ':' + process.env.MODELICAPATH).split(':')
? (process.cwd() + spe + process.env.MODELICAPATH).split(spe)
: [process.cwd()]
}

Expand Down
Loading