diff --git a/server/Classes/Fabricators/Printers/Printer.py b/server/Classes/Fabricators/Printers/Printer.py index e6af091..982349f 100644 --- a/server/Classes/Fabricators/Printers/Printer.py +++ b/server/Classes/Fabricators/Printers/Printer.py @@ -94,7 +94,7 @@ def parseGcode(self, job: Job, isVerbose: bool = False): prev_line = "" # Replace file with the path to the file. "r" means read mode. # now instead of reading from 'g', we are reading line by line - current_app.socketio.emit("console_update", {"message": "Starting Job", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Starting Job", "level": "info", "printerid": self.dbID}) for line in lines: if self.status == "cancelled": self.sendGcode(self.cancelCMD) @@ -126,10 +126,12 @@ def parseGcode(self, job: Job, isVerbose: bool = False): if len(line) == 0 or line.startswith(";"): continue - if job.getTimeStarted() == 0 and ("M75" in line or self.startTimeCMD in line) : + if job.getTimeStarted() == 0 and ("M75" in line or self.startTimeCMD in line): job.setTimeStarted(1) job.setTime(job.calculateEta(), 1) job.setTime(datetime.now(), 2) + if current_app: + current_app.socketio.emit("console_update", {"message": "Fabricating...", "level": "info", "printerid": self.dbID}) assert self.sendGcode(line), f"Failed to send {line}" @@ -175,7 +177,7 @@ def parseGcode(self, job: Job, isVerbose: bool = False): self.sendGcode(self.cancelCMD) self.verdict = "cancelled" if self.logger is not None: self.logger.debug("Job cancelled") - current_app.socketio.emit("console_update", {"message": "Job cancelled", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Job cancelled", "level": "info", "printerid": self.dbID}) return True elif self.status == "printing": self.resume() @@ -209,18 +211,18 @@ def parseGcode(self, job: Job, isVerbose: bool = False): if self.status == "complete": self.verdict = "complete" if self.logger is not None: self.logger.debug("Job complete") - current_app.socketio.emit("console_update", {"message": "Job complete", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Job complete", "level": "info", "printerid": self.dbID}) return True if self.status == "error": self.verdict = "error" if self.logger is not None: self.logger.debug("Job error") - current_app.socketio.emit("console_update", {"message": "Job error", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Job error", "level": "info", "printerid": self.dbID}) return False self.verdict = "complete" self.status = "complete" if self.logger is not None: self.logger.debug("Job complete") - current_app.socketio.emit("console_update", {"message": "Job complete", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Job complete", "level": "info", "printerid": self.dbID}) return True except Exception as e: # self.setStatus("error") @@ -330,6 +332,7 @@ def handleTempLine(self, line: str) -> None: pass except Exception as e: current_app.handle_errors_and_logging(e, self) + def extractIndex(self, gcode: bytes) -> str: """ Method to extract the index of the gcode for use in the callablesHashtable @@ -341,12 +344,12 @@ def extractIndex(self, gcode: bytes) -> str: if hashIndex == "M109" or hashIndex == "M190": if self.logger is not None: self.logger.info("Waiting for temperature to stabilize...") current_app.socketio.emit("console_update", - {"message": "Waiting for temperature to stabilize...", "level": "critical", + {"message": "Waiting for temperature to stabilize...", "level": "info", "printerid": self.dbID}) elif hashIndex == "G28": if self.logger is not None: self.logger.info("Homing...") current_app.socketio.emit("console_update", - {"message": "Homing...", "level": "critical", "printerid": self.dbID}) + {"message": "Homing...", "level": "info", "printerid": self.dbID}) return hashIndex def pause(self): diff --git a/server/Classes/Fabricators/Printers/Prusa/PrusaPrinter.py b/server/Classes/Fabricators/Printers/Prusa/PrusaPrinter.py index 91c8dc5..eb9c25e 100644 --- a/server/Classes/Fabricators/Printers/Prusa/PrusaPrinter.py +++ b/server/Classes/Fabricators/Printers/Prusa/PrusaPrinter.py @@ -23,20 +23,13 @@ class PrusaPrinter(Printer, hasEndingSequence, metaclass=ABCMeta): callablesHashtable = {**Printer.callablesHashtable, **callablesHashtable} - def extractIndex(self, gcode: bytes) -> str: - hashIndex = gcode.decode().split("\n")[0].split(" ")[0] - if hashIndex == "M109" or hashIndex == "M190": - if self.logger is not None: self.logger.info("Waiting for temperature to stabilize...") - current_app.socketio.emit("console_update", {"message": "Waiting for temperature to stabilize...", "level": "critical", "printerid": self.dbID}) - elif hashIndex == "G28": - if self.logger is not None: self.logger.info("Homing...") - current_app.socketio.emit("console_update", {"message": "Homing...", "level": "critical", "printerid": self.dbID}) - elif hashIndex == "G29": + hashIndex = super().extractIndex(gcode) + if hashIndex == "G29": try: g29addon = gcode.decode().split("\n")[0].split(" ")[1] hashIndex += ".01" if g29addon == "P1" else ".02" except IndexError: hashIndex += ".01" - current_app.socketio.emit("console_update", {"message": "Auto bed leveling...", "level": "critical", "printerid": self.dbID}) + current_app.socketio.emit("console_update", {"message": "Auto bed leveling...", "level": "info", "printerid": self.dbID}) return hashIndex