Print Page | Close Window

howto constrain port in maximum one relation

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=925
Printed Date: 27.Mar.2026 at 03:42
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: howto constrain port in maximum one relation
Posted By: edward22243
Subject: howto constrain port in maximum one relation
Date 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





Replies:
Posted By: jpt
Date 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).





Posted By: edward22243
Date Posted: 13.Oct.2020 at 14:28
thanks for the response. I will try what you suggest.


Posted By: stevek
Date 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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net