mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Added first stubs for printer output models
CL-541
This commit is contained in:
parent
f48539cc93
commit
e35fba6f05
5 changed files with 230 additions and 0 deletions
76
cura/PrinterOutput/ExtruderModel.py
Normal file
76
cura/PrinterOutput/ExtruderModel.py
Normal file
|
@ -0,0 +1,76 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot
|
||||
from UM.Logger import Logger
|
||||
|
||||
from typing import Optional
|
||||
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
from cura.PrinterOutput.PrinterModel import PrinterModel
|
||||
from cura.PrinterOutput.MaterialModel import MaterialModel
|
||||
|
||||
|
||||
class ExtruderModel(QObject):
|
||||
hotendIDChanged = pyqtSignal()
|
||||
targetHotendTemperatureChanged = pyqtSignal()
|
||||
hotendTemperatureChanged = pyqtSignal()
|
||||
activeMaterialChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, printer: "PrinterModel", parent=None):
|
||||
super().__init__(parent)
|
||||
self._printer = printer
|
||||
self._target_hotend_temperature = 0
|
||||
self._hotend_temperature = 0
|
||||
self._hotend_id = ""
|
||||
self._active_material = None # type: Optional[MaterialModel]
|
||||
|
||||
@pyqtProperty(QObject, notify = activeMaterialChanged)
|
||||
def activeMaterial(self) -> "MaterialModel":
|
||||
return self._active_material
|
||||
|
||||
def updateActiveMaterial(self, material: Optional["MaterialModel"]):
|
||||
if self._active_material != material:
|
||||
self._active_material = material
|
||||
self.activeMaterialChanged.emit()
|
||||
|
||||
## Update the hotend temperature. This only changes it locally.
|
||||
def updateHotendTemperature(self, temperature: int):
|
||||
if self._hotend_temperature != temperature:
|
||||
self._hotend_temperature = temperature
|
||||
self.hotendTemperatureChanged.emit()
|
||||
|
||||
def updateTargetHotendTemperature(self, temperature: int):
|
||||
if self._target_hotend_temperature != temperature:
|
||||
self._target_hotend_temperature = temperature
|
||||
self.targetHotendTemperatureChanged.emit()
|
||||
|
||||
## Set the target hotend temperature. This ensures that it's actually sent to the remote.
|
||||
@pyqtSlot(int)
|
||||
def setTargetHotendTemperature(self, temperature: int):
|
||||
self._setTargetHotendTemperature(temperature)
|
||||
self.updateTargetHotendTemperature(temperature)
|
||||
|
||||
@pyqtProperty(int, notify = targetHotendTemperatureChanged)
|
||||
def targetHotendTemperature(self) -> int:
|
||||
return self._target_hotend_temperature
|
||||
|
||||
@pyqtProperty(int, notify=hotendTemperatureChanged)
|
||||
def hotendTemperature(self) -> int:
|
||||
return self._hotendTemperature
|
||||
|
||||
## Protected setter for the hotend temperature of the connected printer (if any).
|
||||
# /parameter temperature Temperature hotend needs to go to (in deg celsius)
|
||||
# /sa setTargetHotendTemperature
|
||||
def _setTargetHotendTemperature(self, temperature):
|
||||
Logger.log("w", "_setTargetHotendTemperature is not implemented by this model")
|
||||
|
||||
@pyqtProperty(str, notify = hotendIDChanged)
|
||||
def hotendID(self) -> str:
|
||||
return self._hotend_id
|
||||
|
||||
def updateHotendID(self, id: str):
|
||||
if self._hotend_id != id:
|
||||
self._hotend_id = id
|
||||
self.hotendIDChanged.emit()
|
29
cura/PrinterOutput/MaterialModel.py
Normal file
29
cura/PrinterOutput/MaterialModel.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot
|
||||
|
||||
|
||||
class MaterialModel(QObject):
|
||||
def __init__(self, guid, type, color, brand, parent = None):
|
||||
super().__init__(parent)
|
||||
self._guid = guid
|
||||
self._type = type
|
||||
self._color = color
|
||||
self._brand = brand
|
||||
|
||||
@pyqtProperty(str, constant = True)
|
||||
def guid(self):
|
||||
return self._guid
|
||||
|
||||
@pyqtProperty(str, constant=True)
|
||||
def type(self):
|
||||
return self._type
|
||||
|
||||
@pyqtProperty(str, constant=True)
|
||||
def brand(self):
|
||||
return self._brand
|
||||
|
||||
@pyqtProperty(str, constant=True)
|
||||
def color(self):
|
||||
return self._color
|
10
cura/PrinterOutput/PrintJobModel.py
Normal file
10
cura/PrinterOutput/PrintJobModel.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant
|
||||
|
||||
|
||||
class PrintJobModel(QObject):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
115
cura/PrinterOutput/PrinterModel.py
Normal file
115
cura/PrinterOutput/PrinterModel.py
Normal file
|
@ -0,0 +1,115 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot
|
||||
from UM.Logger import Logger
|
||||
from typing import Optional, List
|
||||
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
from cura.PrinterOutput.PrintJobModel import PrintJobModel
|
||||
from cura.PrinterOutput.ExtruderModel import ExtruderModel
|
||||
|
||||
|
||||
class PrinterModel(QObject):
|
||||
bedTemperatureChanged = pyqtSignal()
|
||||
targetBedTemperatureChanged = pyqtSignal()
|
||||
printerStateChanged = pyqtSignal()
|
||||
activePrintJobChanged = pyqtSignal()
|
||||
nameChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._bed_temperature = 0
|
||||
self._target_bed_temperature = 0
|
||||
self._name = ""
|
||||
|
||||
self._extruders = [] # type: List[ExtruderModel]
|
||||
|
||||
self._active_print_job = None # type: Optional[PrintJobModel]
|
||||
|
||||
# Features of the printer;
|
||||
self._can_pause = True
|
||||
self._can_abort = True
|
||||
self._can_pre_heat_bed = True
|
||||
self._can_control_manually = True
|
||||
|
||||
@pyqtProperty(str, notify=nameChanged)
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
def setName(self, name):
|
||||
self._setName(name)
|
||||
self.updateName(name)
|
||||
|
||||
def _setName(self, name):
|
||||
Logger.log("w", "_setTargetBedTemperature is not implemented by this model")
|
||||
|
||||
def updateName(self, name):
|
||||
if self._name != name:
|
||||
self._name = name
|
||||
self.nameChanged.emit()
|
||||
|
||||
## Update the bed temperature. This only changes it locally.
|
||||
def updateBedTemperature(self, temperature):
|
||||
if self._bed_temperature != temperature:
|
||||
self._bed_temperature = temperature
|
||||
self.bedTemperatureChanged.emit()
|
||||
|
||||
def updateTargetBedTemperature(self, temperature):
|
||||
if self._target_bed_temperature != temperature:
|
||||
self._target_bed_temperature = temperature
|
||||
self.targetBedTemperatureChanged.emit()
|
||||
|
||||
## Set the target bed temperature. This ensures that it's actually sent to the remote.
|
||||
@pyqtSlot(int)
|
||||
def setTargetBedTemperature(self, temperature):
|
||||
self._setTargetBedTemperature(temperature)
|
||||
self.updateTargetBedTemperature(temperature)
|
||||
|
||||
## Protected setter for the bed temperature of the connected printer (if any).
|
||||
# /parameter temperature Temperature bed needs to go to (in deg celsius)
|
||||
# /sa setTargetBedTemperature
|
||||
def _setTargetBedTemperature(self, temperature):
|
||||
Logger.log("w", "_setTargetBedTemperature is not implemented by this model")
|
||||
|
||||
def updateActivePrintJob(self, print_job):
|
||||
if self._active_print_job != print_job:
|
||||
self._active_print_job = print_job
|
||||
self.activePrintJobChanged.emit()
|
||||
|
||||
@pyqtProperty(QObject, notify = activePrintJobChanged)
|
||||
def activePrintJob(self):
|
||||
return self._active_print_job
|
||||
|
||||
@pyqtProperty(str, notify=printerStateChanged)
|
||||
def printerState(self):
|
||||
return self._printer_state
|
||||
|
||||
@pyqtProperty(int, notify = bedTemperatureChanged)
|
||||
def bedTemperature(self):
|
||||
return self._bed_temperature
|
||||
|
||||
@pyqtProperty(int, notify=targetBedTemperatureChanged)
|
||||
def targetBedTemperature(self):
|
||||
return self._target_bed_temperature
|
||||
|
||||
# Does the printer support pre-heating the bed at all
|
||||
@pyqtProperty(bool, constant=True)
|
||||
def canPreHeatBed(self):
|
||||
return self._can_pre_heat_bed
|
||||
|
||||
# Does the printer support pause at all
|
||||
@pyqtProperty(bool, constant=True)
|
||||
def canPause(self):
|
||||
return self._can_pause
|
||||
|
||||
# Does the printer support abort at all
|
||||
@pyqtProperty(bool, constant=True)
|
||||
def canAbort(self):
|
||||
return self._can_abort
|
||||
|
||||
# Does the printer support manual control at all
|
||||
@pyqtProperty(bool, constant=True)
|
||||
def canControlManually(self):
|
||||
return self._can_control_manually
|
0
cura/PrinterOutput/__init__.py
Normal file
0
cura/PrinterOutput/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue