Opened 8 years ago
Last modified 5 years ago
#4003 reopened defect
OMEdit uses wrong modelica:// path
Reported by: | rfranke | Owned by: | adrpo |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Interactive Environment | Version: | |
Keywords: | Cc: | adrpo, sjoelund.se |
Description
The model PowerSystems.Examples.PowerWorld.PowerWorld uses table data from a file. The respective code is:
constant String PowerWorldResources = Modelica.Utilities.Files.loadResource("modelica://PowerSystems.Examples.PowerWorld/Resources/"); Modelica.Blocks.Sources.CombiTimeTable wind( tableName="tab", fileName=PowerWorldResources + "LoadData.txt", tableOnFile=true);
The model works when omc is called from the command line. It also works in the nightly tests. OMEdit raises the error:
Not possible to open file "LoadData.txt": No such file or directory
Attachments (1)
Change History (13)
Changed 8 years ago by adeas31
comment:1 Changed 8 years ago by adeas31
comment:2 Changed 8 years ago by rfranke
- Cc adrpo added
No extra flags or path. It might be a problem of the Windows version though -- I just managed to run the PowerSystems.Examples.PowerWorld.PowerWorld example from OMEdit with the current development version under Linux.
comment:3 Changed 8 years ago by adeas31
- Cc sjoelund.se added
- Component changed from OMEdit to Interactive Environment
- Owner changed from adeas31 to adrpo
- Status changed from new to assigned
comment:4 Changed 8 years ago by adeas31
I tracked down the issue a bit more. The problem is with the regex API used in uriToFilename API.
The regular expression used is ^([A-Za-z_][A-Za-z0-9_]*)?[.]?(.*)?$ and is behaving different on Windows and Linux. So the following call,
regex("Modelica.Blocks", "^([A-Za-z_][A-Za-z0-9_]*)?[.]?(.*)?$", 3);
outputs On Windows,
(2,{"Modelica.Blocks","Modelica.Blocks",""})
outputs On Linux,
(3,{"Modelica.Blocks","Modelica","Blocks"})
comment:5 Changed 8 years ago by adrpo
As far as I can see uriToFilename is not used anywhere.
I think the problem is with the external implementation of: System.uriToClassAndPath, namely decodeUri and decodeUri2 in systemimpl.c.
comment:6 Changed 8 years ago by adeas31
uriToFilename is used.
The code is using Modelica.Utilities.Files.loadResource which extends from ModelicaServices.ExternalReferences.loadResource and function contains,
function loadResource "Return the absolute path name of a URI or local file name (in this default implementation URIs are not supported, but only local file names)" extends Modelica.Utilities.Internal.PartialModelicaServices.ExternalReferences.PartialLoadResource; algorithm fileReference:=OpenModelica.Scripting.uriToFilename(uri); annotation (Documentation(info="<html> <p> The interface of this model is documented at <a href=\"modelica://Modelica.Utilities.Files.loadResource\">Modelica.Utilities.Files.loadResource</a>. </p> </html>")); end loadResource;
comment:7 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.10.0 to 1.11.0
Ticket retargeted after milestone closed
comment:8 Changed 8 years ago by sjoelund.se
- Milestone changed from 1.11.0 to 1.12.0
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:9 Changed 7 years ago by casella
- Milestone changed from 1.12.0 to 1.13.0
Milestone moved to 1.13.0 due to 1.12.0 already being released.
comment:10 Changed 7 years ago by sjoelund.se
We are no longer using regex; is this working on Windows now?
comment:11 Changed 7 years ago by rfranke
- Resolution set to fixed
- Status changed from assigned to closed
Yes, I can load System Libraries -> PowerSystems and simulate PowerSystems.Examples.PowerWorld.PowerWorld now. Thanks!
comment:12 Changed 5 years ago by anonymous
- Milestone 1.13.0 deleted
- Resolution fixed deleted
- Status changed from closed to reopened
- Version v1.10.0-dev-nightly deleted
It's still or again not working.
On Linux the PowerWorld example is working fine. Same example outputs on windows:
... loading "tab" from "C:/Users/XXX/AppData/Local/Temp/OpenModelica/OMEdit/modelica:/PowerSystems.Examples.PowerWorld/Resources/LoadData.txt"<br> Not possible to open file "C:/Users/a/AppData/Local/Temp/OpenModelica/OMEdit/modelica:/PowerSystems.Examples.PowerWorld/Resources/LoadData.txt": No such file or directory<br>
Yeah well, not surprising it can't open the file as Windows disallows colons (:) in their paths.
The attached script gives me the same error.
How are you running it with omc? Do you set some extra flags or path?