- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Run-Time acquisition
Run-Time acquisition
Run-Time acquisition
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
Re: Run-Time acquisition
It's certainly possible.
Reading a sensor would require an external function (probably C). See chapter 9 in Fritzson's book or chapter 12 in the Modelica Language Specification 3.2.
I would suggest that you use sampling to synchronize the input/output calls, as you probably want to take simulations steps more often than you sample the sensor.
Using SimForge should probably be fine, but if you want real-time capabilities you might want to read chapter 6 of the OpenModelica System Documentation - Interactive Simulation Facilities. I suspect that's simpler than making the DAQ functions synchronize the clock, but it can't be used within SimForge yet from what I understand. I might be wrong though
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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.
Re: Run-Time acquisition
OpenModelica System Documentation is OpenModelicaUsersGuide.pdf. It's included in your installation of OpenModelica. If the chapter does not exist in it, you probably don't have a recent enough version of OpenModelica installed (it's a new library).
You can read the latest version of the documentation from http://openmodelica.org/svn/OpenModelica/trunk/doc/ (user/pass from http://www.openmodelica.org/index.php/d … rce-code).
Sending data to a device should be done analogous to acquiring data.
For example you create:
data = readData() and writeData() functions or a single function dataToReceive = readWriteData(dataToSend)
The second is probably easier since Modelica doesn't allow function calls without return value in when-equations.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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 :-)
Re: Run-Time acquisition
It sounds like your omc is not recent enough. Try http://build.openmodelica.org/omc/build … n-5740.msi or build it from source.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Building from source is probably safest. I only use Mac and Linux versions of OMC, so I can't really help you with weird bugs there.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
This is the .dll hell in Windows.
I'll look into it and add the required .dlls in the .msi file.
You shouldn't install Visual Studio Express, but the Microsoft Visual C++ 2010 Redistributable Package (x86)
http://www.microsoft.com/downloads/deta … laylang=en
Even if you install the redistributable package, it might not work.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Check out the source then read the README for instructions. Or you might be able to use just omc (not OMNotebook/OMShell), if omc.exe was compiled with MinGW.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
The README is part of the source code.The username and password are in the first paragraph of the article you linked.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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?
Re: Run-Time acquisition
Oh yea... I forgot about that. Adrian is still reinstalling the webserver OS. Not everything is back up yet.
You can use one of the source files from the Linux build system. They are same, just not version-controlled: http://build.openmodelica.org/apt/pool/ … rig.tar.gz
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hi,
The correct SVN url for the VC7 is here:
https://openmodelica.ida.liu.se/svn/Ope … indows/VC7
The server back to normal now.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
Hi,
No you don't. The only one you need is the one from here:
https://www.openmodelica.org/index.php/ … ource-code
which is:
https://openmodelica.org/svn/OpenModelica/trunk/
and this one:
https://openmodelica.ida.liu.se/svn/Ope … indows/VC7
Where did you get this link from? Is rather old. Let me know so I can update it.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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.
Re: Run-Time acquisition
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
Re: Run-Time acquisition
In Windows by default, javac is not installed on the system $PATH. It's not a problem as the make system will recover and use the jar-file from subversion instead.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
omc_communication.cc and .h are created in Compiler/runtime/ automatically (or should be).
If it's a problem in OMShell or OMNotebook you may have to copy them manually.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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 ;-)
Re: Run-Time acquisition
Hmmm... simulation_result.cpp and solver_euler.cpp don't exist anymore. They have been replaced by solver_main.cpp and simulation_result_{csv,plt,bin}.cpp
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
The project files just are not updated. You might need to update them to match the Makefiles, as that is what is used during development and in OMDev.
- sjoelund.se
- 1700 Posts
Re: Run-Time acquisition
Hi,
You DO NOT need to compile any projects from omc.sln rather than: OMShell, OMNotebook and UpdateEnv.
OMC should be compiled by Eclipse and MinGW, and it should be compiled statically, meaning you need
to add an environment variable OMC_BUILD_STATIC = /static to Eclipse project builder.
We only compile Qt clients with Visual Studio, not OMC as otherwise we cannot load dlls compiled with MinGW
into a Visual Studio compiled executable.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Sorry about that, i should have told you. I'll update the readme soon enough.
Start the VS command line
go to:
> cd C:\OMDev\lib\antlr-win32-msvc\md-mdd
> nmake -f Makefile.win32 clean
> nmake -f Makefile.win32
Now you should have an antlr.lib there build with /md which should be fine for OMNotebook.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hi,
I'm in the process of building the 1.5.0 release myself and I hope I'll be ready with it soon.
I think the problem is that Qt is compiled with Visual Studio 2008 and OMNotebook and OMShell with VS 2010.
I now compiled Qt with VS 2010 and I'll do some testing. I'll let you know how it goes.
As your problem, you should copy all the dlls from Compiler/VC7/Setup/bin to build/bin
Then you also copy OMNotebook and OMShell to that folder. That should work, but unfortunately
the clients crash so I'm now trying to find a solution to that.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hi,
I build a .msi out of the latest revision (5865).
I had to compile Qt and Mico Corba using Visual Studio 2010, but it worked.
I got non-crashing Qt clients (OMShell, OMNotebook and OMPlotWindow are now working).
Here is the .msi:
http://www.ida.liu.se/~pelab/modelica/O … -22_05.msi
Please let me know if is working fine for you.
I have VS2010 installed so it might be the case that on some systems we get missing .dlls.
Sorry for the delay but I'm in holidays and working from time to time.
I will try to push the changes to the projects and the Qt libs compiled with VS2010 but
I'm on a very slow upload internet connection in Romania, so it might take a while.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
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
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hi,
I sent an email to the guy who implemented the interactive functionality, maybe he can help you.
I don't know enough about it to be able to help you ( and I'm in holidays and very un-eager to look
into the sources on how is implemented )
As far as I know there is a C++ client implementation already available inside c_runtime/interactive,
maybe you can do something similar in your gui (or use it directly).
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Run-Time acquisition
Hi Filippo,
I hope the following answers will help you using the interactive capabilities of OM.
1. OMShell only generates the executable file including your model, equations, solvers and so on. This executable file can be used as non-interactive or interactive simulation runtime.
2. The generated file is similar to a server waiting for you requests.
3. Your GUI needs three communication components please see “OpenModelicaUsersGuide.pdf chapter 5.4.1 Network configuration Settings”.
By default your GUI should wait for “control operation replies” on 127.0.0.1:10500 and for “results” on 127.0.0.1:10502.
If you are receiving something but the strings are malformed your TCP/IP implementation to receive messages is not correctly implemented. If it is so and you are using C++ you can take a look at the existing source code of the interactive components from “trunk\\OpenModelica\c_runtime\interactive”
“socket_win.cpp”
“socket_unix.cpp”
For using the example client.cpp you need to copy the following files into VSC++ and to compile them:
Client.cpp
Socket.h
Socket.cpp
Socket_win.cpp
Socket_unix.cpp
regards,
Parham
Re: Run-Time acquisition
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...
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hi Francesco,
I have similar problem as your. I work on project, which communicate with real system. I want regulate this system with OpenModelica. I created to the GUI, and when I start simulating a get only time value.
The example model HelloWorld I used for tests.
I tried send command:
setfilter#1#HelloWorld.x#end
or
setfilter#1#x#end
but I get nothing new only time.
My question is: Can you get values from simulation? Can someone help me with this? My result from simulation is: result#28.4###end, the number is value of time.
Thanks,
xilos
Re: Run-Time acquisition
Hy there again,
I solved my problem So to get values from simulation is needed to define setfilter correctly. I tried for 2 model and its works
Firstly is needed to define variables and parameters. When I had model with Real x, and parameter p the good form of command was: setfilter#1#x#p#end. When I send command setfilter#1#x#end, the program defined as Type p - parameter. And i get olny value of parameter.
xilos
Re: Run-Time acquisition
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
Re: Run-Time acquisition
Hy Francesco,
Thank you for your reply, I ll try this solution. But my biggest problem is link my real model with OpenModelica model. I wanna regulate the system in real time via usb connection, this communication is solved with a python language (I mean USB and PC).
My idea is to create one model for regulation (for example PID regulator) and connect him to other model. The second model will contain variables, which will sets in interactive real time simulation. Outputs from regulator will be filtered by command setfilter...
So the main point is that, I have functions in python to get and set values from usb device, but I need to send him to my OM model. Any idea for solution?
Sorry for my english. I hope you will understand.
Thanks,
xilos
Re: Run-Time acquisition
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.
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Run-Time acquisition