Skip to content

Commit b8d39a3

Browse files
committed
upgrade to Cura 5/API 8.0 and fix simulation progress report
1 parent bdaa9c5 commit b8d39a3

File tree

8 files changed

+138
-118
lines changed

8 files changed

+138
-118
lines changed

CHANGELOG.md

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,146 @@
11
# Changelog of Cura-DuetRRFPlugin
22

3-
## unreleased
4-
* upgrade to QtControls 2, because Cura will upgrade to Qt 6 which removes QtControls 1.
3+
## v1.2.6: 2022-04-23
4+
* bump compatibility for Cura 5.0 / API 8.0, for older Cura versions, please use plugin v1.2.5 or older
5+
* fixed simulation progress reports
56

67
## v1.2.5: 2022-02-11
7-
* bump compatibility for Cura 4.13 / API 7.9, oldest supported release is now 4.11 / 7.7
8-
* embed QOI thumbnail images of the sliced scene into the uploaded gcode file
9-
* add plugin metadata as comment to uploaded gcode file
8+
* bump compatibility for Cura 4.13 / API 7.9, oldest supported release is now 4.11 / 7.7
9+
* embed QOI thumbnail images of the sliced scene into the uploaded gcode file
10+
* add plugin metadata as comment to uploaded gcode file
1011

1112
## v1.2.4: 2021-09-19
12-
* auto-dismiss success message notifications after 15sec
13+
* auto-dismiss success message notifications after 15sec
1314

1415
## v1.2.3: 2021-01-30
15-
* move deleting of unmapped settings to action button on message
16-
* correctly bump plugin version metadata
16+
* move deleting of unmapped settings to action button on message
17+
* correctly bump plugin version metadata
1718

1819
## v1.2.2: 2021-01-27
19-
* add OutputDevices on currently active printer after saving config
20-
* remove OutputDevices on currently active printer after deleting config
20+
* add OutputDevices on currently active printer after saving config
21+
* remove OutputDevices on currently active printer after deleting config
2122

2223
## v1.2.1: 2021-01-21
23-
* fix button width on high-dpi screens
24-
* fix race condition when checking for unmapped settings
24+
* fix button width on high-dpi screens
25+
* fix race condition when checking for unmapped settings
2526

2627
## v1.2.0: 2021-01-10
27-
* store settings in local preferences instead of sharable metadata
28-
* use managed HttpRequestManager instead of low-level QNetworkAccessManager
29-
* add a "Configure" output device for easy initial setup
28+
* store settings in local preferences instead of sharable metadata
29+
* use managed HttpRequestManager instead of low-level QNetworkAccessManager
30+
* add a "Configure" output device for easy initial setup
3031

3132
## v1.1.0: 2020-11-13
32-
* BREAKING CHANGE: migrate settings to be printer-specific
33-
* auto-migrate legacy settings for active printers if printer name matches
34-
* bump compatibility for Cura 4.8 / API 7.4
33+
* BREAKING CHANGE: migrate settings to be printer-specific
34+
* auto-migrate legacy settings for active printers if printer name matches
35+
* bump compatibility for Cura 4.8 / API 7.4
3536

3637
## v1.0.11: 2020-08-29
37-
* bump compatibility for Cura 4.7 / API 7.3
38-
* fix Cura crashes with non-latin strings in Message boxes
38+
* bump compatibility for Cura 4.7 / API 7.3
39+
* fix Cura crashes with non-latin strings in Message boxes
3940

4041
## v1.0.10: 2020-07-22
41-
* fix Cura crashes when using Duet3 with SBC
42+
* fix Cura crashes when using Duet3 with SBC
4243

4344
## v1.0.9: 2020-05-02
44-
* bump compatibility for Cura 4.6 / API 7.2
45-
* fix simulation result reply for RRF HTTP API
45+
* bump compatibility for Cura 4.6 / API 7.2
46+
* fix simulation result reply for RRF HTTP API
4647

4748
## v1.0.8: 2020-04-20
48-
* support new HTTP API for Duet3 with SBC running DuetSoftwareFramework
49+
* support new HTTP API for Duet3 with SBC running DuetSoftwareFramework
4950

5051
## v1.0.7: 2020-04-04
51-
* bump compatibility for Cura 4.5 / API 7.1
52+
* bump compatibility for Cura 4.5 / API 7.1
5253

5354
## v1.0.6: 2020-04-04
54-
* correctly encode special characters in filenames
55-
* mention Duet 3 controllers
55+
* correctly encode special characters in filenames
56+
* mention Duet 3 controllers
5657

5758
## v1.0.5: 2019-11-10
58-
* sanitize filename and forbid certain characters
59+
* sanitize filename and forbid certain characters
5960

6061
## v1.0.4: 2019-11-10
61-
* bump compatibility for Cura 4.4 / API 7.0
62+
* bump compatibility for Cura 4.4 / API 7.0
6263

6364
## v1.0.3: 2019-02-02
64-
* require Cura 4.0 API compatibility
65-
* if you are on Cura 3.6, please install v1.0.2 of this plugin
65+
* require Cura 4.0 API compatibility
66+
* if you are on Cura 3.6, please install v1.0.2 of this plugin
6667

6768
## v1.0.2: 2019-01-06
68-
* fix layout issues on Cura 4.0-beta
69-
* bump compatibility for Cura 4.0 / API 6.0
69+
* fix layout issues on Cura 4.0-beta
70+
* bump compatibility for Cura 4.0 / API 6.0
7071

7172
## v1.0.1: 2018-12-19
72-
* do not try to delete the gcode file before uploading:
73+
* do not try to delete the gcode file before uploading:
7374
RRF safely handles this, https://forum.duet3d.com/topic/8194/cura-duet-reprap-firmware-integration-question
7475

7576
## v1.0.0: 2018-11-25
76-
* tested with Cura 3.6
77-
* add Duet3D icon - permission granted by Think3dPrint3d
78-
* fixed a update issue when changing connection details
79-
* replace deprecated preferences API in favor of the new one
80-
* code cleanup
77+
* tested with Cura 3.6
78+
* add Duet3D icon - permission granted by Think3dPrint3d
79+
* fixed a update issue when changing connection details
80+
* replace deprecated preferences API in favor of the new one
81+
* code cleanup
8182

8283
## v0.0.20: 2018-10-06
83-
* fix broken dialogs
84+
* fix broken dialogs
8485

8586
## v0.0.19: 2018-10-05
86-
* fix more Cura 3.5 incompatibilities
87+
* fix more Cura 3.5 incompatibilities
8788

8889
## v0.0.18: 2018-10-05
89-
* fix Cura 3.5 incompatibility
90-
* bump API code
90+
* fix Cura 3.5 incompatibility
91+
* bump API code
9192

9293
## v0.0.17: 2018-08-10
93-
* fix missing settings at the end of the gcode file
94-
* make use of the default GCodeWrite that Cura uses for "Save to File"
94+
* fix missing settings at the end of the gcode file
95+
* make use of the default GCodeWrite that Cura uses for "Save to File"
9596

9697
## v0.0.16: 2018-04-11
97-
* improve simulation mode
98+
* improve simulation mode
9899

99100
## v0.0.15: 2018-04-01
100-
* fix message box progress
101+
* fix message box progress
101102

102103
## v0.0.14: 2018-04-01
103-
* fixes #10
104+
* fixes #10
104105

105106
## v0.0.13: 2018-03-28
106-
* fixes gcode retrieval for Cura 3.0, 3.1, 3.2, and the latest 3.3 beta
107-
* also see https://github.com/Ultimaker/Cura/commit/495fc8bbd705f5145fe8312207b3f048a7dcc106#diff-a4cb192cad5ce77939fdd0bf0600208d
107+
* fixes gcode retrieval for Cura 3.0, 3.1, 3.2, and the latest 3.3 beta
108+
* also see https://github.com/Ultimaker/Cura/commit/495fc8bbd705f5145fe8312207b3f048a7dcc106#diff-a4cb192cad5ce77939fdd0bf0600208d
108109

109110
## v0.0.12: 2018-03-21
110-
* fix removal error
111+
* fix removal error
111112

112113
## v0.0.11: 2018-03-20
113-
* fixes and slashes
114+
* fixes and slashes
114115

115116
## v0.0.10: 2018-03-20
116-
* improve setting parsing
117+
* improve setting parsing
117118

118119
## v0.0.9: 2018-03-01
119-
* updated plugin location paths
120-
* updated RRF status letter
120+
* updated plugin location paths
121+
* updated RRF status letter
121122

122123
## v0.0.8: 2018-02-17
123-
* hide message after click
124+
* hide message after click
124125

125126
## v0.0.7: 2018-02-17
126-
* fix disconnect params
127+
* fix disconnect params
127128

128129
## v0.0.6: 2018-02-15
129-
* improve error handling
130+
* improve error handling
130131

131132
## v0.0.5: 2018-02-13
132-
* fix Cura 3.2 incompatibility to access the generated G-code.
133+
* fix Cura 3.2 incompatibility to access the generated G-code.
133134

134135
## v0.0.4: 2017-11-21
135-
* send disconnect when done
136+
* send disconnect when done
136137

137138
## v0.0.3: 2017-11-07
138-
* fix error handling
139+
* fix error handling
139140

140141
## v0.0.2: 2017-11-07
141-
* add a file-rename dialog
142-
* add network error handling
142+
* add a file-rename dialog
143+
* add network error handling
143144

144145
## v0.0.1: 2017-10-21
145-
* initial commit
146+
* initial commit

DuetRRFAction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import os
2-
import json
32
import re
4-
from typing import Dict, Type, TYPE_CHECKING, List, Optional, cast
3+
from typing import Optional
54

6-
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
5+
from PyQt6.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
76

87
from cura.CuraApplication import CuraApplication
98
from cura.MachineAction import MachineAction

DuetRRFOutputDevice.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from typing import cast
88
from enum import Enum
99

10-
from PyQt5.QtNetwork import QNetworkReply
11-
from PyQt5.QtCore import QUrl, QObject, QByteArray, QTimer
12-
from PyQt5.QtGui import QDesktopServices
10+
from PyQt6.QtNetwork import QNetworkReply
11+
from PyQt6.QtCore import QUrl, QObject, QByteArray, QTimer
12+
from PyQt6.QtGui import QDesktopServices
1313

1414
from cura.CuraApplication import CuraApplication
1515

@@ -266,7 +266,7 @@ def _assemble_final_gcode(self, gcode_stream, thumbnail_stream):
266266

267267
def _check_duet3_sbc(self, reply, error):
268268
Logger.log("d", "rr_connect failed with error " + str(error))
269-
if error == QNetworkReply.ContentNotFoundError:
269+
if error == QNetworkReply.NetworkError.ContentNotFoundError:
270270
Logger.log("d", "error indicates Duet3+SBC - let's try the DuetSoftwareFramework API instead...")
271271
self._use_rrf_http_api = False # let's try the newer DuetSoftwareFramework for Duet3+SBC API instead
272272
self._send('machine/status',
@@ -278,7 +278,7 @@ def _check_duet3_sbc(self, reply, error):
278278
def _onUploadReady(self, reply):
279279
if self._stage != OutputStage.writing:
280280
return
281-
if reply.error() != QNetworkReply.NoError:
281+
if reply.error() != QNetworkReply.NetworkError.NoError:
282282
Logger.log("d", "Stopping due to reply error: " + reply.error())
283283
return
284284

@@ -303,7 +303,7 @@ def _onUploadReady(self, reply):
303303
def _onUploadDone(self, reply):
304304
if self._stage != OutputStage.writing:
305305
return
306-
if reply.error() != QNetworkReply.NoError:
306+
if reply.error() != QNetworkReply.NetworkError.NoError:
307307
Logger.log("d", "Stopping due to reply error: " + reply.error())
308308
return
309309

@@ -382,7 +382,7 @@ def _onReadyToPrint(self):
382382
def _onPrintStarted(self, reply):
383383
if self._stage != OutputStage.writing:
384384
return
385-
if reply.error() != QNetworkReply.NoError:
385+
if reply.error() != QNetworkReply.NetworkError.NoError:
386386
Logger.log("d", "Stopping due to reply error: " + reply.error())
387387
return
388388

@@ -409,7 +409,7 @@ def _onPrintStarted(self, reply):
409409
def _onSimulationPrintStarted(self, reply):
410410
if self._stage != OutputStage.writing:
411411
return
412-
if reply.error() != QNetworkReply.NoError:
412+
if reply.error() != QNetworkReply.NetworkError.NoError:
413413
Logger.log("d", "Stopping due to reply error: " + reply.error())
414414
return
415415

@@ -437,27 +437,43 @@ def _onCheckStatus(self):
437437
def _onStatusReceived(self, reply):
438438
if self._stage != OutputStage.writing:
439439
return
440-
if reply.error() != QNetworkReply.NoError:
440+
if reply.error() != QNetworkReply.NetworkError.NoError:
441441
Logger.log("d", "Stopping due to reply error: " + reply.error())
442442
return
443443

444444
Logger.log("d", "Status received - decoding...")
445445
reply_body = bytes(reply.readAll()).decode()
446-
Logger.log("d", "Status: " + reply_body)
446+
# Logger.log("d", "Status: " + reply_body)
447447

448448
status = json.loads(reply_body)
449449
if self._use_rrf_http_api:
450450
# RRF 1.21RC2 and earlier used P while simulating
451451
# RRF 1.21RC3 and later uses M while simulating
452452
busy = status["status"] in ['P', 'M']
453453
else:
454-
busy = status["result"]["state"]["status"] == 'simulating'
454+
s = status.get("state", {}).get("status", None)
455+
if not s:
456+
# we might not have received a full status report, assume we are still simulating and busy
457+
busy = True
458+
else:
459+
busy = s == 'simulating'
460+
461+
progress = 0.0
462+
try:
463+
if "fractionPrinted" in status:
464+
progress = float(status["fractionPrinted"])
465+
else:
466+
file_size = status.get("job", {}).get("file", {}).get("size", None)
467+
file_position = status.get("job", {}).get("filePosition", 0)
468+
progress = int(file_position) / int(file_size) * 100.0
469+
except:
470+
pass
455471

456472
if busy:
457473
# still simulating
458-
if self._message and "fractionPrinted" in status:
459-
self._message.setProgress(float(status["fractionPrinted"]))
460-
QTimer.singleShot(1000, self._onCheckStatus)
474+
if self._message:
475+
self._message.setProgress(progress)
476+
QTimer.singleShot(2000, self._onCheckStatus)
461477
else:
462478
Logger.log("d", "Simulation print finished")
463479

@@ -477,7 +493,7 @@ def _onStatusReceived(self, reply):
477493
def _onM37Reported(self, reply):
478494
if self._stage != OutputStage.writing:
479495
return
480-
if reply.error() != QNetworkReply.NoError:
496+
if reply.error() != QNetworkReply.NetworkError.NoError:
481497
Logger.log("d", "Stopping due to reply error: " + reply.error())
482498
return
483499

@@ -492,7 +508,7 @@ def _onM37Reported(self, reply):
492508
def _onReported(self, reply):
493509
if self._stage != OutputStage.writing:
494510
return
495-
if reply.error() != QNetworkReply.NoError:
511+
if reply.error() != QNetworkReply.NetworkError.NoError:
496512
Logger.log("d", "Stopping due to reply error: " + reply.error())
497513
return
498514

@@ -541,7 +557,7 @@ def _onUploadProgress(self, bytesSent, bytesTotal):
541557
self.writeProgress.emit(self, progress)
542558

543559
def _onNetworkError(self, reply, error):
544-
# https://doc.qt.io/qt-5/qnetworkreply.html#NetworkError-enum
560+
# https://doc.qt.io/qt-6/qnetworkreply.html#NetworkError-enum
545561
Logger.log("e", repr(error))
546562
if self._message:
547563
self._message.hide()

DuetRRFPlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22

3-
from PyQt5.QtCore import Qt, QTimer
3+
from PyQt6.QtCore import QTimer
44

55
from cura.CuraApplication import CuraApplication
66
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "DuetRRF",
33
"author": "Thomas Kriechbaumer",
44
"description": "Upload and Print to Duet 2 Wifi / Duet 2 Ethernet / Duet 2 Maestro / Duet 3 with RepRapFirmware.",
5-
"version": "1.2.5",
6-
"supported_sdk_versions": ["7.7.0", "7.8.0", "7.9.0"]
5+
"version": "1.2.6",
6+
"supported_sdk_versions": ["8.0.0"]
77
}

0 commit comments

Comments
 (0)