示例#1
0
def test_marketdata(production):
    """client account information -> setup GDAX connection and print data"""
    p_ids = ['BTC-USD']
    client_socket = ClientSocket(products=p_ids,
                                 auth=True,
                                 api_key=production['api_key'],
                                 api_secret=production['api_secret'],
                                 api_passphrase=production['api_pass'],
                                 channels=[
                                     "level2", "heartbeat", {
                                         "name": "ticker",
                                         "product_ids": p_ids
                                     }
                                 ])
    client_socket.start()
    print(client_socket.url, client_socket.products)

    try:
        while True:
            print("\nMessageCount =", "%i \n" % client_socket.msg_count)
            time.sleep(1)
    except KeyboardInterrupt:
        client_socket.close()

    if client_socket.error:
        sys.exit(1)
    else:
        sys.exit(0)
示例#2
0
if __name__ == '__main__':
    tornado.options.parse_command_line()
    app = tornado.web.Application(
        handlers=[
            (r"/", IndexHandler),
            (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': STATIC_ROOT}),
            (r"/ws", WebSocketHandler)
        ]
    )
    httpServer = tornado.httpserver.HTTPServer(app)
    httpServer.listen(options.port)
    print "Listening on port:", options.port

    mainLoop = tornado.ioloop.IOLoop.instance()
    # adjust the scheduler_interval according to the frames sent by the serial port
    scheduler = tornado.ioloop.PeriodicCallback(checkQueue, 100, io_loop=mainLoop)
    camera_scheduler = tornado.ioloop.PeriodicCallback(checkVideoCapture, 10, io_loop=mainLoop)
    comm_scheduler = tornado.ioloop.PeriodicCallback(checkCommSocket, 10, io_loop=mainLoop)

    # sp = serialworker.SerialProcess(input_queue, output_queue, options.serial)
    # sp.daemon = True

    comm_socket.daemon = True

    # sp.start()
    comm_socket.start()
    scheduler.start()
    camera_scheduler.start()
    comm_scheduler.start()
    mainLoop.start()
示例#3
0
                                             tornado.web.StaticFileHandler, {
                                                 'path': STATIC_ROOT
                                             }), (r"/ws", WebSocketHandler)])
    httpServer = tornado.httpserver.HTTPServer(app)
    httpServer.listen(options.port)
    print "Listening on port:", options.port

    mainLoop = tornado.ioloop.IOLoop.instance()
    # adjust the scheduler_interval according to the frames sent by the serial port
    scheduler = tornado.ioloop.PeriodicCallback(checkQueue,
                                                100,
                                                io_loop=mainLoop)
    camera_scheduler = tornado.ioloop.PeriodicCallback(checkVideoCapture,
                                                       10,
                                                       io_loop=mainLoop)
    comm_scheduler = tornado.ioloop.PeriodicCallback(checkCommSocket,
                                                     10,
                                                     io_loop=mainLoop)

    # sp = serialworker.SerialProcess(input_queue, output_queue, options.serial)
    # sp.daemon = True

    comm_socket.daemon = True

    # sp.start()
    comm_socket.start()
    scheduler.start()
    camera_scheduler.start()
    comm_scheduler.start()
    mainLoop.start()
示例#4
0
    print("Rec'd: " + msg)
    if msg.find('quit') >= 0:
        print("Setting done == True")
        done = True

if __name__ == '__main__':
    global done
    parser = argparse.ArgumentParser(description='Client Socket class - Tester')
    parser.add_argument("port", type=int, help='Port on localhost to use')
    args = parser.parse_args()

    port = args.port if args.port else 12888

    c = ClientSocket('test', ('127.0.0.1', port), '')
    c.setCallback(test_callback_func)
    c.start()
    time.sleep(0.5)  # sleep a bit to allow reply

    start_ts = time.time()
    cnt = 0
    total_loops = 1000
    while not done:
        cnt = cnt+1 if cnt < total_loops else 1
        loop_update = {
            'LocX_mm': '%3.3f' % (randint(0, 500)+random()),
            'LocY_mm': '%3.3f' % (randint(0, 50)+random()),
            'Loop Count': str(cnt),
            'Run Mode': 'Recipe',
            'StageMoving': True,
            'Total Loops': str(total_loops),
            'Elapsed Time': '%5.3f' % (time.time() - start_ts),