pylabrobot.liquid_handling.backends.simulation.SimulatorBackend#

class pylabrobot.liquid_handling.backends.simulation.SimulatorBackend(num_channels: int = 8, simulate_delay: bool = False, ws_host: str = '127.0.0.1', ws_port: int = 2121, fs_host: str = '127.0.0.1', fs_port: int = 1337, open_browser: bool = True)#

Bases: pylabrobot.liquid_handling.backends.websocket.WebSocketBackend

Based on the WebSocketBackend, the simulator backend can be used to simulate robot methods and inspect the results in a browser.

You can view the simulation at http://localhost:1337, where static/index.html will be served.

The websocket server will run at http://localhost:2121 by default. If a new browser page connects, it will replace the existing connection. All previously sent actions will be sent to the new page, with no simualated delay, to ensure that the state of the simulation remains the same. This also happens when a browser reloads the page or on the first page load.

Note that the simulator backend uses Resource ‘s to locate resources, where eg. STAR uses absolute coordinates.

Note

See Using the simulator for a more complete tutorial.

Examples

Running a simple simulation:

>>> import pyhamilton.liquid_handling.backends.simulation.simulation as simulation
>>> from pylabrobot.liquid_handling.liquid_handler import LiquidHandler
>>> sb = simulation.SimulatorBackend()
>>> lh = LiquidHandler(backend=sb)
>>> lh.setup()
INFO:websockets.server:server listening on 127.0.0.1:2121
INFO:pyhamilton.liquid_handling.backends.simulation.simulation:Simulation server started at
  http://127.0.0.1:2121
INFO:pyhamilton.liquid_handling.backends.simulation.simulation:File server started at
  http://127.0.0.1:1337
>>> lh.edit_tips(tips, pattern=[[True]*12]*8)
>>> lh.pick_up_tips(tips["A1:H1"])

Attributes

fst

The file server thread.

httpd

The HTTP server.

loop

The event loop.

num_channels

The number of channels that the robot has.

stop_

The future that is set when the simulation is stopped.

t

The thread that runs the event loop.

websocket

The websocket connection.

Methods

__init__([num_channels, simulate_delay, ...])

Create a new simulation backend.

adjust_well_volume(plate, pattern)

Fill a resource with liquid (simulator only).

aspirate(ops, use_channels)

Aspirate liquid from the specified resource using pip.

aspirate96(aspiration)

Aspirate from all wells in 96 well plate.

assigned_resource_callback(resource)

Called when a new resource was assigned to the robot.

clear_tips(tip_rack)

Completely clear a TipRack resource.

deserialize(data)

Deserialize the backend.

dispense(ops, use_channels)

Dispense liquid from the specified resource using pip.

dispense96(dispense)

Dispense to all wells in 96 well plate.

drop_tips(ops, use_channels)

Drop tips from the specified resource.

drop_tips96(drop)

Drop tips to the specified resource using CoRe 96.

edit_tips(tip_rack, pattern)

Place and/or remove tips on the robot (simulator only).

fill_tip_rack(resource)

Completely fill a TipRack resource with tips.

handle_event(event, data)

Handle an event from the browser.

has_connection()

Return True if a websocket connection has been established.

move_channel_x(channel, x)

Move the specified channel to the specified x coordinate.

move_channel_y(channel, y)

Move the specified channel to the specified y coordinate.

move_channel_z(channel, z)

Move the specified channel to the specified z coordinate.

move_resource(move, **backend_kwargs)

Move a resource to a new location.

pick_up_tips(ops, use_channels)

Pick up tips from the specified resource.

pick_up_tips96(pickup)

Pick up tips from the specified resource using CoRe 96.

prepare_for_manual_channel_operation()

Prepare the robot for manual operation.

send_command(command[, data, wait_for_response])

Send an event to the browser.

serialize()

Serialize the backend so that an equivalent backend can be created by passing the dict as kwargs to the initializer.

setup()

Setup the simulation.

stop()

Stop the simulation.

unassigned_resource_callback(name)

Called when a resource is unassigned from the robot.

wait_for_connection()

Wait for a websocket connection to be established.

Parameters
  • num_channels (int) –

  • simulate_delay (bool) –

  • ws_host (str) –

  • ws_port (int) –

  • fs_host (str) –

  • fs_port (int) –

  • open_browser (bool) –