コード例 #1
0
 def __init__(self):
     """Initialize member variables."""
     self.p = PAxis()
     self.z = ZAxis()
     self.y = YAxis()
     self.x = XAxis()
     self.prompt = Prompt(end='', flush=True)
コード例 #2
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)

        print('Running test routine...')
        await self.axis.wait_until_initialized()
        await self.axis.synchronize_values()
        self.axis.load_calibration_json()
        self.axis.load_discrete_json()
        print('Physical calibration:',
              self.axis.calibration_data['parameters'])

        print('Testing discrete position targeting...')
        relative_heights = ['above', 'top', 'high', 'mid', 'low', 'bottom']

        await self.axis.go_to_high_end_position()
        await self.prompt('Testing cuvette positioning: ')
        for height in relative_heights:
            print('Moving to {}...'.format(height))
            await self.axis.go_to_cuvette(height)
            await self.prompt('Press enter to continue: ')
            await self.axis.go_to_cuvette('far above')
        await self.axis.go_to_high_end_position()
        await self.prompt('Testing 96-well plate positioning: ')
        for height in relative_heights:
            print('Moving to {}...'.format(height))
            await self.axis.go_to_96_well_plate(height)
            await self.prompt('Press enter to continue: ')
            await self.axis.go_to_96_well_plate('far above')

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #3
0
async def acquire_images(camera):
    """Acquire a few images."""
    prompt = Prompt()
    await asyncio.sleep(2.0)
    await prompt('Press enter to capture an image: ')
    await camera.capture_image()
    await prompt('Press enter to capture another image: ')
    await camera.capture_image()
コード例 #4
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)

        print('Running test routine...')
        await self.axis.wait_until_initialized()
        await self.axis.synchronize_values()
        self.axis.load_calibration_json()
        self.axis.load_discrete_json()
        self.axis.load_pid_json()
        print('Physical calibration:',
              self.axis.calibration_data['parameters'])

        print('Testing physical position targeting...')
        positions = list(range(0, 910, 50))
        random.shuffle(positions)
        for position in positions:
            print('Moving to the {} mL mark...'.format(position / 1000))
            try:
                await self.axis.go_to_physical_position(position / 1000)
            except Exception as e:
                print(e)
            await asyncio.sleep(0.5)
            converged_position = await self.axis.physical_position
            print(
                'Converged at the {:.3f} mL mark!'.format(converged_position))
            await self.prompt('Press enter to continue: ')

        print('Testing physical position displacements...')
        await self.axis.go_to_low_end_position()
        await asyncio.sleep(0.5)
        for i in range(0, 18):
            print('Moving up by a 0.05 mL marking...')
            actual_displacement = await self.axis.move_by_physical_delta(0.05)
            print(
                'Moved up by {:.3f} mL markings!'.format(actual_displacement))
            await self.prompt('Press enter to continue: ')

        print('Testing precise volume intake/dispense...')
        await self.axis.go_to_low_end_position()
        await asyncio.sleep(0.5)
        for volume in [0.02, 0.03, 0.04, 0.05, 0.1]:
            print('Preparing for intake...')
            await self.axis.go_to_pre_intake(volume)
            await asyncio.sleep(1.0)
            print('Executing intake of {} mL...'.format(volume))
            actual_intake = await self.axis.intake(volume)
            print('Completed intake of {:.3f} mL!'.format(actual_intake))
            await asyncio.sleep(1.0)
            print('Executing dispense...')
            await self.axis.dispense()
            await self.prompt('Press enter to continue: ')

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #5
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)

        print('Running test routine...')
        await self.axis.wait_until_initialized()
        await self.axis.synchronize_values()
        self.axis.load_calibration_json()
        self.axis.load_discrete_json()
        print('Physical calibration:',
              self.axis.calibration_data['parameters'])

        print('Moving to alignment hole...')
        await self.axis.go_to_physical_position(0)
        await self.prompt('Press enter to continue: ')

        print('Testing physical position targeting...')
        positions = list(range(0, 100, 10))
        random.shuffle(positions)
        for position in positions:
            print('Moving to {} cm from the alignment hole...'.format(
                position / 10))
            try:
                await self.axis.go_to_physical_position(position / 10)
            except Exception as e:
                print(e)
            await asyncio.sleep(0.5)
            converged_position = await self.axis.physical_position
            print('Converged at {:.3f} cm!'.format(converged_position))
            await self.prompt('Press enter to continue: ')

        print('Testing physical position displacements...')
        await self.axis.go_to_low_end_position()
        await asyncio.sleep(0.5)
        for i in range(0, 10):
            print('Moving away from the alignment hole by 1 cm...')
            actual_displacement = await self.axis.move_by_physical_delta(1)
            print('Moved away {:.3f} cm!'.format(actual_displacement))
            await self.prompt('Press enter to continue: ')

        print('Testing discrete position targeting...')
        await self.axis.go_to_low_end_position()
        await self.prompt('Testing cuvette positioning: ')
        for cuvette_row in ['a', 'b', 'c', 'd', 'e', 'f', 'g']:
            await self.axis.go_to_cuvette(cuvette_row)
            await self.prompt('Press enter to continue: ')
        await self.prompt('Testing 96-well plate positioning: ')
        for plate_row in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']:
            await self.axis.go_to_96_well_plate(plate_row)
            await self.prompt('Press enter to continue: ')

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #6
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)

        print('Waiting for {} to initialize...'.format(self.protocol.channel_path))
        await self.protocol.initialized.wait()
        self.colors = {
            0: 'gray',  # braking
            -1: 'orange',  # stalled
            -2: 'green',  # converged
            -3: 'red',  # timer
        }

        print('Requesting all motor parameter values...')
        await self.protocol.motor.request_all()

        print('Requesting all feedback controller parameter values...')
        await self.protocol.feedback_controller.request_all()

        self.num_cycles = 5
        self.low_position = 100
        self.high_position = 700
        await self.set_test_parameters()
        await self.prompt('Press enter to begin: ')
        await self.dashboard.plotter.toggler.start_plotting()
        try:
            while True:
                for i in range(self.num_cycles):
                    await self.go_to_position(self.low_position)
                    await asyncio.sleep(0.5)
                    await self.go_to_position(self.high_position)
                    await asyncio.sleep(0.5)
                print('Finished test cycles!')
                self.dashboard.plotter.position_plotter.stop_plotting()
                self.dashboard.plotter.duty_plotter.stop_plotting()
                await self.set_test_parameters()
                await self.prompt('Press enter to restart: ')
                self.dashboard.plotter.position_plotter.clear()
                self.dashboard.plotter.duty_plotter.clear()
                if self.dashboard.plotter.toggler.plotting:
                    self.dashboard.plotter.position_plotter.start_plotting()
                    self.dashboard.plotter.duty_plotter.start_plotting()
        except KeyboardInterrupt:
            await self.dashboard.plotter.toggler.stop_plotting()

        print('Idling...')
        self.dashboard.plotter.server.run_until_shutdown()
コード例 #7
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)
        fluid_amount = 20

        print('Running test routine...')
        await asyncio.gather(self.p.initialized.wait(),
                             self.z.initialized.wait(),
                             self.y.initialized.wait())
        await self.p.motor.request_complete(-255)

        print('Moving to cuvette...')
        await self.y.feedback_controller.request_complete(720 - 30)
        print('  Y-Axis now at {}'.format(
            self.y.position.last_response_payload))

        while True:
            fluid_amount = await self.prompt.number(
                'Move sample platform to cuvette row. Amount to intake/dispense?',
                fluid_amount)
            print('Preparing pipettor for intake...')
            await self.p.feedback_controller.pid.kd.request(int(0.4 * 100))
            await self.p.feedback_controller.request_complete(
                1023 - int(650 + fluid_amount / 2))
            await asyncio.sleep(0.5)
            print('Performing intake...')
            await self.z.feedback_controller.request_complete(400)
            await asyncio.sleep(0.5)
            await self.intake(fluid_amount)
            await asyncio.sleep(0.5)
            await self.p.position.request()
            print('  Pre-dispense position: {}'.format(
                self.p.position.last_response_payload))
            await asyncio.sleep(0.5)
            await self.z.feedback_controller.request_complete(970)
            await self.prompt('Move sample platform to the weigh boat...')
            await self.z.feedback_controller.request_complete(200)
            await asyncio.sleep(0.5)
            await self.p.motor.request_complete(-255)
            await asyncio.sleep(0.5)
            await self.z.feedback_controller.request_complete(970)

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #8
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        self.prompt = Prompt(end='', flush=True)

        print('Waiting for axis initialization...')
        await self.axis.wait_until_initialized()
        print('Synchronizing axis values...')
        await self.axis.synchronize_values()

        calibration_samples = []
        print('Collecting calibration samples...')
        while True:
            sensor_position = await self.prompt.number(
                'Move to sensor position:',
                random.randint(*self.axis.last_position_limits))
            await self.axis.go_to_sensor_position(sensor_position)
            await asyncio.sleep(0.5)
            sensor_position = await self.axis.sensor_position
            print('Moved to sensor position {}.'.format(sensor_position))
            physical_position = await self.prompt.number(
                'What is the corresponding physical position? (None to finish)',
                None, float)
            if physical_position is None:
                break
            calibration_samples.append((sensor_position, physical_position))

        print('Performing linear regression with {} samples...'.format(
            len(calibration_samples)))
        for calibration_sample in calibration_samples:
            self.axis.add_calibration_sample(*calibration_sample)
        linear_regression = self.axis.fit_calibration_linear()
        print(
            'Linreg slope: {:.4f}; intercept: {:.4f}; R-value: {:.4f}; stderr: {:.4f}'
            .format(*linear_regression))

        output_path = await self.prompt.string(
            'Save calibration data to path:',
            'calibrations/{}_physical.json'.format(self.axis.name))
        self.axis.save_calibration_json(output_path)

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #9
0
    async def test_routine(self):
        """Run the batch execution test routine."""
        prompt = Prompt()

        print('Running test routine...')
        await asyncio.sleep(1.0)

        await prompt('Press enter to start blinking:')

        print('Blinking 5 times:')
        await self.protocol.blink.notify.request(1)
        await self.protocol.blink.low_interval.request(250)
        await self.protocol.blink.high_interval.request(250)
        await self.protocol.blink.request_complete(5)

        while True:
            blinks = await prompt('Enter the number of times to blink:')
            try:
                blinks = int(blinks)
                if blinks <= 0:
                    raise ValueError
                break
            except ValueError:
                print('Invalid input!')

        print('Blinking {} times:'.format(blinks))
        await self.protocol.blink.notify.request(1)
        await self.protocol.blink.request_complete(blinks)

        await self.protocol.blink.notify.request(0)
        asyncio.ensure_future(self.protocol.blink.request(1))
        await prompt(
            'Blinking indefinitely. Press enter to stop blinking, '
            'turn the LED on, and exit:'
        )
        await self.protocol.request(1)

        print(batch.OUTPUT_FOOTER)
        print('Quitting...')
コード例 #10
0
 async def wait_until_initialized(self):
     """Wait until the axis is ready to control."""
     self.prompt = Prompt(end='', flush=True)