当前位置: 首页>>代码示例>>Python>>正文


Python controller.Controller类代码示例

本文整理汇总了Python中infrastructure.controller.Controller的典型用法代码示例。如果您正苦于以下问题:Python Controller类的具体用法?Python Controller怎么用?Python Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_zaxis_should_be_waited_for_buy_outputing_laser_off_signal

    def test_zaxis_should_be_waited_for_buy_outputing_laser_off_signal(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_zaxis = mock_ZAxis.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        zaxis_return_values = [ 0.0,0.0, 0.25, 0.75, 1.0,1.0 ]
        def z_axis_side_effect():
            return zaxis_return_values.pop(0)
        mock_zaxis.current_z_location_mm = z_axis_side_effect

        test_layer1 = Layer(0.0, [ LateralDraw([0.0,0.0],[2.0,2.0],2.0) ])
        test_layer2 = Layer(1.0, [ LateralDraw([2.0,2.0],[0.0,0.0],2.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer1,test_layer2])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator, mock_zaxis)
        self.controller.start()

        self.wait_for_controller()

        mock_zaxis.start.assert_called_with()
        self.assertEqual(4, mock_path_to_audio.process.call_count)
        self.assertEqual(2, mock_laser_control.set_laser_off.call_count)
        self.assertEqual(([2.0,2.0,0.0],[2.0,2.0,0.0],2.0), mock_path_to_audio.process.call_args_list[1][0])
        self.assertEqual(([2.0,2.0,0.0],[2.0,2.0,0.0],2.0), mock_path_to_audio.process.call_args_list[2][0])
开发者ID:colehard,项目名称:peachyprintertools,代码行数:26,代码来源:controller_test.py

示例2: test_should_work_with_no_writer

    def test_should_work_with_no_writer(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        test_layer = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],100.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,None,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()
开发者ID:colehard,项目名称:peachyprintertools,代码行数:12,代码来源:controller_test.py

示例3: print_layers

    def print_layers(self, layer_generator, dry_run = False):
        laser_control = AudioModulationLaserControl(
            self._configuration['output_sample_frequency'],
            self._configuration['on_modulation_frequency'],
            self._configuration['off_modulation_frequency']
            )
        transformer = HomogenousTransformer(self._configuration['calibration_data'], scale = self._configuration["max_deflection"])
        path_to_audio = PathToAudio(
            laser_control.actual_samples_per_second,
            transformer, 
            self._configuration['laser_thickness_mm']
            )
        if dry_run:
            audio_writer = None
            zaxis = None
            zaxis_control = None
            abort_on_error = False
        else:
            audio_writer = AudioWriter(
                self._configuration['output_sample_frequency'], 
                self._configuration['output_bit_depth'],
                )
            zaxis = DripBasedZAxis(
                drips_per_mm = self._configuration['drips_per_mm'], 
                initial_height = 0.0, 
                sample_rate = self._configuration['input_sample_frequency'],
                bit_depth = self._configuration['input_bit_depth'],
                )
            if self._configuration['use_serial_zaxis']:
                zaxis_control = SerialZAxisControl(
                                    self._configuration['serial_port'], 
                                    on_command = self._configuration['serial_on'], 
                                    off_command = self._configuration['serial_off']
                                    )
            else:
                zaxis_control = None
            abort_on_error = True

        self._controller = Controller(
            laser_control,
            path_to_audio,
            audio_writer,
            layer_generator,
            zaxis = zaxis,
            zaxis_control = zaxis_control,
            status_call_back = self._status_call_back,
            max_lead_distance = self._configuration['max_lead_distance_mm'],
            abort_on_error = abort_on_error
            )
        self._controller.start()
开发者ID:colehard,项目名称:peachyprintertools,代码行数:50,代码来源:print_api.py

示例4: test_should_remember_current_posisition

    def test_should_remember_current_posisition(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],2.0), LateralDraw([2.0,2.0],[-1.0,-1.0],2.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        mock_path_to_audio.process.assert_called_with([2.0,2.0,0.0],[-1.0,-1.0,0.0],2.0)
开发者ID:colehard,项目名称:peachyprintertools,代码行数:15,代码来源:controller_test.py

示例5: test_should_turn_on_laser_for_draw_commands

    def test_should_turn_on_laser_for_draw_commands(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],100.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        self.assertEqual(1,mock_laser_control.set_laser_on.call_count)
开发者ID:colehard,项目名称:peachyprintertools,代码行数:15,代码来源:controller_test.py

示例6: test_should_update_machine_status

    def test_should_update_machine_status(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],100.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        self.assertEquals(1, self.controller.get_status()['current_layer'])
        self.assertEquals('Complete',self.controller.get_status()['status'])
开发者ID:colehard,项目名称:peachyprintertools,代码行数:16,代码来源:controller_test.py

示例7: test_should_record_errors_and_abort

    def test_should_record_errors_and_abort(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        mock_layer_generator = mock_LayerGenerator.return_value
        mock_layer_generator.next.return_value =  Layer(1.0,[ LateralDraw([0.0,0.0],[2.0,2.0],2.0) ])
        mock_path_to_audio.process.side_effect = Exception("Something Broke")
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,mock_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        self.assertEquals(1, len(self.controller.get_status()['errors']))
        self.assertEquals("Something Broke", self.controller.get_status()['errors'][0]['message'])
开发者ID:colehard,项目名称:peachyprintertools,代码行数:16,代码来源:controller_test.py

示例8: test_should_record_errors_and_continue_when_abort_on_error_is_false

    def test_should_record_errors_and_continue_when_abort_on_error_is_false(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer1 = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],100.0) ])
        test_layer2 = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],100.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer1, test_layer2])
        mock_path_to_audio.process.side_effect = Exception("Something Broke")
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator, abort_on_error = False)
        self.controller.start()

        self.wait_for_controller()

        self.assertEquals(2, len(self.controller.get_status()['errors']))
开发者ID:colehard,项目名称:peachyprintertools,代码行数:16,代码来源:controller_test.py

示例9: test_should_output_modulate_audio_for_movement_commands

    def test_should_output_modulate_audio_for_movement_commands(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer = Layer(0.0,[ LateralDraw([0.0,0.0],[2.0,2.0],2.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        mock_laser_control.modulate.assert_called_with("SomeAudio")
        mock_audio_writer.write_chunk.assert_called_with("SomeModulatedAudio")
开发者ID:colehard,项目名称:peachyprintertools,代码行数:16,代码来源:controller_test.py

示例10: print_layers

    def print_layers(self, layer_generator, dry_run = False):
        if self._configuration.serial.on:
            self._commander = SerialCommander( self._configuration.serial.port )
        else:
            self._commander = NullCommander()

        laser_control = AudioModulationLaserControl(
            self._configuration.audio.output.sample_rate,
            self._configuration.audio.output.modulation_on_frequency,
            self._configuration.audio.output.modulation_off_frequency,
            self._configuration.options.laser_offset
            )
        transformer = HomogenousTransformer(
            self._configuration.calibration.max_deflection,
            self._configuration.calibration.height,
            self._configuration.calibration.lower_points,
            self._configuration.calibration.upper_points,
            )
        path_to_audio = PathToAudio(
            laser_control.actual_samples_per_second,
            transformer, 
            self._configuration.options.laser_thickness_mm
            )
        if dry_run:
            audio_writer = None
            self.zaxis = None
            zaxis_control = None
            abort_on_error = False
        else:
            audio_writer = AudioWriter(
                self._configuration.audio.output.sample_rate, 
                self._configuration.audio.output.bit_depth,
                )
            self.zaxis = self._get_zaxis()
            abort_on_error = True

        self._controller = Controller(
            laser_control,
            path_to_audio,
            audio_writer,
            layer_generator,
            zaxis = self.zaxis,
            status_call_back = self._status_call_back,
            max_lead_distance = self._configuration.dripper.max_lead_distance_mm,
            abort_on_error = abort_on_error
            )
        self._controller.start()
开发者ID:superblobmonster,项目名称:peachyprintertools,代码行数:47,代码来源:print_api.py

示例11: test_should_ignore_z_in_layer_if_z_axis_none

    def test_should_ignore_z_in_layer_if_z_axis_none(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer1 = Layer(0.0, [ LateralDraw([0.0,0.0],[2.0,2.0],2.0) ])
        test_layer2 = Layer(1.0, [ LateralDraw([2.0,2.0],[0.0,0.0],2.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer1,test_layer2])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator,None)
        self.controller.start()

        self.wait_for_controller()

        self.assertEqual(2,mock_path_to_audio.process.call_count)
        mock_path_to_audio.process.assert_called_with([2.0,2.0,0.0],[0.0,0.0,1.0],2.0)
开发者ID:colehard,项目名称:peachyprintertools,代码行数:17,代码来源:controller_test.py

示例12: test_if_move_command_start_and_current_pos_are_not_the_same_should_move_to_new_posisition

    def test_if_move_command_start_and_current_pos_are_not_the_same_should_move_to_new_posisition(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        test_layer = Layer(0.0,[ LateralMove([0.0,0.0],[0.0,0.0],2.0), LateralMove([2.0,2.0],[-1.0,-1.0],2.0) ])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()

        self.wait_for_controller()

        mock_laser_control.modulate.call_count = 2
        mock_path_to_audio.process.call_count = 2
        mock_laser_control.set_laser_off.assert_called_with()
        self.assertEqual(([0.0,0.0,0.0],[-1.0,-1.0,0.0],2.0), mock_path_to_audio.process.call_args_list[1][0])
开发者ID:colehard,项目名称:peachyprintertools,代码行数:18,代码来源:controller_test.py

示例13: __init__

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

        self._point_generator = SinglePointGenerator()
        self._alignment_generator = CalibrationLineGenerator()

        self._test_patterns = { 
            'Hilbert Space Filling Curve' : HilbertGenerator(),
            'Square' : SquareGenerator(),
            'Circle' : CircleGenerator(),
            'Spiral' : SpiralGenerator(),
            }
        self._current_generator = self._point_generator

        self._laser_control = AudioModulationLaserControl(
            self._configuration['output_sample_frequency'],
            self._configuration['on_modulation_frequency'],
            self._configuration['off_modulation_frequency']
            )
        transformer = TuningTransformer(scale = self._configuration["max_deflection"])
        self._path_to_audio= PathToAudio(
            self._laser_control.actual_samples_per_second,
            transformer,
            self._configuration["laser_thickness_mm"]
            )
        self._audio_writer = None
        self._controller = None
        logging.debug("Setting up audiowriter")
        self._audio_writer = AudioWriter(
            self._configuration['output_sample_frequency'], 
            self._configuration['output_bit_depth'],
            )
        self._current_generator = self._point_generator
        self._controller = Controller(
            self._laser_control,
            self._path_to_audio,
            self._audio_writer,
            self._current_generator,
            )
        self.make_pattern_fit()
        self._controller.start()
开发者ID:colehard,项目名称:peachyprintertools,代码行数:44,代码来源:calibration_api.py

示例14: test_stop_should_close_all_processes_cleanly_while_working_on_commands

    def test_stop_should_close_all_processes_cleanly_while_working_on_commands(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value
        mock_layer_generator = mock_LayerGenerator.return_value
        test_layer = Layer(1.0, [ LateralDraw([2.0,2.0],[0.0,0.0],2.0) for x in range(0,32768)])
        stub_layer_generator = StubLayerGenerator([test_layer])
        mock_path_to_audio.process.return_value = "SomeAudio"
        mock_laser_control.modulate.return_value = "SomeModulatedAudio"
        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,stub_layer_generator)
        self.controller.start()
        time.sleep(0.1)

        self.controller.stop()
        time.sleep(0.1)

        mock_audio_writer.close.assert_called_with()
        
        self.wait_for_controller()
开发者ID:colehard,项目名称:peachyprintertools,代码行数:19,代码来源:controller_test.py

示例15: test_should_change_layer_generator

    def test_should_change_layer_generator(self, mock_LayerGenerator,mock_AudioWriter,mock_PathToAudio,mock_ZAxis,mock_LaserControl):
        mock_laser_control = mock_LaserControl.return_value
        mock_path_to_audio = mock_PathToAudio.return_value
        mock_audio_writer = mock_AudioWriter.return_value

        generator1 = SinglePointGenerator([1.0,1.0])
        generator2 = SinglePointGenerator([0.0,0.0])

        self.controller = Controller(mock_laser_control,mock_path_to_audio,mock_audio_writer,generator1)
        self.controller.start()
        time.sleep(0.1)
        pre_switch = mock_path_to_audio.process.call_args
        self.controller.change_generator(generator2)
        time.sleep(0.1)
        post_switch = mock_path_to_audio.process.call_args
        self.controller.stop()
        self.wait_for_controller()

        self.assertEquals( ([1.0,1.0,0.0],[1.0,1.0,0.0],100.0), pre_switch[0] )
        self.assertEquals( ([0.0,0.0,0.0],[0.0,0.0,0.0],100.0), post_switch[0] )
开发者ID:colehard,项目名称:peachyprintertools,代码行数:20,代码来源:controller_test.py


注:本文中的infrastructure.controller.Controller类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。