feat: added comments
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Autodoc functions
|
Autodoc functions
|
||||||
"""
|
"""
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import common as doc
|
import common as doc
|
||||||
|
|||||||
+109
-50
@@ -88,80 +88,118 @@ def __doc_triggered_iogam__(name, obj, edges, thread):
|
|||||||
return node, edges
|
return node, edges
|
||||||
|
|
||||||
|
|
||||||
|
__set_keys__ = (
|
||||||
|
"Alias",
|
||||||
|
"Type",
|
||||||
|
"DataSource",
|
||||||
|
"NumberOfElements",
|
||||||
|
"NumberOfDimensions",
|
||||||
|
"Ranges",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def __doc_iogam__(id, obj, edges, thread):
|
def __doc_iogam__(id, obj, edges, thread):
|
||||||
node = ""
|
node = ""
|
||||||
if "InputSignals" in obj and "OutputSignals" in obj:
|
if "InputSignals" in obj and "OutputSignals" in obj:
|
||||||
inputs, outputs = obj["InputSignals"], obj["OutputSignals"]
|
inputs, outputs = obj["InputSignals"], obj["OutputSignals"]
|
||||||
output_names = list(outputs.keys())
|
output_names = list(outputs.keys())
|
||||||
input_names = list(inputs.keys())
|
input_names = list(inputs.keys())
|
||||||
j = 0
|
|
||||||
input_size = 0
|
input_size = 0
|
||||||
output_size = 0
|
output_size = 0
|
||||||
i = 0
|
out_i = 0
|
||||||
irow = ""
|
in_i = 0
|
||||||
orow = ""
|
|
||||||
counter = 0
|
counter = 0
|
||||||
while i < len(inputs) and j < len(outputs):
|
while in_i < len(inputs) and out_i < len(outputs):
|
||||||
irelcount = 0
|
irows = []
|
||||||
orelcount = 0
|
orows = []
|
||||||
bold = False
|
bold = False
|
||||||
while input_size <= output_size and i < len(inputs):
|
while input_size <= output_size and in_i < len(inputs):
|
||||||
in_label = input_names[i]
|
in_label = input_names[in_i]
|
||||||
input = inputs[in_label]
|
input = inputs[in_label]
|
||||||
if irow:
|
|
||||||
irow += " | "
|
|
||||||
input_size += doc.signal_byte_size(input)
|
input_size += doc.signal_byte_size(input)
|
||||||
i += 1
|
in_i += 1
|
||||||
alias = doc.signal_alias(in_label, input)
|
alias = doc.signal_alias(in_label, input)
|
||||||
mtype = doc.signal_type(input)
|
mtype = doc.signal_type(input)
|
||||||
if mtype[2]:
|
if mtype[2]:
|
||||||
bold = True
|
bold = True
|
||||||
irow += f"<in_{irelcount}> {doc.type_to_string(mtype)}"
|
irow = f"{doc.type_to_string(mtype)}"
|
||||||
|
for key, val in input.items():
|
||||||
|
if key not in __set_keys__:
|
||||||
|
bold = True
|
||||||
|
irow += f"<br/>{key}: {val}"
|
||||||
datasrc = input["DataSource"]
|
datasrc = input["DataSource"]
|
||||||
edges.append(
|
edges.append(
|
||||||
doc.edge(
|
doc.edge(
|
||||||
doc.signal(datasrc, alias, mtype),
|
doc.signal(datasrc, alias, mtype),
|
||||||
doc.signal(f"{id}_{counter}", f"{irelcount}", mtype),
|
doc.signal(f"{id}_{counter}", f"{len(irows)}", mtype),
|
||||||
thread,
|
thread,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
irelcount += 1
|
irows.append(irow)
|
||||||
while output_size < input_size and j < len(outputs):
|
while output_size < input_size and out_i < len(outputs):
|
||||||
out_label = output_names[j]
|
out_label = output_names[out_i]
|
||||||
output = outputs[out_label]
|
output = outputs[out_label]
|
||||||
output_size += doc.signal_byte_size(output)
|
output_size += doc.signal_byte_size(output)
|
||||||
if orow:
|
out_i += 1
|
||||||
orow += " | "
|
|
||||||
j += 1
|
|
||||||
alias = doc.signal_alias(out_label, output)
|
alias = doc.signal_alias(out_label, output)
|
||||||
mtype = doc.signal_type(output)
|
mtype = doc.signal_type(output)
|
||||||
if mtype[2]:
|
if mtype[2]:
|
||||||
bold = True
|
bold = True
|
||||||
orow += f"<out_{orelcount}> {doc.type_to_string(mtype)}"
|
orow = f"{doc.type_to_string(mtype)}"
|
||||||
|
for key, val in output.items():
|
||||||
|
if key not in __set_keys__:
|
||||||
|
bold = True
|
||||||
|
orow += f"<br/>{key}: {val}"
|
||||||
datasrc = output["DataSource"]
|
datasrc = output["DataSource"]
|
||||||
edges.append(
|
edges.append(
|
||||||
doc.edge(
|
doc.edge(
|
||||||
doc.signal(f"{id}_{counter}", f"{orelcount}", mtype),
|
doc.signal(f"{id}_{counter}", f"{len(orows)}", mtype),
|
||||||
doc.signal(datasrc, alias, mtype),
|
doc.signal(datasrc, alias, mtype),
|
||||||
thread,
|
thread,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
orelcount += 1
|
orows.append(orow)
|
||||||
fill = "#fff"
|
fill = "#fff"
|
||||||
fsize = 14.0
|
total = max(len(orows), len(irows))
|
||||||
if bold or irelcount > 1 or orelcount > 1:
|
if bold or total > 1:
|
||||||
fill = "#333"
|
fill = "#333"
|
||||||
|
bold = True
|
||||||
else:
|
else:
|
||||||
irow = f"<in_{irelcount-1}> "
|
|
||||||
orow = f"<out_{orelcount-1}>"
|
|
||||||
fill = "#666"
|
fill = "#666"
|
||||||
fsize = 0.0
|
|
||||||
node += f'{id}_{counter} [tooltip=" IOGAM::{id} " label="'
|
inode = f"{id}_{counter} [shape=plaintext,"
|
||||||
node += "{ {" + irow + "} | {" + orow + "} }"
|
inode += f'tooltip=" IOGAM::{id} ", label=<'
|
||||||
node += f'", fillcolor="{fill}", color="#666", style=filled,'
|
inode += "<table cellspacing='0' cellborder='1'"
|
||||||
node += f' fontcolor="#fff", fontsize={fsize}, height=0, width=0];\n'
|
inode += f" cellpadding='4' border='0' bgcolor='{fill}'>"
|
||||||
irow = ""
|
|
||||||
orow = ""
|
if bold:
|
||||||
|
for i in range(total):
|
||||||
|
inode += "<tr>"
|
||||||
|
if i < len(irows):
|
||||||
|
inode += f'<td port="in_{i}" bgcolor="{fill}"'
|
||||||
|
if len(orows) > len(irows):
|
||||||
|
inode += f' rowspan="{len(orows)}"'
|
||||||
|
inode += ">"
|
||||||
|
inode += '<font color="#fff">'
|
||||||
|
inode += irows[i]
|
||||||
|
inode += "</font></td>"
|
||||||
|
if i < len(orows):
|
||||||
|
inode += f'<td port="out_{i}" bgcolor="{fill}"'
|
||||||
|
if len(orows) < len(irows):
|
||||||
|
inode += f' rowspan="{len(irows)}"'
|
||||||
|
inode += ">"
|
||||||
|
inode += '<font color="#fff">'
|
||||||
|
inode += orows[i]
|
||||||
|
inode += "</font></td>"
|
||||||
|
inode += "</tr>"
|
||||||
|
else:
|
||||||
|
inode += "<tr><td port='in_0'></td>"
|
||||||
|
inode += "<td port='out_0'></td></tr>"
|
||||||
|
inode += "</table>>"
|
||||||
|
inode += "];\n"
|
||||||
|
node += inode
|
||||||
|
irows = []
|
||||||
|
orows = []
|
||||||
counter += 1
|
counter += 1
|
||||||
return node, edges
|
return node, edges
|
||||||
|
|
||||||
@@ -192,9 +230,24 @@ def __doc_constgam__(id, obj, edges, thread):
|
|||||||
def __doc_message_gam__(id, obj, edges, thread):
|
def __doc_message_gam__(id, obj, edges, thread):
|
||||||
label = id[2:]
|
label = id[2:]
|
||||||
node = f' {id} [label="{label}\n{obj["Class"]} | '
|
node = f' {id} [label="{label}\n{obj["Class"]} | '
|
||||||
sigs, edges = __doc_common_gam__(id, obj, edges, thread)
|
inputs = ""
|
||||||
if sigs:
|
if "InputSignals" in obj:
|
||||||
node += sigs + '"];'
|
for i, (l, sig) in enumerate(obj["InputSignals"].items()):
|
||||||
|
alias = doc.signal_alias(l, sig)
|
||||||
|
mtype = doc.signal_type(sig)
|
||||||
|
datasrc = sig["DataSource"]
|
||||||
|
edges.append(
|
||||||
|
doc.edge(
|
||||||
|
doc.signal(datasrc, alias, mtype),
|
||||||
|
doc.signal(id, l, mtype),
|
||||||
|
thread,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if i != 0:
|
||||||
|
inputs += " | "
|
||||||
|
inputs += f"<in_{doc.format_name(l)}> {l}"
|
||||||
|
if inputs:
|
||||||
|
node += inputs + '"];'
|
||||||
else:
|
else:
|
||||||
node = ""
|
node = ""
|
||||||
|
|
||||||
@@ -233,7 +286,8 @@ def __doc_events__(id, obj, edges, thread):
|
|||||||
else:
|
else:
|
||||||
nodes += f"{fn} "
|
nodes += f"{fn} "
|
||||||
nodes += "</td></tr></table>>];\n"
|
nodes += "</td></tr></table>>];\n"
|
||||||
nodes += f" {id} -> {id}_{event_id}_{msg_id} [arrowhead=box];\n"
|
nodes += f" {id}:e -> {id}_{event_id}_{msg_id}:w"
|
||||||
|
nodes += " [arrowhead=box, constraint=true];\n"
|
||||||
return nodes, edges
|
return nodes, edges
|
||||||
|
|
||||||
|
|
||||||
@@ -370,20 +424,23 @@ def __process_ds__(name, obj, edges):
|
|||||||
for sig in sigs:
|
for sig in sigs:
|
||||||
if sig not in order:
|
if sig not in order:
|
||||||
lost.append(sig)
|
lost.append(sig)
|
||||||
node = f'{name} [label="{name}\n{cls} | '
|
node = f"{name} [shape=plaintext; label=<"
|
||||||
|
node += (
|
||||||
|
'<table border="0" cellpadding="4" cellborder="1" cellspacing="0">\n'
|
||||||
|
)
|
||||||
|
node += f"<tr><td><b>{name}</b><br/>{cls}</td></tr>\n"
|
||||||
for i, sig_name in enumerate(order):
|
for i, sig_name in enumerate(order):
|
||||||
if i > 0:
|
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
node += " | "
|
|
||||||
sig_type = sigs[sig_name]
|
sig_type = sigs[sig_name]
|
||||||
node += f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})"
|
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
|
node += "</td></tr>\n"
|
||||||
for sig_name in lost:
|
for sig_name in lost:
|
||||||
logging.warning(f"Lost signal {name}:{sig_name}")
|
logging.warning(f"Lost signal {name}:{sig_name}")
|
||||||
if node:
|
node += f'<tr><td port="{doc.format_name(sig_name)}">'
|
||||||
node += " | "
|
|
||||||
sig_type = sigs[sig_name]
|
sig_type = sigs[sig_name]
|
||||||
node += f"<{doc.format_name(sig_name)}> {sig_name} ({doc.type_to_string(sig_type)})"
|
node += f"{sig_name} ({doc.type_to_string(sig_type)})"
|
||||||
node += '", color=blue];\n'
|
node += "</td></tr>\n"
|
||||||
|
node += "</table>>, color=blue];\n"
|
||||||
if not multi_thread and node:
|
if not multi_thread and node:
|
||||||
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
node = f"subgraph cluster_{thread}" + "{\n" + node + "};\n"
|
||||||
return node, edges
|
return node, edges
|
||||||
@@ -398,6 +455,7 @@ def __process_edges__(edges, datasources):
|
|||||||
trg_sig = doc.format_name(target[1])
|
trg_sig = doc.format_name(target[1])
|
||||||
a = f"{src_obj}"
|
a = f"{src_obj}"
|
||||||
b = f"{trg_obj}"
|
b = f"{trg_obj}"
|
||||||
|
ranked = True
|
||||||
if src_obj in datasources:
|
if src_obj in datasources:
|
||||||
a += f":{src_sig}"
|
a += f":{src_sig}"
|
||||||
else:
|
else:
|
||||||
@@ -410,7 +468,8 @@ def __process_edges__(edges, datasources):
|
|||||||
in_type = doc.type_to_string(source[2])
|
in_type = doc.type_to_string(source[2])
|
||||||
out_type = doc.type_to_string(target[2])
|
out_type = doc.type_to_string(target[2])
|
||||||
mtype = in_type if in_type == out_type else f"{in_type} -> {out_type}"
|
mtype = in_type if in_type == out_type else f"{in_type} -> {out_type}"
|
||||||
arrows += f'{a} -> {b} [tooltip=" {mtype} ", labelfloat=false];\n'
|
arrows += f'{a}:e -> {b}:w [tooltip=" {mtype} ", labelfloat=false'
|
||||||
|
arrows += f", constraint={ranked}];\n"
|
||||||
return arrows
|
return arrows
|
||||||
|
|
||||||
|
|
||||||
@@ -418,8 +477,8 @@ def doc_state(label, state, app):
|
|||||||
global __PATH__
|
global __PATH__
|
||||||
mdstate = ""
|
mdstate = ""
|
||||||
graph = f"digraph {label[1:]}" + "{\n"
|
graph = f"digraph {label[1:]}" + "{\n"
|
||||||
graph += "ranksep = 1;\n"
|
graph += "ranksep = 2;\n"
|
||||||
graph += "nodesep = 0.5;\n"
|
graph += "nodesep = 0.05;\n"
|
||||||
graph += "rankdir = LR;\n"
|
graph += "rankdir = LR;\n"
|
||||||
graph += "node [shape=Mrecord];\n"
|
graph += "node [shape=Mrecord];\n"
|
||||||
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
graph += f"label=<State: <B>{label[1:]}</B>>;\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user