Signals are now only emitted when setting changed instead of always.

This commit is contained in:
Jaime van Kessel 2016-09-08 17:20:01 +02:00
parent 6197a5b77a
commit 544941e33e

View file

@ -150,6 +150,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
@pyqtSlot(int)
def setTargetBedTemperature(self, temperature):
self._setTargetBedTemperature(temperature)
if self._target_bed_temperature != temperature:
self._target_bed_temperature = temperature
self.targetBedTemperatureChanged.emit()
@ -212,6 +213,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
# This simply sets the bed temperature, but ensures that a signal is emitted.
# /param temperature temperature of the bed.
def _setBedTemperature(self, temperature):
if self._bed_temperature != temperature:
self._bed_temperature = temperature
self.bedTemperatureChanged.emit()
@ -228,6 +230,8 @@ class PrinterOutputDevice(QObject, OutputDevice):
@pyqtSlot(int, int)
def setTargetHotendTemperature(self, index, temperature):
self._setTargetHotendTemperature(index, temperature)
if self._target_hotend_temperatures[index] != temperature:
self._target_hotend_temperatures[index] = temperature
self.targetHotendTemperaturesChanged.emit()
@ -251,6 +255,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
# /param index Index of the hotend
# /param temperature temperature of the hotend (in deg C)
def _setHotendTemperature(self, index, temperature):
if self._hotend_temperatures[index] != temperature:
self._hotend_temperatures[index] = temperature
self.hotendTemperaturesChanged.emit()
@ -267,7 +272,6 @@ class PrinterOutputDevice(QObject, OutputDevice):
self._material_ids[index] = material_id
self.materialIdChanged.emit(index, material_id)
@pyqtProperty("QVariantList", notify = hotendIdChanged)
def hotendIds(self):
return self._hotend_ids
@ -302,6 +306,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
## Set the connection state of this output device.
# /param connection_state ConnectionState enum.
def setConnectionState(self, connection_state):
if self._connection_state != connection_state:
self._connection_state = connection_state
self.connectionStateChanged.emit(self._id)
@ -351,6 +356,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
if self._head_z != z:
self._head_z = z
position_changed = True
if position_changed:
self.headPositionChanged.emit()