- Index
- » Developer
- » OpenModelica development
- » Custom Component Annotations
Custom Component Annotations
Custom Component Annotations
Hello,
I've been experimenting with the omc.updatComponent, omc.addComponent functions and trying to set custom annotations on the components. This is not working or I am not using the proper syntax.
so, two questions:
1) is there a way to set custom annotations on a component using the omc API. I'm wondering how OpenModelica sets such information
2) If not, what is the best way to modify the omc to fix this problem?
Kind regards
Chahé
Re: Custom Component Annotations
Hi,
It should be possible to set anything in there. Maybe you're not using the proper API syntax.
See here a bit (with examples) on how to use the API:
http://openmodelica.org/svn/OpenModelic … -HowTo.pdf
user: anonymous
pass:none <-- write none here.
If you get stuck add an small example here of what is not working so that we can better help you out.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Custom Component Annotations
Hi Adrian,
thanks indeed I was using the wrong syntax: annotation= instead of annotate=
its all working perfectly.
Do you know if there is a built in way to get any annotations properly. using getComponentAnnotations and getNthComponentAnnotation I was getting Error where I was expecting the modifications on my custom annotation. Right now I added some functions to the OMC .mo files to get the unparsed annotation but I'll be happier if I knew there is a solution that already works.
BTW, what is the process of contributing our changes back to the OMC? Hopefully them being integrated of course if suitable?
Chahé
Re: Custom Component Annotations
Hi,
Is easy to contribute back: Go here (read at the bottom):
https://www.openmodelica.org/index.php/ … ource-code
make a user in CodeBeamer, join the OpenModelica project and I can give you write access to Subversion so you can push your changes.
Just make sure you run the full testsuite and don't get any other failures than without your changes.
Read also here about legal issues when contributing:
https://www.openmodelica.org/index.php/ … -agreement
As far as I know , right now there is no API to get the annotations in string format, they are flattened out.
However, it might be that you can use getNamedAnnotation(path, "annotationname"), but as far as I know that is only for classes.
It might be that Adeel knows more about this, i'll send him an email and point him to this post so he can reply if he can.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Custom Component Annotations
What kind of modifications do you have in your custom annotations?
For non flattened annotations you can use,
- getAnnotationCount(M1) // returns the annotation count e.g 2
- getNthAnnotationString(M1, 1) // returns the Nth annotation as a string.
But it only works for classes, it doesn't give you components annotations.
Adeel.
- adeas
- 454 Posts
Re: Custom Component Annotations
Ok. Thanks. I will look into the references you provided.
I am also working on letting OMEdit optionally connect to a remote OMC. Actually, it was very easy to implement given the current OMEdit design.
Are there any others out there working on client/server versions of OMEdit for collaborative design? All these things on annotations I'm asking relate to the same purpose which is to annotate ownership/subscription information to the components and from there enable the client/server OmEdit to work + other custom clients.
Cheers
Chahé
BTW, I suppose you're in Europe and its 3am??
Re: Custom Component Annotations
Hi,
As far as I know there is nobody else working on OMEdit (or other clients) for collaborative tasks.
Yes, is 3:10 here but we're night owls
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: Custom Component Annotations
Hi Adeel,
sorry I missed your post while replying to Adrian.
Here's an example custom annotation:
String a1x annotation(__myTag(Data(name = "<String1>",values= {"<SString1>","<SString2>"})));
Technically, I could get by by storing the same information at the parent class level but then I would have to store information for each parameter all lumped into one big annotation attached to the class itself.
I have modified some of the functions in Interactive.mo to give me the String for component. I'm not sure I have a very robust implementation but its working for now. So this new function together with the updateComponent function gives me both read and write access to custom annotations.
Best Regards
Chahé
- Index
- » Developer
- » OpenModelica development
- » Custom Component Annotations