def test_given_an_xy_movement_na_xy_path_should_be_created(self):
        samples_per_second = 11
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        expected = numpy.array([[0.0, 0.0], [0.25, 0.25], [0.5, 0.5], [0.75, 0.75], [1.0, 1.0]])

        actual = path2audio.process([0.0, 0.0, 1.0], [1.0, 1.0, 1.0], 3.0)
        self.assertNumpyArrayEquals(expected, actual)
    def test_given_an_non_zero_origin(self):
        samples_per_second = 11
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        expected = numpy.array([[1.0, 1.0], [0.75, 0.75], [0.5, 0.5], [0.25, 0.25], [0.0, 0.0]])

        actual = path2audio.process([1.0, 1.0, 1.0], [0.0, 0.0, 1.0], 3.0)
        self.assertNumpyArrayClose(expected, actual)
    def test_given_a_command_with_no_change_assume_movment_and_time_equal_to_laser_width(self):
        samples_per_second = 4
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        expected = numpy.array([[0.0, 0.0], [0.0, 0.0]])

        actual = path2audio.process([0.0, 0.0, 1.0], [0.0, 0.0, 1.0], 1.0)
        self.assertNumpyArrayClose(expected, actual)
    def test_can_change_transformer(self):
        samples_per_second = 4
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        path2audio.set_transformer(TuningTransformer())
        expected = numpy.array([[1.0, 1.0], [1.0, 1.0]])

        actual = path2audio.process([1.0, 1.0, 1.0], [1.0, 1.0, 1.0], 1.0)
        self.assertNumpyArrayClose(expected, actual)
Пример #5
0
    def test_can_change_transformer(self):
        samples_per_second = 4
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        path2audio.set_transformer(TuningTransformer())
        expected = numpy.array([[1.0, 1.0], [1.0, 1.0]])

        actual = path2audio.process([1.0, 1.0, 1.0], [1.0, 1.0, 1.0], 1.0)
        self.assertNumpyArrayClose(expected, actual)
Пример #6
0
    def test_given_a_command_with_no_change_assume_movment_and_time_equal_to_laser_width(
            self):
        samples_per_second = 4
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        expected = numpy.array([[0.0, 0.0], [0.0, 0.0]])

        actual = path2audio.process([0.0, 0.0, 1.0], [0.0, 0.0, 1.0], 1.0)
        self.assertNumpyArrayClose(expected, actual)
Пример #7
0
    def test_given_an_non_zero_origin(self):
        samples_per_second = 11
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        expected = numpy.array([[1.0, 1.0], [0.75, 0.75], [0.5, 0.5],
                                [0.25, 0.25], [0.0, 0.0]])

        actual = path2audio.process([1.0, 1.0, 1.0], [0.0, 0.0, 1.0], 3.0)
        self.assertNumpyArrayClose(expected, actual)
Пример #8
0
    def test_given_an_xy_movement_na_xy_path_should_be_created(self):
        samples_per_second = 11
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        expected = numpy.array([[0.0, 0.0], [0.25, 0.25], [0.5, 0.5],
                                [0.75, 0.75], [1.0, 1.0]])

        actual = path2audio.process([0.0, 0.0, 1.0], [1.0, 1.0, 1.0], 3.0)
        self.assertNumpyArrayEquals(expected, actual)
    def test_in_the_event_of_a_distance_smaller_then_a_sample_the_vertex_time_should_not_be_skiped(self):
        samples_per_second = 10
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        expected1 = numpy.empty((0, 2))
        expected2 = numpy.array([[0.0, 0.0], [1.0, 1.0]])

        actual1 = path2audio.process([0.0, 0.0, 1.0], [0.0, 1.0, 1.0], 10.0)
        actual2 = path2audio.process([0.0, 1.0, 1.0], [1.0, 1.0, 1.0], 10.0)

        self.assertNumpyArrayEquals(expected1, actual1)
        self.assertNumpyArrayEquals(expected2, actual2)
Пример #10
0
    def test_when_handling_subone_sample_data_vertical_changes_cause_reset(self):
        samples_per_second = 10
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer, laser_size)
        expected1 = numpy.empty((0, 2))
        expected2 = numpy.array([[0.0, 1.0], [1.0, 1.0]])

        actual1 = path2audio.process([0.0, 0.0, 1.0], [0.0, 1.0, 1.0], 10.0)
        actual2 = path2audio.process([0.0, 1.0, 1.1], [1.0, 1.0, 1.1], 5.0)

        self.assertNumpyArrayEquals(expected1, actual1)
        self.assertNumpyArrayEquals(expected2, actual2)
Пример #11
0
    def test_when_handling_subone_sample_data_vertical_changes_cause_reset(
            self):
        samples_per_second = 10
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        expected1 = numpy.empty((0, 2))
        expected2 = numpy.array([[0.0, 1.0], [1.0, 1.0]])

        actual1 = path2audio.process([0.0, 0.0, 1.0], [0.0, 1.0, 1.0], 10.0)
        actual2 = path2audio.process([0.0, 1.0, 1.1], [1.0, 1.0, 1.1], 5.0)

        self.assertNumpyArrayEquals(expected1, actual1)
        self.assertNumpyArrayEquals(expected2, actual2)
Пример #12
0
    def test_in_the_event_of_a_distance_smaller_then_a_sample_the_vertex_time_should_not_be_skiped(
            self):
        samples_per_second = 10
        laser_size = 0.5
        path2audio = PathToPoints(samples_per_second, self.transformer,
                                  laser_size)
        expected1 = numpy.empty((0, 2))
        expected2 = numpy.array([[0.0, 0.0], [1.0, 1.0]])

        actual1 = path2audio.process([0.0, 0.0, 1.0], [0.0, 1.0, 1.0], 10.0)
        actual2 = path2audio.process([0.0, 1.0, 1.0], [1.0, 1.0, 1.0], 10.0)

        self.assertNumpyArrayEquals(expected1, actual1)
        self.assertNumpyArrayEquals(expected2, actual2)
Пример #13
0
class CalibrationAPI(object):
    def __init__(self, configuration_manager):
        logger.info("Calibartion API Startup")
        self._configuration_manager = configuration_manager
        self._configuration = self._configuration_manager.load()

        self._point_generator = SinglePointGenerator()
        self._blink_generator = BlinkGenerator()
        self._orientaiton_generator = OrientationGenerator()
        self._alignment_generator = CalibrationLineGenerator()
        self._scale_generator = ScaleGenerator(speed=2.0, radius=1.0)

        self._test_patterns = {
            'Hilbert Space Filling Curve': HilbertGenerator(),
            'Square': SquareGenerator(),
            'Circle': CircleGenerator(),
            'Spiral': SpiralGenerator(),
            'Memory Hourglass': MemoryHourglassGenerator(),
            'Damping Test': DampingTestGenerator(),
            'NESW': NESWGenerator(),
            'Twitch': TwitchGenerator(),
            }

        self._current_generator = self._point_generator

        self._laser_control = LaserControl(self._configuration.cure_rate.override_laser_power_amount)
        transformer = TuningTransformer(scale=self._configuration.calibration.max_deflection)
        self._controller = None
        logger.debug("Setting up audiowriter")

        self._current_generator = self._point_generator

        self._state = MachineState()
        self._status = MachineStatus()

        self._communicator = UsbPacketCommunicator(self._configuration.circut.calibration_queue_length)
        self._communicator.start()
        self._disseminator = MicroDisseminator(
            self._laser_control,
            self._communicator,
            self._configuration.circut.data_rate
            )

        self._path_to_points = PathToPoints(
            self._disseminator.samples_per_second,
            transformer,
            self._configuration.options.laser_thickness_mm
            )

        post_fire_delay_speed = None
        slew_delay_speed = None
        if self._configuration.options.post_fire_delay:
            post_fire_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.post_fire_delay) / 1000.0)
        if self._configuration.options.slew_delay:
            slew_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.slew_delay) / 1000.0)

        self._writer = LayerWriter(
            self._disseminator,
            self._path_to_points,
            self._laser_control,
            self._state,
            post_fire_delay_speed=post_fire_delay_speed,
            slew_delay_speed=slew_delay_speed
            )

        self._layer_processing = LayerProcessing(
            self._writer,
            self._state,
            self._status,
            )

        self._controller = Controller(
            self._writer,
            self._layer_processing,
            self._current_generator,
            self._status,
            abort_on_error=False,
            )

        self.make_pattern_fit()
        self._controller.start()


    def set_print_area(self, width, height, depth):
        self._configuration.calibration.print_area_x = width
        self._configuration.calibration.print_area_y = height
        self._configuration.calibration.print_area_z = depth
        self._save()

    def get_print_area(self):
        return (self._configuration.calibration.print_area_x, self._configuration.calibration.print_area_y, self._configuration.calibration.print_area_z)

    def set_orientation(self, x_flip, yflip, swap_axis):
        self._configuration.calibration.flip_x_axis = x_flip
        self._configuration.calibration.flip_y_axis = yflip
        self._configuration.calibration.swap_axis = swap_axis
        self._save()

    def get_orientation(self):
        return (self._configuration.calibration.flip_x_axis, self._configuration.calibration.flip_y_axis, self._configuration.calibration.swap_axis)

    '''Used to show a single point with no calibration applied'''
    def show_point(self, xyz=[0.5, 0.5, 0.5]):
        # logger.info('Showing point')
        x, y, z = xyz
        self._point_generator.xy = [x, y]
        if (self._current_generator != self._point_generator):
            self._unapply_calibration()
            self._update_generator(self._point_generator)

    '''Used to show a blinking point with no calibration applied used for aligning on and off laser posisition'''
    def show_blink(self, xyz=[0.5, 0.5, 0.0]):
        logger.info('Showing blink')
        x, y, z = xyz
        self._blink_generator.xy = [x, y]
        if (self._current_generator != self._blink_generator):
            self._unapply_calibration()
            self._update_generator(self._blink_generator)

    '''Used to show pattern with no calibration applied used for determining orientation'''
    def show_orientation(self):
        logger.info('Showing Orientation')
        if (self._current_generator != self._orientaiton_generator):
            self._unapply_calibration()
            self._update_generator(self._orientaiton_generator)

    '''Used to show a single line on one axis used to line up calibration grid'''
    def show_line(self):
        logger.info('Showing line')
        self._unapply_calibration()
        self._update_generator(self._alignment_generator)

    '''Used to show a test pattern with calibration applied'''
    def show_test_pattern(self, pattern):
        logger.info('Showing test pattern %s' % pattern)
        if pattern in self._test_patterns.keys():
            self._apply_calibration()
            self._update_generator(self._test_patterns[pattern])
        else:
            logger.error('Pattern: %s does not exist' % pattern)
            raise Exception('Pattern: %s does not exist' % pattern)

    '''Shows the scale square'''
    def show_scale(self):
        logger.info('Showing scale')
        self._unapply_calibration()
        self._update_generator(self._scale_generator)

    def get_max_deflection(self):
        return self._configuration.calibration.max_deflection

    def set_max_deflection(self, deflection):
        self._configuration.calibration.max_deflection = deflection
        self._unapply_calibration()
        self._save()

    '''Allows user so force the laser on'''
    def set_laser_off_override(self, state):
        self._controller.laser_off_override = state

    '''Changes the speed at which the test pattern is drawn in mm/sec'''
    def set_test_pattern_speed(self, speed):
        [pattern.set_speed(speed) for pattern in self._test_patterns.values()]

    '''Changes the height at which the test pattern is drawn in mm'''
    def set_test_pattern_current_height(self, current_height):
        [pattern.set_current_height(current_height) for pattern in self._test_patterns.values()]

    '''returns a list of test patterns'''
    def get_test_patterns(self):
        return self._test_patterns.keys()

    '''Returns the current calibration for the printer'''
    def current_calibration(self):
        return self._configuration.calibration

    '''deprecated use set_lower_points and set_upper_points, set_height'''
    def save_points(self, height, lower_points, upper_points):
        self.set_lower_points(lower_points)
        self.set_upper_points(upper_points)
        self.set_height(height)

    '''Gets the lower calibration points'''
    def get_lower_points(self):
        return self._configuration.calibration.lower_points

    '''Set and saves the suppliled lower calibration'''
    def set_lower_points(self, lower_points):
        self._configuration.calibration.lower_points = lower_points
        self._save()

    '''Gets the upper calibration points'''
    def get_upper_points(self):
        return self._configuration.calibration.upper_points

    '''Set and saves the suppliled upper calibration'''
    def set_upper_points(self, upper_points):
        self._configuration.calibration.upper_points = upper_points
        self._save()

    '''Gets the calibration height'''
    def get_height(self):
        return self._configuration.calibration.height

    '''Set and saves the upper calibration height'''
    def set_height(self, height):
        self._configuration.calibration.height = height
        self._save()

    def _save(self):
        self._configuration_manager.save(self._configuration)
        self.make_pattern_fit()

    # deprecated
    def make_pattern_fit(self):
        for pattern in self._test_patterns.values():
            pattern.set_radius(self.get_largest_object_radius())

    '''Must be called before shutting down applications'''
    def close(self):
        self._controller.close()

    def _update_generator(self, generator):
        self._current_generator = generator
        self._controller.change_generator(self._current_generator)

    def _apply_calibration(self):
        self._path_to_points.set_transformer(
            HomogenousTransformer(
                self._configuration.calibration.max_deflection,
                self._configuration.calibration.height,
                self._configuration.calibration.lower_points,
                self._configuration.calibration.upper_points
                )
            )

    def _unapply_calibration(self):
        self._path_to_points.set_transformer(
            TuningTransformer(scale=self._configuration.calibration.max_deflection))

    def _validate_points(self, points):
        if (len(points) != 4):
            return False
        return True

    '''Based on current calibrations_gets_maximum_size_of_object at the base layer'''
    def get_largest_object_radius(self):
        lowest = None
        for (x, y) in self._configuration.calibration.lower_points.values():
            if not lowest or abs(x) < lowest:
                lowest = abs(x)
            if abs(y) < lowest:
                lowest = abs(y)
        logger.info("Calulated max radius of object as: %s mm" % lowest)
        return lowest

    def stop(self):
            self._controller.stop()
Пример #14
0
class CalibrationAPI(object):
    '''The calibration API proivides the tools required to setup a Peacy Printer'''

    def __init__(self, configuration_manager):
        logger.info("Calibartion API Startup")
        self._configuration_manager = configuration_manager
        self._configuration = self._configuration_manager.load()

        self._point_generator = SinglePointGenerator()
        self._blink_generator = BlinkGenerator()
        self._orientaiton_generator = OrientationGenerator()
        self._alignment_generator = CalibrationLineGenerator()
        self._scale_generator = ScaleGenerator(speed=2.0, radius=1.0)

        self._test_patterns = {
            'Hilbert Space Filling Curve': HilbertGenerator(),
            'Square': SquareGenerator(),
            'Circle': CircleGenerator(),
            'Spiral': SpiralGenerator(),
            'Memory Hourglass': MemoryHourglassGenerator(),
            'Damping Test': DampingTestGenerator(),
            'NESW': NESWGenerator(),
            'Twitch': TwitchGenerator(),
            }

        self._current_generator = self._point_generator

        self._laser_control = LaserControl(self._configuration.cure_rate.override_laser_power_amount)
        transformer = TuningTransformer(scale=self._configuration.calibration.max_deflection)
        self._controller = None
        logger.debug("Setting up audiowriter")

        self._current_generator = self._point_generator

        self._state = MachineState()
        self._status = MachineStatus()

        self._communicator = UsbPacketCommunicator(self._configuration.circut.calibration_queue_length)
        self._communicator.start()
        self._disseminator = MicroDisseminator(
            self._laser_control,
            self._communicator,
            self._configuration.circut.data_rate
            )

        self._path_to_points = PathToPoints(
            self._disseminator.samples_per_second,
            transformer,
            self._configuration.options.laser_thickness_mm
            )

        post_fire_delay_speed = None
        slew_delay_speed = None
        if self._configuration.options.post_fire_delay:
            post_fire_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.post_fire_delay) / 1000.0)
        if self._configuration.options.slew_delay:
            slew_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.slew_delay) / 1000.0)

        self._writer = LayerWriter(
            self._disseminator,
            self._path_to_points,
            self._laser_control,
            self._state,
            post_fire_delay_speed=post_fire_delay_speed,
            slew_delay_speed=slew_delay_speed
            )

        self._layer_processing = LayerProcessing(
            self._writer,
            self._state,
            self._status,
            )

        self._controller = Controller(
            self._writer,
            self._layer_processing,
            self._current_generator,
            self._status,
            abort_on_error=False,
            )

        self.make_pattern_fit()
        self._controller.start()

    def subscribe_to_status(self, callback):
        '''Provides ability to subscribe to a printer safety status message (PrinterStatusMessage)'''

        self._communicator.register_handler(PrinterStatusMessage, callback)

    def set_print_area(self, width, height, depth):
        '''Set the print area (width, height, depth) in mm'''

        self._configuration.calibration.print_area_x = width
        self._configuration.calibration.print_area_y = height
        self._configuration.calibration.print_area_z = depth
        self._save()

    def get_print_area(self):
        '''Gets the print area (width, height, depth) in mm'''

        return (self._configuration.calibration.print_area_x, self._configuration.calibration.print_area_y, self._configuration.calibration.print_area_z)

    def set_orientation(self, x_flip, yflip, swap_axis):
        '''Allows for compensation of coil hook up by flipping and reversing axis'''

        self._configuration.calibration.flip_x_axis = x_flip
        self._configuration.calibration.flip_y_axis = yflip
        self._configuration.calibration.swap_axis = swap_axis
        self._save()

    def get_orientation(self):
        '''Gets the compensation for coil hook up returns tuple3 of booleans (flip x axis, flip y axis, swap axis) '''

        return (self._configuration.calibration.flip_x_axis, self._configuration.calibration.flip_y_axis, self._configuration.calibration.swap_axis)

    def show_point(self, xyz=[0.5, 0.5, 0.5]):
        '''Used to show a single point with no calibration applied'''

        # logger.info('Showing point')
        x, y, z = xyz
        self._point_generator.xy = [x, y]
        if (self._current_generator != self._point_generator):
            self._unapply_calibration()
            self._update_generator(self._point_generator)

    def show_blink(self, xyz=[0.5, 0.5, 0.0]):
        '''Used to show a blinking point with no calibration applied used for aligning on and off laser posisition'''

        logger.info('Showing blink')
        x, y, z = xyz
        self._blink_generator.xy = [x, y]
        if (self._current_generator != self._blink_generator):
            self._unapply_calibration()
            self._update_generator(self._blink_generator)

    def show_orientation(self):
        '''Used to show pattern with no calibration applied used for determining orientation'''

        logger.info('Showing Orientation')
        if (self._current_generator != self._orientaiton_generator):
            self._unapply_calibration()
            self._update_generator(self._orientaiton_generator)

    def show_line(self):
        '''Used to show a single line on one axis used to line up calibration grid'''

        logger.info('Showing line')
        self._unapply_calibration()
        self._update_generator(self._alignment_generator)

    def show_test_pattern(self, pattern):
        '''Used to show a test pattern with calibration applied'''

        logger.info('Showing test pattern %s' % pattern)
        if pattern in self._test_patterns.keys():
            self._apply_calibration()
            self._update_generator(self._test_patterns[pattern])
        else:
            logger.error('Pattern: %s does not exist' % pattern)
            raise Exception('Pattern: %s does not exist' % pattern)

    def show_scale(self):
        '''Shows the scale square'''

        logger.info('Showing scale')
        self._unapply_calibration()
        self._update_generator(self._scale_generator)

    def get_max_deflection(self):
        '''Gets the maximum allowable deflection of the mirrors as percentage'''

        return self._configuration.calibration.max_deflection
    
    def set_max_deflection(self, deflection):
        '''Sets the maximum allowable deflection of the mirrors as percentage'''

        self._configuration.calibration.max_deflection = deflection
        self._unapply_calibration()
        self._save()

    def set_laser_off_override(self, state):
        '''Allows user so force the laser on'''

        self._controller.laser_off_override = state

    def set_test_pattern_speed(self, speed):
        '''Changes the speed at which the test pattern is drawn in mm/sec'''

        [pattern.set_speed(speed) for pattern in self._test_patterns.values()]

    def set_test_pattern_current_height(self, current_height):
        '''Changes the height at which the test pattern is drawn in mm'''

        [pattern.set_current_height(current_height) for pattern in self._test_patterns.values()]

    def get_test_patterns(self):
        '''returns a list of test patterns'''

        return self._test_patterns.keys()

    def current_calibration(self):
        '''Returns the current calibration for the printer'''

        return self._configuration.calibration

    def save_points(self, height, lower_points, upper_points):
        '''deprecated use set_lower_points and set_upper_points, set_height'''

        self.set_lower_points(lower_points)
        self.set_upper_points(upper_points)
        self.set_height(height)

    def get_lower_points(self):
        '''Gets the lower calibration points'''

        return self._configuration.calibration.lower_points

    def set_lower_points(self, lower_points):
        '''Set and saves the suppliled lower calibration'''

        self._configuration.calibration.lower_points = lower_points
        self._save()

    def get_upper_points(self):
        '''Gets the upper calibration points'''

        return self._configuration.calibration.upper_points

    def set_upper_points(self, upper_points):
        '''Set and saves the suppliled upper calibration'''

        self._configuration.calibration.upper_points = upper_points
        self._save()

    def get_height(self):
        '''Gets the calibration height'''

        return self._configuration.calibration.height

    def set_height(self, height):
        '''Set and saves the upper calibration height'''

        self._configuration.calibration.height = height
        self._save()

    def _save(self):
        self._configuration_manager.save(self._configuration)
        self.make_pattern_fit()

    # deprecated
    def make_pattern_fit(self):
        for pattern in self._test_patterns.values():
            pattern.set_radius(self.get_largest_object_radius())

    def close(self):
        '''Must be called before shutting down applications'''

        self._controller.close()

    def _update_generator(self, generator):
        self._current_generator = generator
        self._controller.change_generator(self._current_generator)

    def _apply_calibration(self):
        self._path_to_points.set_transformer(
            HomogenousTransformer(
                self._configuration.calibration.max_deflection,
                self._configuration.calibration.height,
                self._configuration.calibration.lower_points,
                self._configuration.calibration.upper_points
                )
            )

    def _unapply_calibration(self):
        self._path_to_points.set_transformer(
            TuningTransformer(scale=self._configuration.calibration.max_deflection))

    def _validate_points(self, points):
        if (len(points) != 4):
            return False
        return True

    def get_largest_object_radius(self):
        '''Based on current calibrations_gets_maximum_size_of_object at the base layer'''

        lowest = None
        for (x, y) in self._configuration.calibration.lower_points.values():
            if not lowest or abs(x) < lowest:
                lowest = abs(x)
            if abs(y) < lowest:
                lowest = abs(y)
        logger.info("Calulated max radius of object as: %s mm" % lowest)
        return lowest

    def stop(self):
        '''Stops the calibaration interactivity'''

        self._controller.stop()
Пример #15
0
    def __init__(self, configuration_manager):
        logger.info("Calibartion API Startup")
        self._configuration_manager = configuration_manager
        self._configuration = self._configuration_manager.load()

        self._point_generator = SinglePointGenerator()
        self._blink_generator = BlinkGenerator()
        self._orientaiton_generator = OrientationGenerator()
        self._alignment_generator = CalibrationLineGenerator()
        self._scale_generator = ScaleGenerator(speed=2.0, radius=1.0)

        self._test_patterns = {
            'Hilbert Space Filling Curve': HilbertGenerator(),
            'Square': SquareGenerator(),
            'Circle': CircleGenerator(),
            'Spiral': SpiralGenerator(),
            'Memory Hourglass': MemoryHourglassGenerator(),
            'Damping Test': DampingTestGenerator(),
            'NESW': NESWGenerator(),
            'Twitch': TwitchGenerator(),
            }

        self._current_generator = self._point_generator

        self._laser_control = LaserControl(self._configuration.cure_rate.override_laser_power_amount)
        transformer = TuningTransformer(scale=self._configuration.calibration.max_deflection)
        self._controller = None
        logger.debug("Setting up audiowriter")

        self._current_generator = self._point_generator

        self._state = MachineState()
        self._status = MachineStatus()

        self._communicator = UsbPacketCommunicator(self._configuration.circut.calibration_queue_length)
        self._communicator.start()
        self._disseminator = MicroDisseminator(
            self._laser_control,
            self._communicator,
            self._configuration.circut.data_rate
            )

        self._path_to_points = PathToPoints(
            self._disseminator.samples_per_second,
            transformer,
            self._configuration.options.laser_thickness_mm
            )

        post_fire_delay_speed = None
        slew_delay_speed = None
        if self._configuration.options.post_fire_delay:
            post_fire_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.post_fire_delay) / 1000.0)
        if self._configuration.options.slew_delay:
            slew_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.slew_delay) / 1000.0)

        self._writer = LayerWriter(
            self._disseminator,
            self._path_to_points,
            self._laser_control,
            self._state,
            post_fire_delay_speed=post_fire_delay_speed,
            slew_delay_speed=slew_delay_speed
            )

        self._layer_processing = LayerProcessing(
            self._writer,
            self._state,
            self._status,
            )

        self._controller = Controller(
            self._writer,
            self._layer_processing,
            self._current_generator,
            self._status,
            abort_on_error=False,
            )

        self.make_pattern_fit()
        self._controller.start()
Пример #16
0
    def __init__(self, configuration_manager):
        logger.info("Calibartion API Startup")
        self._configuration_manager = configuration_manager
        self._configuration = self._configuration_manager.load()

        self._point_generator = SinglePointGenerator()
        self._blink_generator = BlinkGenerator()
        self._orientaiton_generator = OrientationGenerator()
        self._alignment_generator = CalibrationLineGenerator()
        self._scale_generator = ScaleGenerator(speed=2.0, radius=1.0)

        self._test_patterns = {
            'Hilbert Space Filling Curve': HilbertGenerator(),
            'Square': SquareGenerator(),
            'Circle': CircleGenerator(),
            'Spiral': SpiralGenerator(),
            'Memory Hourglass': MemoryHourglassGenerator(),
            'Damping Test': DampingTestGenerator(),
            'NESW': NESWGenerator(),
            'Twitch': TwitchGenerator(),
            }

        self._current_generator = self._point_generator

        self._laser_control = LaserControl(self._configuration.cure_rate.override_laser_power_amount)
        transformer = TuningTransformer(scale=self._configuration.calibration.max_deflection)
        self._controller = None
        logger.debug("Setting up audiowriter")

        self._current_generator = self._point_generator

        self._state = MachineState()
        self._status = MachineStatus()

        self._communicator = UsbPacketCommunicator(self._configuration.circut.calibration_queue_length)
        self._communicator.start()
        self._disseminator = MicroDisseminator(
            self._laser_control,
            self._communicator,
            self._configuration.circut.data_rate
            )

        self._path_to_points = PathToPoints(
            self._disseminator.samples_per_second,
            transformer,
            self._configuration.options.laser_thickness_mm
            )

        post_fire_delay_speed = None
        slew_delay_speed = None
        if self._configuration.options.post_fire_delay:
            post_fire_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.post_fire_delay) / 1000.0)
        if self._configuration.options.slew_delay:
            slew_delay_speed = self._configuration.options.laser_thickness_mm / (float(self._configuration.options.slew_delay) / 1000.0)

        self._writer = LayerWriter(
            self._disseminator,
            self._path_to_points,
            self._laser_control,
            self._state,
            post_fire_delay_speed=post_fire_delay_speed,
            slew_delay_speed=slew_delay_speed
            )

        self._layer_processing = LayerProcessing(
            self._writer,
            self._state,
            self._status,
            )

        self._controller = Controller(
            self._writer,
            self._layer_processing,
            self._current_generator,
            self._status,
            abort_on_error=False,
            )

        self.make_pattern_fit()
        self._controller.start()
Пример #17
0
    def print_layers(self,
                     layer_generator,
                     print_sub_layers=True,
                     dry_run=False,
                     force_source_speed=False):
        logger.info("Shuffled: %s" %
                    self._configuration.options.use_shufflelayers)
        logger.info("Sublayered: %s" %
                    self._configuration.options.use_sublayers)
        logger.info("Overlapped: %s" % self._configuration.options.use_overlap)

        if self._configuration.options.use_sublayers and print_sub_layers:
            layer_generator = SubLayerGenerator(
                layer_generator,
                self._configuration.options.sublayer_height_mm)
        if self._configuration.options.use_shufflelayers:
            layer_generator = ShuffleGenerator(
                layer_generator,
                self._configuration.options.shuffle_layers_amount)
        if self._configuration.options.use_overlap:
            layer_generator = OverLapGenerator(
                layer_generator, self._configuration.options.overlap_amount)

        if self._configuration.serial.on:
            self._commander = SerialCommander(self._configuration.serial.port)
        else:
            self._commander = NullCommander()

        self.laser_control = LaserControl(
            self._configuration.cure_rate.override_laser_power_amount)

        transformer = HomogenousTransformer(
            self._configuration.calibration.max_deflection,
            self._configuration.calibration.height,
            self._configuration.calibration.lower_points,
            self._configuration.calibration.upper_points,
        )

        state = MachineState()
        self._status = MachineStatus()

        if dry_run:
            abort_on_error = False
        else:
            abort_on_error = True

        self._zaxis = self._get_zaxis(dry_run)

        disseminator = self._get_digital_disseminator(dry_run)

        path_to_points = PathToPoints(
            disseminator.samples_per_second, transformer,
            self._configuration.options.laser_thickness_mm)

        if force_source_speed:
            override_draw_speed = None
            override_move_speed = None
        else:
            override_draw_speed = self._configuration.cure_rate.draw_speed if self._configuration.cure_rate.use_draw_speed else None
            override_move_speed = self._configuration.cure_rate.move_speed if self._configuration.cure_rate.use_draw_speed else None

        pre_layer_delay = self._configuration.options.pre_layer_delay if self._configuration.options.pre_layer_delay else 0.0
        post_fire_delay_speed = None
        slew_delay_speed = None
        if self._configuration.options.post_fire_delay:
            post_fire_delay_speed = self._configuration.options.laser_thickness_mm / (
                float(self._configuration.options.post_fire_delay) / 1000.0)
        if self._configuration.options.slew_delay:
            slew_delay_speed = self._configuration.options.laser_thickness_mm / (
                float(self._configuration.options.slew_delay) / 1000.0)

        if self._configuration.options.wait_after_move_milliseconds > 0:
            wait_speed = self._configuration.options.laser_thickness_mm / (
                float(self._configuration.options.wait_after_move_milliseconds)
                / 1000.0)
        else:
            wait_speed = None

        self._writer = LayerWriter(disseminator,
                                   path_to_points,
                                   self.laser_control,
                                   state,
                                   move_distance_to_ignore=self._configuration.
                                   options.laser_thickness_mm,
                                   override_draw_speed=override_draw_speed,
                                   override_move_speed=override_move_speed,
                                   wait_speed=wait_speed,
                                   post_fire_delay_speed=post_fire_delay_speed,
                                   slew_delay_speed=slew_delay_speed)

        self._layer_processing = LayerProcessing(
            self._writer,
            state,
            self._status,
            self._zaxis,
            self._configuration.dripper.max_lead_distance_mm,
            self._commander,
            pre_layer_delay,
            self._configuration.serial.layer_started,
            self._configuration.serial.layer_ended,
            self._configuration.serial.print_ended,
            self._configuration.serial.on_command,
            self._configuration.serial.off_command,
        )

        if self._zaxis:
            self._zaxis.set_call_back(self._status.drip_call_back)
            self._zaxis.start()

        self._controller = Controller(
            self._writer,
            self._layer_processing,
            layer_generator,
            self._status,
            abort_on_error=abort_on_error,
        )

        self._controller.start()