mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
USB printing now uses printeroutputdevice for temperatures
CURA-1339
This commit is contained in:
parent
45b3e8fbd6
commit
0a46567c17
3 changed files with 11 additions and 25 deletions
|
@ -25,7 +25,8 @@ UM.Dialog
|
|||
Label
|
||||
{
|
||||
//: USB Printing dialog label, %1 is head temperature
|
||||
text: catalog.i18nc("@label","Extruder Temperature %1").arg(manager.extruderTemperature)
|
||||
Component.onCompleted: console.log(manager.hotendTemperatures)
|
||||
text: catalog.i18nc("@label","Extruder Temperature %1").arg(manager.hotendTemperatures[0])
|
||||
}
|
||||
Label
|
||||
{
|
||||
|
|
|
@ -197,7 +197,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
self._printer_connections[serial_port] = connection
|
||||
|
||||
def _onPrinterConnectionStateChanged(self, serial_port):
|
||||
if self._printer_connections[serial_port].connectionState == ConnectionState.CLOSED:
|
||||
if self._printer_connections[serial_port].connectionState == ConnectionState.CONNECTED:
|
||||
self.getOutputDeviceManager().addOutputDevice(self._printer_connections[serial_port])
|
||||
else:
|
||||
self.getOutputDeviceManager().removeOutputDevice(serial_port)
|
||||
|
@ -209,7 +209,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
|
|||
self._printer_connections_model.addRoleName(Qt.UserRole + 1,"name")
|
||||
self._printer_connections_model.addRoleName(Qt.UserRole + 2, "printer")
|
||||
for connection in self._printer_connections:
|
||||
if self._printer_connections[connection].isConnected:
|
||||
if self._printer_connections[connection].connectionState == ConnectionState.CONNECTED:
|
||||
self._printer_connections_model.appendItem({"name":connection, "printer": self._printer_connections[connection]})
|
||||
return self._printer_connections_model
|
||||
|
||||
|
|
|
@ -69,21 +69,6 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
# List of gcode lines to be printed
|
||||
self._gcode = []
|
||||
|
||||
# Number of extruders
|
||||
self._extruder_count = 1
|
||||
|
||||
# Temperatures of all extruders
|
||||
self._extruder_temperatures = [0] * self._extruder_count
|
||||
|
||||
# Target temperatures of all extruders
|
||||
self._target_extruder_temperatures = [0] * self._extruder_count
|
||||
|
||||
#Target temperature of the bed
|
||||
self._target_bed_temperature = 0
|
||||
|
||||
# Temperature of the bed
|
||||
self._bed_temperature = 0
|
||||
|
||||
# Current Z stage location
|
||||
self._current_z = 0
|
||||
|
||||
|
@ -274,6 +259,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
if sucesfull_responses >= self._required_responses_auto_baud:
|
||||
self._serial.timeout = 2 # Reset serial timeout
|
||||
self.setConnectionState(ConnectionState.CONNECTED)
|
||||
self._listen_thread.start() # Start listening
|
||||
Logger.log("i", "Established printer connection on port %s" % self._serial_port)
|
||||
return
|
||||
|
||||
|
@ -408,15 +394,14 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
Logger.log("i", "Printer connection listen thread started for %s" % self._serial_port)
|
||||
temperature_request_timeout = time.time()
|
||||
ok_timeout = time.time()
|
||||
while self._connected:
|
||||
while self._connection_state == ConnectionState.CONNECTED:
|
||||
line = self._readline()
|
||||
|
||||
if line is None:
|
||||
break # None is only returned when something went wrong. Stop listening
|
||||
|
||||
if time.time() > temperature_request_timeout:
|
||||
if self._extruder_count > 0:
|
||||
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._extruder_count
|
||||
if self._num_extruders > 0:
|
||||
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._num_extruders
|
||||
self.sendCommand("M105 T%d" % (self._temperature_requested_extruder_index))
|
||||
else:
|
||||
self.sendCommand("M105")
|
||||
|
@ -437,7 +422,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
|
||||
elif b" T:" in line or line.startswith(b"T:"): #Temperature message
|
||||
try:
|
||||
self._setExtruderTemperature(self._temperature_requested_extruder_index,float(re.search(b"T: *([0-9\.]*)", line).group(1)))
|
||||
self._setHotendTemperature(self._temperature_requested_extruder_index, float(re.search(b"T: *([0-9\.]*)", line).group(1)))
|
||||
except:
|
||||
pass
|
||||
if b"B:" in line: # Check if it's a bed temperature
|
||||
|
@ -469,8 +454,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||
|
||||
else: # Request the temperature on comm timeout (every 2 seconds) when we are not printing.)
|
||||
if line == b"":
|
||||
if self._extruder_count > 0:
|
||||
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._extruder_count
|
||||
if self._num_extruders > 0:
|
||||
self._temperature_requested_extruder_index = (self._temperature_requested_extruder_index + 1) % self._num_extruders
|
||||
self.sendCommand("M105 T%d" % self._temperature_requested_extruder_index)
|
||||
else:
|
||||
self.sendCommand("M105")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue