pylabrobot.resources.ResourceStack

Contents

pylabrobot.resources.ResourceStack#

class pylabrobot.resources.ResourceStack(name: str, direction: str, resources: List[Resource] | None = None)#

Bases: Resource

ResourceStack represent a group of resources that are stacked together and act as a single unit. Stacks can grow be configured to be able to grow in x, y, or z direction. Stacks growing in the x direction are from left to right. Stacks growing in the y direction are from front to back. Stacks growing in the z direction are from bottom to top, and function as the stack data type <https://en.wikipedia.org/wiki/Stack_(abstract_data_type)>.

Variables:
  • name – The name of the resource group.

  • location – The location of the resource group. This will be the location of the first resource in the group.

  • category – The category of the resource group.

  • resources – The resources in the resource group.

Parameters:

Examples

Making a resource group containing a plate on top of a lid:

>>> stack = ResourceStack(“patched_plate”, "z", [
...   Resource("lid", size_x=1, size_y=1, size_z=20),
...   Resource("plate", size_x=1, size_y=1, size_z=10),
... ])
>>> stack.get_size_x()
1
>>> stack.get_size_z()
30

Moving a plate to the a stacking area.

>>> lh.move_plate(plate, stacking_area)

Moving a lid to the stacking area.

>>> lh.move_lid(plate.lid, stacking_area)

Getting a plate from the stacking area and moving it to a PlateCarrier.

>>> lh.move_plate(stacking_area.get_top_item(), plt_car[0])

Attributes

name

Get the name of this resource.

Methods

__init__(name, direction[, resources])

assign_child_resource(resource)

Assign a child resource to this resource.

center([x, y, z])

Get the center of this resource.

centers([xn, yn, zn])

Get equally spaced points in the x, y, and z directions.

copy()

deregister_did_assign_resource_callback(callback)

Remove a callback that will be called after a resource is assigned to this resource.

deregister_did_unassign_resource_callback(...)

Remove a callback that will be called after a resource is unassigned from this resource.

deregister_state_update_callback(callback)

Remove a callback that will be called when the state of the resource changes.

deregister_will_assign_resource_callback(...)

Remove a callback that will be called before a resource is assigned to this resource.

deregister_will_unassign_resource_callback(...)

Remove a callback that will be called before a resource is unassigned from this resource.

deserialize(data)

Deserialize a resource from a dictionary.

get_absolute_location([x, y, z])

Get the absolute location of this resource, probably within the pylabrobot.resources.Deck.

get_all_children()

Recursively get all children of this resource.

get_anchor(x, y, z)

Get a relative location within the resource.

get_resource(name)

Get a resource by name.

get_size_x()

get_size_y()

get_size_z()

Get the size of this resource in the z-direction.

get_top_item()

Get the top item in the stack.

load_all_state(state)

Load state for this resource and all children.

load_from_json_file(json_file)

Loads resources from a JSON file.

load_state(state)

Load state for this resource only.

load_state_from_file(fn)

Load the state of this resource and all children from a JSON file.

register_did_assign_resource_callback(callback)

Add a callback that will be called after a resource is assigned to this resource.

register_did_unassign_resource_callback(callback)

Add a callback that will be called after a resource is unassigned from this resource.

register_state_update_callback(callback)

Register a callback that will be called when the state of the resource changes.

register_will_assign_resource_callback(callback)

Add a callback that will be called before a resource is assigned to this resource.

register_will_unassign_resource_callback(...)

Add a callback that will be called before a resource is unassigned from this resource.

rotate(degrees)

Rotate counter clockwise by the given number of degrees.

rotated(degrees)

Return a copy of this resource rotated by the given number of degrees.

save(fn[, indent])

Save a resource to a JSON file.

save_state_to_file(fn[, indent])

Save the state of this resource and all children to a JSON file.

serialize()

Serialize this resource.

serialize_all_state()

Serialize the state of this resource and all children.

serialize_state()

Serialize the state of this resource only.

unassign()

Unassign this resource from its parent.

unassign_child_resource(resource)

Unassign a child resource from this resource.