Skip to content

Commit

Permalink
Ability to rename printers.
Browse files Browse the repository at this point in the history
  • Loading branch information
loociano committed May 26, 2020
1 parent df4430c commit 871fd63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
30 changes: 11 additions & 19 deletions src/MPSM2NetworkedPrinterOutputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

from UM.FileHandler.FileHandler import FileHandler
from UM.Logger import Logger
from UM.i18n import i18nCatalog
from UM.Scene.SceneNode import SceneNode

from UM.i18n import i18nCatalog
# pylint:disable=import-error
from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.Models.ExtruderConfigurationModel \
Expand All @@ -23,24 +22,23 @@
import NetworkedPrinterOutputDevice, AuthState
from cura.PrinterOutput.PrinterOutputDevice \
import ConnectionType, ConnectionState

from .GCodeWriteFileJob import GCodeWriteFileJob
# pylint:disable=relative-beyond-top-level
from .MPSM2OutputController import MPSM2OutputController
from .Models.MPSM2PrinterOutputModel import MPSM2PrinterOutputModel
from .Models.MPSM2PrinterStatusModel import MPSM2PrinterStatusModel
from .Models.MPSM2PrintJobOutputModel import MPSM2PrintJobOutputModel
from .Network.ApiClient import ApiClient
from .GCodeWriteFileJob import GCodeWriteFileJob
from .Messages.PrintJobUploadProgressMessage \
import PrintJobUploadProgressMessage
from .Messages.PrintJobUploadBlockedMessage \
import PrintJobUploadBlockedMessage
from .Messages.PrintJobUploadSuccessMessage \
import PrintJobUploadSuccessMessage
from .Messages.PrintJobUploadCancelMessage \
import PrintJobUploadCancelMessage
from .Messages.PrintJobUploadIsPrintingMessage \
import PrintJobUploadIsPrintingMessage
from .Messages.PrintJobUploadProgressMessage \
import PrintJobUploadProgressMessage
from .Messages.PrintJobUploadSuccessMessage \
import PrintJobUploadSuccessMessage
from .Models.MPSM2PrintJobOutputModel import MPSM2PrintJobOutputModel
from .Models.MPSM2PrinterOutputModel import MPSM2PrinterOutputModel
from .Models.MPSM2PrinterStatusModel import MPSM2PrinterStatusModel
from .Network.ApiClient import ApiClient
from .Parser.MPSM2PrinterStatusParser \
import MPSM2PrinterStatusParser

Expand Down Expand Up @@ -106,14 +104,8 @@ def __init__(self, device_id: str, address: str, instance_number=1,
self._requested_cancel_print = False
self._requested_hotend_temperature = None # int
self._requested_bed_temperature = None # int
self.setName(device_name)

# Set the display name from the properties.
self.setName(self.getProperty('name'))

# Set the display name of the printer type.
definitions = CuraApplication.getInstance().getContainerRegistry() \
.findContainers(id=self.printerType)
self._printer_type_name = definitions[0].getName() if definitions else ''
self._job_upload_message = PrintJobUploadProgressMessage(
self._on_print_upload_cancelled)
self._api_client = ApiClient(self.address,
Expand Down
5 changes: 1 addition & 4 deletions src/Network/DeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Copyright 2020 Luc Rubio <[email protected]>
Plugin is licensed under the GNU Lesser General Public License v3.0.
"""
from UM.Settings.Interfaces import ContainerInterface
from typing import Optional, Callable, List, cast

from PyQt5.QtCore import pyqtSignal, QObject

from UM import i18nCatalog
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.Interfaces import ContainerInterface
from UM.Signal import Signal
# pylint:disable=import-error
from cura.CuraApplication import CuraApplication
Expand Down Expand Up @@ -232,9 +232,6 @@ def _get_stored_manual_addresses(self) -> List[str]:
def _connect_to_output_device(self, device: MPSM2NetworkedPrinterOutputDevice,
machine: GlobalStack) -> None:
Logger.log('d', 'Connecting to Output Device with key: %s.', device.key)
machine.setName(device.name)
machine.setMetaDataEntry(self.METADATA_MPSM2_KEY, device.key)
machine.setMetaDataEntry('group_name', device.name)
machine.addConfiguredConnectionType(device.connectionType.value)

if not device.isConnected():
Expand Down

0 comments on commit 871fd63

Please sign in to comment.