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)

script.mos (118 bytes ) - added by Adeel Asghar 8 years ago.

Download all attachments as: .zip

Change History (13)

by Adeel Asghar, 8 years ago

Attachment: script.mos added

comment:1 by Adeel Asghar, 8 years ago

The attached script gives me the same error.
How are you running it with omc? Do you set some extra flags or path?

comment:2 by Rüdiger Franke, 8 years ago

Cc: Adrian Pop 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 Adeel Asghar, 8 years ago

Cc: Martin Sjölund added
Component: OMEditInteractive Environment
Owner: changed from Adeel Asghar to Adrian Pop
Status: newassigned

comment:4 by Adeel Asghar, 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 Adrian Pop, 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 Adeel Asghar, 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:7 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:8 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:9 by Francesco Casella, 7 years ago

Milestone: 1.12.01.13.0

Milestone moved to 1.13.0 due to 1.12.0 already being released.

comment:10 by Martin Sjölund, 7 years ago

We are no longer using regex; is this working on Windows now?

comment:11 by Rüdiger Franke, 7 years ago

Resolution: fixed
Status: assignedclosed

Yes, I can load System Libraries -> PowerSystems and simulate PowerSystems.Examples.PowerWorld.PowerWorld now. Thanks!

comment:12 by anonymous, 5 years ago

Milestone: 1.13.0
Resolution: fixed
Status: closedreopened
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.

Note: See TracTickets for help on using tickets.