我正在寻找一种方法将信号连接转换为简单的方案或图形.
假设我有2个组件,它们周围有2个线路/信号:
component A: input - S1 output - S2 component B: input - S2 output - S1
这将是输入数据文件,输出将是一个方案,将其显示为2个块,其周围有连接线或插图.
我想知道在Perl的世界中是否存在这种实现.
解决方法
听起来你想要像
graphviz图形生成器这样的东西.
它是用C语言编写的,但有一个Perl接口:GraphViz.
例:
use GraphViz; use File::Slurp qw(write_file); my $g = GraphViz->new; $g->add_node('componentA'); $g->add_node('componentB'); $g->add_edge('componentB' => 'componentA',label => 'S1'); $g->add_edge('componentA' => 'componentB',label => 'S2'); write_file('out.png',$g->as_png);
您可以通过信号编号上的散列加载输入数据并跟踪组件连接,然后为每个数据调用add_edge.
输出:
graphviz output http://img704.imageshack.us/img704/2624/outd.png
(标签是可选的).