UltiMaker uses functional, analytical and tracking cookies. Tracking cookies enhance your experience on our website and may also collect your personal data outside of Ultimaker websites. If you agree with the use of tracking cookies, click “I agree, continue browsing”. You can withdraw your consent at any time. If you do not consent with the use of tracking cookies, click “Refuse”. You can find more information about cookies on our Privacy and Cookie Policy page.
.py communication with .qml for printer status plugin
Posted
· .py communication with .qml for printer status plugin
Well, you shouldn't add it in the monitor stage directly, that's for one. The monitor stage is intended to display data that it gets from
a "PrinterOutputDevice" (or in your case, probably the "NetworkedPrinterOutputDevice")
As you may know, Cura has a pretty extensive plugin system. Both situations that also do what you want are the "UM3NetworkPrinting" plugin (bundled with cura) and the OctoprintPlugin (https://github.com/fieldOfView/Cura-OctoPrintPlugin).
So what needs to be done is that you create your own version of the printerOutputDevice / NetworkedPrinterOutputDevice (by means of inheritance) and ensure that the properties / functions that it exposes are filled with the correct data.
A bit more general info on Qt/QML to make the code a bit more understandable; Qt heavily relies on properties (pyqtProperty), signals (pyqtSignal) and slots (pyqtSlot). Properties are essentially attributes, but with one major exception; they have the "notify" ability. When you use a property in QML and the property is changed on the python side, you can notify the QML that this happend by emitting the right signal (signalling the change, hence the name). Lets look at a bit of code:
First of is the bit that starts with the @ sign. This is a decorator, which is a pretty nifty built in feature of python. What it essentially does is taking whatever is below it and modify it (eg "decorating it"). In this case, it's turning the function into a property that is also exposed to QML. The first parameter is the return type (A list of QVariant) and the second one is telling it what signal is emitted if the value is changed. You can either set the "notify" or you can set "constant=True" in which case you indicate that the value will never change once set.
Slots on the other hand are what Qt calls exposed functions. So all functions that are decorated with the pyqtSlot are functions that can be called from QML. They use a similar pattern as the properties.
The first parameter of the decoration is the first parameter accepted by the function (so the printer parameter). The name is set as this is usefull for debugging. Finally, you could also set the "result" parameter, which indicates the return type of the slot (if any).
Posted
· .py communication with .qml for printer status plugin
Dear Nallath,
Thank you do much for this thorough answer. I certainly wasn't expecting this amount of detail.
I have been looking into ahoeben's (fileofview) Octoprintplugin, especialy how he accesses the PrintMonitor part.
However, since I'm unfamiliar with the inner workings of Cura, it raised a lot more questions, which is why I reverted to not "reusing" Cura's internal features, but just redrawing GUI elements in the MonitorStage and feeding it with values.
Needless to say, that's apparently not the way to go 🙂
@nallath, thank you so much again for clarifying this situation! I will a take a more in-depth dive into Cura's code and figure out how
all the componenets work together.
Is there by any chance a graphic/description that details how Cura's set up internally, that I missed?
Al the best,
-h
Link to post
Share on other sites
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more.
S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
(Sorry, was out of office when this released)
This update is for...
All UltiMaker S series
New features
Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
Recommended Posts
nallath 1,120
Well, you shouldn't add it in the monitor stage directly, that's for one. The monitor stage is intended to display data that it gets from
a "PrinterOutputDevice" (or in your case, probably the "NetworkedPrinterOutputDevice")
As you may know, Cura has a pretty extensive plugin system. Both situations that also do what you want are the "UM3NetworkPrinting" plugin (bundled with cura) and the OctoprintPlugin (https://github.com/fieldOfView/Cura-OctoPrintPlugin).
So what needs to be done is that you create your own version of the printerOutputDevice / NetworkedPrinterOutputDevice (by means of inheritance) and ensure that the properties / functions that it exposes are filled with the correct data.
A bit more general info on Qt/QML to make the code a bit more understandable; Qt heavily relies on properties (pyqtProperty), signals (pyqtSignal) and slots (pyqtSlot). Properties are essentially attributes, but with one major exception; they have the "notify" ability. When you use a property in QML and the property is changed on the python side, you can notify the QML that this happend by emitting the right signal (signalling the change, hence the name). Lets look at a bit of code:
First of is the bit that starts with the @ sign. This is a decorator, which is a pretty nifty built in feature of python. What it essentially does is taking whatever is below it and modify it (eg "decorating it"). In this case, it's turning the function into a property that is also exposed to QML. The first parameter is the return type (A list of QVariant) and the second one is telling it what signal is emitted if the value is changed. You can either set the "notify" or you can set "constant=True" in which case you indicate that the value will never change once set.
Slots on the other hand are what Qt calls exposed functions. So all functions that are decorated with the pyqtSlot are functions that can be called from QML. They use a similar pattern as the properties.
The first parameter of the decoration is the first parameter accepted by the function (so the printer parameter). The name is set as this is usefull for debugging. Finally, you could also set the "result" parameter, which indicates the return type of the slot (if any).
Link to post
Share on other sites
hauschka 0
Dear Nallath,
Thank you do much for this thorough answer. I certainly wasn't expecting this amount of detail.
I have been looking into ahoeben's (fileofview) Octoprintplugin, especialy how he accesses the PrintMonitor part.
However, since I'm unfamiliar with the inner workings of Cura, it raised a lot more questions, which is why I reverted to not "reusing" Cura's internal features, but just redrawing GUI elements in the MonitorStage and feeding it with values.
Needless to say, that's apparently not the way to go 🙂
@nallath, thank you so much again for clarifying this situation! I will a take a more in-depth dive into Cura's code and figure out how
all the componenets work together.
Is there by any chance a graphic/description that details how Cura's set up internally, that I missed?
Al the best,
-h
Link to post
Share on other sites