Drop

The Drop class provides a convenient wrapper to encapsulate the state of a drop on the device, and to move it using up, down, left, right commands. It makes use of the move_drops API method to perform moves.

An example of using the Drop class to move a single drop:

from pdclient import PdClient
from pdclient.drop import Drop, Dir
client = PdClient('http://localhost:7000/rpc')
start_pos = [4, 8]
size = [2, 2]
drop = Drop(start_pos, size, client)

# Measure the sum of capacitance for all electrodes in the drop
cap = pdclient.bulk_capacitance()
drop_cap = sum([cap[pin] for pin in drop.pins()])

# Enable all electrodes in the drop
drop.activate()

# Move the drop
drop.move_up()

# Move the drop with enum argument
drop.move(Dir.LEFT)`

Drops can also be moved simultaneously, by passing several move commands to the move_drops method at once. In this case, the API method will return after all move operations are completed, and will return a separate result object for each indicating, e.g. if the move was successful. The pdclient.drop.move_multiple_drops function provides support for moving multiple Drop objects this way.

from pdclient import PdClient from pdclient.drop import Drop, Dir, move_multiple_drops

client = PdClient(’http://localhost:7000/rpc’) drop0 = Drop((0, 0), (2, 2), client) drop1 = Drop((5, 0), (2, 2), client)

results = move_multiple_drops((drop0, Dir.DOWN), (drop1, Dir.DOWN)) for i, r in enumerate(results):

if not r[‘success’]:
print(f”Drop {i} failed to move”)

API Reference

class pdclient.drop.Drop(pos: Sequence[int], size: Sequence[int], client: PdClient)[source]

Represents a drop on the electrode board

activate()[source]

Activate the electrodes for this drop

get_move_command(dir: Union[str, pdclient.drop.Dir], **kwargs) → pdclient.api_types.MoveCommand[source]

Returns a MoveCommand which can be passed to the move_drops method

Raises InvalidMoveException if the current or new drop position are not valid on the current electrode board. For example, if the move causes the drop to move off the electrode grid.

**kwargs are passed on to the MoveCommand, and can be used to set other move options, e.g. timeout, or threshold.

move(dir: Union[str, pdclient.drop.Dir], **kwargs)[source]

Move the drop one electrode in the given direction

If the move is successful, self.pos is updated to reflect the new position.

Parameters:dir – One of [Dir.UP, Dir.DOWN, dir.LEFT, dir.RIGHT], or (case-insensitive) strings [“up”, “down”, “left”, “right”]
Returns:The move_drop response object from the API
move_down(**kwargs)[source]

Move the drop one electrode down (i.e. y = y + 1)

move_left(**kwargs)[source]

Move the drop one electrode left (i.e. x = x - 1)

move_right(**kwargs)[source]

Move the drop one electrode right (i.e. x = x + 1)

move_up(**kwargs)[source]

Move the drop one electrode up (i.e. y = y - 1)

pins()[source]

Return all pins which are part of the drop