예제 #1
0
def node_status():
    #    a = request.args.get('a', 0, type=int)
    #j = jsonify([ dict(addr=k) for k in app.nodes ])

    global client
    if client is None:
        client = RpcClient(
            dict([('' + str(i), k) for i, k in enumerate(app.nodes)]))

    # Make RPC requests for list_chunks and get_statistics asynchronously
    timeout = 5.

    ltokens = client.list_chunks(wait=False)
    stats = client.get_statistics(timeout=timeout)
    ch = client.wait_for_tokens(ltokens, timeout=timeout)
    ch = [msgpack.unpackb(p[0]) if p is not None else None for p in ch]

    # print('Chunks:')
    # for bch in ch:
    #     if bch is None:
    #         continue
    #     for b,f0,f1,w in bch:
    #         Nchunk = 1024 * 400
    #         print('  beam', b, 'chunk', f0/Nchunk, '+', (f1-f0)/Nchunk, 'from', w)

    #print('Stats[0]:', stats[0])

    stat = [
        dict(addr=k, status='ok', chunks=chi, stats=st)
        for k, chi, st in zip(app.nodes, ch, stats)
    ]
    j = json.dumps(stat)
    # print('JSON:', j)
    return j
예제 #2
0
    #data[:, i*50:i*50+100] = 200
    # in the frequency direction (where we have better counting)
    data[i * 50:i * 50 + 100, :] = 200
    ichunk = i + chunk0

    ch = simulate_l0.assembled_chunk(beam_id, fpga_counts_per_sample, ichunk,
                                     data, offset, scale, rfi)
    #print('Chunk:', ch)
    print('Sending chunk...')
    l0.send_chunk(0, ch)

    if i == 5:
        os.system(prom_cmd)

        print('After sending 5 chunks:')
        print(client.get_statistics())

        print('Sending write request...')
        res = client.write_chunks([0],
                                  0, (50 + 4) * 384 * 1024,
                                  'chunk-test-rfi-mask-(FPGA0).msgpack',
                                  need_rfi=need_rfi,
                                  waitAll=False)
        print('Got write request result:', res)
        reqs, token = res
        writereq = reqs[0]
        for c in writereq:
            print('  ', c)
        sleep(1)

    if writereq is not None: