Migrate from info to debug

This commit is contained in:
sergiuToporjinschi
2022-01-29 21:51:58 +02:00
parent b5cd1b4c22
commit 4bca9f9795
7 changed files with 73 additions and 62 deletions
+21
View File
@@ -15,3 +15,24 @@ the plugin manager.
## Configuration ## Configuration
**TODO:** Describe your plugin's configuration options (if any). **TODO:** Describe your plugin's configuration options (if any).
## Regex for getting temperatures
\s*T:(?P<toolTemp>\d{1,3}.\d{1,3}).*B:(?P<betTemp>\d{1,3}.\d{1,3}).*
## extrude command from JS
OctoPrint.printer.issueToolCommand("extrude", {"amount":100, "speed":50})
## Notification JS
new PNotify({
title: "Success",
text: _.sprintf(text, {
command: _.escape(commandSpec.name)
}),
type: "success"
});
+18 -18
View File
@@ -9,13 +9,15 @@ from __future__ import absolute_import
# #
# Take a look at the documentation on what other plugin mixins are available. # Take a look at the documentation on what other plugin mixins are available.
import octoprint.plugin import octoprint.plugin
import re import re
from octoprint_CalibrationTools import ( from octoprint_CalibrationTools import (
api api
) )
class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin, class CalibrationtoolsPlugin(
octoprint.plugin.StartupPlugin,
octoprint.plugin.TemplatePlugin, octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin, octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin, octoprint.plugin.AssetPlugin,
@@ -34,21 +36,18 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin,
self._api = api.API(self) self._api = api.API(self)
def on_after_startup(self): def on_after_startup(self):
self._logger.info("----------------[CalibrationTools]----------------") self._logger.debug("----------------[CalibrationTools]----------------")
self.collectCommand = True self.collectCommand = True
self._printer.commands("M92") self._printer.commands("M92")
# API handling # API handling
def get_api_commands(self): def get_api_commands(self):
self._logger.info("get_api_commands")
return self._api.get_api_commands() return self._api.get_api_commands()
def on_api_command(self, command, data): def on_api_command(self, command, data):
self._logger.info("on_api_command")
return self._api.on_api_command(command, data) return self._api.on_api_command(command, data)
def on_api_get(self, request): def on_api_get(self, request):
self._logger.info("on_api_get")
return self._api.on_api_get(request) return self._api.on_api_get(request)
##~~ AssetPlugin mixin ##~~ AssetPlugin mixin
@@ -60,9 +59,7 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin,
"css": ["css/style.css"] "css": ["css/style.css"]
} }
# self._printer.commands(commands)
# extrude(amount, speed=None, tags=None, *args, **kwargs)
# set_temperature(heater, value, tags=None, *args, **kwargs)
##~~ Softwareupdate hook ##~~ Softwareupdate hook
def comm_protocol_gcode_received(self, comm, line, *args, **kwargs): def comm_protocol_gcode_received(self, comm, line, *args, **kwargs):
if not self.collectCommand: return line if not self.collectCommand: return line
@@ -83,20 +80,20 @@ class CalibrationtoolsPlugin(octoprint.plugin.StartupPlugin,
self.m92Data["E"] = float(eValue) self.m92Data["E"] = float(eValue)
# Send the new data to the UI to be reloaded # Send the new data to the UI to be reloaded
self._logger.info(line) self._logger.debug(line)
self._logger.info("gCode: %s", command) self._logger.debug("gCode: %s", command)
self._logger.info("X: %s", xValue) self._logger.debug("X: %s", xValue)
self._logger.info("Y: %s", yValue) self._logger.debug("Y: %s", yValue)
self._logger.info("Z: %s", zValue) self._logger.debug("Z: %s", zValue)
self._logger.info("E: %s", eValue) self._logger.debug("E: %s", eValue)
self._logger.info("Finished data collection, updating UI") self._logger.debug("Finished data collection")
self.collectCommand = False self.collectCommand = False
return line return line
def comm_protocol_gcode_sending(self, comm, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs): def comm_protocol_gcode_sending(self, comm, phase, cmd, cmd_type, gcode, subcode=None, tags=None, *args, **kwargs):
# https://docs.octoprint.org/en/master/plugins/hooks.html#protocol_gcodephase_hook self._logger.debug("sending GCODE")
if cmd == "M92": if cmd == "M92":
self._logger.info("{} detected, collecting data".format(cmd)) self._logger.debug("{} detected, collecting data".format(cmd))
self.collectCommand = True self.collectCommand = True
def get_update_information(self): def get_update_information(self):
@@ -138,5 +135,8 @@ def __plugin_load__():
global __plugin_hooks__ global __plugin_hooks__
__plugin_hooks__ = { __plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information "octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information,
"octoprint.comm.protocol.gcode.received": __plugin_implementation__.comm_protocol_gcode_received,
"octoprint.comm.protocol.gcode.sending": __plugin_implementation__.comm_protocol_gcode_sending
# "octoprint.comm.protocol.atcommand.sending": __plugin_implementation__.comm_protocol_atcommand_sending
} }
+5 -5
View File
@@ -2,7 +2,7 @@
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
import flask import flask
CMD_LOAD_STEPS_EEPROM = "loadSteps" CMD_LOAD_STEPS = "loadSteps"
class API: class API:
@@ -16,11 +16,11 @@ class API:
@staticmethod @staticmethod
def get_api_commands(): def get_api_commands():
return { return {
CMD_LOAD_STEPS_EEPROM: [] CMD_LOAD_STEPS: []
} }
def on_api_get(self, request): def on_api_get(self, request):
self._logger.info("on api get") self._logger.debug("api.on_api_get")
return flask.jsonify( return flask.jsonify(
{ {
"data": self.m92Data "data": self.m92Data
@@ -28,8 +28,8 @@ class API:
) )
def on_api_command(self, command, data): def on_api_command(self, command, data):
if command == CMD_LOAD_STEPS_EEPROM: self._logger.debug("api command [%s] received", command)
self._logger.info("CMD_LOAD_STEPS_EEPROM") if command == CMD_LOAD_STEPS:
self._printer.commands("M92") self._printer.commands("M92")
return flask.jsonify({ return flask.jsonify({
"data": self.m92Data "data": self.m92Data
@@ -14,7 +14,7 @@
border-radius: 4px; border-radius: 4px;
} }
#tab_plugin_CalibrationTools .tab-content { #tab_plugin_CalibrationTools .tab-content, #tab_plugin_CalibrationTools .tab-content > .tab-pane {
border: none; border: none;
} }
@@ -1,14 +1,3 @@
//Notification
// new PNotify({
// title: "Success",
// text: _.sprintf(text, {
// command: _.escape(commandSpec.name)
// }),
// type: "success"
// });
$(function () { $(function () {
function CalibrationToolsViewModel(parameters) { function CalibrationToolsViewModel(parameters) {
var self = this; var self = this;
@@ -54,19 +43,7 @@ $(function () {
self.steps["E"](response.data.E); self.steps["E"](response.data.E);
} }
self.calibrateESteps = function () { self.loadESteps = function () {
// OctoPrint.simpleApiCommand("loadSteps")
// OctoPrint.control.sendGcodeWithParameters("M92").done(function (responseM92) {
// OctoPrint.simpleApiGet("CalibrationTools").done(function (response) {
// console.log("CalibrationTools");
// self.from_json(response);
// });
// });
console.log("calibrateESteps");
console.log(self.steps.E(), self.results.remainedLength(), self.results.newSteps());
}
self.loadStepsFromEPROM = function () {
OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) { OctoPrint.simpleApiCommand("CalibrationTools","loadSteps").done(function (response) {
self.from_json(response); self.from_json(response);
}) })
@@ -17,17 +17,17 @@
</blockquote> </blockquote>
{% endmacro %} {% endmacro %}
{% macro field(label, number, binding, enable, unit) %} {% macro field(label, title, number, binding, enable, unit) %}
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"> <div class="span6">
<label for="{{ label }}" class="pull-right" style="margin-top: 5px;"> <label for="{{ label }}" class="pull-right" style="margin-top: 5px;" title="{{ title }}">
{{ _(label) }} {{ _(label) }}
</label> </label>
</div> </div>
<div class="span6"> <div class="span6">
<div class="input-append"> <div class="input-append">
<input type="{{ number }}" id="{{ label }}" class="input-small" step="0.01" data-bind="value: {{ binding }}, enable: {{ enable }}"> <input type="{{ number }}" id="{{ label }}" title="{{ title }}" class="input-small" step="0.01" data-bind="value: {{ binding }}, enable: {{ enable }}">
<span class="add-on">{{ _(unit) }}</span> <span class="add-on" title="{{ title }}">{{ _(unit) }}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -2,11 +2,12 @@
{{ snipped.subSection("EEPROM values") }} {{ snipped.subSection("EEPROM values") }}
{{ snipped.field("E steps", "number", "$root.steps.E", "false", "steps/mm") }} {{ snipped.field("E steps", "Number of steps/mm currently set in EEPROM", "number", "$root.steps.E", "false", "steps/mm") }}
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"></div> <div class="span6"></div>
<div class="span6"> <div class="span6">
<button class="btn" data-bind="click: $root.loadStepsFromEPROM, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"> <button class="btn" data-bind="click: $root.loadESteps, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
title="Loads current value of steps/mm from current printer settings by calling M92">
<i class="fas fa-sync-alt" style="color:false" data-color="false"></i>&nbsp&nbsp <i class="fas fa-sync-alt" style="color:false" data-color="false"></i>&nbsp&nbsp
Load EEPROM data Load EEPROM data
</button> </button>
@@ -15,16 +16,28 @@
{{ snipped.subSection("Compute", true) }} {{ snipped.subSection("Compute", true) }}
{{ snipped.field("Actual extrusion", "number", "$root.results.actualExtrusion", "false", "mm") }} <div class="row-fluid" style="margin-bottom: 5px;">
{{ snipped.field("New steps value", "number", "$root.results.newSteps", "false", "steps/mm") }} <div class="span6"></div>
{{ snipped.field("Extrusion marking length", "number", "$root.results.markLength", "true", "mm") }} <div class="span6">
{{ snipped.field("Measured value", "number", "$root.results.remainedLength", "true", "mm") }} <button class="btn btn-success" data-bind="click: $root.startExtrusion, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
title="This will trigger M90, M83, G1 E100 F50, M82, G90 in order for extruding filament">
<i class="fas fa-play" style="color:false" data-color="false"></i>&nbsp&nbsp
Start extrusion
</button>
</div>
</div>
{{ snipped.field("Actual extrusion", "How much filament has been extruded", "number", "$root.results.actualExtrusion", "false", "mm") }}
{{ snipped.field("New steps/mm", "The new number of steps/mm which should be set on EEPROM", "number", "$root.results.newSteps", "false", "steps/mm") }}
{{ snipped.field("Extrusion marking length", "The length marked on filament before extrusion", "number", "$root.results.markLength", "true", "mm") }}
{{ snipped.field("Measured value", "The length between filament mark and extruder entry after extrusion", "number", "$root.results.remainedLength", "true", "mm") }}
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"></div> <div class="span6"></div>
<div class="span6"> <div class="span6">
<button class="btn btn-primary" data-bind="click: $root.calibrateESteps, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"> <button class="btn btn-primary" data-bind="click: $root.saveESteps, enable: $root.controlViewModel.isOperational() && (!$root.controlViewModel.isPrinting())"
<i class="fas fa-play" data-color="#000000"></i>&nbsp&nbsp title="Saves the new calculated value of steps/mm on printer EEPROM">
Start calibration <i class="fas fa-save" data-color="#000000"></i>&nbsp&nbsp
Set new value
</button> </button>
</div> </div>
</div> </div>
@@ -33,6 +46,6 @@
{{ snipped.quote(" {{ snipped.quote("
First <a href='https://teachingtechyt.github.io/calibration.html#esteps' target='_blank'>Read this</a><br><br> First <a href='https://teachingtechyt.github.io/calibration.html#esteps' target='_blank'>Read this</a><br><br>
This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is This calibration is best done with the extruder detached from the hot end, so no restriction is present on the movement. If it is convenient, you can partially disassemble the printer so the output of the extruder is
open and the filament exits in free air. If this is inconvenient, the process below aims to minimise restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be open and the filament exits in free air. If this is inconvenient, the process below aims to minimize restrictions by extruding very slowly and with a slightly higher temperature. The results from this should still be
reliable. reliable.
", "text-warning" ) }} ", "text-warning" ) }}