lbl-srg / modelica-json

Modelica to JSON Parser
Other
22 stars 17 forks source link

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

Open AntoineGautier opened 2 months ago

AntoineGautier commented 2 months ago

Classes from MSL

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.

Classes instantiated using simple names

The class name lookup also fails for some classes from MBL which are instantiated with their simple name (not composed using dot notation).

utilM2j.searchPath( // returns [ "/Users/reituag/python/notebooks/js/Enable.mo" ] instead of [ "/home/reituag/gitrepo/modelica-buildings/Buildings/Templates/Plants/Controls/HeatRecoveryChillers/Enable.mo" ]
    ['Enable'], 
    'Buildings.Templates.Plants.Controls.HeatRecoveryChillers', 
    '/home/reituag/gitrepo/modelica-buildings/Buildings/Templates/Plants/Controls/HeatRecoveryChillers/Controller.mo')
AntoineGautier commented 2 months 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?

AntoineGautier commented 1 month ago

@anandkp92 Let me know if I can help on this one: it's a blocker for other developments.