def test_transfer(): opentrons_connect() robot.home('xyzab') # calibrate stuff on the deck # tiprack = containers.load('tiprack-200ul', 'A1') # water = containers.load('point', 'A1', 'water') # plate_source = containers.load('96-flat', 'D1', 'plate') # plate_dest = containers.load('96-flat', 'D2', 'plate') p200 = instruments.Pipette(axis='b', max_volume=200) # given a slot, instantiate and calibrate a 96-well # p200.calibrate_plunger(top=12, bottom=20, blow_out=20, drop_tip=27) # p200.update_calibrations() wells = { 'A1': 'B1', 'A2': 'B2', 'A3': 'B3', } source = { 'labware': '96-flat', 'slot': 'C1', } dest = { 'labware': '96-flat', 'slot': 'B1', } transfer(p200, source, dest, wells, 100) robot.disconnect()
def singletons(virtual_smoothie_env): rb.reset() yield {'robot': rb, 'instruments': ins, 'labware': cns, 'modules': mods} rb.disconnect() rb.reset()
def web_transfer1(data): opentrons_connect() robot.home('xyzab') # calibrate pipette p200 = instruments.Pipette(axis='b', max_volume=200) p200.calibrate_plunger(top=3, bottom=18, blow_out=18, drop_tip=18) p200.update_calibrations() # calibrate labware tiprack = calibrateToSlot(labwareDict[data['tiprack']['labware']], 'tiprack', data['tiprack']['slot'], data['tiprack']['coords'], p200) source = calibrateToSlot(labwareDict[data['source']['labware']], 'source', data['source']['slot'], data['source']['coords'], p200) dest = calibrateToSlot(labwareDict[data['dest']['labware']], 'dest', data['dest']['slot'], data['dest']['coords'], p200) print("type labware", type(source)) # the actual transfer source_wells = data['source']['wells'] dest_wells = data['dest']['wells'] vol = data['parameters']['volume'] print("volume: ", vol) print("source", source_wells) print("dest", dest_wells) # make well dictionary wells = {} for source_well, dest_well in zip(source_wells, dest_wells): wells.update({source_well: dest_well}) print("wells", wells) print("starting transfers") p200.pick_up_tip(tiprack.wells('A1')) for key, value in wells.items(): p200.aspirate(vol, source.wells(key)) p200.dispense(dest.wells(value)) # robot.run() print("finished transfers") # somehow the opentrons transfer functions calls an error???!! # since demo is tomorrow, easier to make my own dumb transfer functionf or now # p200.transfer(vol, source.wells(source_wells), dest.wells(dest_wells)) print("transfer done!") robot.home('xyzab') robot.disconnect()
def disconnectRobot(): status = 'success' data = None robot = Robot.get_instance() try: robot.disconnect() emit_notifications(["Successfully disconnected"], 'info') except Exception as e: status = 'error' data = str(e) emit_notifications([data], 'danger') return flask.jsonify({'status': status, 'data': data})
def run(self): self.default_setup() while not self.stop.is_set(): if self.disconnect.is_set(): if robot.is_connected(): robot.disconnect() logging.debug('OT-2 robot disconnected') self.disconnect.clear() try: command = command_queue.get(block=True, timeout=0.01) missive = command['missive'] except Empty: continue with stdout_redirect() as out: try: print(missive) retval = eval(missive, self.global_context, self.local_context) if retval: print(retval) except SyntaxError: try: exec(missive, self.global_context, self.local_context) except Exception as E: print('EXEC Caught an "%s" exception: %s' % (type(E).__name__, str(E))) print(traceback.format_exc()) # pdb.post_mortem() except Exception as e: print('EVAL Caught an "%s" exception: %s' % (type(e).__name__, str(e))) print(traceback.format_exc()) # pdb.post_mortem() if len(out.getvalue()) > 0: command['missive'] = str(out.getvalue()) else: command['missive'] = 'ACK' response_queue.put(command) command_queue.task_done() if robot.is_connected(): robot.disconnect() logging.debug('OT-2 robot disconnected')
def connectRobot(): port = request.json.get('port') options = request.json.get('options', {'limit_switches': False}) status = 'success' data = None robot = Robot.get_instance() try: robot.connect(port, options=options) except Exception as e: # any robot version incompatibility will be caught here robot.disconnect() status = 'error' data = str(e) if "versions are incompatible" in data: data += ". To upgrade, go to docs.opentrons.com" emit_notifications([data], 'danger') return flask.jsonify({'status': status, 'data': data})
def web_transfer(source_data, dest_data, vol): opentrons_connect() robot.home('xyzab') p200 = instruments.Pipette(axis='b', max_volume=200) # "drop_tip": 18.01, # "top": 3.01, # "blow_out": 18.01, # "bottom": 18.01 p200.calibrate_plunger(top=3, bottom=18, blow_out=18, drop_tip=18) p200.update_calibrations() # make well dictionary wells = {} for source, dest in zip(source_data['wells'], dest_data['wells']): wells.update({source: dest}) print("protocols.py:", wells) transfer(p200, source_data, dest_data, wells, vol) print("robot homing") robot.home('xyzab') robot.disconnect()
def _simulate(self): self._reset() stack = [] res = [] commands = [] self._containers.clear() self._instruments.clear() self._modules.clear() self._interactions.clear() def on_command(message): payload = message['payload'] description = payload.get('text', '').format(**payload) if message['$'] == 'before': level = len(stack) stack.append(message) commands.append(payload) res.append({ 'level': level, 'description': description, 'id': len(res) }) else: stack.pop() unsubscribe = self._broker.subscribe(command_types.COMMAND, on_command) old_robot_connect = robot.connect try: # ensure actual pipettes are cached before driver is disconnected self._hardware.cache_instruments() if self._use_v2: instrs = {} for mount, pip in self._hardware.attached_instruments.items(): if pip: instrs[mount] = { 'model': pip['model'], 'id': pip.get('pipette_id', '') } sim = adapters.SynchronousAdapter.build( API.build_hardware_simulator, instrs, [mod.name() for mod in self._hardware.attached_modules], strict_attached_instruments=False) sim.home() self._simulating_ctx = ProtocolContext.build_using( self._protocol, loop=self._loop, hardware=sim, broker=self._broker, extra_labware=getattr(self._protocol, 'extra_labware', {})) run_protocol(self._protocol, context=self._simulating_ctx) else: robot.broker = self._broker # we don't rely on being connected anymore so make sure we are robot.connect() robot.cache_instrument_models() robot.disconnect() def robot_connect_error(port=None, options=None): raise RuntimeError( 'Protocols executed through the Opentrons App may not ' 'use robot.connect(). Allowing this call would cause ' 'the robot to execute commands during simulation, and ' 'then raise an error on execution.') robot.connect = robot_connect_error exec(self._protocol.contents, {}) finally: # physically attached pipettes are re-cached during robot.connect() # which is important, because during a simulation, the robot could # think that it holds a pipette model that it actually does not if not self._use_v2: robot.connect = old_robot_connect robot.connect() unsubscribe() instruments, containers, modules, interactions = _accumulate( [_get_labware(command) for command in commands]) self._containers.extend(_dedupe(containers)) self._instruments.extend( _dedupe( instruments + list(self._simulating_ctx.loaded_instruments.values()))) self._modules.extend( _dedupe(modules + [ m._geometry for m in self._simulating_ctx.loaded_modules.values() ])) self._interactions.extend(_dedupe(interactions)) # Labware calibration happens after simulation and before run, so # we have to clear the tips if they are left on after simulation # to ensure that the instruments are in the expected state at the # beginning of the labware calibration flow if not self._use_v2: robot.clear_tips() return res
total = 0 for val in readings: total += val ave = float(total / len(readings)) print("average out of 3:", ave) pipette.max_volume = ave print(pipette.max_volume) pipette.update_calibrations() if __name__ == '__main__': opentrons_connect() robot.home('xyzab') # calibrate stuff on the deck tiprack = containers.load('tiprack-200ul', 'A1') water = containers.load('point', 'A1', 'water') scale = containers.load('point', 'A1', 'scale') scale_screen = containers.load('point', 'A1', 'screen') p200 = instruments.Pipette(axis='b', max_volume=200) # p200.calibrate_plunger(top=12, bottom=27, blow_out=33, drop_tip=34) # p200.update_calibrations() # pick up tip pipcal.calibrate(p200, scale, water, tiprack) robot.disconnect()
def _simulate(self): self._reset() stack = [] res = [] commands = [] self._containers.clear() self._instruments.clear() self._modules.clear() self._interactions.clear() def on_command(message): payload = message['payload'] description = payload.get('text', '').format( **payload ) if message['$'] == 'before': level = len(stack) stack.append(message) commands.append(payload) res.append( { 'level': level, 'description': description, 'id': len(res)}) else: stack.pop() unsubscribe = subscribe(types.COMMAND, on_command) try: # ensure actual pipettes are cached before driver is disconnected robot.cache_instrument_models() # TODO (artyom, 20171005): this will go away # once robot / driver simulation flow is fixed robot.disconnect() if self._is_json_protocol: execute_protocol(self._protocol) else: exec(self._protocol, {}) finally: # physically attached pipettes are re-cached during robot.connect() # which is important, because during a simulation, the robot could # think that it holds a pipette model that it actually does not robot.connect() unsubscribe() instruments, containers, modules, interactions = _accumulate( [_get_labware(command) for command in commands]) self._containers.extend(_dedupe(containers)) self._instruments.extend(_dedupe(instruments)) self._modules.extend(_dedupe(modules)) self._interactions.extend(_dedupe(interactions)) return res