MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Connectivity Constraints for Ports
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Connectivity Constraints for Ports

 Post Reply Post Reply
Author
Message
cmorais View Drop Down
Contributor
Contributor
Avatar

Joined: 23.Mar.2018
Location: Ireland
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote cmorais Quote  Post ReplyReply Direct Link To This Post Topic: Connectivity Constraints for Ports
    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!


Edited by stevek - 23.Mar.2018 at 14:54
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Answer Answer
Post Options Post Options   Thanks (1) Thanks(1)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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.


Edited by stevek - 23.Mar.2018 at 14:56
Back to Top
cmorais View Drop Down
Contributor
Contributor
Avatar

Joined: 23.Mar.2018
Location: Ireland
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote cmorais Quote  Post ReplyReply Direct Link To This Post 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!
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.