- Index
- » Developer
- » OpenModelica development
- » OMC: Annotations updating problem
OMC: Annotations updating problem
OMC: Annotations updating problem
Hi developers!
I am currently using OMC, controlled with OMShell, to manage modelica files. I have encountered an issue regarding annotations updating. I have a few questions/issues, and I am very open to suggestions and help!
Here is some sample code that I am trying to modify:
package test
parameter Real testReal "This is a real parameter";
end test;
Bug 1- First of all, to change/add annotations, I am using the function "updateComponent()", in OMShell.
>>> updateComponent(testReal, Real, test, annotate=Placement(transformation(extent = {{1,2},{3,4}})))
true
Now that works. However, the annotation takes a very weird format:
Expected: parameter Real testReal "This is a real parameter" annotation(Placement(transformation(extent = {{1,2},{3,4}})));
Actual: parameter Real testReal "This is a real parameter" annotation(Placement = transformation(extent = {{1,2},{3,4}}));
Which is wrong!
Bug 2- When trying to add multiple annotations, the function returns true, but does nothing...
>>> updateComponent(testReal, Real, test, annotate=(Placement(transformation(extent = {{1,2},{3,4}}))),Dialog())
true
That works too (returns true). However, the function does nothing.
Expected: parameter Real testReal "This is a real parameter" annotation(Placement(transformation(extent = {{1,2},{3,4}})), Dialog());
Actual: parameter Real testReal "This is a real parameter";
My question(s):
-Can anybody think of any better way to change annotations for parameters?
-Am I using the "annotate=" argument in a wrong fashion?
Re: OMC: Annotations updating problem
Hi,
Solution 1 - You are not specifying the annotate string properly. It should be,
>> updateComponent(testReal, Real, test, annotate=Placement(transformation=transformation(extent = {{1,2},{3,4}})))
instead of,
>> updateComponent(testReal, Real, test, annotate=Placement(transformation(extent = {{1,2},{3,4}})))
Solution 2 - A component can only have a placement annotation AFAIK. Read Modelica Specification 3.2 section 17.5.2 Component Instance
The Dialog annotation is for the class and you have to use addClassAnnotation API for it. However, multiple annotations are not supported through addClassAnnotation. You have to set them individually through addClassAnnotation.
Answers:
- No updateComponent is the only way.
- Yes you are using annotate= in a wrong way. Read solution 1. For further reading check this document https://openmodelica.org/svn/OpenModeli … -HowTo.pdf and study updateComponent API usage.
Anonymous read access is allowed with user: anonymous and pass: none.
Adeel.
- adeas
- 454 Posts
Re: OMC: Annotations updating problem
Hi,
Alternative link without user/password via Trac:
https://trac.openmodelica.org/OpenModel … aAPI-Howto
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: OMC: Annotations updating problem
Thank you adeas! Your implication will be of great help.
I would like to clarify my intentions for bug #2. First of all, I am using Dymola. At least in Dymola, the Dialog() annotation is accepted to generate drop-downs, checkboxes and others to choose values for parameters, within a class.
Moreover, I would like to add personalized annotations, to store additional data. For example, I would like to be able to write the following annotation:
parameter Real testReal annotation(Placement(transformation(.....)), my_custom_annotation(data(x=1, y=2)))
I would expect something like the following to work:
updateComponent(testReal, Real, test, annotate=(Placement(transformation=transformation(extent = {{1,2},{3,4}}))), my_custom_annotation(data=data(x=1, y=2)))
But updateComponent doesn't seem to accept multiple annotations, even if it returns true...
Again, thanks a lot for your help and time!
- Index
- » Developer
- » OpenModelica development
- » OMC: Annotations updating problem