A list for the developers of CellML tools

Text archives Help


[cellml-dev] retrieve main model component name


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] retrieve main model component name
  • Date: Wed, 25 Jan 2012 07:17:12 +1300

On 25/01/12 05:29, Paolo Pannarale wrote:
> Dear developers, I managed to programmatically integrate a cellml
> model from java, writing my own jni which mainly encapsulate the
> runcellml.cpp example of cis.
> I had to adopt this solution because the integrationProgressObserver
> methods weren't never called by the cis run in java.
> by the way...I've one final issue:
Could you explain how you fixed this issue? It would be good to include
your solution in the CellML API implementation.

>
> when i get a variable from a computation target
> "iface::cellml_api::CellMLVariable* source = ct->variable();"
> how can I retrieve the component name of that variable in the main
> model rather than in the source imported model?
> in the case of multiple model imports I can't know which variable I'm
> handling...

Firstly, note that there is not necessarily a component in the main
model corresponding to the component you retrieve - the encapsulation
feature of CellML means that you can import one component and have a
series of other components 'encapsulated under it' come with it.

Also note that a variable in an encapsulated component may or may not be
connected to a variable in a component that is imported to the top level
(or perhaps appears in the top level).

Without knowing exactly what you are trying to do, it is therefore hard
to give a precise answer; however, some tips that might help:
* The parentElement attribute takes you up a level in the CellML
API's tree; the tree is based on the DOM, except that you can go up a
level from an imported model element to get to the import element.
* Therefore: from a CellML variable "source", c =
source.parentElement() is the component, m = c.parentElement() is the
Model, and ie = m.parentElement() will either be null, if it is the
toplevel model, or an Import element. Using the query_interface
functionality, you can convert ie to support a cellml_api.CellMLImport
interface, and then access cs = components() to get an
ImportComponentSet, ci = cs.iterateImportComponents() to get an
ImportComponentIterator, and then repeatedly call ic =
ci.nextImportComponent() to get an ImportComponent. You want to match
ic.componentRef() to c.name() to find the component in the model (but be
aware there might not be one, if c is brought in because it is
encapsulated under another component). Note that there can be multiple
levels of imports, so you may now need to repeat the whole process to go
up another level, and so on.
* To find all the variables that are connected to a given variable,
use the CeVAS service. Obtain the CeVAS bootstrap using the normal
procedure for obtaining a bootstrap, and call
createCeVASForModel(toplevelModel) on it, to get a CeVAS object. Call
findVariableSet on the variable to get a CellMLComponentIterator; you
can now just call nextComponent() repeatedly until you get null. Note
that the variables you get could be in different units; CUSES can be
used to work out the conversion factors between them.

Best wishes,
Andrew

>
> Thank you very much, Paolo
>
> --
> '[M]y work, which I've done for a long time, was not pursued in
> order to gain the praise I now enjoy, but chiefly from a craving
> after knowledge, which I notice resides in me more than in most
> other men. And wherewithal, whenever I found out anything remarkable,
> I have thought it my duty to put down my discovery on paper, so that
> all ingenious people might be informed thereof.'
> (van Leeuwenhoek, Letter to the Royal Society, June 12 1716)
>
> "Make it as simple as possible. But not simpler".
> (Albert Einstein)
>
> "The best way to predict the future is to invent it".
> (Alan Kay)
>
> ___________________________________
>
> Questo documento ? indirizzato esclusivamente al destinatario.
> Tutte le informazioni ivi contenute, compresi eventuali allegati,
> sono soggette a riservatezza secondo i termini del D.Lgs. 196/2003
> in materia di "privacy" e ne ? proibito l'utilizzo da parte di
> altri soggetti. Se avesse ricevuto per errore questo messaggio,
> La preghiamo cortesemente di contattare il mittente al pi? presto
> e di cancellare il messaggio subito dopo. Grazie.
> ----
> This document is exclusively intended for the stated addressee.
> All information therein, including any attachment, are reserved
> as per Italian D.Lgs. 196/2003 about privacy, and cannot be used
> by third parties. In case you received this message by mistake,
> please inform the sender and delete the message afterward.
> Thank you.
>
>
> _______________________________________________
> cellml-tools-developers mailing list
> cellml-tools-developers at cellml.org
> http://lists.cellml.org/mailman/listinfo/cellml-tools-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.cellml.org/pipermail/cellml-tools-developers/attachments/20120125/2b9973a4/attachment.htm>




Archive powered by MHonArc 2.6.18.

Top of page