Ejemplo n.º 1
0
    def start_counting_drips(self, drip_call_back=None):
        '''Turns on the counting of drips. Stop must be called to end this.'''

        self.drip_call_back = drip_call_back
        if self._current_config.serial.on:
            self._commander = SerialCommander(self._current_config.serial.port)
        self._change_dripper()
Ejemplo n.º 2
0
    def test_waits_for_ok_on_init(self, mock_Serial):
        expected_port = "COM1"
        expected_baud = 19200
        expected_message = 'D'
        mock_serial = mock_Serial.return_value
        mock_serial.readline.return_value = "OK\n"

        SerialCommander(expected_port,expected_baud)

        mock_Serial.assert_called_with(expected_port,expected_baud,timeout = 1, writeTimeout = 1, interCharTimeout=1 )
        mock_serial.write.assert_called_with(expected_message)
Ejemplo n.º 3
0
    def test_sending_command_writes_to_serial(self, mock_Serial):
        expected_port = "COM1"
        expected_baud = 9600
        expected_message = 'Hi'
        mock_serial = mock_Serial.return_value
        mock_serial.readline.return_value = 'OK\n'

        serial_commander = SerialCommander(expected_port,expected_baud)
        serial_commander.send_command(expected_message)

        mock_Serial.assert_called_with(expected_port,expected_baud,timeout = 1, writeTimeout = 1, interCharTimeout=1)
        self.assertEquals(expected_message, mock_serial.write.mock_calls[1][1][0].rstrip())
Ejemplo n.º 4
0
    def test_rasies_Exceptions_if_no_ok_on_init(self, mock_Serial):
        expected_port = "COM1"
        expected_baud = 19200
        expected_message = 'D'
        mock_serial = mock_Serial.return_value
        mock_serial.readline.return_value = "ERR\n"

        with self.assertRaises(Exception):
            SerialCommander(expected_port,expected_baud, connection_timeout = 0.1)

        mock_Serial.assert_called_with(expected_port,expected_baud,timeout = 1, writeTimeout = 1, interCharTimeout=1)
        mock_serial.write.assert_called_with(expected_message)
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
 def start_counting_drips(self, drip_call_back=None):
     self.drip_call_back = drip_call_back
     if self._current_config.serial.on:
         self._commander = SerialCommander(self._current_config.serial.port)
     self._change_dripper()