mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 11:39:03 +08:00
Merge branch '4.9'
This commit is contained in:
commit
34ba341115
@ -7,26 +7,34 @@ from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
|
||||
from UM.Job import Job
|
||||
from UM.Logger import Logger
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Utils.Threading import call_on_qt_thread
|
||||
|
||||
from ..Models.Http.ClusterMaterial import ClusterMaterial
|
||||
from ..Models.LocalMaterial import LocalMaterial
|
||||
from ..Messages.MaterialSyncMessage import MaterialSyncMessage
|
||||
|
||||
import time
|
||||
import threading
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .LocalClusterOutputDevice import LocalClusterOutputDevice
|
||||
|
||||
|
||||
class SendMaterialJob(Job):
|
||||
|
||||
"""Asynchronous job to send material profiles to the printer.
|
||||
|
||||
This way it won't freeze up the interface while sending those materials.
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, device: "LocalClusterOutputDevice") -> None:
|
||||
super().__init__()
|
||||
self.device = device # type: LocalClusterOutputDevice
|
||||
|
||||
self._send_material_thread = threading.Thread(target = self._sendMissingMaterials)
|
||||
self._send_material_thread.setDaemon(True)
|
||||
|
||||
self._remote_materials = {} # type: Dict[str, ClusterMaterial]
|
||||
|
||||
def run(self) -> None:
|
||||
"""Send the request to the printer and register a callback"""
|
||||
|
||||
@ -36,9 +44,15 @@ class SendMaterialJob(Job):
|
||||
"""Callback for when the remote materials were returned."""
|
||||
|
||||
remote_materials_by_guid = {material.guid: material for material in materials}
|
||||
self._sendMissingMaterials(remote_materials_by_guid)
|
||||
self._remote_materials = remote_materials_by_guid
|
||||
# It's not the nicest way to do it, but if we don't handle this in a thread
|
||||
# we are blocking the main interface (even though the original call was done in a job)
|
||||
# This should really be refactored so that calculating the list of materials that need to be sent
|
||||
# to the printer is done outside of the job (and running the job actually sends the materials)
|
||||
# TODO: Fix this hack that was introduced for 4.9.1
|
||||
self._send_material_thread.start()
|
||||
|
||||
def _sendMissingMaterials(self, remote_materials_by_guid: Dict[str, ClusterMaterial]) -> None:
|
||||
def _sendMissingMaterials(self) -> None:
|
||||
"""Determine which materials should be updated and send them to the printer.
|
||||
|
||||
:param remote_materials_by_guid: The remote materials by GUID.
|
||||
@ -47,7 +61,7 @@ class SendMaterialJob(Job):
|
||||
if len(local_materials_by_guid) == 0:
|
||||
Logger.log("d", "There are no local materials to synchronize with the printer.")
|
||||
return
|
||||
material_ids_to_send = self._determineMaterialsToSend(local_materials_by_guid, remote_materials_by_guid)
|
||||
material_ids_to_send = self._determineMaterialsToSend(local_materials_by_guid, self._remote_materials)
|
||||
if len(material_ids_to_send) == 0:
|
||||
Logger.log("d", "There are no remote materials to update.")
|
||||
return
|
||||
@ -96,7 +110,11 @@ class SendMaterialJob(Job):
|
||||
|
||||
file_name = os.path.basename(file_path)
|
||||
self._sendMaterialFile(file_path, file_name, root_material_id)
|
||||
time.sleep(1) # Throttle the sending a bit.
|
||||
|
||||
# This needs to be called on the QT thread since the onFinished needs to happen
|
||||
# in the same thread as where the network manager is located (aka; main thread)
|
||||
@call_on_qt_thread
|
||||
def _sendMaterialFile(self, file_path: str, file_name: str, material_id: str) -> None:
|
||||
"""Send a single material file to the printer.
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
"platform": "ultimaker_platform.3mf",
|
||||
"has_materials": true,
|
||||
"has_machine_quality": true,
|
||||
"exclude_materials": ["generic_hips", "generic_petg", "generic_bam", "ultimaker_bam", "generic_pva", "ultimaker_pva", "generic_tough_pla", "ultimaker_tough_pla_black", "ultimaker_tough_pla_green", "ultimaker_tough_pla_red", "ultimaker_tough_pla_white", "generic_cffcpe", "generic_cffpa", "generic_gffcpe", "generic_gffpa", "structur3d_dap100silicone", "ultimaker_petg_blue", "ultimaker_petg_grey", "ultimaker_petg_black", "ultimaker_petg_green", "ultimaker_petg_white", "ultimaker_petg_orange", "ultimaker_petg_silver", "ultimaker_petg_yellow", "ultimaker_petg_transparent", "ultimaker_petg_red_translucent", "ultimaker_petg_blue_translucent", "ultimaker_petg_green_translucent", "ultimaker_petg_yellow_fluorescent", "ultimaker_petg_red" ],
|
||||
"exclude_materials": ["generic_hips", "generic_petg", "generic_bam", "ultimaker_bam", "generic_pva", "ultimaker_pva", "generic_tough_pla", "ultimaker_tough_pla_black", "ultimaker_tough_pla_green", "ultimaker_tough_pla_red", "ultimaker_tough_pla_white", "generic_cffcpe", "generic_cffpa", "generic_gffcpe", "generic_gffpa", "structur3d_dap100silicone", "ultimaker_petg_blue", "ultimaker_petg_grey", "ultimaker_petg_black", "ultimaker_petg_green", "ultimaker_petg_white", "ultimaker_petg_orange", "ultimaker_petg_silver", "ultimaker_petg_yellow", "ultimaker_petg_transparent", "ultimaker_petg_red_translucent", "ultimaker_petg_blue_translucent", "ultimaker_petg_green_translucent", "ultimaker_petg_yellow_fluorescent", "ultimaker_petg_red" ],
|
||||
"first_start_actions": ["UMOUpgradeSelection", "BedLevel"],
|
||||
"supported_actions": ["UMOUpgradeSelection", "BedLevel"],
|
||||
"machine_extruder_trains":
|
||||
|
@ -12,7 +12,7 @@
|
||||
"has_materials": true,
|
||||
"has_machine_quality": true,
|
||||
"quality_definition": "ultimaker_original",
|
||||
"exclude_materials": ["generic_hips", "generic_petg", "generic_bam", "ultimaker_bam", "generic_pva", "ultimaker_pva", "generic_tough_pla", "ultimaker_tough_pla_black", "ultimaker_tough_pla_green", "ultimaker_tough_pla_red", "ultimaker_tough_pla_white", "generic_cffcpe", "generic_cffpa", "generic_gffcpe", "generic_gffpa", "structur3d_dap100silicone" ],
|
||||
"exclude_materials": ["generic_hips", "generic_petg", "generic_bam", "ultimaker_bam", "generic_pva", "ultimaker_pva", "generic_tough_pla", "ultimaker_tough_pla_black", "ultimaker_tough_pla_green", "ultimaker_tough_pla_red", "ultimaker_tough_pla_white", "generic_cffcpe", "generic_cffpa", "generic_gffcpe", "generic_gffpa", "structur3d_dap100silicone", "ultimaker_petg_blue", "ultimaker_petg_grey", "ultimaker_petg_black", "ultimaker_petg_green", "ultimaker_petg_white", "ultimaker_petg_orange", "ultimaker_petg_silver", "ultimaker_petg_yellow", "ultimaker_petg_transparent", "ultimaker_petg_red_translucent", "ultimaker_petg_blue_translucent", "ultimaker_petg_green_translucent", "ultimaker_petg_yellow_fluorescent", "ultimaker_petg_red" ],
|
||||
"machine_extruder_trains":
|
||||
{
|
||||
"0": "ultimaker_original_dual_1st",
|
||||
|
Loading…
x
Reference in New Issue
Block a user