From 8711d45ab6425a7318101db7c7ebf8ced67c4578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 3 Apr 2014 17:44:36 +0200 Subject: [PATCH] added staged stuff --- config_files/targets.config | 8 ++++---- ekgplotter/ekgplotter/main.py | 32 +++++++++++++------------------ sensors2osc/sensors2osc/common.py | 17 ++++++++-------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/config_files/targets.config b/config_files/targets.config index 4405876..575c46b 100644 --- a/config_files/targets.config +++ b/config_files/targets.config @@ -1,6 +1,6 @@ -host=tommy;port=8000;label=tommy-live -host=tommy;port=8001;label=tommy-max -host=lucas;port=8000;label=lucas -host=stefan;port=8000;label=stefan +host=lucas;port=8000;label=lucas-dump host=mario;port=8000;label=mario-resolume host=mario;port=8001;label=mario-max +host=stefan;port=8000;label=stefan-dump +host=tommy;port=8000;label=tommy-live +host=tommy;port=8001;label=tommy-max diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index 778700d..9dab294 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -165,10 +165,10 @@ class Actor(object): self.num_data = num_data #self.plotItem.setShadowPen(pen=Actor.shadowPen, width=3, cosmetic=True) self.plotPoint = pg.ScatterPlotItem(pen=Actor.shadowPen, brush=self.brush, size=5) - + def __str__(self): return "" % (self.name, self.active, self.data_pointer) - + __repr__ = __str__ def scale_data(self, ix, max_items): @@ -335,11 +335,6 @@ class EkgPlot(object): class MyHandler(BaseHTTPRequestHandler): - def __del__(self): - if hasattr(self, "thread"): - self.thread.running = False - self.thread.join() - def do_GET(self): try: @@ -352,23 +347,22 @@ class MyHandler(BaseHTTPRequestHandler): directory = os.path.dirname(os.path.abspath(__file__)) data = open(os.path.join(directory, self.path), "rb").read() self.send_response(200) - self.send_header('Content-type', 'text/html') + self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(data) elif self.path.endswith(".mjpeg"): self.thread = thread = OSCThread(self.server.args) thread.daemon = True thread.start() - - self.send_response(200) actor_names = ["bjoern", "merle", "uwe"] num_data = 100 colors = ["r", "g", "b"] qtapp = QtGui.QApplication([]) plotter = EkgPlot(actor_names, num_data, colors) - - self.wfile.write("Content-Type: multipart/x-mixed-replace; boundary=--aaboundary\r\n\r\n") + self.send_response(200) + self.send_header("Content-Type", "multipart/x-mixed-replace; boundary=--aaboundary") + self.end_headers() #lastTime = time.time() #fps = None event_loop = QtCore.QEventLoop() @@ -432,15 +426,15 @@ class JustAHTTPServer(HTTPServer): def main(): - arg_parser = create_arg_parser("ekgplotter") - own_group = add_main_group(arg_parser) - own_group.add_argument('-x', "--http_host", default="::", + arg_parser = ArgParser("ekgplotter") + own_group = arg_parser.add_main_group() + arg_parser.add_argument(own_group, '-x', "--http_host", default="::", help='my host, defaults to "::"') - own_group.add_argument('-X', "--http_port", default=9000, + arg_parser.add_argument(own_group, '-X', "--http_port", default=9000, type=int, help='my port, defaults to 9000') - add_chaosc_group(arg_parser) - add_subscriber_group(arg_parser, "ekgplotter") - args = finalize_arg_parser(arg_parser) + arg_parser.add_chaosc_group() + add_subscriber_group() + args = arg_parser.finalize() http_host, http_port = resolve_host(args.http_host, args.http_port, args.address_family) diff --git a/sensors2osc/sensors2osc/common.py b/sensors2osc/sensors2osc/common.py index 79dce84..c6d1ec0 100644 --- a/sensors2osc/sensors2osc/common.py +++ b/sensors2osc/sensors2osc/common.py @@ -26,7 +26,7 @@ import serial import socket import time -from chaosc.argparser_groups import create_arg_parser, finalize_arg_parser, add_chaosc_group +from chaosc.argparser_groups import ArgParser try: @@ -75,17 +75,18 @@ class Platform(object): def create_args(name): - arg_parser = create_arg_parser(name) + arg_parser = ArgParser(name) + arg_parser.add_global_group() main_group = arg_parser.add_argument_group("main") - main_group.add_argument("-d", '--device', required=True, + arg_parser.add_argument(main_group, "-D", '--device', required=True, type=str, help='device node under /dev') - main_group.add_argument("-a", '--actor', required=True, + arg_parser.add_argument(main_group, "-a", '--actor', required=True, type=str, help='actor name') - main_group.add_argument('-4', '--ipv4_only', action="store_true", - help='select ipv4 sockets, defaults tp ipv6"') - add_chaosc_group(arg_parser) + arg_parser.add_argument(main_group, '-b', '--baudrate', type=int, default=115200, choices=sorted(serial.baudrate_constants.keys()), + help='selects the baudrate, default=115200, for valid values execute "import serial;print sorted(serial.baudrate_constants.keys())"') + arg_parser.add_chaosc_group() - args = finalize_arg_parser(arg_parser) + args = arg_parser.finalize() return args