lbl-srg / modelica-json

Modelica to JSON Parser
Other
21 stars 17 forks source link

Failing to find some Modelica files from MSL with util.searchPath #246

Open AntoineGautier opened 1 week ago

AntoineGautier commented 1 week ago

The function searchPath from util.js fails to find the path to the Modelica files of various types from the MSL.

console.log(process.env.MODELICAPATH) // returns /home/reituag/gitrepo/modelica-buildings:/opt/dymola-2024xRefresh1-x86_64/Modelica/Library/

fs.lstatSync('/opt/dymola-2024xRefresh1-x86_64/Modelica/Library/Modelica 4.0.0/package.mo').isFile() // returns true

utilM2j.searchPath( // returns []
    ['Modelica.Units.SI.Time'], 
    'Buildings.Templates.Plants.Controls.HeatPumps', 
    '/home/reituag/gitrepo/modelica-buildings/Buildings/Templates/Plants/Controls/HeatPumps/AirToWater.mo')

utilM2j.searchPath( // returns []
    ['Modelica.StateGraph.InitialStepWithSignal', 'Modelica.StateGraph.StepWithSignal'], 
    'Buildings.Templates.Plants.Controls.Utilities', 
    '/home/reituag/gitrepo/modelica-buildings/Buildings/Templates/Plants/Controls/Utilities/StageIndex.mo')

These types have in common that they are part of packages using the Single File Mapping rules.

AntoineGautier commented 1 week ago

I can confirm this issue from the command line:

$ echo $MODELICAPATH
/home/reituag/gitrepo/modelica-buildings:/opt/dymola-2024xRefresh1-x86_64/Modelica/Library/
$ rm -rf json
$ node ../modelica-json/app.js -f Buildings/Fluid/Actuators/BaseClasses/PartialDamperExponential.mo
...
$ tree json
json
└── Buildings
    └── Fluid
        ├── Actuators
        │   └── BaseClasses
        │       ├── ActuatorSignal.json
        │       └── PartialDamperExponential.json
        ├── BaseClasses
        │   ├── ActuatorFilter.json
        │   └── PartialResistance.json
        └── Interfaces
            ├── PartialTwoPortInterface.json
            └── PartialTwoPort.json

6 directories, 6 files

The classes from MSL (such as Modelica.Units.SI.*) are not parsed. This is with the master branch of modelica-json, commit f0b714b

@JayHuLBL Can you reproduce it on your system?