@@ -1001,6 +1001,69 @@ def unused_signals(self):
10011001 return ({inputs [i ][:2 ]: inputs [i ][2 ] for i in unused_sysinp },
10021002 {outputs [i ][:2 ]: outputs [i ][2 ] for i in unused_sysout })
10031003
1004+ def signal_table (self , show_names = False ):
1005+ """Print table of signal names, sources, and destinations.
1006+
1007+ Intended primarily for systems that have been connected implicitly
1008+ using signal names.
1009+
1010+ Parameters
1011+ ----------
1012+ show_names : bool (optional)
1013+ Instead of printing out the system number, print out the name of
1014+ each system. Default is False because system name is not usually
1015+ specified when performing implicit interconnection using
1016+ :func:`interconnect`.
1017+
1018+ Examples
1019+ --------
1020+ >>> P = ct.ss(1,1,1,0, inputs='u', outputs='y')
1021+ >>> C = ct.tf(10, [.1, 1], inputs='e', outputs='u')
1022+ >>> L = ct.interconnect([C, P], inputs='e', outputs='y')
1023+ >>> L.signal_table()
1024+ signal | source | destination
1025+ --------------------------------------------------------------
1026+ e | input | system 0
1027+ u | system 0 | system 1
1028+ y | system 1 | output
1029+ """
1030+
1031+ spacing = 26
1032+ print ('signal' .ljust (10 ) + '| source' .ljust (spacing ) + '| destination' )
1033+ print ('-' * (10 + spacing * 2 ))
1034+
1035+ # collect signal labels
1036+ signal_labels = []
1037+ for sys in self .syslist :
1038+ signal_labels += sys .input_labels + sys .output_labels
1039+ signal_labels = set (signal_labels )
1040+
1041+ for signal_label in signal_labels :
1042+ print (signal_label .ljust (10 ), end = '' )
1043+ sources = '| '
1044+ dests = '| '
1045+
1046+ # overall interconnected system inputs and outputs
1047+ if self .find_input (signal_label ) is not None :
1048+ sources += 'input'
1049+ if self .find_output (signal_label ) is not None :
1050+ dests += 'output'
1051+
1052+ # internal connections
1053+ for idx , sys in enumerate (self .syslist ):
1054+ loc = sys .find_output (signal_label )
1055+ if loc is not None :
1056+ if not sources .endswith (' ' ):
1057+ sources += ', '
1058+ sources += sys .name if show_names else 'system ' + str (idx )
1059+ loc = sys .find_input (signal_label )
1060+ if loc is not None :
1061+ if not dests .endswith (' ' ):
1062+ dests += ', '
1063+ dests += sys .name if show_names else 'system ' + str (idx )
1064+ print (sources .ljust (spacing ), end = '' )
1065+ print (dests .ljust (spacing ), end = '\n ' )
1066+
10041067 def _find_inputs_by_basename (self , basename ):
10051068 """Find all subsystem inputs matching basename
10061069
0 commit comments