MCPcopy Create free account
hub / github.com/PX4/PX4-Autopilot / write

Method write

Tools/uorb_graph/create.py:648–711  ·  view source on GitHub ↗
(self, file_name)

Source from the content-addressed store, hash-verified

646 self._graph = graph
647
648 def write(self, file_name):
649
650 print('Writing to '+file_name)
651
652 output_topics = self._graph.output_topics
653 output_scopes = self._graph.output_scopes
654 topic_colors = self._graph.topic_colors
655
656 data = {}
657 nodes = []
658
659 # nodes
660 # (sort by length, such that short names are last. The rendering order
661 # will be the same, so that in case of an overlap, the shorter label
662 # will be on top)
663 for scope_tuple in sorted(output_scopes.items(), key=(lambda st: len(st[0])), reverse=True):
664 node = {}
665 node['id'] = 'm_'+scope_tuple[0]
666 node['name'] = scope_tuple[0]
667 node['type'] = scope_tuple[1].typename
668 node['color'] = '#666666'
669 # TODO: add url to open module documentation?
670 nodes.append(node)
671
672 for topic in sorted(output_topics, key=len, reverse=True):
673 node = {}
674 node['id'] = 't_'+topic
675 node['name'] = topic
676 node['type'] = 'topic'
677 node['color'] = topic_colors[topic]
678 # url is opened when double-clicking on the node
679 node['url'] = 'https://github.com/PX4/PX4-Autopilot/blob/main/msg/'+topic_filename(topic)+'.msg'
680 nodes.append(node)
681
682 data['nodes'] = nodes
683
684 edges = []
685
686
687 # edges
688 for name,scope in output_scopes.items():
689 for topic in scope.publications:
690 if topic in output_topics:
691 edge = {}
692 edge['source'] = 'm_'+name
693 edge['target'] = 't_'+topic
694 edge['color'] = topic_colors[topic]
695 edge['style'] = 'dashed'
696 edges.append(edge)
697
698 for name,scope in output_scopes.items():
699 for topic in scope.subscriptions:
700 if topic in output_topics:
701 edge = {}
702 edge['source'] = 't_'+topic
703 edge['target'] = 'm_'+name
704 edge['color'] = topic_colors[topic]
705 edge['style'] = 'normal'

Callers 15

__sendMethod · 0.45
__drawProgressBarMethod · 0.45
__eraseMethod · 0.45
save_compressedFunction · 0.45
read_messagesMethod · 0.45
write_ulog_messagesMethod · 0.45
usb_serialload.pyFile · 0.45
extract_file_onlyFunction · 0.45
_exec_cmdFunction · 0.45
_get_fileFunction · 0.45

Calls 3

topic_filenameFunction · 0.85
appendMethod · 0.80
dumpMethod · 0.80

Tested by 1

do_testFunction · 0.36