Also sync when connecting with printer

Though right now it seems to sync way too often. I don't know why it keeps connecting.

Contributes to issue CURA-5034.
This commit is contained in:
Ghostkeeper 2018-06-12 13:56:21 +02:00
parent 194bb5e8c8
commit a4171dd561
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -4,7 +4,6 @@
from UM.FileHandler.FileWriter import FileWriter #To choose based on the output file mode (text vs. binary). from UM.FileHandler.FileWriter import FileWriter #To choose based on the output file mode (text vs. binary).
from UM.FileHandler.WriteFileJob import WriteFileJob #To call the file writer asynchronously. from UM.FileHandler.WriteFileJob import WriteFileJob #To call the file writer asynchronously.
from UM.Logger import Logger from UM.Logger import Logger
from UM.JobQueue import JobQueue #To send material profiles in the background.
from UM.Application import Application from UM.Application import Application
from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
@ -19,6 +18,7 @@ from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel
from cura.PrinterOutput.NetworkCamera import NetworkCamera from cura.PrinterOutput.NetworkCamera import NetworkCamera
from cura.PrinterOutputDevice import ConnectionState #To see when we're fully connected.
from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController
from .SendMaterialJob import SendMaterialJob from .SendMaterialJob import SendMaterialJob
@ -62,6 +62,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
# See comments about this hack with the clusterPrintersChanged signal # See comments about this hack with the clusterPrintersChanged signal
self.printersChanged.connect(self.clusterPrintersChanged) self.printersChanged.connect(self.clusterPrintersChanged)
self.connectionStateChanged.connect(self._onConnectionStateChanged)
self._accepts_commands = True self._accepts_commands = True
# Cluster does not have authentication, so default to authenticated # Cluster does not have authentication, so default to authenticated
@ -368,6 +370,11 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
# Keep a list of all completed jobs so we know if something changed next time. # Keep a list of all completed jobs so we know if something changed next time.
self._finished_jobs = finished_jobs self._finished_jobs = finished_jobs
## Called when the connection to the cluster changes.
def _onConnectionStateChanged(self) -> None:
if self.connectionState == ConnectionState.connected:
self.sendMaterialProfiles()
def _update(self) -> None: def _update(self) -> None:
if not super()._update(): if not super()._update():
return return
@ -417,6 +424,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
self.printJobsChanged.emit() # Do a single emit for all print job changes. self.printJobsChanged.emit() # Do a single emit for all print job changes.
def _onGetPrintersDataFinished(self, reply: QNetworkReply) -> None: def _onGetPrintersDataFinished(self, reply: QNetworkReply) -> None:
self.connect()
if not checkValidGetReply(reply): if not checkValidGetReply(reply):
return return