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.
|