Example #1
0
    def test_print_gcode_should_use_start_height(self, *args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.actual_samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True) as mocked_open:
            api.print_gcode(gcode_path)
            self.mock_GCodeReader.assert_called_with(
                mocked_open.return_value,
                scale=config.options.scaling_factor,
                start_height=expected_start_height)

        self.mock_SerialDripZAxis.assert_called_with(
            self.mock_usb_packet_communicator,
            config.dripper.drips_per_mm,
            expected_start_height,
        )
    def test_print_gcode_should_use_emulated_dripper_if_specified_in_config(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'emulated'
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_TimedDripZAxis.assert_called_with(
            config.dripper.drips_per_mm,
            0.0,
            drips_per_second=config.dripper.emulated_drips_per_second)
        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            zaxis=self.mock_timed_drip_zaxis,
            max_lead_distance=config.dripper.max_lead_distance_mm,
            commander=self.mock_null_commander,
            pre_layer_delay=config.options.pre_layer_delay,
            layer_start_command=config.serial.layer_started,
            layer_ended_command=config.serial.layer_ended,
            print_start_command=config.serial.print_start,
            print_ended_command=config.serial.print_ended,
            dripper_on_command=config.serial.on_command,
            dripper_off_command=config.serial.off_command,
        )
Example #3
0
    def test_print_gcode_should_print_shuffle_overlap_and_sublayer_if_requested(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.use_shufflelayers = True
        config.options.use_overlap = True
        config.options.use_sublayers = True
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            self.mock_g_code_reader.get_layers.return_value = "LayerGenerator"
            api.print_gcode(gcode_path)

        self.mock_SubLayerGenerator.assert_called_with(
            "LayerGenerator", config.options.sublayer_height_mm)
        self.mock_ShuffleGenerator.assert_called_with(
            self.mock_sub_layer_generator,
            config.options.shuffle_layers_amount)
        self.mock_OverLapGenerator.assert_called_with(
            self.mock_shuffle_generator, config.options.overlap_amount)

        self.mock_Controller.assert_called_with(
            self.mock_layer_writer,
            self.mock_layer_processing,
            self.mock_over_lap_generator,
            self.mock_machine_status,
            abort_on_error=True,
        )
Example #4
0
    def test_print_gcode_should_create_required_classes_and_start_it_without_override_speed_if_force_source_speed_flagged(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.cure_rate.draw_speed = 77.7
        config.options.slew_delay = 5
        config.options.post_fire_delay = 5
        config.options.wait_after_move_milliseconds = 5

        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path, force_source_speed=True)

        self.mock_LayerWriter.assert_called_with(
            self.mock_micro_disseminator,
            self.mock_path_to_audio,
            self.mock_laser_control,
            self.mock_machine_state,
            move_distance_to_ignore=config.options.laser_thickness_mm,
            override_draw_speed=None,
            override_move_speed=None,
            wait_speed=100.0,
            post_fire_delay_speed=100.0,
            slew_delay_speed=100.0)
    def test_print_gcode_should_use_photo_dripper_if_specified_in_config(self, * args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'photo'
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_PhotoZAxis.assert_called_with(0.0, config.dripper.photo_zaxis_delay)
        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            self.mock_photo_zaxis,
            config.dripper.max_lead_distance_mm,
            self.mock_null_commander,
            config.options.pre_layer_delay,
            config.serial.layer_started,
            config.serial.layer_ended,
            config.serial.print_ended,
            config.serial.on_command,
            config.serial.off_command,
            )
    def test_print_gcode_should_use_start_height(self, *args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.actual_samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True) as mocked_open:
            api.print_gcode(gcode_path)
            self.mock_GCodeReader.assert_called_with(
                mocked_open.return_value,
                scale=config.options.scaling_factor,
                start_height=expected_start_height
                )

        self.mock_SerialDripZAxis.assert_called_with(
            self.mock_usb_packet_communicator,
            config.dripper.drips_per_mm,
            expected_start_height,
            )
    def test_print_gcode_should_create_required_classes_and_start_it_with_pre_layer_delay(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.pre_layer_delay = 1.0
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            zaxis=self.mock_serial_drip_zaxis,
            max_lead_distance=config.dripper.max_lead_distance_mm,
            commander=self.mock_null_commander,
            pre_layer_delay=config.options.pre_layer_delay,
            layer_start_command=config.serial.layer_started,
            layer_ended_command=config.serial.layer_ended,
            print_start_command=config.serial.print_start,
            print_ended_command=config.serial.print_ended,
            dripper_on_command=config.serial.on_command,
            dripper_off_command=config.serial.off_command,
            )
Example #8
0
    def test_print_gcode_should_use_photo_dripper_if_specified_in_config(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'photo'
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_PhotoZAxis.assert_called_with(
            0.0, config.dripper.photo_zaxis_delay)
        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            self.mock_photo_zaxis,
            config.dripper.max_lead_distance_mm,
            self.mock_null_commander,
            config.options.pre_layer_delay,
            config.serial.layer_started,
            config.serial.layer_ended,
            config.serial.print_ended,
            config.serial.on_command,
            config.serial.off_command,
        )
    def test_print_gcode_should_use_emulated_dripper_if_specified_in_config(self, * args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'emulated'
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_TimedDripZAxis.assert_called_with(config.dripper.drips_per_mm, 0.0, drips_per_second=config.dripper.emulated_drips_per_second)
        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            zaxis=self.mock_timed_drip_zaxis,
            max_lead_distance=config.dripper.max_lead_distance_mm,
            commander=self.mock_null_commander,
            pre_layer_delay=config.options.pre_layer_delay,
            layer_start_command=config.serial.layer_started,
            layer_ended_command=config.serial.layer_ended,
            print_start_command=config.serial.print_start,
            print_ended_command=config.serial.print_ended,
            dripper_on_command=config.serial.on_command,
            dripper_off_command=config.serial.off_command,
            )
    def test_print_gcode_should_create_required_classes_and_start_it_without_override_speed_if_force_source_speed_flagged(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.cure_rate.draw_speed = 77.7
        config.options.slew_delay = 5
        config.options.post_fire_delay = 5
        config.options.wait_after_move_milliseconds = 5

        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path, force_source_speed=True)

        self.mock_LayerWriter.assert_called_with(
            self.mock_micro_disseminator,
            self.mock_path_to_audio,
            self.mock_laser_control,
            self.mock_machine_state,
            move_distance_to_ignore=config.options.laser_thickness_mm,
            override_draw_speed=None,
            override_move_speed=None,
            wait_speed=100.0,
            post_fire_delay_speed=100.0,
            slew_delay_speed=100.0
            )
Example #11
0
    def test_print_gcode_should_create_required_classes_and_start_it_with_pre_layer_delay(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.pre_layer_delay = 1.0
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            self.mock_serial_drip_zaxis,
            config.dripper.max_lead_distance_mm,
            self.mock_null_commander,
            config.options.pre_layer_delay,
            config.serial.layer_started,
            config.serial.layer_ended,
            config.serial.print_ended,
            config.serial.on_command,
            config.serial.off_command,
        )
    def test_get_status_calls_controller_status(self, *args):
        self.setup_mocks(args)
        api = PrintAPI(self.default_config)
        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode("Spam")
            api.get_status()

        self.mock_controller.get_status.assert_called_with()
    def test_subscribe_to_status_should_do_nothing_if_printer_not_started(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        api = PrintAPI(config)
        mock_call_back = MagicMock()

        api.subscribe_to_status(mock_call_back)

        self.assertEquals(0, self.mock_UsbPacketCommunicator.return_value.register_handler.call_count)
    def test_subscribe_to_status_should_if_printer_started(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        api = PrintAPI(config)
        mock_call_back = MagicMock()

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode('FakeFile')
            api.subscribe_to_status(mock_call_back)

        self.mock_UsbPacketCommunicator.return_value.register_handler.assert_called_with(PrinterStatusMessage, mock_call_back)
    def test_print_gcode_should_use_emulated_dripper_and_start_height(self, * args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'emulated'
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_TimedDripZAxis.assert_called_with(config.dripper.drips_per_mm, expected_start_height, drips_per_second=config.dripper.emulated_drips_per_second)
    def test_print_gcode_should_use_photo_dripper_and_start_height(self, * args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'photo'
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_PhotoZAxis.assert_called_with(expected_start_height, config.dripper.photo_zaxis_delay)
    def test_subscribe_to_status_should_do_nothing_if_printer_not_started(
            self, *args):
        self.setup_mocks(args)
        config = self.default_config
        api = PrintAPI(config)
        mock_call_back = MagicMock()

        api.subscribe_to_status(mock_call_back)

        self.assertEquals(
            0, self.mock_UsbPacketCommunicator.return_value.register_handler.
            call_count)
    def test_print_gcode_should_send_email_when_complete_and_email_enabled(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.email.on = True
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        api.close()

        self.mock_EmailNotificationService.assert_called_with(self.mock_email_gateway, config.email.sender, config.email.recipient)
        self.mock_email_notification_service.send_message.assert_called_with("Print Complete", "%s is complete" % gcode_path)
    def test_set_drips_per_second_throws_error_if_not_using_emulated_drips(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"

        self.mock_serial_drip_zaxis.set_drips_per_second.side_effect = Exception()

        config = self.default_config

        api = PrintAPI(config)
        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        with self.assertRaises(Exception):
            api.set_drips_per_second(12)
    def test_print_should_set_call_back_on_zaxis(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.actual_samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_serial_drip_zaxis.set_call_back.assert_called_with(self.mock_machine_status.drip_call_back)
Example #21
0
    def test_print_gcode_should_use_photo_dripper_and_start_height(
            self, *args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'photo'
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_PhotoZAxis.assert_called_with(
            expected_start_height, config.dripper.photo_zaxis_delay)
Example #22
0
    def test_configuration_returns_configuration(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        config.email.on = True
        api = PrintAPI(config)

        self.assertEqual(config, api.configuration)
Example #23
0
    def test_print_gcode_should_use_emulated_dripper_and_start_height(
            self, *args):
        self.setup_mocks(args)
        expected_start_height = 7.7
        gcode_path = "FakeFile"
        config = self.default_config
        config.dripper.dripper_type = 'emulated'
        api = PrintAPI(config, start_height=expected_start_height)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_TimedDripZAxis.assert_called_with(
            config.dripper.drips_per_mm,
            expected_start_height,
            drips_per_second=config.dripper.emulated_drips_per_second)
    def test_print_gcode_should_print_shuffle_layers_if_requested(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.use_shufflelayers = True
        config.options.use_overlap = False
        config.options.use_sublayers = False
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            api.print_gcode(gcode_path)

        self.mock_Controller.assert_called_with(
            self.mock_layer_writer,
            self.mock_layer_processing,
            self.mock_shuffle_generator,
            self.mock_machine_status,
            abort_on_error=True,
            )
Example #25
0
    def test_print_should_set_call_back_on_zaxis(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.actual_samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_serial_drip_zaxis.set_call_back.assert_called_with(
            self.mock_machine_status.drip_call_back)
Example #26
0
    def test_print_gcode_should_print_shuffle_layers_if_requested(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.use_shufflelayers = True
        config.options.use_overlap = False
        config.options.use_sublayers = False
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        self.mock_Controller.assert_called_with(
            self.mock_layer_writer,
            self.mock_layer_processing,
            self.mock_shuffle_generator,
            self.mock_machine_status,
            abort_on_error=True,
        )
    def test_print_gcode_should_print_shuffle_overlap_and_sublayer_if_requested(self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.options.use_shufflelayers = True
        config.options.use_overlap = True
        config.options.use_sublayers = True
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True):
            self.mock_g_code_reader.get_layers.return_value = "LayerGenerator"
            api.print_gcode(gcode_path)

        self.mock_SubLayerGenerator.assert_called_with("LayerGenerator", config.options.sublayer_height_mm)
        self.mock_ShuffleGenerator.assert_called_with(self.mock_sub_layer_generator, config.options.shuffle_layers_amount)
        self.mock_OverLapGenerator.assert_called_with(self.mock_shuffle_generator, config.options.overlap_amount)

        self.mock_Controller.assert_called_with(
            self.mock_layer_writer,
            self.mock_layer_processing,
            self.mock_over_lap_generator,
            self.mock_machine_status,
            abort_on_error=True,
            )
Example #28
0
    def test_get_status_calls_controller_status(self, *args):
        self.setup_mocks(args)
        api = PrintAPI(self.default_config)
        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode("Spam")
            api.get_status()

        self.mock_controller.get_status.assert_called_with()
    def test_subscribe_to_status_should_if_printer_started(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        api = PrintAPI(config)
        mock_call_back = MagicMock()

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode('FakeFile')
            api.subscribe_to_status(mock_call_back)

        self.mock_UsbPacketCommunicator.return_value.register_handler.assert_called_with(
            PrinterStatusMessage, mock_call_back)
Example #30
0
    def test_set_drips_per_second_throws_error_if_not_using_emulated_drips(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"

        self.mock_serial_drip_zaxis.set_drips_per_second.side_effect = Exception(
        )

        config = self.default_config

        api = PrintAPI(config)
        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        with self.assertRaises(Exception):
            api.set_drips_per_second(12)
Example #31
0
    def test_print_gcode_should_send_email_when_complete_and_email_enabled(
            self, *args):
        self.setup_mocks(args)
        gcode_path = "FakeFile"
        config = self.default_config
        config.email.on = True
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True):
            api.print_gcode(gcode_path)

        api.close()

        self.mock_EmailNotificationService.assert_called_with(
            self.mock_email_gateway, config.email.sender,
            config.email.recipient)
        self.mock_email_notification_service.send_message.assert_called_with(
            "Print Complete", "%s is complete" % gcode_path)
Example #32
0
 def get_print_api(self, start_height=0.0):
     return PrintAPI(self._configuration_api.get_current_config(),
                     start_height=start_height)
Example #33
0
    def test_print_gcode_should_create_required_classes_and_start_it_for_digital(
            self, *args):
        self.setup_mocks(args)

        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        config.options.use_shufflelayers = False
        config.options.use_sublayers = False
        config.options.use_overlap = False
        config.options.post_fire_delay = 5
        config.options.slew_delay = 5
        config.options.wait_after_move_milliseconds = 5
        config.dripper.dripper_type = 'microcontroller'
        api = PrintAPI(config)

        with patch('__builtin__.open',
                   mock_open(read_data='bibble'),
                   create=True) as mocked_open:
            api.print_gcode(gcode_path)
            self.mock_GCodeReader.assert_called_with(
                mocked_open.return_value,
                scale=config.options.scaling_factor,
                start_height=0.0)

        self.mock_LaserControl.assert_called_with(
            config.cure_rate.override_laser_power_amount)

        self.mock_UsbPacketCommunicator.assert_called_with(
            config.circut.print_queue_length)

        self.mock_usb_packet_communicator.start.assert_called_with()

        self.mock_MicroDisseminator.assert_called_with(
            self.mock_laser_control, self.mock_usb_packet_communicator,
            config.circut.data_rate)

        self.assertEquals(0, self.mock_usb_packet_communicator.call_count)

        self.mock_HomogenousTransformer.assert_called_with(
            config.calibration.max_deflection,
            config.calibration.height,
            config.calibration.lower_points,
            config.calibration.upper_points,
        )

        self.mock_PathToPoints.assert_called_with(
            actual_samples_per_second, self.mock_homogenous_transformer,
            config.options.laser_thickness_mm)

        self.mock_LayerWriter.assert_called_with(
            self.mock_micro_disseminator,
            self.mock_path_to_audio,
            self.mock_laser_control,
            self.mock_machine_state,
            move_distance_to_ignore=config.options.laser_thickness_mm,
            override_draw_speed=config.cure_rate.draw_speed,
            override_move_speed=config.cure_rate.move_speed,
            wait_speed=100.0,
            post_fire_delay_speed=100.0,
            slew_delay_speed=100.0,
        )

        self.mock_SerialDripZAxis.assert_called_with(
            self.mock_usb_packet_communicator, config.dripper.drips_per_mm,
            0.0)

        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            self.mock_serial_drip_zaxis,
            config.dripper.max_lead_distance_mm,
            self.mock_null_commander,
            config.options.pre_layer_delay,
            config.serial.layer_started,
            config.serial.layer_ended,
            config.serial.print_ended,
            config.serial.on_command,
            config.serial.off_command,
        )
Example #34
0
 def test_print_can_be_stopped_before_started(self, *args):
     api = PrintAPI(self.default_config)
     api.close()
 def test_print_can_be_stopped_before_started(self, *args):
     api = PrintAPI(self.default_config)
     api.close()
    def test_print_gcode_should_create_required_classes_and_start_it_for_digital(self, *args):
        self.setup_mocks(args)

        gcode_path = "FakeFile"
        actual_samples_per_second = 7
        fake_layers = "Fake Layers"

        self.mock_micro_disseminator.samples_per_second = actual_samples_per_second
        self.mock_g_code_reader.get_layers.return_value = fake_layers

        config = self.default_config
        config.options.use_shufflelayers = False
        config.options.use_sublayers = False
        config.options.use_overlap = False
        config.options.post_fire_delay = 5
        config.options.slew_delay = 5
        config.options.wait_after_move_milliseconds = 5
        config.dripper.dripper_type = 'microcontroller'
        api = PrintAPI(config)

        with patch('__builtin__.open', mock_open(read_data='bibble'), create=True) as mocked_open:
            api.print_gcode(gcode_path)
            self.mock_GCodeReader.assert_called_with(
                mocked_open.return_value,
                scale=config.options.scaling_factor,
                start_height=0.0
                )

        self.mock_LaserControl.assert_called_with(
            config.cure_rate.override_laser_power_amount
            )

        self.mock_UsbPacketCommunicator.assert_called_with(config.circut.print_queue_length)
        
        self.mock_usb_packet_communicator.start.assert_called_with()

        self.mock_MicroDisseminator.assert_called_with(
            self.mock_laser_control,
            self.mock_usb_packet_communicator,
            config.circut.data_rate
            )

        self.assertEquals(0, self.mock_usb_packet_communicator.call_count)

        self.mock_HomogenousTransformer.assert_called_with(
            config.calibration.max_deflection,
            config.calibration.height,
            config.calibration.lower_points,
            config.calibration.upper_points,
            )

        self.mock_PathToPoints.assert_called_with(
            actual_samples_per_second,
            self.mock_homogenous_transformer,
            config.options.laser_thickness_mm
            )

        self.mock_LayerWriter.assert_called_with(
            self.mock_micro_disseminator,
            self.mock_path_to_audio,
            self.mock_laser_control,
            self.mock_machine_state,
            move_distance_to_ignore=config.options.laser_thickness_mm,
            override_draw_speed=config.cure_rate.draw_speed,
            override_move_speed=config.cure_rate.move_speed,
            wait_speed=100.0,
            post_fire_delay_speed=100.0,
            slew_delay_speed=100.0,
            )

        self.mock_SerialDripZAxis.assert_called_with(
            self.mock_usb_packet_communicator,
            config.dripper.drips_per_mm,
            0.0
            )

        self.mock_LayerProcessing.assert_called_with(
            self.mock_layer_writer,
            self.mock_machine_state,
            self.mock_machine_status,
            self.mock_serial_drip_zaxis,
            config.dripper.max_lead_distance_mm,
            self.mock_null_commander,
            config.options.pre_layer_delay,
            config.serial.layer_started,
            config.serial.layer_ended,
            config.serial.print_ended,
            config.serial.on_command,
            config.serial.off_command,
            )