lbl-srg / modelica-json

Modelica to JSON Parser
Other
22 stars 17 forks source link

BOPTEST: bestest_air, white space and sematic model missing annotations #251

Open EttoreZ opened 1 month ago

EttoreZ commented 1 month ago

This issue reports problems found when trying to postprocess BOPTEST bestest_air model using modelica-json to extrapolate semantic model from Modelica annotations. Two issues were found:

  1. When white space is removed from extrapolated model metadataLanguage line, modelica-json throws an error
  2. The extrapolated semantic model is incomplete, since not all annotations are extracted

To reproduce both errors go BOPTEST folder in terminal project1-boptest/testcases/bestest_air/models and run node $MODELICAJSONPATH/app.js -f BESTESTAir/TestCases/TestCase_Ideal.mo -o semantic -m modelica -d m2j_output. BOPTEST reference branch issue591

For error 1. Before running command remove white space in ‘BESTESTAir.TestCases.TestCase_Ideal.mo’ metadataLanguage declaration (see screenshot)

image

This is the resulting error:

image

For error 2. When .ttl file is generate two annotations are missing, one for the zone temperature BESTESTAir.BaseClasses.Case600FF.reaTRooAir and one for the zone CO2 BESTESTAir.BaseClasses.Case600FF.reaCO2RooAir. Reason unclear, only difference from other annotations is the level of nesting (Annotation is 2 levels deep instead of 1 level deep compared to starting model).

anandkp92 commented 1 day ago

@EttoreZ This is a bit weird, but I tried replicating this on my machine and with/without whitespaces I did not get any error and I was able to generate the semantic model. Can you give some more details about your environment?

anandkp92 commented 1 day ago

Adding similar issues faced by Lazlo:

Having a similar error with multizone_simple_office_air on fork: https://github.com/anandkp92/project1-boptest/tree/issue591_semantics/testcases/multizone_office_simple_air

The error is:

error:   *** Error when parsing /home/lazlo/volttron-simulated-digital-twin/simulated-digital-twin/project1-boptest/testcases/multizone_office_simple_air/models/MultiZoneOfficeSimpleAir/BaseClasses/Floor.mo: "line 1:0 token recognition error at: ''
".
/home/lazlo/Desktop/modelica-json/lib/modelicaToJSON.js:35
    throw new Error(msg)
          ^

Error: *** Error when parsing /home/lazlo/volttron-simulated-digital-twin/simulated-digital-twin/project1-boptest/testcases/multizone_office_simple_air/models/MultiZoneOfficeSimpleAir/BaseClasses/Floor.mo: "line 1:0 token recognition error at: ''
".
    at Object.toJSON (/home/lazlo/Desktop/modelica-json/lib/modelicaToJSON.js:35:11)
    at getRawJson (/home/lazlo/Desktop/modelica-json/lib/parser.js:63:22)
    at getSimpleJson (/home/lazlo/Desktop/modelica-json/lib/parser.js:96:19)
    at /home/lazlo/Desktop/modelica-json/lib/parser.js:114:25
    at Array.forEach (<anonymous>)
    at getSimpleJson (/home/lazlo/Desktop/modelica-json/lib/parser.js:112:22)
    at Object.getJsons (/home/lazlo/Desktop/modelica-json/lib/parser.js:47:24)
    at /home/lazlo/Desktop/modelica-json/app.js:101:10
    at new Promise (<anonymous>)
    at Object.<anonymous> (/home/lazlo/Desktop/modelica-json/app.js:97:35)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.11.1

After changing to the directory testcases/multizone_simple_office_air/models run the following command

node $MODELICAJSONPATH/app.js -f MultiZoneOfficeSimpleAir/TestCases/TestCase.mo -o semantic -m modelica -d m2j_output