Esempio n. 1
0
def acquire(config, xys, pos, image_bounds, dummy, coords_fname, measure=True):
    if image_bounds:
        for x, y, *z in pos:
            if not all([
                    image_bounds[0][0] > x > image_bounds[1][0],
                    image_bounds[0][1] < y < image_bounds[1][1]
            ]):
                print(x, y, [
                    image_bounds[0][0] > x > image_bounds[1][0],
                    image_bounds[0][1] < y < image_bounds[1][1]
                ])
                raise IOError('Pixel {} out of bounding box {}'.format(
                    (x, y), image_bounds))

    if not dummy:
        rc.save_coords(coords_fname, xys, pos, [], [])
        rc.initialise_and_login(config)
        try:
            rc.sendline('Begin')
            rc.expect("OK")
            try:
                for i, xyz in enumerate(pos):
                    # Turn off light after 100 scans
                    if i > 100:
                        rc.set_light(0)
                    rc.acquirePixel(xyz, measure=measure)
            except Exception as e:
                print(e)
                raise

            rc.flush_output_buffer(
                3
            )  # Wait before ending - it seems like a few commands get queued, and sending End immediately stops them
            rc.sendline("End")
        finally:
            # Turn off light after any acquisition
            rc.set_light(0)
            rc.close()
    else:
        try:
            for xyz in pos:
                rc.acquirePixel(xyz, dummy=True)
        except Exception as e:
            print(e)
            raise
    print('done')
Esempio n. 2
0
def set_light(config_fn, value):
    config = json.load(open(config_fn))
    rc.initialise_and_login(config)
    rc.set_light(value)
Esempio n. 3
0
def stop_telnet(config_fn):
    config = json.load(open(config_fn))
    rc.initialise_and_login(config)
    return rc.close(quit=True)
Esempio n. 4
0
def getpos(config_fn, log_fname=None, autofocus=True, reset_light_to=255):
    config = json.load(open(config_fn))
    rc.initialise_and_login(config)
    return rc.get_position(autofocus)