def make_pipette(mount, o): return pipettes.AttachedPipette( model=o.get('model'), name=o.get('name'), id=o.get('pipette_id'), mount_axis=str(Axis.by_mount(mount)).lower(), plunger_axis=str(Axis.of_plunger(mount)).lower(), tip_length=o.get('tip_length', 0) if o.get('model') else None)
def _key_by_uuid(self, new_pipettes: typing.Dict) -> typing.Dict: pipette_dict = {} for mount, data in new_pipettes.items(): token = uuid4() data['mount_axis'] = Axis.by_mount(mount) data['plunger_axis'] = Axis.of_plunger(mount) pipette_dict[token] = {**data} return pipette_dict
async def get_attached_pipettes(request): """ Query robot for model strings on 'left' and 'right' mounts, and return a dict with the results keyed by mount. By default, this endpoint provides cached values, which will not interrupt a running session. WARNING: if the caller supplies the "refresh=true" query parameter, this method will interrupt a sequence of Smoothie operations that are in progress, such as a protocol run. Example: ``` { 'left': { 'model': 'p300_single_v1', 'name': 'p300_single', 'tip_length': 51.7, 'mount_axis': 'z', 'plunger_axis': 'b', 'id': '<pipette id string>' }, 'right': { 'model': 'p10_multi_v1', 'name': 'p10_multi', 'tip_length': 40, 'mount_axis': 'a', 'plunger_axis': 'c', 'id': '<pipette id string>' } } ``` If a pipette is "uncommissioned" (e.g.: does not have a model string written to on-board memory), or if no pipette is present, the corresponding mount will report `'model': null` """ hw = hw_from_req(request) if request.url.query.get('refresh') == 'true': await hw.cache_instruments() response = {} attached = hw.attached_instruments for mount, data in attached.items(): response[mount.name.lower()] = { 'model': data.get('model', None), 'name': data.get('name', None), 'id': data.get('pipette_id', None), 'mount_axis': str(Axis.by_mount(mount)).lower(), 'plunger_axis': str(Axis.of_plunger(mount)).lower() } if data.get('model'): response[mount.name.lower()]['tip_length'] \ = data.get('tip_length', 0) return web.json_response(response, status=200)