Permalink
Browse files

adding text_input and text_output msg blocks

  • Loading branch information...
1 parent d46b795 commit 7b12b79bc029d483ce71878960b24871ddbfd954 @osh committed Apr 15, 2014
Showing with 163 additions and 0 deletions.
  1. +2 −0 grc/CMakeLists.txt
  2. +26 −0 grc/text_input.xml
  3. +26 −0 grc/text_output.xml
  4. +2 −0 python/CMakeLists.txt
  5. +2 −0 python/__init__.py
  6. +49 −0 python/text_input.py
  7. +56 −0 python/text_output.py
View
@@ -26,5 +26,7 @@ install(FILES
cpsd_plot.xml
cpower_plot.xml
pdu_meta_extract.xml
+ text_input.xml
+ text_output.xml
DESTINATION share/gnuradio/grc/blocks
)
View
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<block>
+ <name>PyQT Text Input</name>
+ <key>pyqt_text_input</key>
+ <category>pyqt</category>
+ <import>import pyqt</import>
+ <make>#set $win = 'self._%s_win'%$id
+pyqt.text_input()
+self._$(id)_win = self.$(id);
+$(gui_hint()($win))
+</make>
+
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
View
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<block>
+ <name>PyQT Text Output</name>
+ <key>pyqt_text_output</key>
+ <category>pyqt</category>
+ <import>import pyqt</import>
+ <make>#set $win = 'self._%s_win'%$id
+pyqt.text_output()
+self._$(id)_win = self.$(id);
+$(gui_hint()($win))
+</make>
+
+ <param>
+ <name>GUI Hint</name>
+ <key>gui_hint</key>
+ <value></value>
+ <type>gui_hint</type>
+ <hide>part</hide>
+ </param>
+
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+</block>
@@ -40,6 +40,8 @@ GR_PYTHON_INSTALL(
cpower_plot.py
plotter_base.py
pdu_meta_extract.py
+ text_input.py
+ text_output.py
DESTINATION ${GR_PYTHON_DIR}/pyqt
)
View
@@ -56,6 +56,8 @@
from value_hist import *;
from cpower_plot import *;
from pdu_meta_extract import *;
+from text_input import *;
+from text_output import *;
# ----------------------------------------------------------------
# Tail of workaround
View
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 Tim O'Shea
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+import numpy
+from gnuradio import gr;
+from scipy import signal
+import pylab
+import numpy
+from PyQt4 import Qt, QtCore, QtGui
+import pmt
+
+class text_input(gr.sync_block, QtGui.QLineEdit):
+ def __init__(self, blkname="text_input", label="", *args):
+ gr.sync_block.__init__(self,blkname,[],[])
+ QtGui.QLineEdit.__init__(self, *args)
+ self.returnPressed.connect(self.text_changed);
+ self.message_port_register_out(pmt.intern("pdus"));
+
+ def text_changed(self):
+ s = self.text().toUtf8();
+ nvec = numpy.fromstring((s), dtype=numpy.uint8, count=len(s));
+ vec = pmt.to_pmt(nvec);
+ self.message_port_pub(pmt.intern("pdus"), pmt.cons(pmt.PMT_NIL, vec));
+ self.clear();
+
+ def work(self, input_items, output_items):
+ pass
+
+
+
+
View
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 Tim O'Shea
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+import numpy
+from gnuradio import gr;
+from scipy import signal
+import pylab
+import numpy
+from PyQt4 import Qt, QtCore, QtGui
+import pmt
+
+class text_output(gr.sync_block, QtGui.QTextEdit):
+ __pyqtSignals__ = ("updateText(int)")
+ def __init__(self, blkname="text_output", label="", *args):
+ gr.sync_block.__init__(self,blkname,[],[])
+ QtGui.QTextEdit.__init__(self, *args)
+ self.message_port_register_in(pmt.intern("pdus"));
+ self.set_msg_handler(pmt.intern("pdus"), self.handle_input);
+ # connect the plot callback signal
+ QtCore.QObject.connect(self,
+ QtCore.SIGNAL("updateText(int)"),
+ self.updateText)
+
+ def handle_input(self, msg):
+ vec = pmt.cdr(msg);
+ nvec = pmt.to_python(vec);
+ self.s = nvec.tostring();
+ self.emit(QtCore.SIGNAL("updateText(int)"), 0)
+
+ def updateText(self, a):
+ self.append(self.s);
+
+ def work(self, input_items, output_items):
+ pass
+
+
+
+

0 comments on commit 7b12b79

Please sign in to comment.