From 9c822b7e9337d040aa5d6ea8506ebfcecdd99c4c Mon Sep 17 00:00:00 2001 From: make-ing Date: Wed, 2 Mar 2016 15:48:52 +0100 Subject: [PATCH] added multipass placeholder functions --- src/octoprint/printer/standard.py | 16 ++++++++++++++++ src/octoprint/server/api/job.py | 13 ++++++++++++- .../static/js/app/viewmodels/printerstate.js | 2 ++ src/octoprint/util/comm_acc2.py | 6 ++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 5fee8558..a10580dd 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -433,6 +433,22 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): payload["origin"] = FileDestinations.SDCARD eventManager().fire(Events.PRINT_FAILED, payload) + def increase_passes(self): + """ + increase the number of passes by one. + """ + if self._comm is None: + return + self._comm.increasePasses() + + def degrease_passes(self): + """ + degrease the number of passes by one. + """ + if self._comm is None: + return + self._comm.degreasePasses() + def get_state_string(self): """ Returns a human readable string corresponding to the current communication state. diff --git a/src/octoprint/server/api/job.py b/src/octoprint/server/api/job.py index b2d9b02e..65f4143a 100644 --- a/src/octoprint/server/api/job.py +++ b/src/octoprint/server/api/job.py @@ -23,7 +23,9 @@ def controlJob(): "start": [], "restart": [], "pause": [], - "cancel": [] + "cancel": [], + "incpasses": [], + "degpasses": [] } command, data, response = get_json_command_from_request(request, valid_commands) @@ -48,6 +50,15 @@ def controlJob(): if not activePrintjob: return make_response("Printer is neither printing nor paused, 'cancel' command cannot be performed", 409) printer.cancel_print() + elif command == "incpasses": + if not activePrintjob: + return make_response("Printer is neither printing nor paused, 'incpasses' command cannot be performed", 409) + printer.increase_passes() + elif command == "degpasses": + if not activePrintjob: + return make_response("Printer is neither printing nor paused, 'degpasses' command cannot be performed", 409) + printer.degrease_passes() + return NO_CONTENT diff --git a/src/octoprint/static/js/app/viewmodels/printerstate.js b/src/octoprint/static/js/app/viewmodels/printerstate.js index 51f816f4..85e27832 100644 --- a/src/octoprint/static/js/app/viewmodels/printerstate.js +++ b/src/octoprint/static/js/app/viewmodels/printerstate.js @@ -332,10 +332,12 @@ $(function() { self.increasePasses = function(){ self.numberOfPasses(self.numberOfPasses()+1); + self._jobCommand("incpasses"); } self.decreasePasses = function(){ var passes = Math.max(self.numberOfPasses()-1, 1); self.numberOfPasses(passes); + self._jobCommand("degpasses"); } self.onEventPrintDone = function(){ diff --git a/src/octoprint/util/comm_acc2.py b/src/octoprint/util/comm_acc2.py index 39a0318a..df297939 100644 --- a/src/octoprint/util/comm_acc2.py +++ b/src/octoprint/util/comm_acc2.py @@ -893,6 +893,12 @@ class MachineCom(object): self._send_event.set() eventManager().fire(Events.PRINT_PAUSED, payload) + def increasePasses(self): + self._log("increase Passes") + + def degreasePasses(self): + self._log("degrease Passes") + def getStateString(self): if self._state == self.STATE_NONE: return "Offline"