foo and bar and tried to change dump window size

This commit is contained in:
Lucas Pleß 2014-12-03 19:50:56 +01:00
parent 39ae53f598
commit 6486a586e0
8 changed files with 81 additions and 51 deletions

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>811</width>
<height>606</height>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="font">
<font>
<family>Monospace</family>
<pointsize>14</pointsize>
<pointsize>12</pointsize>
<italic>true</italic>
</font>
</property>
@ -28,8 +28,8 @@
<widget class="QGraphicsView" name="graphics_view">
<property name="minimumSize">
<size>
<width>785</width>
<height>580</height>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="palette">

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'dump_grabber.ui'
#
# Created: Wed Dec 3 17:45:11 2014
# Created: Wed Dec 3 19:47:52 2014
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
@ -26,10 +26,10 @@ except AttributeError:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(811, 606)
MainWindow.resize(640, 480)
font = QtGui.QFont()
font.setFamily(_fromUtf8("Monospace"))
font.setPointSize(14)
font.setPointSize(12)
font.setItalic(True)
MainWindow.setFont(font)
self.centralwidget = QtGui.QWidget(MainWindow)
@ -39,7 +39,7 @@ class Ui_MainWindow(object):
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.graphics_view = QtGui.QGraphicsView(self.centralwidget)
self.graphics_view.setMinimumSize(QtCore.QSize(785, 580))
self.graphics_view.setMinimumSize(QtCore.QSize(640, 480))
palette = QtGui.QPalette()
brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
brush.setStyle(QtCore.Qt.SolidPattern)

View File

@ -58,13 +58,13 @@ class ExclusiveTextStorage(object):
self.column_width = column_width
self.line_height = line_height
self.graphics_scene = scene
self.num_lines, self.offset = divmod(576, self.line_height)
self.num_lines, self.offset = divmod(480, self.line_height)
self.data = deque()
def init_columns(self):
color = self.colors[0]
for line_index in range(self.num_lines):
text_item = self.graphics_scene.addSimpleText("", self.default_font)
text_item = self.graphics_scene.addSimpleText("fooooo", self.default_font)
text_item.setBrush(color)
text_item.setPos(0, line_index * self.line_height)
self.lines.append(text_item)
@ -89,8 +89,7 @@ class ExclusiveTextStorage(object):
self.data.append((column, text))
class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
MjpegStreamingConsumerInterface, PsyQtChaoscClientBase):
class MainWindow(QtGui.QMainWindow, Ui_MainWindow, PsyQtChaoscClientBase):
"""This app receives per actor osc messages and provides an mjpeg stream
with colored text representation arranged in columns"""
@ -99,9 +98,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
self.args = args
super(MainWindow, self).__init__()
self.setupUi(self)
self.http_server = MjpegStreamingServer(
(args.http_host, args.http_port), self)
self.http_server.listen(port=args.http_port)
self.graphics_view.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.graphics_view.setVerticalScrollBarPolicy(
@ -109,33 +106,32 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
self.graphics_view.setRenderHint(QtGui.QPainter.Antialiasing, True)
self.graphics_view.setFrameStyle(QtGui.QFrame.NoFrame)
self.graphics_scene = QtGui.QGraphicsScene(self)
self.graphics_scene.setSceneRect(0, 0, 775, 580)
self.graphics_scene.setSceneRect(0, 0, 640, 480)
self.graphics_view.setScene(self.graphics_scene)
self.default_font = QtGui.QFont("Monospace", 14)
self.default_font = QtGui.QFont("Monospace", 12)
self.default_font.setStyleHint(QtGui.QFont.Monospace)
self.default_font.setBold(True)
self.graphics_scene.setFont(self.default_font)
self.font_metrics = QtGui.QFontMetrics(self.default_font)
self.line_height = self.font_metrics.height()
columns = 3
self.column_width = 775 / columns
self.column_width = 640 / columns
self.text_storage = ExclusiveTextStorage(columns, self.default_font,
self.column_width,
self.line_height,
self.graphics_scene)
self.text_storage.init_columns()
self.regex = re.compile("^/(uwe|merle|bjoern)/(.*?)$")
self.osc_sock.readyRead.connect(self.got_message)
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.render_image)
self.timer.start(100)
def pubdir(self):
return os.path.dirname(os.path.abspath(__file__))
def closeEvent(self, event):
msg = OSCMessage("/unsubscribe")
msg.appendTypedArg("localhost", "s")
msg.appendTypedArg(self.args.client_port, "i")
msg.appendTypedArg(self.args.authenticate, "s")
self.osc_sock.writeDatagram(
QByteArray(msg.encode_osc()), QHostAddress("127.0.0.1"), 7110)
self.unsubscribe()
def handle_osc_error(self, error):
logger.info("osc socket error %d", error)
@ -144,24 +140,31 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
self.text_storage.add_text(column, text)
def render_image(self):
#print "render_iamge"
self.text_storage.finish()
image = QPixmap(768, 576)
image.fill(QtCore.Qt.black)
painter = QPainter(image)
painter.setRenderHints(QPainter.RenderHint(
QPainter.Antialiasing | QPainter.TextAntialiasing), True)
painter.setFont(self.default_font)
self.graphics_view.render(
painter, target=QtCore.QRectF(0, 0, 768, 576),
source=QtCore.QRect(0, 0, 768, 576))
painter.end()
buf = QBuffer()
buf.open(QIODevice.WriteOnly)
image.save(buf, "JPG", 100)
image_data = buf.data()
return image_data
#image = QPixmap(768, 576)
#image.fill(QtCore.Qt.black)
#painter = QPainter(image)
#painter.setRenderHints(QPainter.RenderHint(
# QPainter.Antialiasing | QPainter.TextAntialiasing), True)
#painter.setFont(self.default_font)
#self.graphics_view.render(
# painter, target=QtCore.QRectF(0, 0, 768, 576),
# source=QtCore.QRect(0, 0, 768, 576))
#painter.end()
#buf = QBuffer()
#buf.open(QIODevice.WriteOnly)
#image.save(buf, "JPG", 100)
#image_data = buf.data()
#return image_data
def got_message(self):
def convert(value):
if isinstance(value, float):
return "%.1f" % value
else:
return str(value)
while self.osc_sock.hasPendingDatagrams():
data, address, port = self.osc_sock.readDatagram(
self.osc_sock.pendingDatagramSize())
@ -176,13 +179,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow,
else:
if actor == "merle":
self.add_text(0, "%s = %s" % (
text, ", ".join([str(i) for i in args])))
text, ", ".join([convert(i) for i in args])))
elif actor == "uwe":
self.add_text(1, "%s = %s" % (
text, ", ".join([str(i) for i in args])))
text, ", ".join([convert(i) for i in args])))
elif actor == "bjoern":
self.add_text(2, "%s = %s" % (
text, ", ".join([str(i) for i in args])))
text, ", ".join([convert(i) for i in args])))
return True
@ -198,12 +201,13 @@ def main():
arg_parser.add_subscriber_group()
args = arg_parser.finalize()
args.http_host, args.http_port = resolve_host(
args.http_host, args.http_port, args.address_family)
args.chaosc_host, args.chaosc_port = resolve_host(
args.chaosc_host, args.chaosc_port, args.address_family)
#args.http_host, args.http_port = resolve_host(
# args.http_host, args.http_port, args.address_family)
#args.chaosc_host, args.chaosc_port = resolve_host(
# args.chaosc_host, args.chaosc_port, args.address_family)
window = MainWindow(args)
window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
window.show()
sys.excepthook = window.sigint_handler
signal.signal(signal.SIGTERM, window.sigterm_handler)

View File

@ -118,7 +118,7 @@ class EkgPlotWidget(QMainWindow):
self.max_actors = len(actor_names)
self.actor_height = self.max_value / self.max_actors
self.fps = 12.5
self.num_data = 640
self.num_data = 100
self.plot_widget.showGrid(False, False)
self.plot_widget.setYRange(0, 255)
self.plot_widget.setXRange(0, self.num_data)
@ -196,7 +196,7 @@ class EkgPlotWidget(QMainWindow):
actor_name = res.group(1)
actor_obj = self.actors[actor_name]
actor_obj.add_value(args[0])
# logger.info("actor: %r, %r", actor_name, args)
logger.info("actor: %r, %r", actor_name, args)
def render_image(self):
for actor_obj in self.active_actors:
@ -212,6 +212,7 @@ class EkgPlotWidget(QMainWindow):
def got_message(self):
while self.osc_sock.hasPendingDatagrams():
data, address, port = self.osc_sock.readDatagram(self.osc_sock.pendingDatagramSize())
print data,address,port
try:
osc_address, typetags, args = decode_osc(data, 0, len(data))
self.update(osc_address, args)
@ -234,6 +235,7 @@ def main():
args.chaosc_host, args.chaosc_port = resolve_host(args.chaosc_host, args.chaosc_port, args.address_family)
window = EkgPlotWidget(args)
window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
logger.info("foooooooo")
window.setWindowTitle("EKGPlotterMain")
window.show()

9
fensterkram/datenstrom.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
dump_grabber -H 192.168.1.23 -P 7110 -s -o 192.168.1.34 -p 6001 -L -4
#dump_grabber -H chaosc -P 7110 -s -o 192.168.1.34 -p 6001 -L -4
#vlc --no-audio --video-on-top --no-video-title-show --no-osd \
# --repeat --qt-notification 0 --no-video-deco --autoscale \
# http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

7
fensterkram/ekgplotter.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
ekgplotter -o 192.168.1.34 -p 6002 -L
#vlc --no-audio --video-on-top --no-video-title-show --no-osd \
# --repeat --qt-notification 0 --no-video-deco --autoscale \
# http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

7
fensterkram/vlc_texter.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
vlc --no-audio --video-on-top --no-video-title-show --no-osd \
--repeat --qt-notification 0 --no-video-deco --autoscale \
http://walterebert.com/playground/video/hls/sintel-trailer.m3u8

View File

@ -84,7 +84,8 @@ class PsyQtChaoscClientBase(PsyQtClientBase):
def subscribe(self):
logger.info("subscribe")
msg = OSCMessage("/subscribe")
msg.appendTypedArg("localhost", "s")
logger.info(self.args.client_host)
msg.appendTypedArg(self.args.client_host, "s")
msg.appendTypedArg(self.args.client_port, "i")
msg.appendTypedArg(self.args.authenticate, "s")
if self.args.subscriber_label is not None:
@ -94,7 +95,7 @@ class PsyQtChaoscClientBase(PsyQtClientBase):
def unsubscribe(self):
logger.info("unsubscribe")
msg = OSCMessage("/unsubscribe")
msg.appendTypedArg("localhost", "s")
msg.appendTypedArg(self.args.client_host, "s")
msg.appendTypedArg(self.args.client_port, "i")
msg.appendTypedArg(self.args.authenticate, "s")
self.osc_sock.writeDatagram(QByteArray(msg.encode_osc()), QHostAddress(self.args.chaosc_host), self.args.chaosc_port)