コード例 #1
0
ファイル: KiddoPrinter.py プロジェクト: Kiddo3D/Cura
 def __init__(self):
     OutputDevice.__init__(self, "KiddoPrinter")
     self.setName(catalog.i18nc("@item:inmenu", "Print"))
     self.setShortDescription(catalog.i18nc("@action:button", "Print with Kiddo"))
     self.setDescription(catalog.i18nc("@info:tooltip", "Print with Kiddo"))
     self.setIconName("print")
     self.setPriority(1)
     self._writing = False
コード例 #2
0
    def __init__(self, box_IP, box_ID, parent=None):
        QObject.__init__(self, parent)
        OutputDevice.__init__(self, box_IP)
        SignalEmitter.__init__(self)

        self.originalFlavor = self.getGCodeFlavor()
        Application.getInstance().applicationShuttingDown.connect(self.onShutDown)
        ### Interface related ###
        self.setName(catalog.i18nc("@item:inmenu", "Doodle3D printing"))
        self.setShortDescription(catalog.i18nc("@action:button", "Print with Doodle3D"))
        self.setDescription(catalog.i18nc("@info:tooltip", "Print with "+ box_ID))
        self.setIconName("print")
        self._control_view = None     # The print interface window, it gets created later
        self.printButton = True
        #######################################################################

        ### Printer ###
        self._box_IP = box_IP         # IP address of this Doodle3D WiFi box
        self._box_ID = box_ID
        self._is_connecting = False   # Printer is connecting
        self._is_connected = False    # Printer is connected
        self._is_printing = False     # Printer is printing
        self._is_cancelling = False   # Printer is cancelling
        self._progress = 0            # Printer progress (0 to 100%)

        self.printBoolean = False
        
        self._heatedUp = False         # Printer heated up
        self._extTemperature = 0       # Extruder temperature
        self._extTargetTemperature = 0 # Target Extruder Temperature
        self._bedTemperature = 0       # Temperature of the bed
        self._bedTargetTemperature = 0     # Target Temperature of the bed

        self._currentLine = 0         # Current line (in the gcode_list) in printing
        self.currentblock = 0
        self.total = 0         
        self._totalLines = 0          # Total lines that's gonna be printed
        self._progress = 0            # Progress of the print
        self._printPhase = ""         # 3 printer phases: "Heating up... ", "Printing... " and "Print Completed "
        self._printerState = ""
        self._stateLocked = False       

        self._gcode_list = []         # Cura-generated GCode
        #######################################################################

        ### Threading ###
        self._printer_info_thread = threading.Thread(target=self.getPrinterInfo)  # The function that gets threaded
        self._printer_info_thread.daemon = True # Daemon threads are automatically killed automatically upon program quit
        self._printer_info_thread.start()       # Starts thread

        self._connect_thread = threading.Thread(target=self._connect)
        self._connect_thread.daemon = True
コード例 #3
0
 def _onOutputStart(self, output_device: OutputDevice) -> None:
     """If this is the sort of output 'device' (like local or online file storage, rather than a printer),
        the user could have altered the file-name, and thus the project name should be altered as well."""
     if isinstance(output_device, ProjectOutputDevice):
         new_name = output_device.getLastOutputName()
         if new_name is not None:
             self.setJobName(
                 os.path.splitext(os.path.basename(new_name))[0])
コード例 #4
0
ファイル: TestOutputDevice.py プロジェクト: Ultimaker/Uranium
def test_getAndSet(data):
    output_device = OutputDevice("Random_id")

    output_device.metaDataChanged = MagicMock()
    # Attempt to set the value
    getattr(output_device, "set" + data["attribute"])(data["value"])

    # Ensure that the value got set
    assert getattr(output_device, "get" + data["attribute"])() == data["value"]

    # Check if signal fired.
    assert output_device.metaDataChanged.emit.call_count == 1

    # Attempt to set the setter to the same value again.
    getattr(output_device, "set" + data["attribute"])(data["value"])
    # Ensure signal fired only once!
    assert output_device.metaDataChanged.emit.call_count == 1
コード例 #5
0
def test_getAndSet(data):
    output_device = OutputDevice("Random_id")

    output_device.metaDataChanged = MagicMock()
    # Attempt to set the value
    getattr(output_device, "set" + data["attribute"])(data["value"])

    # Ensure that the value got set
    assert getattr(output_device, "get" + data["attribute"])() == data["value"]

    # Check if signal fired.
    assert output_device.metaDataChanged.emit.call_count == 1

    # Attempt to set the setter to the same value again.
    getattr(output_device, "set" + data["attribute"])(data["value"])
    # Ensure signal fired only once!
    assert output_device.metaDataChanged.emit.call_count == 1
コード例 #6
0
def test_addRemoveOutputDevice():
    manager = OutputDeviceManager()

    manager.outputDevicesChanged.emit = MagicMock()
    manager.activeDeviceChanged.emit = MagicMock()

    output_device = OutputDevice("test_device_one")
    output_device.setPriority(2)
    output_device_2 = OutputDevice("test_device_two")
    output_device_2.setPriority(9001)

    manager.addOutputDevice(output_device)
    assert manager.outputDevicesChanged.emit.call_count == 1
    assert manager.getOutputDevice("test_device_one") == output_device

    # Our new device is also the one with the highest priority (as it's the only one). So it should be active.
    assert manager.getActiveDevice() == output_device

    manager.addOutputDevice(output_device)
    assert manager.outputDevicesChanged.emit.call_count == 1

    manager.addOutputDevice(output_device_2)
    assert manager.outputDevicesChanged.emit.call_count == 2
    # We added a new device with a higher priority, so that one should be the active one
    assert manager.getActiveDevice() == output_device_2

    assert set([output_device,
                output_device_2]) == set(manager.getOutputDevices())
    assert set(["test_device_one",
                "test_device_two"]) == set(manager.getOutputDeviceIds())

    # Try to manually change the active device a few times
    manager.setActiveDevice("test_device_one")
    assert manager.activeDeviceChanged.emit.call_count == 3
    assert manager.getActiveDevice() == output_device
    manager.setActiveDevice("test_device_two")
    assert manager.activeDeviceChanged.emit.call_count == 4
    assert manager.getActiveDevice() == output_device_2

    # As usual, doing it twice shouldn't cause more updates
    manager.setActiveDevice("test_device_two")
    assert manager.activeDeviceChanged.emit.call_count == 4
    manager.setActiveDevice("Whatever")  # Simply shouldn't cause issues.

    # Time to remove the device again
    assert manager.removeOutputDevice("test_device_two")
    assert manager.getActiveDevice() == output_device
    assert manager.outputDevicesChanged.emit.call_count == 3
    # Trying to remove it again should return false
    assert not manager.removeOutputDevice("test_device_two")
    assert manager.outputDevicesChanged.emit.call_count == 3
コード例 #7
0
def test_addRemoveOutputDevice():
    manager = OutputDeviceManager()

    manager.outputDevicesChanged.emit = MagicMock()
    manager.activeDeviceChanged.emit = MagicMock()

    output_device = OutputDevice("test_device_one")
    output_device.setPriority(2)
    output_device_2 = OutputDevice("test_device_two")
    output_device_2.setPriority(9001)

    manager.addOutputDevice(output_device)
    assert manager.outputDevicesChanged.emit.call_count == 1
    assert manager.getOutputDevice("test_device_one") == output_device

    # Our new device is also the one with the highest priority (as it's the only one). So it should be active.
    assert manager.getActiveDevice() == output_device

    manager.addOutputDevice(output_device)
    assert manager.outputDevicesChanged.emit.call_count == 1

    manager.addOutputDevice(output_device_2)
    assert manager.outputDevicesChanged.emit.call_count == 2
    # We added a new device with a higher priority, so that one should be the active one
    assert manager.getActiveDevice() == output_device_2

    assert set([output_device, output_device_2]) == set(manager.getOutputDevices())
    assert set(["test_device_one", "test_device_two"]) == set(manager.getOutputDeviceIds())

    # Try to manually change the active device a few times
    manager.setActiveDevice("test_device_one")
    assert manager.activeDeviceChanged.emit.call_count == 3
    assert manager.getActiveDevice() == output_device
    manager.setActiveDevice("test_device_two")
    assert manager.activeDeviceChanged.emit.call_count == 4
    assert manager.getActiveDevice() == output_device_2

    # As usual, doing it twice shouldn't cause more updates
    manager.setActiveDevice("test_device_two")
    assert manager.activeDeviceChanged.emit.call_count == 4
    manager.setActiveDevice("Whatever")  # Simply shouldn't cause issues.

    # Time to remove the device again
    assert manager.removeOutputDevice("test_device_two")
    assert manager.getActiveDevice() == output_device
    assert manager.outputDevicesChanged.emit.call_count == 3
    # Trying to remove it again should return false
    assert not manager.removeOutputDevice("test_device_two")
    assert manager.outputDevicesChanged.emit.call_count == 3
コード例 #8
0
    def __init__(self, serial_port, parent = None):
        QObject.__init__(self, parent)
        OutputDevice.__init__(self, serial_port)
        SignalEmitter.__init__(self)
        #super().__init__(serial_port)
        self.setName(catalog.i18nc("@item:inmenu", "USB printing"))
        self.setShortDescription(catalog.i18nc("@action:button", "Print with USB"))
        self.setDescription(catalog.i18nc("@info:tooltip", "Print with USB"))
        self.setIconName("print")

        self._serial = None
        self._serial_port = serial_port
        self._error_state = None

        self._connect_thread = threading.Thread(target = self._connect)
        self._connect_thread.daemon = True

        self._end_stop_thread = threading.Thread(target = self._pollEndStop)
        self._end_stop_thread.deamon = True
        self._poll_endstop = -1

        # Printer is connected
        self._is_connected = False

        # Printer is in the process of connecting
        self._is_connecting = False

        # The baud checking is done by sending a number of m105 commands to the printer and waiting for a readable
        # response. If the baudrate is correct, this should make sense, else we get giberish.
        self._required_responses_auto_baud = 3

        self._progress = 0

        self._listen_thread = threading.Thread(target=self._listen)
        self._listen_thread.daemon = True

        self._update_firmware_thread = threading.Thread(target= self._updateFirmware)
        self._update_firmware_thread.daemon = True
        
        self._heatup_wait_start_time = time.time()

        ## Queue for commands that need to be send. Used when command is sent when a print is active.
        self._command_queue = queue.Queue()

        self._is_printing = False

        ## Set when print is started in order to check running time.
        self._print_start_time = None
        self._print_start_time_100 = None

        ## Keep track where in the provided g-code the print is
        self._gcode_position = 0

        # List of gcode lines to be printed
        self._gcode = []

        # Number of extruders
        self._extruder_count = 1

        # Temperatures of all extruders
        self._extruder_temperatures = [0] * self._extruder_count

        # Target temperatures of all extruders
        self._target_extruder_temperatures = [0] * self._extruder_count

        #Target temperature of the bed
        self._target_bed_temperature = 0 

        # Temperature of the bed
        self._bed_temperature = 0

        # Current Z stage location 
        self._current_z = 0

        self._x_min_endstop_pressed = False
        self._y_min_endstop_pressed = False
        self._z_min_endstop_pressed = False

        self._x_max_endstop_pressed = False
        self._y_max_endstop_pressed = False
        self._z_max_endstop_pressed = False

        # In order to keep the connection alive we request the temperature every so often from a different extruder.
        # This index is the extruder we requested data from the last time.
        self._temperature_requested_extruder_index = 0 

        self._updating_firmware = False

        self._firmware_file_name = None

        self._control_view = None
コード例 #9
0
    def __init__(self, serial_port, parent=None):
        QObject.__init__(self, parent)
        OutputDevice.__init__(self, serial_port)
        SignalEmitter.__init__(self)
        #super().__init__(serial_port)
        self.setName(catalog.i18nc("@item:inmenu", "USB printing"))
        self.setShortDescription(
            catalog.i18nc("@action:button", "Print with USB"))
        self.setDescription(catalog.i18nc("@info:tooltip", "Print with USB"))
        self.setIconName("print")

        self._serial = None
        self._serial_port = serial_port
        self._error_state = None

        self._connect_thread = threading.Thread(target=self._connect)
        self._connect_thread.daemon = True

        self._end_stop_thread = threading.Thread(target=self._pollEndStop)
        self._end_stop_thread.daemon = True
        self._poll_endstop = -1

        # Printer is connected
        self._is_connected = False

        # Printer is in the process of connecting
        self._is_connecting = False

        # The baud checking is done by sending a number of m105 commands to the printer and waiting for a readable
        # response. If the baudrate is correct, this should make sense, else we get giberish.
        self._required_responses_auto_baud = 3

        self._progress = 0

        self._listen_thread = threading.Thread(target=self._listen)
        self._listen_thread.daemon = True

        self._update_firmware_thread = threading.Thread(
            target=self._updateFirmware)
        self._update_firmware_thread.daemon = True
        self.firmwareUpdateComplete.connect(self._onFirmwareUpdateComplete)

        self._heatup_wait_start_time = time.time()

        ## Queue for commands that need to be send. Used when command is sent when a print is active.
        self._command_queue = queue.Queue()

        self._is_printing = False

        ## Set when print is started in order to check running time.
        self._print_start_time = None
        self._print_start_time_100 = None

        ## Keep track where in the provided g-code the print is
        self._gcode_position = 0

        # List of gcode lines to be printed
        self._gcode = []

        # Number of extruders
        self._extruder_count = 1

        # Temperatures of all extruders
        self._extruder_temperatures = [0] * self._extruder_count

        # Target temperatures of all extruders
        self._target_extruder_temperatures = [0] * self._extruder_count

        #Target temperature of the bed
        self._target_bed_temperature = 0

        # Temperature of the bed
        self._bed_temperature = 0

        # Current Z stage location
        self._current_z = 0

        self._x_min_endstop_pressed = False
        self._y_min_endstop_pressed = False
        self._z_min_endstop_pressed = False

        self._x_max_endstop_pressed = False
        self._y_max_endstop_pressed = False
        self._z_max_endstop_pressed = False

        # In order to keep the connection alive we request the temperature every so often from a different extruder.
        # This index is the extruder we requested data from the last time.
        self._temperature_requested_extruder_index = 0

        self._updating_firmware = False

        self._firmware_file_name = None

        self._control_view = None
コード例 #10
0
ファイル: TestOutputDevice.py プロジェクト: Ultimaker/Uranium
def test_createOutputDevice():
    output_device = OutputDevice("Random_id")
    assert output_device.getId() == "Random_id"
コード例 #11
0
def test_createOutputDevice():
    output_device = OutputDevice("Random_id")
    assert output_device.getId() == "Random_id"