Effacer les filtres
Effacer les filtres

How can I access child stereotype attributes of System Composer model in Matlab?

7 vues (au cours des 30 derniers jours)
Benjamin Steinle
Benjamin Steinle le 11 Mar 2020
Réponse apportée : Feimi le 20 Oct 2023
Hello,
I have build a System Composer model where I have four stereotypes: the order of inheritance is "mainElement" > "componentType" > "componentAttributes" > "component", "mainElement" has no base stereotype.
Now I want to calculate the weight of the attached model "FCS_Architecture_Boeing_777". When I try to access the value of the attribute "unitWeight" of the stereotype "component", it says " Unrecognized method, property, or field 'component' for class 'systemcomposer.arch.Component' " in line 47 in "computeOverallSysWeight". I created another stereotype "Component" (with capital C!) without base stereotype. When I want to access this one it works.
Is there a possibility to access "child stereotypes" and their attribute values?
Thanks in advance.
Benjamin

Réponses (1)

Feimi
Feimi le 20 Oct 2023
Hi Benjamin,
systemcomposer.arch.Component is the object type in our public API and its documentation is here:
In order to access a property (attribute in your question) of a stereotype that is applied on your component, you can use the following command:
value = myComponent.getPropertyValue('DataModel.component.unitWeight') % myComponent is a systemcomposer.arch.Component object
There are some examples of the usage of this function documented here: https://www.mathworks.com/help/systemcomposer/ref/systemcomposer.arch.architecture.getpropertyvalue.html
Additionally, I assume that your use case is to calculate the weight by summing up the weights of every component. In that case, we shipped a workflow (in 2020b) that exactly fits your need. Please take a look at this example:
Feimi

Catégories

En savoir plus sur System Composer dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by