Exemple #1
0
def _migrate_container(container_name):
    print('migrating {} from json to database'.format(container_name))
    container = get_persisted_container(container_name)
    container = rotate_container_for_alpha(container)
    print("CONTAINER: {}, {}".format(container_name, container._coordinates))

    database.save_new_container(container, container_name)
Exemple #2
0
def _setup_container(container_name):
    try:
        container = database.load_container(container_name)

    # Database.load_container throws ValueError when a container name is not
    # found.
    except ValueError:
        # First must populate "get persisted container" list
        old_container_loading.load_all_containers_from_disk()
        # Load container from old json file
        container = old_container_loading.get_persisted_container(
            container_name)
        # Rotate coordinates to fit the new deck map
        rotated_container = database_migration.rotate_container_for_alpha(
            container)
        # Save to the new database
        database.save_new_container(rotated_container, container_name)

    container.properties['type'] = container_name
    container_x, container_y, container_z = container._coordinates

    if not fflags.split_labware_definitions():
        # infer z from height
        if container_z == 0 and 'height' in container[0].properties:
            container_z = container[0].properties['height']

    from opentrons.util.vector import Vector
    container._coordinates = Vector(container_x, container_y, container_z)

    return container
Exemple #3
0
def calibrate_container_with_delta(pose_tree,
                                   container,
                                   delta_x,
                                   delta_y,
                                   delta_z,
                                   save,
                                   new_container_name=None):

    delta = Point(delta_x, delta_y, delta_z)

    new_coordinates = change_base(
        pose_tree, src=container, dst=container.parent) + delta

    pose_tree = update(pose_tree, container, new_coordinates)

    if ff.split_labware_definitions():
        for well in container.wells():
            well._coordinates = well._coordinates + delta
    else:
        container._coordinates = container._coordinates + delta

    if save and new_container_name:
        database.save_new_container(container, new_container_name)
    elif save:
        database.overwrite_container(container)
    return pose_tree
Exemple #4
0
def _load_weird_container(container_name):
    """ Load a container from persisted containers, whatever that is """
    # First must populate "get persisted container" list
    old_container_loading.load_all_containers_from_disk()
    # Load container from old json file
    container = old_container_loading.get_persisted_container(container_name)
    # Rotate coordinates to fit the new deck map
    rotated_container = database_migration.rotate_container_for_alpha(
        container)
    # Save to the new database
    database.save_new_container(rotated_container, container_name)
    return container
Exemple #5
0
def migrate_containers_and_wells():
    print("Loading json containers...")
    load_all_containers_from_disk()
    print("Json container file load complete.")
    print("Starting migration...")
    for container_name in list_container_names():
        print('migrating {} from json to database'.format(container_name))
        container = get_persisted_container(container_name)

        container = rotate_container_for_alpha(container)
        print("CONTAINER: {}, {}".format(container_name,
                                         container._coordinates))

        database.save_new_container(container, container_name)
    print("Database migration complete!")
Exemple #6
0
    def _calibrate_container_with_delta(pose_tree,
                                        container,
                                        delta_x,
                                        delta_y,
                                        delta_z,
                                        save,
                                        new_container_name=None):

        delta = pose_tracker.Point(delta_x, delta_y, delta_z)

        # Note: pose tree is updated here, in order to update in-memory state.
        # Separately from that, on-disk state is updated. This is a point of
        # possible dis-unity. Would probably work better to un-load the labware
        # after calibration, and then reload it (would have to figure out where
        # in the call-stack this could be done without raising exceptions due
        # to trying to access old references).

        # Have to update all of the things in the pose tree that have the same
        # load name, otherwise you end up getting the calibration values
        # added together in the on-disk representation
        target_name = container.get_name()
        matching_entries = [
            x for x in list(pose_tree.keys())
            if type(x) == Container and x.get_name() == target_name
        ]
        for entry in matching_entries:
            old_coordinates = pose_tracker.change_base(pose_tree,
                                                       src=entry,
                                                       dst=entry.parent)
            new_coordinates = old_coordinates + delta

            pose_tree = pose_tracker.update(pose_tree, entry, new_coordinates)
            entry._coordinates = entry._coordinates + delta

        if save and container.properties.get('labware_hash'):
            save_new_offsets(container.properties['labware_hash'], delta,
                             container.properties['definition'])
        elif save and new_container_name:
            database.save_new_container(container, new_container_name)
        elif save:
            database.overwrite_container(container)
        return pose_tree
Exemple #7
0
def create(name, grid, spacing, diameter, depth, volume=0):
    """
    Creates a labware definition based on a rectangular gird, depth, diameter,
    and spacing. Note that this function can only create labware with regularly
    spaced wells in a rectangular format, of equal height, depth, and radius.
    Irregular labware defintions will have to be made in other ways or modified
    using a regular definition as a starting point. Also, upon creation a
    definition always has its lower-left well at (0, 0, 0), such that this
    labware _must_ be calibrated before use.

    :param name: the name of the labware to be used with `labware.load`
    :param grid: a 2-tuple of integers representing (<n_columns>, <n_rows>)
    :param spacing: a 2-tuple of floats representing
        (<col_spacing, <row_spacing)
    :param diameter: a float representing the internal diameter of each well
    :param depth: a float representing the distance from the top of each well
        to the internal bottom of the same well
    :param volume: [optional] the maximum volume of each well
    :return: the labware object created by this function
    """
    columns, rows = grid
    col_spacing, row_spacing = spacing
    custom_container = Container()
    properties = {
        'type': 'custom',
        'diameter': diameter,
        'height': depth,
        'total-liquid-volume': volume
    }

    for r in range(rows):
        for c in range(columns):
            well = Well(properties=properties)
            well_name = chr(r + ord('A')) + str(1 + c)
            coordinates = (c * col_spacing, (rows - r - 1) * row_spacing, 0)
            custom_container.add(well, well_name, coordinates)
    database.save_new_container(custom_container, name)
    return database.load_container(name)
Exemple #8
0
    def _calibrate_container_with_delta(pose_tree,
                                        container,
                                        delta_x,
                                        delta_y,
                                        delta_z,
                                        save,
                                        new_container_name=None):

        delta = pose_tracker.Point(delta_x, delta_y, delta_z)

        new_coordinates = pose_tracker.change_base(
            pose_tree, src=container, dst=container.parent) + delta

        pose_tree = pose_tracker.update(pose_tree, container, new_coordinates)
        container._coordinates = container._coordinates + delta

        if save and container.properties.get('labware_hash'):
            save_new_offsets(container.properties['labware_hash'], delta)
        elif save and new_container_name:
            database.save_new_container(container, new_container_name)
        elif save:
            database.overwrite_container(container)
        return pose_tree