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

developing an application by C# or java to use OpenModelica Features

developing an application by C# or java to use OpenModelica Features

Hello everyone
I am new in OpenModelica. I am trying to use OpenModelica indirectly by developing an interface using java or C# and .NET. Here I have some questions and I will be grateful for any help.

1. I want to develop an interface for my users. Entering scripts of OpenModelica in an editor and pressing make button my program should send scripts to OpenModelica and get the results as a test.cpp file. Finally I should compile this test.cpp file. Is it any solution to do so?

2-is it any way to compile a test.cpp file using omc.exe indirectly by windows command window cmd.exe?

Re: developing an application by C# or java to use OpenModelica Features

Read the System Documentation. There are several ways of doing this with OMC:
1. via command line:
   omc script.mos
2. via corba
    runScript("script.mos");

Cheers,
Adrian Pop/

Re: developing an application by C# or java to use OpenModelica Features

thank you for your good answer
if it is possible i have another question:

Hello
I have a problem in executing an exe file from C# code:
I am working on OpenModelica that is a free open source simulation tool. Final executable result of simulating with OpenModelika is an exe file. Once we have this exe file, we can get the simulation result by double clicking on this file. However to executing truly the program needs a text file called *_init.txt to be along with exe file in the same directory. Executing the exe file generates final result as a *.plt file in the same directory.
Considering the above mentioned situation my problem begins here:
I am trying to execute the exe file programmatically by C# code:
            Process myProc = new Process();
            myProc.StartInfo.FileName = "dir..\\Sinulation.exe";
            myProc.StartInfo.UseShellExecute = true;
            myProc.Start();
executing the exe file with above code don’t generate the *.plt file.
Is it any way to solve this problem?
I will very thankful for any help

Re: developing an application by C# or java to use OpenModelica Features

You need to set the working directory where the executable should start.
In this working directory the _init.txt file should be present!

See here how to set the working directory:
http://stackoverflow.com/questions/1149 … -directory

Note that there might be additional issues if the process (the .exe) generates
output on standard output or on standard error (these streams needs to be processes).

Cheers,
Adrian Pop/

Re: developing an application by C# or java to use OpenModelica Features

Thank you for your good answer, i fixed the problem by your good reply:
            Process myProc = new Process();
            ProcessStartInfo _startInfo = new ProcessStartInfo();
            _startInfo.FileName= " dir..\\Sinulation.exe ";
            _startInfo.WorkingDirectory="dir..:\\";
            _startInfo.CreateNoWindow = true;
            myProc.StartInfo = _startInfo;
            myProc.Start();

There are 0 guests and 0 other users also viewing this topic
You are here: