diff --git a/src/MPSM2NetworkedPrinterOutputDevice.py b/src/MPSM2NetworkedPrinterOutputDevice.py index c8149a5..aa48b1c 100644 --- a/src/MPSM2NetworkedPrinterOutputDevice.py +++ b/src/MPSM2NetworkedPrinterOutputDevice.py @@ -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:' 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', diff --git a/src/Network/DeviceManager.py b/src/Network/DeviceManager.py index 8b0cc65..17d4e82 100644 --- a/src/Network/DeviceManager.py +++ b/src/Network/DeviceManager.py @@ -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 = \ @@ -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() @@ -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())