Import Instance

Dear Community,

How can we import a model instance inside another model?

The example is the following:

Imagine we have a system language which is used to describe systems and a component language which is used to describe components. The components are created inside their own models because they can become quite complex and should be reusable.

How can we import already modelled components into a system model? 

 

 

Best,

Gary


0
6 comments
Avatar
Permanently deleted user

Sounds like you need a smart reference. Have a look at the References section on 

https://confluence.jetbrains.com/display/MPSD20172/Structure 

 

 

0
Avatar
Permanently deleted user

Hello,

Thanks you for your answer. We tried to use smart references. The problem with a reference is that it only allows us to use 1..1 cardinality but a system might contain many components, which are modelled independently.

Introducing a reference concept, as proposed in the forum already is not a solution because we encounter the same problems, namely referencing multiple instances(nodes). 

Are you aware of any working solution?

Best,

0
Avatar
Permanently deleted user

To create multiple "references" use children (rather then references) and allow instances of the reference with a [0..n] or [1..n] cardinality.

0
Avatar
Permanently deleted user

Hello,

This somehow doesn't work for me. If I create an instance of this concept, it automatically creates component containers and doesn't allow us to import a model, that was modelled before, by its name. (See first screenshot of Sys above)

0

First, to clarify: I assume that by "import" you mean "reference" (as opposed to "copy" or "include").

To create multiple references, as Norm said, you need to add a level of indirection: create a "reference concept": it's a concept that only has a reference to another concept. In your case, a good name for this concept would be ComponentReference. It would have a reference to exactly one component. (There should be an intention to mark it as a smart reference by annotating it with "@smart reference" attribute. "Smart" means that MPS will add/remove it transparently when editing.) Then change compList to be ComponentReference[0..n].

0
Avatar
Permanently deleted user

Problem Solved. Thank you!

0

Please sign in to leave a comment.