Opened 8 years ago
Last modified 5 years ago
#4003 reopened defect
OMEdit uses wrong modelica:// path
Reported by: | Rüdiger Franke | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Interactive Environment | Version: | |
Keywords: | Cc: | Adrian Pop, Martin Sjölund |
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)
by , 8 years ago
Attachment: | script.mos added |
---|
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Cc: | 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 by , 8 years ago
Cc: | added |
---|---|
Component: | OMEdit → Interactive Environment |
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 8 years ago
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 by , 8 years ago
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 by , 8 years ago
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:8 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:9 by , 7 years ago
Milestone: | 1.12.0 → 1.13.0 |
---|
Milestone moved to 1.13.0 due to 1.12.0 already being released.
comment:11 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Yes, I can load System Libraries -> PowerSystems and simulate PowerSystems.Examples.PowerWorld.PowerWorld now. Thanks!
comment:12 by , 5 years ago
Milestone: | 1.13.0 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | v1.10.0-dev-nightly |
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?