Progress is now shown for LegacyPrinter while printing

CL-541
This commit is contained in:
Jaime van Kessel 2017-11-24 09:22:50 +01:00
parent 4597bb09ed
commit c523a6ddf6
5 changed files with 64 additions and 21 deletions

View file

@ -11,7 +11,6 @@ MYPY = False
if MYPY:
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
from cura.PrinterOutput.ExtruderOuputModel import ExtruderOutputModel
class PrinterOutputModel(QObject):

View file

@ -568,6 +568,7 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
if not self._printers:
self._printers = [PrinterOutputModel(output_controller=None, number_of_extruders=self._number_of_extruders)]
self.printersChanged.emit()
# LegacyUM3 always has a single printer.
printer = self._printers[0]

View file

@ -13,7 +13,7 @@ Item
property bool isUM3: Cura.MachineManager.activeQualityDefinitionId == "ultimaker3"
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property bool authenticationRequested: printerConnected && Cura.MachineManager.printerOutputDevices[0].authenticationState == 2 // AuthState.AuthenticationRequested
property bool authenticationRequested: printerConnected && (Cura.MachineManager.printerOutputDevices[0].authenticationState == 2 || Cura.MachineManager.printerOutputDevices[0].authenticationState == 5) // AuthState.AuthenticationRequested or AuthenticationReceived.
Row
{
@ -119,7 +119,9 @@ Item
onClicked: manager.loadConfigurationFromPrinter()
function isClusterPrinter() {
if(Cura.MachineManager.printerOutputDevices.length == 0)
return false
//TODO: Hardcoded this for the moment now. These info components might also need to move.
/*if(Cura.MachineManager.printerOutputDevices.length == 0)
{
return false;
}
@ -129,7 +131,7 @@ Item
{
return false;
}
return true;
return true;*/
}
}
}

View file

@ -84,7 +84,6 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
def _onDeviceConnectionStateChanged(self, key):
if key not in self._discovered_devices:
return
print("STATE CHANGED", key)
if self._discovered_devices[key].isConnected():
self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key])
else:

View file

@ -17,16 +17,39 @@ Item
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property real progress: printerConnected ? Cura.MachineManager.printerOutputDevices[0].progress : 0
property var activePrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0].activePrinter : null
property var activePrintJob: activePrinter ? activePrinter.activePrintJob: null
property real progress:
{
if(!printerConnected)
{
return 0
}
if(activePrinter == null)
{
return 0
}
if(activePrintJob == null)
{
return 0
}
if(activePrintJob.timeTotal == 0)
{
return 0 // Prevent devision by 0
}
return activePrintJob.timeElapsed / activePrintJob.timeTotal * 100
}
property int backendState: UM.Backend.state
property bool showProgress: {
// determine if we need to show the progress bar + percentage
if(!printerConnected || !printerAcceptsCommands) {
if(activePrintJob == null)
{
return false;
}
switch(Cura.MachineManager.printerOutputDevices[0].jobState)
switch(base.activePrintJob.state)
{
case "printing":
case "paused":
@ -50,7 +73,7 @@ Item
if(!printerConnected || !printerAcceptsCommands)
return UM.Theme.getColor("text");
switch(Cura.MachineManager.printerOutputDevices[0].printerState)
switch(activePrinter.printerState)
{
case "maintenance":
return UM.Theme.getColor("status_busy");
@ -58,7 +81,7 @@ Item
return UM.Theme.getColor("status_stopped");
}
switch(Cura.MachineManager.printerOutputDevices[0].jobState)
switch(base.activePrintJob.state)
{
case "printing":
case "pre_print":
@ -85,17 +108,27 @@ Item
property string statusText:
{
if(!printerConnected)
{
return catalog.i18nc("@label:MonitorStatus", "Not connected to a printer");
}
if(!printerAcceptsCommands)
{
return catalog.i18nc("@label:MonitorStatus", "Printer does not accept commands");
}
var printerOutputDevice = Cura.MachineManager.printerOutputDevices[0]
if(printerOutputDevice.printerState == "maintenance")
if(activePrinter.printerState == "maintenance")
{
return catalog.i18nc("@label:MonitorStatus", "In maintenance. Please check the printer");
}
switch(printerOutputDevice.jobState)
if(base.activePrintJob == null)
{
return " "
}
switch(base.activePrintJob.state)
{
case "offline":
return catalog.i18nc("@label:MonitorStatus", "Lost connection with the printer");
@ -163,7 +196,11 @@ Item
{
return false;
}
switch(Cura.MachineManager.printerOutputDevices[0].jobState)
if(base.activePrintJob == null)
{
return false
}
switch(base.activePrintJob.state)
{
case "pausing":
case "resuming":
@ -185,7 +222,8 @@ Item
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width;
}
Row {
Row
{
id: buttonsRow
height: abortButton.height
anchors.top: progressBar.bottom
@ -194,17 +232,21 @@ Item
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
spacing: UM.Theme.getSize("default_margin").width
Row {
Row
{
id: additionalComponentsRow
spacing: UM.Theme.getSize("default_margin").width
}
Connections {
Connections
{
target: Printer
onAdditionalComponentsChanged:
{
if(areaId == "monitorButtons") {
for (var component in CuraApplication.additionalComponents["monitorButtons"]) {
if(areaId == "monitorButtons")
{
for (var component in CuraApplication.additionalComponents["monitorButtons"])
{
CuraApplication.additionalComponents["monitorButtons"][component].parent = additionalComponentsRow
}
}
@ -220,7 +262,7 @@ Item
property bool userClicked: false
property string lastJobState: ""
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].canPause
visible: printerConnected && activePrinter.canPause
enabled: (!userClicked) && printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
(["paused", "printing"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
@ -261,8 +303,8 @@ Item
{
id: abortButton
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].canAbort
enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
visible: printerConnected && activePrinter.canAbort
enabled: printerConnected && activePrinter.acceptsCommands &&
(["paused", "printing", "pre_print"].indexOf(Cura.MachineManager.printerOutputDevices[0].jobState) >= 0)
height: UM.Theme.getSize("save_button_save_to_button").height