Пример #1
0
    def __init__(self, options):
        gr.top_block.__init__(self)  

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6667"
        probe_adr = "tcp://*:5557"
        source_adr = "tcp://"+self.options.servername+":5555"

        # blocks
        #self.zmq_source = zmqblocks.source_reqrep_nopoll(gr.sizeof_float,source_adr)
        self.zmq_source = zmqblocks.source_reqrep(gr.sizeof_float,source_adr)
        #self.zmq_source = zmqblocks.source_pushpull(gr.sizeof_float,source_adr)
        #self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float,probe_adr)
        self.zmq_probe = zmqblocks.sink_pubsub(gr.sizeof_float,probe_adr)

        # connects
        self.connect(self.zmq_source, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg",self.start_fg)
        self.rpc_manager.add_interface("stop_fg",self.stop_fg)
        self.rpc_manager.start_watcher()
Пример #2
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6667"
        probe_adr = "tcp://*:5557"
        source_adr = "tcp://" + self.options.servername + ":5555"

        # blocks
        # self.zmq_source = zmqblocks.source_reqrep_nopoll(gr.sizeof_float,source_adr)
        self.zmq_source = zmqblocks.source_reqrep(gr.sizeof_float, source_adr)
        # self.zmq_source = zmqblocks.source_pushpull(gr.sizeof_float,source_adr)
        # self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float,probe_adr)
        self.zmq_probe = zmqblocks.sink_pubsub(gr.sizeof_float, probe_adr)

        # connects
        self.connect(self.zmq_source, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg", self.start_fg)
        self.rpc_manager.add_interface("stop_fg", self.stop_fg)
        self.rpc_manager.start_watcher()
Пример #3
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options

        # create a QT application
        self.qapp = QtGui.QApplication(sys.argv)
        # give Ctrl+C back to system
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        # socket addresses
        rpc_adr_server = "tcp://localhost:6666"
        rpc_adr_reply = "tcp://*:6666"
        probe_adr_gui = "tcp://localhost:5556"
        probe_adr_fg = "tcp://*:5556"
        sink_adr = "tcp://*:5555"
        source_adr = "tcp://localhost:5555"

        # create the main window
        self.ui = gui.gui("Loop", rpc_adr_server, rpc_adr_server,
                          probe_adr_gui)
        self.ui.show()

        # the strange sampling rate gives a nice movement in the plot :P
        self.samp_rate = samp_rate = 48200

        # blocks
        self.gr_sig_source = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE,
                                                 1000, 1, 0)
        self.null_source = blocks.null_source(gr.sizeof_float)
        self.throttle = blocks.throttle(gr.sizeof_float, samp_rate)
        self.zmq_source = zmqblocks.source_pushpull_feedback(
            gr.sizeof_float, source_adr)
        self.mult_a = blocks.multiply_const_ff(1)
        self.mult_b = blocks.multiply_const_ff(0.5)
        self.add = blocks.add_ff(1)
        #self.zmq_sink = zmqblocks.sink_reqrep_nopoll(gr.sizeof_float, sink_adr)
        #self.zmq_sink = zmqblocks.sink_reqrep(gr.sizeof_float, sink_adr)
        self.zmq_sink = zmqblocks.sink_pushpull(gr.sizeof_float, sink_adr)
        self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float, probe_adr_fg)
        #self.null_sink = blocks.null_sink(gr.sizeof_float)

        # connects
        self.connect(self.gr_sig_source, self.mult_a)
        self.connect(self.zmq_source, self.mult_b, (self.add, 1))
        #        self.connect(self.null_source, (self.add,1))
        self.connect(self.mult_a, (self.add, 0), self.throttle, self.zmq_sink)
        self.connect(self.throttle, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr_reply)
        self.rpc_manager.add_interface("start_fg", self.start_fg)
        self.rpc_manager.add_interface("stop_fg", self.stop_fg)
        self.rpc_manager.add_interface("set_waveform", self.set_waveform)
        self.rpc_manager.add_interface("set_k", self.mult_a.set_k)
        self.rpc_manager.add_interface("get_sample_rate",
                                       self.throttle.sample_rate)
        self.rpc_manager.start_watcher()
Пример #4
0
    def __init__(self, options):
        gr.top_block.__init__(self)  

        self.options = options

        # create a QT application
        self.qapp = QtGui.QApplication(sys.argv)
        # give Ctrl+C back to system
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        # socket addresses
        rpc_adr_server = "tcp://localhost:6666"
        rpc_adr_reply = "tcp://*:6666"
        probe_adr_gui = "tcp://localhost:5556"
        probe_adr_fg = "tcp://*:5556"
        sink_adr = "tcp://*:5555"
        source_adr = "tcp://localhost:5555"

        # create the main window
        self.ui = gui.gui("Loop",rpc_adr_server,rpc_adr_server,probe_adr_gui)
        self.ui.show()

        # the strange sampling rate gives a nice movement in the plot :P
        self.samp_rate = samp_rate = 48200

        # blocks
        self.gr_sig_source = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE , 1000, 1, 0)
        self.null_source = blocks.null_source(gr.sizeof_float)
        self.throttle = blocks.throttle(gr.sizeof_float, samp_rate)
        self.zmq_source = zmqblocks.source_pushpull_feedback(gr.sizeof_float,source_adr)
        self.mult_a = blocks.multiply_const_ff(1)
        self.mult_b = blocks.multiply_const_ff(0.5)
        self.add = blocks.add_ff(1)
        #self.zmq_sink = zmqblocks.sink_reqrep_nopoll(gr.sizeof_float, sink_adr)
        #self.zmq_sink = zmqblocks.sink_reqrep(gr.sizeof_float, sink_adr)
        self.zmq_sink = zmqblocks.sink_pushpull(gr.sizeof_float, sink_adr)
        self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float, probe_adr_fg)
        #self.null_sink = blocks.null_sink(gr.sizeof_float)

        # connects
        self.connect(self.gr_sig_source, self.mult_a)
        self.connect(self.zmq_source, self.mult_b, (self.add,1))
#        self.connect(self.null_source, (self.add,1))
        self.connect(self.mult_a, (self.add, 0), self.throttle, self.zmq_sink)
        self.connect(self.throttle, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr_reply)
        self.rpc_manager.add_interface("start_fg",self.start_fg)
        self.rpc_manager.add_interface("stop_fg",self.stop_fg)
        self.rpc_manager.add_interface("set_waveform",self.set_waveform)
        self.rpc_manager.add_interface("set_k",self.mult_a.set_k)
        self.rpc_manager.add_interface("get_sample_rate",self.throttle.sample_rate)
        self.rpc_manager.start_watcher()
Пример #5
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6666"
        probe_adr = "tcp://*:5556"
        sink_adr = "tcp://*:5555"

        # the strange sampling rate gives a nice movement in the plot :P
        self.samp_rate = samp_rate = 48200

        # blocks
        self.gr_sig_source = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE,
                                                 1000, 1, 0)
        self.throttle = blocks.throttle(gr.sizeof_float, samp_rate)
        self.mult = blocks.multiply_const_ff(1)
        #self.zmq_sink = zmqblocks.sink_reqrep_nopoll(gr.sizeof_float, sink_adr)
        self.zmq_sink = zmqblocks.sink_reqrep(gr.sizeof_float, sink_adr)
        #self.zmq_sink = zmqblocks.sink_pushpull(gr.sizeof_float, sink_adr)
        #self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float, probe_adr)
        self.zmq_probe = zmqblocks.sink_pubsub(gr.sizeof_float, probe_adr)
        #self.null_sink = blocks.null_sink(gr.sizeof_float)

        # connects
        self.connect(self.gr_sig_source, self.mult, self.throttle,
                     self.zmq_sink)
        self.connect(self.throttle, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg", self.start_fg)
        self.rpc_manager.add_interface("stop_fg", self.stop_fg)
        self.rpc_manager.add_interface("set_waveform", self.set_waveform)
        self.rpc_manager.add_interface("set_k", self.mult.set_k)
        self.rpc_manager.add_interface("get_sample_rate",
                                       self.throttle.sample_rate)
        self.rpc_manager.add_interface("two_arg_rpc", self.two_arg_rpc)
        self.rpc_manager.start_watcher()
Пример #6
0
    def __init__(self, options):
        gr.top_block.__init__(self)  

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6666"
        probe_adr = "tcp://*:5556"
        sink_adr = "tcp://*:5555"

        # the strange sampling rate gives a nice movement in the plot :P
        self.samp_rate = samp_rate = 48200

        # blocks
        self.gr_sig_source = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE , 1000, 1, 0)
        self.throttle = blocks.throttle(gr.sizeof_float, samp_rate)
        self.mult = blocks.multiply_const_ff(1)
        #self.zmq_sink = zmqblocks.sink_reqrep_nopoll(gr.sizeof_float, sink_adr)
        self.zmq_sink = zmqblocks.sink_reqrep(gr.sizeof_float, sink_adr)
        #self.zmq_sink = zmqblocks.sink_pushpull(gr.sizeof_float, sink_adr)
        #self.zmq_probe = zmqblocks.sink_pushpull(gr.sizeof_float, probe_adr)
        self.zmq_probe = zmqblocks.sink_pubsub(gr.sizeof_float, probe_adr)
        #self.null_sink = blocks.null_sink(gr.sizeof_float)

        # connects
        self.connect(self.gr_sig_source, self.mult, self.throttle, self.zmq_sink)
        self.connect(self.throttle, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zmqblocks.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg",self.start_fg)
        self.rpc_manager.add_interface("stop_fg",self.stop_fg)
        self.rpc_manager.add_interface("set_waveform",self.set_waveform)
        self.rpc_manager.add_interface("set_k",self.mult.set_k)
        self.rpc_manager.add_interface("get_sample_rate",self.throttle.sample_rate)
        self.rpc_manager.add_interface("two_arg_rpc",self.two_arg_rpc)
        self.rpc_manager.start_watcher()
Пример #7
0
    def __init__(self, window_name, options, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        # give Ctrl+C back to system
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self.gui = uic.loadUi(os.path.join(os.path.dirname(__file__),'main_window.ui'), self)

        self.update_timer = Qt.QTimer()

        # socket addresses
        rpc_adr_server = "tcp://"+options.servername+":6666"
        rpc_adr_client = "tcp://"+options.clientname+":6667"
        probe_adr_server = "tcp://"+options.servername+":5556"
        probe_adr_client = "tcp://"+options.clientname+":5557"

        # ZeroMQ
        self.probe_manager = zmqblocks.probe_manager()
        self.probe_manager.add_socket(probe_adr_server, 'float32', self.plot_data_server)
        self.probe_manager.add_socket(probe_adr_client, 'float32', self.plot_data_client)

        self.rpc_mgr_server = zmqblocks.rpc_manager()
        self.rpc_mgr_server.set_request_socket(rpc_adr_server)
        self.rpc_mgr_client = zmqblocks.rpc_manager()
        self.rpc_mgr_client.set_request_socket(rpc_adr_client)

        self.gui.setWindowTitle(window_name)
        self.gui.qwtPlotServer.setTitle("Signal Scope")
        self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples")
        self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude")
        self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100)
        self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2)
        self.gui.qwtPlotClient.setTitle("Signal Scope")
        self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples")
        self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude")
        self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100)
        self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2)

        # Grid
        pen = Qt.QPen(Qt.Qt.DotLine)
        pen.setColor(Qt.Qt.black)
        pen.setWidth(0)
        grid_server = Qwt.QwtPlotGrid()
        grid_client = Qwt.QwtPlotGrid()
        grid_server.setPen(pen)
        grid_client.setPen(pen)
        grid_server.attach(self.gui.qwtPlotServer)
        grid_client.attach(self.gui.qwtPlotClient)

        #Signals
        self.connect(self.update_timer, QtCore.SIGNAL("timeout()"), self.probe_manager.watcher)
        self.connect(self.gui.pushButtonRunServer, QtCore.SIGNAL("clicked()"), self.start_fg_server)
        self.connect(self.gui.pushButtonStopServer, QtCore.SIGNAL("clicked()"), self.stop_fg_server)
        self.connect(self.gui.pushButtonRunClient, QtCore.SIGNAL("clicked()"), self.start_fg_client)
        self.connect(self.gui.pushButtonStopClient, QtCore.SIGNAL("clicked()"), self.stop_fg_client)
        self.connect(self.gui.pushButtonTwoArgs, QtCore.SIGNAL("clicked()"), self.send_two_arg_request)
        self.connect(self.gui.comboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.set_waveform)
        self.connect(self.gui.spinBox, QtCore.SIGNAL("valueChanged(int)"), self.set_gain)
        self.shortcut_start = QtGui.QShortcut(Qt.QKeySequence("Ctrl+S"), self.gui)
        self.shortcut_stop = QtGui.QShortcut(Qt.QKeySequence("Ctrl+C"), self.gui)
        self.shortcut_exit = QtGui.QShortcut(Qt.QKeySequence("Ctrl+D"), self.gui)
        self.connect(self.shortcut_exit, QtCore.SIGNAL("activated()"), self.gui.close)

        # start update timer
        self.update_timer.start(30)