Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

readRealParameter

readRealParameter

Hi,
I am try to read  variables  from file.

Here is file:
test.txt
a = 2;
b = 3;
c = 4;

Here is the Code:
parameter String file = Files.loadResource("c:/oki/test.txt");
  parameter Real a = Examples.readRealParameter(file, "a");
  parameter Real b = Examples.readRealParameter(file, "b");
  parameter Real c = Examples.readRealParameter(file, "c");

Simulation is extremely slow. PC read this three variables  almost 7-9 seconds.
Finally , variables read but some errors.

Do you have any idea what's wrong?

Oki

Here is Errors:
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_scanToken':
rd2_functions.c:149: warning: passing argument 7 of 'mmc_mk_box6' discards qualifiers from pointer target type
C:/OpenModelica1.9.1//include/omc/c/meta/meta_modelica_mk_box.h:57: note: expected 'void *' but argument is of type 'modelica_string'
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Streams_readLine':
rd2_functions.c:175: warning: return discards qualifiers from pointer target type
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_repeat':
rd2_functions.c:605: warning: return discards qualifiers from pointer target type
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_scanDelimiter':
rd2_functions.c:717: warning: return discards qualifiers from pointer target type
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_substring':
rd2_functions.c:829: warning: return discards qualifiers from pointer target type
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_Advanced_scanIdentifier':
rd2_functions.c:851: warning: passing argument 4 of 'omc_Modelica_Utilities_Strings_Advanced_scanIdentifier' from incompatible pointer type
rd2_functions.c:831: note: expected 'const char **' but argument is of type 'void **'
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_Advanced_scanString':
rd2_functions.c:982: warning: passing argument 4 of 'omc_Modelica_Utilities_Strings_Advanced_scanString' from incompatible pointer type
rd2_functions.c:962: note: expected 'const char **' but argument is of type 'void **'
rd2_functions.c: In function 'boxptr_Modelica_Utilities_Strings_scanDelimiter_concatenate':
rd2_functions.c:1043: warning: return discards qualifiers from pointer target type

Re: readRealParameter

Which version of MSL are you using (version and revision)? And OpenModelica revision? On Linux, the example finishes very quickly.
It could just be that loadResource doesn't work because it is not given a URI. Since it is already a path, you could simply try making it the path directly.

Re: readRealParameter

OMedit 1.9.1. r22929
What is MSL?

I am working on Win7.  loadSource section is very quick. But  .readRealParameter() is not.
URI mean file path on PC right: In this case "c:/oki/test.txt"

Re: readRealParameter

MSL = Modelica Standard Library. Versions before 3.1 are much slower than 3.2.1 w.r.t. file reading. If loadResource is the problem, it could be an OpenModelica issue. If readRealParameter is the issue, it might be a modelica.org issue.

Re: readRealParameter

My MSL is 3.2.1

There are 0 guests and 0 other users also viewing this topic