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:
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) >>> await 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
The file server thread.
The HTTP server.
The event loop.
The number of channels that the robot has.
The future that is set when the simulation is stopped.
The thread that runs the event loop.
The websocket connection.
Methods
__init__
([num_channels, simulate_delay, ...])Create a new simulation backend.
adjust_wells_liquids
(plate, liquids)Fill all wells in a plate with the same mix of liquids (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.
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 the robot for manual operation.
send_command
(command[, data, wait_for_response])Send an event to the browser.
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.
Called when a resource is unassigned from the robot.
Wait for a websocket connection to be established.