Print Page | Close Window

Connectivity Constraints for Ports

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: http://www.metacase.com/forums/forum_posts.asp?TID=882
Printed Date: 19.Apr.2024 at 18:45
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Connectivity Constraints for Ports
Posted By: cmorais
Subject: Connectivity Constraints for Ports
Date Posted: 23.Mar.2018 at 13:57
Hi,

I've a problem that I couldn't find any awnser...
I'm using the Metaedit+ 5.5 Windows


In my model, I have an object (let's call it "panel")that has 5 ports.
When I was binding the "panel", I specified that ports from 1  to 4 can connect one object of four different kinds ( say: a,b,c, and d objects)
And the port 5 just one object of the C kind.
My graph just has one relationship ("connected in"). So it should be: the Object A is connected in the Panel in the port 1.
So, I put the cardinality 1..1  but I still can conect more that one in the same port in the graph (with same kind or not, do not matter).

I tried a constrain, but there isn't one that is applied to ports input ("just one connection in this port").
Is there a property that keeps the total connection to a port, so I can filter? Or is a problem with cardinality? It should bock these connection?

Thanks!



Replies:
Posted By: stevek
Date Posted: 23.Mar.2018 at 14:52
Since you want to limit the connections to the different ports individually, the most common way would be to have different role types for each port. Then you simply make a Connectivity constraint on how many instances of a given role type can connect to an object of this type. E.g. you'd have Role1's connecting to each port 1, and a constraint "Panel may have at most 1 role of type Role1". 

There are two other ways you can make a constraint on how many roles can connect to a given port in an object:

Make the symbol display an error
E.g. the port area for port 1 could have a red square with a generator-based condition, so it is shown only when there are 2 or more roles connected to that port. Let's make it just generate an X for each time the port is connected:

do ~()#Port1Type { 'X' }

and compare that with a wildcard comparison =~ to a String

XX*

Note that here I'm assuming you've made a different Port type for each type of port. That's the right approach when you want to consider them as different types, as here. If you have the same type, but e.g. a different Name for each port instance, you could do:

do ~()#PortType; where :Name = '1' { 'X' }

Show the errors in the LiveCheck pane
Write a generator in that graph type, listing all problems in the graph:

__LiveCheck()
foreach .panel
{  @roles = ''
    do ~()#Port1Type; where @roles++ unique '1' 
   {  'Panel ' id;1 ' port 1 has ' @roles ' roles connected' newline
   }
}

That's a little creative, in that we use @roles to contain a running count of the roles to that port, but the initial value is an empty string, so "where" will not run the block for the first role, only for the subsequent illegal extra roles. And since we only want to show the line once, even if there are many roles, we also add "unique '1'", which will only run the block once.


Posted By: cmorais
Date Posted: 23.Mar.2018 at 15:34
Yeah! The role alternative worked like a charm.

I guess I'll use the other two alternatives  latter on, but the roles thing worked fine  Smile

Thank you very much!



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