redesing tab

This commit is contained in:
sergiuToporjinschi
2022-01-30 14:08:52 +02:00
parent 8495d89cd3
commit d6323b6392
7 changed files with 123 additions and 39 deletions
+36 -4
View File
@@ -5,9 +5,11 @@ import octoprint.plugin
import flask
CMD_LOAD_STEPS = "loadSteps"
CMD_TEST = "TEST"
CMD_LOAD_STEPS = "loadSteps"
CMD_START_EXTRUSION = "startExtrusion"
CMD_SAVE_E_STEPS = "saveESteps"
def someTestFunc(self, temps):
self._logger.debug("a ajuns %s", temps)
@@ -19,6 +21,7 @@ class API(octoprint.plugin.SimpleApiPlugin):
return {
CMD_LOAD_STEPS: [],
CMD_START_EXTRUSION: [],
CMD_SAVE_E_STEPS: [],
CMD_TEST: []
}
@@ -33,16 +36,45 @@ class API(octoprint.plugin.SimpleApiPlugin):
def on_api_command(self, command, data):
self._logger.debug("api command [%s] received", command)
if command == CMD_LOAD_STEPS:
if not self._printer.is_ready():
self._logger.warning("Printer not ready, operation canceled")
return flask.abort(503, {
"msg": "Printer not ready, operation canceled"
})
self._printer.commands("M92")
return flask.jsonify({
"data": self.data["steps"]
})
if command == CMD_START_EXTRUSION:
self._logger.debug("Heating the tools")
self._printer.commands("M104 S180")
if not self._printer.is_ready():
self._logger.warning("Printer not ready, operation canceled")
return flask.abort(503, {
"msg": "Printer not ready, operation canceled"
})
# Register event to be trigger when temp is achieved
self.registerEventTemp("T0", 180, self.startExtrusion)
# Heating the tool
self._printer.commands("M104 S180")
return
if command == CMD_SAVE_E_STEPS:
return
if command == CMD_TEST:
self.registerEventTemp("T0", 100, someTestFunc)
return
# self.registerEventTemp("T0", 100, someTestFunc)
return flask.abort(503, {
"msg": "Printer not ready, operation canceled"
})
@staticmethod
def startExtrusion(self, temps, *args):
self._logger.debug("Temperature achieved, extrusion started %s, %s", temps, args)
# Extrude
self._printer.extrude(amount=120, speed=50)