This commit is contained in:
ckielstra 2016-04-08 11:06:24 +02:00
parent 27e3f8b33f
commit 4c233e75f4
2 changed files with 13 additions and 11 deletions

View file

@ -25,6 +25,7 @@ import Arcus
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
class CuraEngineBackend(Backend): class CuraEngineBackend(Backend):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -84,7 +85,7 @@ class CuraEngineBackend(Backend):
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onInstanceChanged) Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onInstanceChanged)
## Get the command that is used to call the engine. ## Get the command that is used to call the engine.
# This is usefull for debugging and used to actually start the engine # This is useful for debugging and used to actually start the engine
# \return list of commands and args / parameters. # \return list of commands and args / parameters.
def getEngineCommand(self): def getEngineCommand(self):
active_machine = Application.getInstance().getMachineManager().getActiveMachineInstance() active_machine = Application.getInstance().getMachineManager().getActiveMachineInstance()
@ -158,7 +159,7 @@ class CuraEngineBackend(Backend):
Logger.log("d", "Killing engine process") Logger.log("d", "Killing engine process")
try: try:
self._process.terminate() self._process.terminate()
Logger.log("d", "Engine process is killed. Recieved return code %s", self._process.wait()) Logger.log("d", "Engine process is killed. Received return code %s", self._process.wait())
self._process = None self._process = None
#self._createSocket() # Re create the socket #self._createSocket() # Re create the socket
except Exception as e: # terminating a process that is already terminating causes an exception, silently ignore this. except Exception as e: # terminating a process that is already terminating causes an exception, silently ignore this.
@ -261,7 +262,7 @@ class CuraEngineBackend(Backend):
def _onToolOperationStarted(self, tool): def _onToolOperationStarted(self, tool):
self._terminate() # Do not continue slicing once a tool has started self._terminate() # Do not continue slicing once a tool has started
self._enabled = False # Do not reslice when a tool is doing it's 'thing' self._enabled = False # Do not reslice when a tool is doing its 'thing'
def _onToolOperationStopped(self, tool): def _onToolOperationStopped(self, tool):
self._enabled = True # Tool stop, start listening for changes again. self._enabled = True # Tool stop, start listening for changes again.

View file

@ -23,6 +23,7 @@ from PyQt5.QtCore import QUrl, QObject, pyqtSlot, pyqtProperty, pyqtSignal, Qt
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
class PrinterConnection(OutputDevice, QObject, SignalEmitter): class PrinterConnection(OutputDevice, QObject, SignalEmitter):
def __init__(self, serial_port, parent = None): def __init__(self, serial_port, parent = None):
QObject.__init__(self, parent) QObject.__init__(self, parent)
@ -262,14 +263,14 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
self._is_connecting = True self._is_connecting = True
programmer = stk500v2.Stk500v2() programmer = stk500v2.Stk500v2()
try: try:
programmer.connect(self._serial_port) # Connect with the serial, if this succeeds, it"s an arduino based usb device. programmer.connect(self._serial_port) # Connect with the serial, if this succeeds, it's an arduino based usb device.
self._serial = programmer.leaveISP() self._serial = programmer.leaveISP()
except ispBase.IspError as e: except ispBase.IspError as e:
Logger.log("i", "Could not establish connection on %s: %s. Device is not arduino based." %(self._serial_port,str(e))) Logger.log("i", "Could not establish connection on %s: %s. Device is not arduino based." %(self._serial_port,str(e)))
except Exception as e: except Exception as e:
Logger.log("i", "Could not establish connection on %s, unknown reasons. Device is not arduino based." % self._serial_port) Logger.log("i", "Could not establish connection on %s, unknown reasons. Device is not arduino based." % self._serial_port)
# If the programmer connected, we know its an atmega based version. Not all that usefull, but it does give some debugging information. # If the programmer connected, we know its an atmega based version. Not all that useful, but it does give some debugging information.
for baud_rate in self._getBaudrateList(): # Cycle all baud rates (auto detect) for baud_rate in self._getBaudrateList(): # Cycle all baud rates (auto detect)
Logger.log("d","Attempting to connect to printer with serial %s on baud rate %s", self._serial_port, baud_rate) Logger.log("d","Attempting to connect to printer with serial %s on baud rate %s", self._serial_port, baud_rate)
if self._serial is None: if self._serial is None:
@ -468,7 +469,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
## Private function to set the temperature of an extruder ## Private function to set the temperature of an extruder
# \param index index of the extruder # \param index index of the extruder
# \param temperature recieved temperature # \param temperature received temperature
def _setExtruderTemperature(self, index, temperature): def _setExtruderTemperature(self, index, temperature):
try: try:
self._extruder_temperatures[index] = temperature self._extruder_temperatures[index] = temperature
@ -522,7 +523,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
if line.startswith(b"Error:"): if line.startswith(b"Error:"):
# Oh YEAH, consistency. # Oh YEAH, consistency.
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n" # Marlin reports a MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!" # But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
# So we can have an extra newline in the most common case. Awesome work people. # So we can have an extra newline in the most common case. Awesome work people.
if re.match(b"Error:[0-9]\n", line): if re.match(b"Error:[0-9]\n", line):
@ -538,7 +539,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
self._setExtruderTemperature(self._temperature_requested_extruder_index,float(re.search(b"T: *([0-9\.]*)", line).group(1))) self._setExtruderTemperature(self._temperature_requested_extruder_index,float(re.search(b"T: *([0-9\.]*)", line).group(1)))
except: except:
pass pass
if b"B:" in line: # Check if it"s a bed temperature if b"B:" in line: # Check if it's a bed temperature
try: try:
self._setBedTemperature(float(re.search(b"B: *([0-9\.]*)", line).group(1))) self._setBedTemperature(float(re.search(b"B: *([0-9\.]*)", line).group(1)))
except Exception as e: except Exception as e:
@ -587,7 +588,7 @@ class PrinterConnection(OutputDevice, QObject, SignalEmitter):
line = line.strip() line = line.strip()
try: try:
if line == "M0" or line == "M1": if line == "M0" or line == "M1":
line = "M105" #Don"t send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause. line = "M105" #Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
if ("G0" in line or "G1" in line) and "Z" in line: if ("G0" in line or "G1" in line) and "Z" in line:
z = float(re.search("Z([0-9\.]*)", line).group(1)) z = float(re.search("Z([0-9\.]*)", line).group(1))
if self._current_z != z: if self._current_z != z: