- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » mos file commands
mos file commands
mos file commands
Hello,
I am trying to translate or instantiate models using a .mos file.
The file is the following
loadModel(Modelica);
translateModel(DM_CIVAU7CIVAU1_NGU_SM); getErrorString();
I would like to retrieve all logs messages generated during this process as a string. I tried getMessagesString() but did not get any message. How could I do this ?
Besides, I would like to save the instantied model as a .mo file. The instantiateModel function generates a string, is there a way to generate a native .mo file ?
Thank you,
Re: mos file commands
Maybe you are looking for
Code:
.OpenModelica.Scripting.reopenStandardStream
. Therewith, you can redirect a certain standard stream to a file.
reopenStandardStream
- lochel
- 45 Posts
Re: mos file commands
Ther getErrorString(); command should do what you want.
Please mind that the string that you get from this command refers to the last command you gave, thus it has to be run right after the translateModel command.
This works for sure
Code:
simRes := translateModel(myModelTypeName);
simulateMsg := getErrorString();
print(simulateMsg); getErrorString();
you might also want to try
Code:
simRes := translateModel(myModelTypeName);
errors:=getMessagesStringInternal();
print("getMessagesStringInternal() returned \n"); getErrorString();
print("Errors size is "+String(size(errors,1))); getErrorString();
for err_sel in 1:size(errors,1) loop
curErr := errors[err_sel];
curErrMess := curErr.message;
print(curErrMess); getErrorString();
end for;
You can get myModelTypeName with searchClassNames(myModelName)
- DarioMangoni
- 45 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » mos file commands