X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=tools%2Fdrawmodules.py;h=8ae72886c8bf41ddf2554a355c806e0368ca8dc6;hb=HEAD;hp=51c6aaaca9f6fdfa6b7eddb9a150f732b763faeb;hpb=84bd150c667e693c7ba6c31819b3f155f53e514a;p=senf.git diff --git a/tools/drawmodules.py b/tools/drawmodules.py index 51c6aaa..8ae7288 100755 --- a/tools/drawmodules.py +++ b/tools/drawmodules.py @@ -2,6 +2,8 @@ import sys +COLOR_SCHEME = 'pastel19' # see http://www.graphviz.org/doc/info/colors.html +NETEMU = ["InterfaceAnnotater" , "PacketMonitor" , "PacketTypeChecker"] mode = "MODULE" sys.stdout.write(""" @@ -11,6 +13,11 @@ node [shape=Mrecord, fontsize=8, fontname="Helvetica"]; modules = {} connectors = {} +p = 0 + +for opt in sys.argv: + if opt in ("-p","--packet"): + p = 1 for line in sys.stdin: line = line.strip() @@ -25,40 +32,70 @@ for line in sys.stdin: else: connectorid, type = line.split(' ',1); connectorid = connectorid[1:] - elts = type.rsplit(' ',1); + + packet = type.rsplit('<',1)[1] + packet = packet.rsplit('::',1)[-1] + packet = packet.split('>',1)[0] + + throttled = False + elts = type.rsplit(' ', 1); if elts[-1].startswith('0x'): - type, peerid = elts - peerid = peerid[1:] + type, peerid = elts[0], elts[1][1:] else: - peerid = None - modules[moduleid][1].append((connectorid, type, peerid)) - connectors[connectorid] = moduleid + if elts[-1] == ('throttled'): + throttled = True + elts = elts[0].rsplit(' ', 1) + type, peerid = elts[0], elts[1][1:] + else: + peerid = None + modules[moduleid][1].append((connectorid, type, peerid, packet)) + connectors[connectorid] = (moduleid, throttled) for moduleid, (module, cs) in modules.iteritems(): module = module.split('<',1)[0] + if module.rsplit('::',1)[-1] in NETEMU or module.startswith("senf::emu"): + color = 5 + elif module.endswith("Source") or module.endswith("Sink"): + color = 1 + elif "senf" not in module.split('::',1)[0]: + color = 6 + else: + color = 3 module = module.rsplit('::',1)[-1] inputs = [] outputs = [] - for connectorid, type, peerid in cs: + for connectorid, type, peerid, packet in cs: if 'Input' in type: inputs.append("<%s>%s" % (connectorid,connectorid)) else: outputs.append("<%s>%s" % (connectorid,connectorid)) rows = [] if inputs: rows.append("{%s}" % "|".join(inputs)) - rows.append("%s (%s)" % (module, moduleid)) + rows.append("%s" % (module)) if outputs: rows.append("{%s}" % "|".join(outputs)) - sys.stdout.write('%s [label="{%s}"]\n' % (moduleid, "|".join(rows) )) + sys.stdout.write('%s [label="{%s}" style="filled" fillcolor="/%s/%s" ]\n' + % (moduleid, "|".join(rows),COLOR_SCHEME, color )) anonid = 0 for moduleid, (type, cs) in modules.iteritems(): - for connectorid, type, peerid in cs: + for connectorid, type, peerid, packet in cs: opts = [] if "Passive" in type: opts.append("arrowtail=odot"); + if "Output" in type and peerid is not None: + if "Active" in type and connectors[peerid][1]: + opts.append("arrowhead=tee") + opts.append('headlabel="!"') + if "Passive" in type and connectors[connectorid][1]: + opts.append("arrowtail=tee") + opts.append('taillabel="!"') opts = ",".join(opts) if opts: opts = " [%s]" % opts if "Output" in type and peerid is not None: - sys.stdout.write('%s:%s -> %s:%s%s\n' - % (moduleid, connectorid, connectors[peerid], peerid, opts)) + if "Packet" in packet and p is 1: + sys.stdout.write('%s:%s -> %s:%s%s [label=" %s", fontsize=8, fontname="Helvetica"]\n' + % (moduleid, connectorid, connectors[peerid][0], peerid, opts,packet)) + else: + sys.stdout.write('%s:%s -> %s:%s%s\n' + % (moduleid, connectorid, connectors[peerid][0], peerid, opts)) elif peerid is None: sys.stdout.write('anon%d [label="", shape=point, height=.05];\n' % anonid) if "Output" in type: @@ -68,3 +105,4 @@ for moduleid, (type, cs) in modules.iteritems(): anonid += 1 sys.stdout.write("}\n") +