mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-30 07:44:22 +08:00
Merge pull request #6057 from Ultimaker/network-plugin-remove-hardcoded-references
Get rid of any hard-coded references to machines
This commit is contained in:
commit
87517a77c2
@ -250,31 +250,15 @@ Cura.MachineAction
|
||||
renderType: Text.NativeRendering
|
||||
text:
|
||||
{
|
||||
if(base.selectedDevice)
|
||||
{
|
||||
if (base.selectedDevice.printerType == "ultimaker3")
|
||||
{
|
||||
return "Ultimaker 3";
|
||||
if (base.selectedDevice) {
|
||||
// It would be great to use a more readable machine type here,
|
||||
// but the new discoveredPrintersModel is not used yet in the UM networking actions.
|
||||
// TODO: remove actions or replace 'connect via network' button with new flow?
|
||||
return base.selectedDevice.printerType
|
||||
}
|
||||
else if (base.selectedDevice.printerType == "ultimaker3_extended")
|
||||
{
|
||||
return "Ultimaker 3 Extended";
|
||||
}
|
||||
else if (base.selectedDevice.printerType == "ultimaker_s5")
|
||||
{
|
||||
return "Ultimaker S5";
|
||||
}
|
||||
else
|
||||
{
|
||||
return catalog.i18nc("@label", "Unknown") // We have no idea what type it is. Should not happen 'in the field'
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
width: Math.round(parent.width * 0.5)
|
||||
|
@ -11,20 +11,8 @@ import UM 1.2 as UM
|
||||
*/
|
||||
Item
|
||||
{
|
||||
// The printer name
|
||||
id: monitorPrinterPill
|
||||
property var text: ""
|
||||
property var tagText: {
|
||||
switch(text) {
|
||||
case "Ultimaker 3":
|
||||
return "UM 3"
|
||||
case "Ultimaker 3 Extended":
|
||||
return "UM 3 EXT"
|
||||
case "Ultimaker S5":
|
||||
return "UM S5"
|
||||
default:
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
implicitHeight: 18 * screenScaleFactor // TODO: Theme!
|
||||
implicitWidth: Math.max(printerNameLabel.contentWidth + 12 * screenScaleFactor, 36 * screenScaleFactor) // TODO: Theme!
|
||||
@ -40,9 +28,9 @@ Item
|
||||
id: printerNameLabel
|
||||
anchors.centerIn: parent
|
||||
color: UM.Theme.getColor("monitor_text_primary")
|
||||
text: tagText
|
||||
text: monitorPrinterPill.text
|
||||
font.pointSize: 10 // TODO: Theme!
|
||||
visible: text !== ""
|
||||
visible: monitorPrinterPill.text !== ""
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import os
|
||||
from queue import Queue
|
||||
from threading import Event, Thread
|
||||
from time import time
|
||||
from typing import Optional, TYPE_CHECKING, Dict, Callable
|
||||
from typing import Optional, TYPE_CHECKING, Dict, Callable, Union, Any
|
||||
|
||||
from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo
|
||||
|
||||
@ -395,17 +395,28 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||
self._application.getDiscoveredPrintersModel().removeDiscoveredPrinter(device.address)
|
||||
self.discoveredDevicesChanged.emit()
|
||||
|
||||
## Returns a dict of printer BOM numbers to machine types.
|
||||
# These numbers are available in the machine definition already so we just search for them here.
|
||||
def _getPrinterTypeIdentifiers(self) -> Dict[str, str]:
|
||||
container_registry = self._application.getContainerRegistry()
|
||||
ultimaker_machines = container_registry.findContainersMetadata(type="machine", manufacturer="Ultimaker B.V.")
|
||||
|
||||
found_machine_type_identifiers = {} # type: Dict[str, str]
|
||||
for machine in ultimaker_machines:
|
||||
machine_bom_number = machine.get("firmware_update_info", {}).get("id", None)
|
||||
machine_type = machine.get("id", None)
|
||||
if machine_bom_number and machine_type:
|
||||
found_machine_type_identifiers[str(machine_bom_number)] = machine_type
|
||||
|
||||
return found_machine_type_identifiers
|
||||
|
||||
def _onAddDevice(self, name, address, properties):
|
||||
# Check what kind of device we need to add; Depending on the firmware we either add a "Connect"/"Cluster"
|
||||
# or "Legacy" UM3 device.
|
||||
cluster_size = int(properties.get(b"cluster_size", -1))
|
||||
|
||||
printer_type = properties.get(b"machine", b"").decode("utf-8")
|
||||
printer_type_identifiers = {
|
||||
"9066": "ultimaker3",
|
||||
"9511": "ultimaker3_extended",
|
||||
"9051": "ultimaker_s5"
|
||||
}
|
||||
printer_type_identifiers = self._getPrinterTypeIdentifiers()
|
||||
|
||||
for key, value in printer_type_identifiers.items():
|
||||
if printer_type.startswith(key):
|
||||
|
Loading…
x
Reference in New Issue
Block a user