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

How to create new annotation type to store URL links to other data?

How to create new annotation type to store URL links to other data?

Hi,

I am running a java application that is able to execute any commands (I am using Java OMC library: http://code.google.com/p/javaomc/)

I know that some data is stored in annotations and that there is already several types of annotation, like Diagram or Icon.

I didn't found any type of annotation that is made to add a link to a resource (an URL).

Is there any annotation type for that?
If no, is there a way to create my own annotation type?

Thanks in advance for your answers,

Aurelien

Re: How to create new annotation type to store URL links to other data?

I found this document, giving the commands that I can launch: https://www.openmodelica.org/download/OMC_API-HowTo.pdf

Particularly, at the page 8, I found this method: addClassAnnotation(A1<cref>, annotate=<expr>)

I can also use :
getAnnotations(A1<cref>) to get the list of annotations
save(A1<cref>) to save the file

I tried to add the annotation: annotate=MyNewAnnotation(http://somesite.com), and it return an error
But with :  annotate=MyNewAnnotation(httpsomesite.com), it works perfectly

The problem seems to come from the"//" that is not parsed properly, what can I do to avoid this problem using //?

Will I have any compilation/simulation proble; if I add any "custom" annotations like that in my model?
(I mean as far as its name is different from any "official" annotation, of course.)

Re: How to create new annotation type to store URL links to other data?

You would need to add URL's as Strings. The usual way to add URL's to Modelica models is through the documentation annotation: Documentation(info="<html><a href=\"...\">...</a></html>")

If you want a new annotation, you should make it a vendor-specific annotation:
annotation(__MyPrefix_MyNewAnnotation = "http://...")
or
annotation(__MyPrefix(MyNewAnnotation = "http://..."))

Re: How to create new annotation type to store URL links to other data?

Thank you very much,

I will use one of these formats for my application
Between quotes, I can store my "//"

Re: How to create new annotation type to store URL links to other data?

Just one more question...
If I store my links in the Documentation annotation, as a "html href", as you explained,
will people using OMEdit be able to see this link an click on it easily?

Re: How to create new annotation type to store URL links to other data?

I tried it and on the class documentation, my link apear.

Thank you so much

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