博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GNU Radio中流图的动态配置
阅读量:6420 次
发布时间:2019-06-23

本文共 2388 字,大约阅读时间需要 7 分钟。

How can I reconfigure a flow graph? How do I use lock(), unlock()?

A running flow graph is static, and can't be changed. There are two ways to implement reconfigurability:

  • Use lock() / unlock()
  • Create blocks that react dynamically

Using lock() and unlock(), you will actually stop the flow graph, and can then disconnect and re-connect blocks. In the following example, the flow graph will run for a second, the stop the execution (lock), disconnect the source, connect a different one, and resume. The resulting file will first have data from the vector source, then lots of zeros.

#!/usr/bin/env pythonimport timefrom gnuradio import grfrom gnuradio import blocksdef main():    tb = gr.top_block()    src1 = blocks.vector_source_f(range(16), repeat=True)    throttle = blocks.throttle(gr.sizeof_float, 1e6)    sink = blocks.file_sink(gr.sizeof_float, 'out.dat')    tb.connect(src1, throttle, sink)    tb.start()    time.sleep(1)    print "Locking flowgraph..."     tb.lock()    tb.disconnect(src1)    src2 = blocks.null_source(gr.sizeof_float)    tb.connect(src2, throttle)    print "Unlocking flowgraph..."     tb.unlock()    time.sleep(2)    tb.stop()    tb.wait()if __name__ == "__main__":    main()

Note that this is not meant for sample-precision timing, but rather for situations where time does not really matter.

If sample-timing is an issue, use general blocks to react to certain events. In the following example, we assume that you have written a general block which stops reading from the first sink at a given time, and then seamlessly switches over to the second input:

#!/usr/bin/env pythonimport timefrom gnuradio import grfrom gnuradio import blocksimport my_awesome_oot_module as myoot # This is your custom moduledef main():    tb = gr.top_block()    src1 = blocks.vector_source_f(range(16), repeat=True)    src2 = blocks.null_source(gr.sizeof_float)    switch = myoot.switch() # This is your custom block    throttle = blocks.throttle(gr.sizeof_float, 1e6)    sink = blocks.file_sink(gr.sizeof_float, 'out.dat')    tb.connect(src1, switch, throttle, sink)    tb.connect(src2, (switch, 1))    tb.start()    time.sleep(2)    tb.stop()    tb.wait()if __name__ == "__main__":    main()

There are many blocks that react to input data, or incoming tags.

参考:http://gnuradio.org/redmine/projects/gnuradio/wiki/FAQ#How-can-I-reconfigure-a-flow-graph-How-do-I-use-lock-unlock

转载地址:http://ixmra.baihongyu.com/

你可能感兴趣的文章
一键安装kubernetes 1.13.0 集群
查看>>
RabbitMq的集群搭建
查看>>
spring boot + mybatis 同时访问多数据源
查看>>
URL中汉字转码
查看>>
[转]go正则实例
查看>>
Selector中关于顺序的注意事项
查看>>
小黑小波比.清空<div>标签内容
查看>>
Java中的ExceptionInInitializerError异常及解决方法
查看>>
Spring 注入bean时的初始化和销毁操作
查看>>
java线程同步原理(lock,synchronized)
查看>>
MyEclipse中使用Hql编辑器找不到Hibernate.cfg.xml文件解决方法
查看>>
yRadio以及其它
查看>>
第四节 对象和类
查看>>
闪迪(SanDisk)U盘防伪查询(官方网站)
查看>>
Android onMeasure方法介绍
查看>>
无锁数据结构
查看>>
MySQL的变量查看和设置
查看>>
android onNewIntent
查看>>
XML特殊符号
查看>>
kaptcha可配置项
查看>>