MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - howto constrain port in maximum one relation
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

howto constrain port in maximum one relation

 Post Reply Post Reply
Author
Message
edward22243 View Drop Down
Major Contributor
Major Contributor
Avatar

Joined: 19.Apr.2019
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote edward22243 Quote  Post ReplyReply Direct Link To This Post Topic: howto constrain port in maximum one relation
    Posted: 11.Oct.2020 at 10:01
Hello, i have a graph with a 'skillscontainter' object which has defined a decomposition to the same graph. So when I insert a 'skillscontainer' and open it I can make a productdefinition there as well (kind of like a product-assembly with subassemblies, and subassembly may have other subassemblies etc.).

I defined an 'InPort' object which functions as a kind of feedthrough, so relation from top-level can connect to skillcontainer. These ports will also show up graphically (done with a template in symbol editor of skillscontainer; use subobjects as ports), see pic below with 2 Inports shown.

So far intro.

Problem: I cannot constrain the amount of relations to the Inport shown on the outer rim of the skillscontainer. It should only be in one relationship, but if I add contraints to the Inport object or the Skillscontainer than this does not seem to hold true for the Inports object used as ports in the decomposition (long story, hope it is not confusing).

Short story: look at picture, i have two lines to yellow "2" and I do not want to allow this, only one allowed. How to constrain this?

two connections to Inport object used as port for decompositoin


Back to Top
jpt View Drop Down
MetaCase
MetaCase
Avatar

Joined: 25.Mar.2008
Points: 239
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpt Quote  Post ReplyReply Direct Link To This Post Posted: 13.Oct.2020 at 13:38
This type of constraints can be set with MERL executed e.g. in a port symbol to highlight ports with multiple relations or shown in LiveCheck pane at modeling time below the diagram. MERL would be like:

do #() {
  @noOfRoles = __(do ~() {'1'})
  if @noOfRoles > '1' num then
    'error'
  endif
}

and () above for port and role could be replaced with your metamodel concepts.

Some extra considerations:

1.  You may also have own constraints if a port can be a source for multiple relations but not a target for multiple connections (using different port in ~())

2. If case the same port (like '2' in the example you provided) is reused as port for some other object then the above script should include also the context, so that when port '2' is connected with 'subassy'it is different case than when the same port '2' is used with 'subassy2' (another object).

Also, while not directly related to your question:

if ports (e.g. '1' and '2') would be of different type, there could be own constraints for them.

And in case connections would be based on different values given by modeler, port constraints could be set with Graph Tool allow setting constraints per value (like below).



Back to Top
edward22243 View Drop Down
Major Contributor
Major Contributor
Avatar

Joined: 19.Apr.2019
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote edward22243 Quote  Post ReplyReply Direct Link To This Post Posted: 13.Oct.2020 at 14:28
thanks for the response. I will try what you suggest.
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Post Options Post Options   Thanks (1) Thanks(1)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 03.Jun.2021 at 14:25

This type of constraint can also, and perhaps better, be handled with MERL executed in a role symbol to highlight roles that are fighting for the same port:
@origRoleOid = oid
do #() { @origPortOid = oid }
/* check other roles on this object */
do .()~() where oid <> @origRoleOid
/* does this role connect to our original port? */
   do #() where oid = @origPortOid { 'error' }
}
If you have different constraints depending on the direction or role type, e.g. if a port can be a source for multiple roles but not a target for multiple roles, you can replace ~() with the constrained role type, e.g. ~To

Similarly if the same role type can connect to different types of ports, and these have different constraints, you can replace #() with the constrained port type.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.078 seconds.