Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildModel() is not working #58

Closed
Amuri44 opened this issue Dec 23, 2021 · 3 comments
Closed

buildModel() is not working #58

Amuri44 opened this issue Dec 23, 2021 · 3 comments

Comments

@Amuri44
Copy link

Amuri44 commented Dec 23, 2021

I am trying to implement the code in julia:
https://openmodelica.org/doc/OpenModelicaUsersGuide/1.18/scripting_api.html#simulation-parameter-sweep
the loadFile is working but the buildModel (i.e., sendExpression(omc,"buildModel(BouncingBall)");) is not (although it works in omshell). Any idea or reason for that?

@Amuri44 Amuri44 changed the title buildModel is not working buildModel() is not working Dec 23, 2021
@arun3688
Copy link
Contributor

@Amuri44 , there is an extra parenthesis and semicolon, It should be sendExpression(omc, "buildModel(BouncingBall)") also please note that if there are some problems you should always use getErrorString() to see the error message sendExpression(omc, "getErrorString()"), So your code should be like this

sendExpression(omc, "buildModel(BouncingBall)")
sendExpression(omc, "getErrorString()")

@arun3688
Copy link
Contributor

sendExpression(omc,"buildModel("C:/Users/amroa/AppData/Local/Temp/OpenModelica/BouncingBall")")
sendExpression(omc,"getErrorString()")

This is wrong, you cannot use buildModel like that, can you paste your full code

@Amuri44
Copy link
Author

Amuri44 commented Dec 28, 2021

@arun3688
Thanks for your reply! I have two concerns please:
1- The code worked in the default directory i.e. "C:\Users\user_name\AppData\Local\Temp\OpenModelica" and the system() command returned “0”. However, when I change the path directory to be through the One-Drive(i.e. "C:/path1/One-Drive/path2/model"), the code works except the system() command and it returns “1”. I did this also in the omshell with the same problem. Do you know why?

2- I want to put the system() command within a time-loop (iterations), in which the results of system() command will effect the next iteration. So, generating a results file such as .mat and reading form it (at each iteration) will consume a lot of time. Is there any way to show the results of system() command directly into the workspace of omshell rather than reading them from the generated results file (.mat)? I used val(variable, time) but it didnt return anything.

3- I am trying to set the path directory to the location returned by @DIR as written below, but it is not working. Any idea why?
omc= OMJulia.OMCSession();
sendExpression(omc,"cd("$(@DIR)")"); sendExpression(omc,"getErrorString()");

@Amuri44 Amuri44 closed this as completed Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants