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
  • Index
  • » Users
  • » De Filippo
  • » Profile

Posts

Posts

Yes, I think it works this way, but I need information about interactive mode.
In this case, according to guide, numberOfIntervals should be the numbers of step in a second.
My problem is I'd like to know how many time per second the sistem is solved, how often the extern function is called, and how often results are sent.
Are they all syncronous? (I mean for every step the extern function is called and results are given)

Thanks anyway,
Francesco

Thanks for reply.
Is Tstop the stop time of simulation? I don't have it in interactive mode.
I'm sorry but maybe I haven't understood..

Hi all,
I need to know what exactly sets the numberOfIntervals parameter in buildModel() function, if I use the model in interactive mode.
I'm using also this kind of way (suggested by you) to evaluate a derivate

Code:


(delay(var, step) - var)) / step

so I need to know which is the relationship between that parameter and the simulation step.
I made some tries but I cant understand.
I'm also using a socket in an external C function to read some inputs. I get results with a strange time value.
I hope I well explainded, and you can help me.
Thanks in advance,
Francesco

Hi,
No problem for your English..(mine is not so good too :-) )..where are you from?
I'm trying to do something similar using a socket in an external c function.
But I still have some problem now.
If your can write your code for USB port in C language you could try to read from bus directly in the external function..
I don't know if I've well explained.
Receiving results is not a problem; you just need a server listening to OMI Transfer Client in order to get the string of results.

Hi, sorry for delay.
My problem was to link an external C function but..
I used this string of command

setfilter#flag#var1l:var2:var3#par1:par2#end


If you don't need parameters you can write

setfilter#flag#var1l:var2:var3##end.

This works fine. You should receive a string for results like this:

result#ID#Tn#var1=Val:var2=Val#par1=Val:par2=Val#end

or like this one, if you have no parameter to read:

result#ID#Tn#var1=Val:var2=Val##end

I don't know if this should be useful for you..
Regards,
Francesco

Oct-21-10 10:24:58
Topic: C++ call

I was wrong again..the MSG_PEEK works because it doesn't clean the buffer and so the receive function always read the first input I send..I didn't notice it before..
I think the external function is called 10-11 times before sending the first results string..but I can't receive it..Maybe there's a problem  in my application..

Oct-20-10 18:49:55
Topic: C++ call

I'm sorry but I wrote a bad sentence..the fastest for me is 100, the middle value...
and I'm in interactive mode so I can't know how long it takes the simulation..

Oct-20-10 18:44:59
Topic: C++ call

I'm just trying to change the numberOfintervals parameter of build() command but I don't understand how it works..
First of all: is this parameter the number of simulation step (and result sendings) in a second (during interactive simulation)?
I tried using 10, 100 and 1000 but the fastest is 100 (WHY? current/sad )

Oct-20-10 18:27:53
Topic: C++ call

I solved!
I choosed a bad flag for recv() function..with MSG_PEEK instead of  0 it works..
But it's not fast enough..

Oct-20-10 18:12:04
Topic: C++ call

Yes, I've done this..or I think I've done current/smile ..this is the new code

Code:


void importExt(int val, double* a,double* b,double* c)
{

static WORD wVersionRequested = MAKEWORD(2,2);
    static WSADATA wsaData;
    WSAStartup(wVersionRequested, &wsaData);

        static SOCKET sock;

        static SOCKADDR_IN addr;

static int is_initialized = 0;
    if (!is_initialized)
    {         

    sock=socket(AF_INET, SOCK_STREAM, 0);   
    crea_addr(&addr,10503,"127.0.0.1");

   
        if(connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))==0);
            is_initialized = 1;
    }


    if(is_initialized)
   
    {
   
        char buf[40]={0};
    send(sock,"\0",sizeof("\0"),0);
    int n;
   
        n=recv(sock, buf, sizeof(buf), 0);
        buf[n]=0;
       
        cout<< buf<<" \n";       
        *a=0;
        *b=0;
        *c=0;

return ;
    }

I can see some exchanges of data (both in OM and in my application) and then all stops waiting for something..but I don't have any result from simulator yet..

Oct-20-10 18:01:46
Topic: C++ call

Hi,
I can't communicate in this way..
Is it possible the socket is automatically closed when the external function returns?
Is there a debug mode for OM ?
thanks for help!

Oct-20-10 12:52:20
Topic: C++ call

Yes I connect everytime because I thougth I couldn't stay connected because the external function is called at every step of the simulation..Maybe I haven't well understood how it works exactly..
Another question..do you think I can declare parameters instead of variables in order to modify them using classical OMI commands? Is this way fast enough in receiving input?
I need to change these values almost every time step.

Oct-20-10 12:30:19
Topic: C++ call

Hi!
It seems to be not fast enough.
The cpp-function receives data in a fast way but the return to OM seems slow..
This is the code, it's just for test speed.

Code:



void crea_addr(struct sockaddr_in* addr,int port, char* server)
{
addr->sin_family = AF_INET;
addr->sin_addr.s_addr = inet_addr(server);
addr->sin_port = htons(port);

}

void importExt(int val, double* a,double* b,double* c)
{

               WORD wVersionRequested = MAKEWORD(2,2);
               WSADATA wsaData;
               WSAStartup(wVersionRequested, &wsaData);

            SOCKET sock;

        SOCKADDR_IN addr;

                char buf[100];

    sock=socket(AF_INET, SOCK_STREAM, 0);   
    crea_addr(&addr,10503,"127.0.0.1");

    if(connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr))==0)
        {
   
        int n=recv(sock, buf, sizeof(buf), 0);
        closesocket(sock);
        buf[n]=0;
       
        cout<< buf<<" \n";
        *a=0;
        *b=0;
        *c=0;
                 closesocket(sock);
                 return ;
    }
    else
    {
    *a=0;
    *b=0;
    *c=0;
    }

return;
}

As I said the cout is called fast, but results from OMI tu my application are slower..Obviously no problems if I close the socket in my application..
Any suggest?
Thanks,
Francesco

Oct-18-10 23:09:59
Topic: C++ call

I think I'll use socket to interface the c-function..I've already written a code to receive data during interactive simulation..so I think I could add this new part to the old one..thanks for suggests!

Oct-18-10 14:53:49
Topic: C++ call

Thank you very much!
I wasn't sure about it.
Regards,
Francesco

Oct-18-10 13:58:00
Topic: C++ call

Hi,
Is it possible calling some C++ function from  OpenModelica C-external function ?
Thanks,
Francesco

sjoelund.se wrote:

Yes, but the problem is supposed to be there, as Modelica doesn't support function calls on the form you are describing
(a,b,c) = fn() is ok
(a,-b,c) = fn() is not

In this case it's not a big problem for me now..
Thanks again!
Francesco

I'm sorry but I wrote a wrong number!
I'm already using the 6338 version.. I've got the problem with this version..
If it's a bug, has the 6133 version the same problem?
Excuse me again!

Thank you very much..
I'm happy in helping you (a little bit) abut your development work..In the meanwhile, which is the newest version I can use?
Regards,
Francesco

Hi,
I've got this error in building a model:

Tuple assignment only allowed when rhs is a function call

referring to this line of code

Code:

equation 


  (del, -vx) = ExternalFunc1(val);
 
 

ExternalFunc1() calls an external C function

This model works properly on my laptop  with an old version of OM (1.5.0  5840 if I remember well)..

I passed it to another computer in which I installed the newest OM version (6380).

Is it due to the newer version or maybe I miss some files in the other computer?

Thanks in advance,

Francecso

Thank you very much for reply.
I'm working in interactive mode..In this case numberOfIntervals, according to the Guide, sets the number of outputs ( and results given ? ) per second..Is that correct?

Thanks,
Francesco

HI!,
Does someone know where I can find a more detailed description for the following parameters of the simulate() command?
        numberOfIntervals
        outputInterval
        method
        tolerance
        fixedStepSize.
I notice a difference only if I change the first one.
Thanks in advance,
Francesco

thank you very much for answering...
I used your (x-delay(x, step))/step instead of der(x) and it seems working..I hope it works too with a more complex model.
Thank you again,
Francesco

Hi,
I just need an information about der() operator. I receive two signals as outputs of a C external function.
Then I've to put them in a system of equation.
If I write

Code:

Real vx(start=12);      

Real del(start=0);   
 
Real psi;   
Real phi;   

equation

(del,vx)=ExternalFunc1(val);
  phi=del*vx/10000000;
  vx=psi/cpitch;

it works properly.

But if I insert a der operator on the acquired variable.


Code:

Real vx;      

Real del;   
 
Real psi;   
Real phi;   

equation

(del,vx)=ExternalFunc1(val);
  phi=del*vx/10000000;
  der(vx)=psi/cpitch;

it gives me the following error:


resultFile = "Simulation failed.
Error: Model is structurally singular, error found sorting equations Algorithm no: 0 for inputs: () => outputs: (vx, del);
Algorithm no: 0 for inputs: () => outputs: (vx, del);
for variables del(3)

I tried also adding an initial equation but the result is the same. I think I'm making some mistake but I can't find it.
Can you help me please?

Regards,
Francesco

Hi I created an GUI interface using QT4 libraries both for widget and for metworking..Now I can communicate with OMI quite properly..
So I begin writing a simple model that acquires two variables from an external device ()   (using an external C function).
I've written an initial simple system of equation but the model doesn't work if I use a derivate of a variable. htis is the model code:


Code:

model car0


 
  parameter Integer val=1;
  parameter Real cpitch=0.2;
   
Real vx(start=12);     
Real del(start=0);   
 
Real psi;   
Real phi;   

equation

(del,vx)=ExternalFunc1(val);
  phi=del*vx/10000000;
  der(vx)=psi/cpitch;
 
initial equation
der(vx)=0;
   
end car0;

The ExternelFunction1 just passes the acquired values to the two uotput variables del and vx.
Please, help me understanding  what doesn't work or let me know what I've to study for better understand what should I do using der() operator during real time simulation in OpenModelica.
Regards,
Francesco

Thank very much for suggest..but as I said I've finally understood that this afternoon..I'll have a look at those files..they will be surely useful.
Thank you very much.

Francesco

P.S.:My name is Francesco and my surname is De Filippo but it's the same thing...current/wink

Hi..
Ok..I've solved also the reply problem..I created a client to send and two server to receive in the GUI...It works now..
Thank you very much anyway..Enjoy your holidays current/cool and don't look at Forum current/wink

Hi,
Nobody can help me?
I didn't think my English was so bad  :-)

Hi, I'm back.
I've solved the connection problem.
I created a GUI that can send the strings to the "server"..It receive and execute properly.
I've tried to get its reply but I cannot do it..I'm waiting for reply on 127.0.0.1:10500 (I tried also 10502 and 10501) but the GUI stop working or I receive only strange strings..Should I attend a particular procedure?
In addition, how can I acquire the resut? Is it possible to have a variable value continuously?How?

Thanks
Regards

Francesco

Hi,
I'm back to the initial problem...
I've written a simple model who calls an external c++ function wich acquire the position of the mouse (really I need to take some information from another device but I think this is not a problem ).
It works properly because if I simulate the model in OMShell I can plot the mouse position variation. Now I'd like doing that "real-time" and I'd like to decide when simulation starts and ends..In order to do that I've studied the suggested guides..But I haven't understood if I have to create a GUI and a client-server connection or if I've just to use OMShell for interfacing between "Server" and "client"..
Sorrry again..

Francesco

Ok..I've just installed it and....IT WORKS!!, great! (I have also VS2010 Installed)
Thank you very much! I'm sorry I've bothered your holidays..

Regards,

Francesco

Hi,
I  have already tried copying all files from a directory to the other and it doesn´´t work....I cannot try now the other solution..
Anyway, I wait for your news then..
Thank you very much for your work.

Best regards,

Francesco

I've tried to copy QtGui4 and QtCore4 in the build folder..I've tried different version found in OpenModelica and OpenModelicaLibraries directories; I just can notice a dfferent entry point nt found...
In addition these are Vusual Studio warning messages:

Warning    2    warning MSB8012: TargetName(OMNotebookQT4) does not match the Linker's OutputFile property value (OMNotebook). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets    992    6    OMNotebookQT4

Warning    1    warning MSB8012: TargetPath(C:\dev\OpenModelica\Compiler\VC7\omc\Release\OMNotebookQT4.exe) does not match the Linker's OutputFile property value (C:\dev\OpenModelica\OMNotebook\OMNotebookQT4\Release\OMNotebook.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets    990    6    OMNotebookQT4


And finally..
After the OMNotebookQT4 compiling  some *.xml files should be copied in $(ProjectDir)\..\..\build\share\omnotebook ?
I have two questions about that:
1) Should these files be modified during the compiling? (I've found just the version of checkout date )
2)Is  /../omnotebook a folder? in that folder there is a file called omnotebook (I think it's an helptext file)..OMNotebookQT4 cannot be compiled if I leave omnotebook in the path..

Sorry for long post..but I don't know what I've to do; I need that version my master thesis in Mechanical Eng. and I'm spending a lot of time compiling it..

Regards
Francesco

Here again..VisualStudio gives no errors but lots of Warnings...OMShell, OMNotebook and OMPlotWindow in folder   /../OpenModelica/build/bin don't work..

OMShell gives this error

Entry Point Not Found
---------------------------
The procedure entry point ?windowsVersion@QSysInfo@@SA?AW4WinVersion@1@XZ could not be located in the dynamic link library QtCored4.dll.
---------------------------

OMNotebook and OMPlotWindow give:

The procedure entry point ?windowsVersion@QSysInfo@@SA?AW4WinVersion@1@XZ could not be located in the dynamic link library QtGui4.dll.

Can they depen on warnings or I should copy and paste these .dll from a directory to another  one (which ones?)..
Thank and sorry for (probably) stupid questions

Oh..I've solved it (or I hope so)..
I've changed the directories in project->Properties->Build Events->Post-Build..I've set my exact path indìstead of $(projectDi) or $(TargetDir)...Is it ok?

bye

Ok..errors disappear..thanks..but I've copied also the new antlr.lib in C:\OMDev\lib\antlr-win32-msvc\ and in C:\dev\OpenModelica\Compiler\VC7\antlr..
Now I've got this error and 5 Intellisense Error (should I don't consider them?) and this error:

error MSB3073: The command "copy C:\dev\OpenModelica\Compiler\VC7\omc\Release\\OMNotebook.exe C:\dev\OpenModelica\OMNotebook\OMNotebookQT4\\..\..\build\bin\
copy C:\dev\OpenModelica\OMNotebook\OMNotebookQT4\\*.xml C:\dev\OpenModelica\OMNotebook\OMNotebookQT4\\..\..\build\share\omnotebook\
:VCEnd" exited with code 1.    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets

What does it mean?

regards,

Francesco

Ok...you could tell me that a littke bit before...I've asked if I had to follow all the steps in each README...
Ok, don't worry, no problem..thank you very much anyway..;-)

So, I've compiled OMShell and UpdateEnv but I cant buid OMNotebookQT4 (that's right?)...It gives me lots of "unresolved external symbol"  related to antlrd library..
Perhaps I didn't have to compile it in Visual Studio cmd...
Can you help me?

regards,
Francesco

Oh yes..these files are present..what should I do? Sould I rename them? and which one of simulation_result_{csv,plt,bin}?

Do you think I've got bad versions of OpenModelica or of   I don't know what?

Hi,
I'm waiting for your replies but in the meanwhile I'm trying do something.
I've recompiled the antlr library and I've put the new file in C:\OMDev\lib\antlr-win32-msvc\  as written in a Dr. Pope old post..but I've also had to put the new antlr.lib in C:\OMDev\lib\antlr-win32-msvc\md-mdd to fix previous errors.
Now I've got some new errors:


lots of    msvcprt.lib               already defined in                 antlr.lib

lots of    libcpmt.lib               already defined in                 msvcprt.lib

lots of    LIBCMT.lib              already defined in                 MSVCRT.lib

just a     MSVCRT.lib            already defined in                 LIBCMT.lib



I've tried to ignore some of this libraries but it gives other errors of  "unresolved external symbol" for       *.obj file..

I don't know If I've well explained and I hope in your help.

Francesco

P.S.: Suggests about simulation_result.cpp and olver_euler.cpp missing?

P.S.2:  If it is available a working build version with which I can chenge input and simulate run-time, that's the best solution for my troubles ;-)

OK...lots of file were in C:\dev\OpenModelica\c_runtime\interactive instead of C:\dev\OpenModelica\c_runtime\ or viceversa....I copied them from a directory to the other
(Could I add both paths in "Additional Include directories"of c_runtime project? It should be better...)
Anyway I have other missing files

'..\..\c_runtime\simulation_result.cpp': No such file or directory    C:\dev\OpenModelica\Compiler\VC7\c1xx    c_runtime
'..\..\c_runtime\solver_euler.cpp': No such file or directory                    C:\dev\OpenModelica\Compiler\VC7\c1xx    c_runtime

and some LINK errors (unresolved external)  for antlr.lib,.. I read how to fix them for older version of OpenModelica and VisualStudio but I don'y know if I can apply those methods..

Regards and thank you very nuch for kind collaboration!

Francesco

Ok, thanks..
And what about the errors in Visual Studio? Have I to fix them or there's something goes wrong?
Bye
Francesco

Oh, sorry..Maybe it can't find sh.exe and in can't create modelica_java; Is it right?
Well, the file sh.exe is in the correct directory.

regards,

francesco

Hi,
I decided to repeat the whole installation. I've noticed that Eclipse does't give errors in the Problem tab but in th Console tab I can read an error:

...
* Compiling modelica_java.jar
/bin/sh.exe: javac: command not found
make[2]: *** [modelica_java.jar] Error 127
make[2]: Leaving directory `/c/dev/OpenModelica/c_runtime/java_interface'
...

modelica_java.jar misses.. Is it a problem to fix or may I skip it?

Please, I need you help!

Regards,
Francesco

Hi,

the previous file is in OpenModelica/Compiler/runtime/..I've set the path and this problem doesn't appear..Now It can't find omc_communication.cc. It is in the same directory of omc_communication.h so I don't know what I've to do..

Regards,

Francesco.

Hi,
I've compiled the project in Eclipse as writtem in the README-OMDev-MINGW.txt file; it seems working properly (every tests succeded). I had to change "${project_loc}" with the exact path of the project in OMDev-MINGW-OpenModelicaBuilder.launch file..

Now I'm trying building project in Visual Studio..It gives a lot of errors but lots of them are linked to 'omc_communication.h'.

This is the error:
Error    125    error C1083: Cannot open include file: 'omc_communication.h': No such file or directory.

I can try to set the correct path to this file but before I would ask  If the error can depend on a previous mistake.

Bye

Francesco

Hi..
I'm here with others questions.
If I want to build OMC using Visual Studio 2010, do I have to do ALL the steps in the README-OMDev-MINGW.txt and in the INSTALL.txt anyway?
I'm sorry but I can't understand If I should leave out some step.

Regards
Francesco

Hi,
Ok thanks...
I've found it in the INSTALL.txt note of OMDev, from this link http://www.ida.liu.se/~adrpo/omc/omdev/mingw/ ...
You said follow only the "Read me file"..but I've had a look at that one too..sorry .. :-/

bye
Francesco

Hi,
Do I need this subversion?

Subversion and Eclipse:
=======================
Checkout OpenModelica sources from:
svn co svn://mir20.ida.liu.se/modelica/OpenModelica/trunk/ OpenModelica

This link seems not working..

bye!

Hi,
I've tried accessing this forum for all the afternoon, but it seems not working..Anyway...I need also this subversion in order to build the code:

https://openmodelica.org/svn/OpenModeli … allers/VC7

Do I have to wait for webserver OS reinstalling or can I have it in a different way?

Regards

Francesco

Ok...but when I try to checkout the sourse as written in the articol I get this error

Command       Checkout from https://openmodelica.org/svn/OpenModelica/trunk, revision HEAD, Fully recursive, Externals included
Error                  OPTIONS of 'https://openmodelica.org/svn/OpenModelica/trunk': 200 OK (https://openmodelica.org)
Finished!

operation failed.


So I thougth I need to set up a putty session before, as written in the guide..
Am I wrong?

HI,
Sould I follow the OpenModelica-TortoiseSVN+Putty-HOWTO.pdf?..And what are my ida account and my password? where can I get them?
regards

Sorry...I mean "I've already installed that version of Visual C++"....:-)

Hi,
I've installed that one yet and it doesn't work..I'll try building from source.
Thanks
Francesco

Ok..let's try..I've never build from sources...Do I have to follow this?   http://www.openmodelica.org/index.php/d … ource-code

Hi,
this version doesn't work on my computers (I've tried both on Windows 7 and XP )..
It misses MSVCP100.dll..I've downloaded the 2010 version of Visual C++..Now OpenMShell crashes because of MSVCR100.dll (note the "R")...
Do you know how can I fix this problem? Should I build it from source ?
thanks,
Francesco

Hi,
I'm sorry for the stupid question but:

where and how I've to do start the model with parametre -interactive (pages 72-73 of OpenModelicaUserGuide.pdf).

I've tried in a cmd window (nomefile.exe -interactive). It immediatly generates a    _res.plt file.

I'm sorry but I'm not so skilled in this field and the documentation is so poor yet (or it is too much poor for me :-)

Thank you very  much..Really I haven't found that chapter in my documentation (also if I downloaded Openmodelica yesterday again)..However Interactive Simulation Facilities is the 6th chapter of OpenmodelicaSystem.pdf...No problem ;-)..

dataToReceive = readWriteData(dataToSend) ...great...I'm so stupid..I haven't thougth about it

Bye

Hi,

now I'm able to call a C++ function that acquires run-time some data from an external device but I haven't found anything about syncronization of input/output calls.

I haven't got the Fritzson's book and I can't find thie reference "OpenModelica System Documentation - Interactive Simulation Facilities", may you post me the link?

In addition I don't know how to send back some results from Modelica to an actuator (or to a C file).

Thanks.

Ok, thank you very much for fast answering.
I'm going to study and I hope understand all (I'm a mechanical engineer :-)
Bye

Hi,
I'm Francesco. I've never used OpenModelica until 2 weeks ago.
I want to know if I can acquire some data from some external real sensor, solve some equation and give back some input for actuators.
Is it possible with Openmodelica. I can use only free libraries and softwares . Where can I find a tutorial or some examples (also simple) explaining how to do that?
In addition: I'm coding with SimForce now. Do you think I have to use another program?

Thank you very much and sorry for my English

  • Index
  • » Users
  • » De Filippo
  • » Profile
You are here: