Skip to content

Commit

Permalink
Fix: remove ability to rename networked printer.
Browse files Browse the repository at this point in the history
Networked printers must have a 'group_name', which is immutable.

(cherry picked from commit f5381b5)
  • Loading branch information
loociano committed Jun 1, 2020
1 parent 39c71ce commit 29908dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
8 changes: 3 additions & 5 deletions src/MPSM2NetworkedPrinterOutputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ class MPSM2NetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
hasTargetHotendInProgressChanged = pyqtSignal()
hasTargetBedInProgressChanged = pyqtSignal()

def __init__(self, device_id: str, address: str, instance_number=1,
parent=None) -> None:
"""Constructor
def __init__(self, device_id: str, address: str, parent=None) -> None:
"""Constructor.
Args:
device_id: 'manual:<ip_address>'
address: IP address, for example '192.168.0.70'
"""
device_name = 'Monoprice Select Mini V2{}'.format(
' #{}'.format(instance_number) if instance_number > 1 else '')
device_name = 'MPSM V2 {}'.format(address)
mpsm2_properties = {
b'name': device_name.encode('utf-8'),
b'machine': b'Malyan M200',
Expand Down
16 changes: 5 additions & 11 deletions src/Network/DeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,8 @@ def _on_printer_status_response(

Logger.log('d', 'Received response from printer on address %s: %s.',
address, response)
self._store_manual_address(address)
instance_number = 1
try:
instance_number = self._get_stored_manual_addresses().index(address) + 1
except ValueError:
Logger.log('e', 'Could not find address %s in user preferences', address)
device = MPSM2NetworkedPrinterOutputDevice(
DeviceManager._get_device_id(address), address, instance_number)
DeviceManager._get_device_id(address), address)
device.onPrinterUpload.connect(self.onPrinterUpload)
device.update_printer_status(response)
discovered_printers_model = \
Expand All @@ -158,6 +152,7 @@ def _on_printer_status_response(
machine_type=device.printerType,
device=device)

self._store_manual_address(address)
self._discovered_devices[device.getId()] = device
self.discoveredDevicesChanged.emit()
self.connect_to_active_machine()
Expand All @@ -182,13 +177,12 @@ def _create_machine(self, device_id: str) -> None:
return

if self._machines.get(device_id) is None:
machine_name = device.name if len(self._machines) == 0 \
else device.name + '#{}'.format(len(self._machines) + 1)
new_machine = CuraStackBuilder.createMachine(machine_name,
device.printerType)
new_machine = CuraStackBuilder.createMachine(
device.name, device.printerType)
if not new_machine:
Logger.log('e', 'Failed to create a new machine.')
return
new_machine.setMetaDataEntry('group_name', device.name)
new_machine.setMetaDataEntry(self.METADATA_MPSM2_KEY, device.key)
CuraApplication.getInstance().getMachineManager().setActiveMachine(
new_machine.getId())
Expand Down

0 comments on commit 29908dc

Please sign in to comment.